ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

hostent.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS DNS Shared Library
00004  * FILE:        lib/dnslib/hostent.c
00005  * PURPOSE:     Functions for dealing with Host Entry structures
00006  */
00007 
00008 /* INCLUDES ******************************************************************/
00009 #include "precomp.h"
00010 
00011 /* DATA **********************************************************************/
00012 
00013 /* FUNCTIONS *****************************************************************/
00014 
00015 PHOSTENT
00016 WINAPI
00017 Hostent_Init(IN PVOID *Buffer,
00018              IN WORD AddressFamily,
00019              IN ULONG AddressSize,
00020              IN ULONG AddressCount,
00021              IN ULONG AliasCount)
00022 {
00023     PHOSTENT Hostent;
00024     ULONG_PTR BufferPosition = (ULONG_PTR)*Buffer;
00025 
00026     /* Align the hostent on the buffer's 4 byte boundary */
00027     BufferPosition += 3 & ~3;
00028 
00029     /* Set up the basic data */
00030     Hostent = (PHOSTENT)BufferPosition;
00031     Hostent->h_length = (WORD)AddressSize;
00032     Hostent->h_addrtype = AddressFamily;
00033 
00034     /* Put aliases after Hostent */
00035     Hostent->h_aliases = (PCHAR*)((ULONG_PTR)(Hostent + 1) & ~3);
00036 
00037     /* Zero it out */
00038     RtlZeroMemory(Hostent->h_aliases, AliasCount * sizeof(PCHAR));
00039 
00040     /* Put addresses after aliases */
00041     Hostent->h_addr_list = (PCHAR*)
00042                            ((ULONG_PTR)Hostent->h_aliases +
00043                             (AliasCount * sizeof(PCHAR)) + sizeof(PCHAR));
00044 
00045     /* Update the location */
00046     BufferPosition = (ULONG_PTR)Hostent->h_addr_list +
00047                      ((AddressCount * sizeof(PCHAR)) + sizeof(PCHAR));
00048 
00049     /* Send it back */
00050     *Buffer = (PVOID)BufferPosition;
00051 
00052     /* Return the hostent */
00053     return Hostent;
00054 }
00055 
00056 VOID
00057 WINAPI
00058 Dns_PtrArrayToOffsetArray(PCHAR *List,
00059                           ULONG_PTR Base)
00060 {
00061     /* Loop every pointer in the list */
00062     do 
00063     {
00064         /* Update the pointer */
00065         *List = (PCHAR)((ULONG_PTR)*List - Base);
00066     } while(*List++);
00067 }
00068 
00069 VOID
00070 WINAPI
00071 Hostent_ConvertToOffsets(IN PHOSTENT Hostent)
00072 {
00073     /* Do we have a name? */
00074     if (Hostent->h_name)
00075     {
00076         /* Update it */
00077         Hostent->h_name -= (ULONG_PTR)Hostent;
00078     }
00079 
00080     /* Do we have aliases? */
00081     if (Hostent->h_aliases)
00082     {
00083         /* Update the pointer */
00084         Hostent->h_aliases -= (ULONG_PTR)Hostent;
00085 
00086         /* Fix them up */
00087         Dns_PtrArrayToOffsetArray(Hostent->h_aliases, (ULONG_PTR)Hostent);
00088     }
00089 
00090     /* Do we have addresses? */
00091     if (Hostent->h_addr_list)
00092     {
00093         /* Fix them up */
00094         Dns_PtrArrayToOffsetArray(Hostent->h_addr_list, (ULONG_PTR)Hostent);
00095     }
00096 }
00097 

Generated on Sun May 27 2012 04:35:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.