ReactOS  0.4.14-dev-323-g6fe6a88
hostent.c File Reference
#include "precomp.h"
Include dependency graph for hostent.c:

Go to the source code of this file.

Functions

PHOSTENT WINAPI Hostent_Init (IN PVOID *Buffer, IN WORD AddressFamily, IN ULONG AddressSize, IN ULONG AddressCount, IN ULONG AliasCount)
 
VOID WINAPI Dns_PtrArrayToOffsetArray (PCHAR *List, ULONG_PTR Base)
 
VOID WINAPI Hostent_ConvertToOffsets (IN PHOSTENT Hostent)
 

Function Documentation

◆ Dns_PtrArrayToOffsetArray()

VOID WINAPI Dns_PtrArrayToOffsetArray ( PCHAR List,
ULONG_PTR  Base 
)

Definition at line 58 of file hostent.c.

60 {
61  /* Loop every pointer in the list */
62  do
63  {
64  /* Update the pointer */
65  *List = (PCHAR)((ULONG_PTR)*List - Base);
66  } while(*List++);
67 }
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PCHAR
Definition: match.c:90
LIST_ENTRY List
Definition: psmgr.c:57

Referenced by Hostent_ConvertToOffsets().

◆ Hostent_ConvertToOffsets()

VOID WINAPI Hostent_ConvertToOffsets ( IN PHOSTENT  Hostent)

Definition at line 71 of file hostent.c.

72 {
73  /* Do we have a name? */
74  if (Hostent->h_name)
75  {
76  /* Update it */
77  Hostent->h_name -= (ULONG_PTR)Hostent;
78  }
79 
80  /* Do we have aliases? */
81  if (Hostent->h_aliases)
82  {
83  /* Update the pointer */
84  Hostent->h_aliases -= (ULONG_PTR)Hostent;
85 
86  /* Fix them up */
87  Dns_PtrArrayToOffsetArray(Hostent->h_aliases, (ULONG_PTR)Hostent);
88  }
89 
90  /* Do we have addresses? */
91  if (Hostent->h_addr_list)
92  {
93  /* Fix them up */
94  Dns_PtrArrayToOffsetArray(Hostent->h_addr_list, (ULONG_PTR)Hostent);
95  }
96 }
VOID WINAPI Dns_PtrArrayToOffsetArray(PCHAR *List, ULONG_PTR Base)
Definition: hostent.c:58
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ULONG_PTR
Definition: config.h:101

Referenced by SaBlob_CreateHostent().

◆ Hostent_Init()

PHOSTENT WINAPI Hostent_Init ( IN PVOID Buffer,
IN WORD  AddressFamily,
IN ULONG  AddressSize,
IN ULONG  AddressCount,
IN ULONG  AliasCount 
)

Definition at line 17 of file hostent.c.

22 {
23  PHOSTENT Hostent;
24  ULONG_PTR BufferPosition = (ULONG_PTR)*Buffer;
25 
26  /* Align the hostent on the buffer's 4 byte boundary */
27  BufferPosition += 3 & ~3;
28 
29  /* Set up the basic data */
30  Hostent = (PHOSTENT)BufferPosition;
31  Hostent->h_length = (WORD)AddressSize;
32  Hostent->h_addrtype = AddressFamily;
33 
34  /* Put aliases after Hostent */
35  Hostent->h_aliases = (PCHAR*)((ULONG_PTR)(Hostent + 1) & ~3);
36 
37  /* Zero it out */
38  RtlZeroMemory(Hostent->h_aliases, AliasCount * sizeof(PCHAR));
39 
40  /* Put addresses after aliases */
41  Hostent->h_addr_list = (PCHAR*)
42  ((ULONG_PTR)Hostent->h_aliases +
43  (AliasCount * sizeof(PCHAR)) + sizeof(PCHAR));
44 
45  /* Update the location */
46  BufferPosition = (ULONG_PTR)Hostent->h_addr_list +
47  ((AddressCount * sizeof(PCHAR)) + sizeof(PCHAR));
48 
49  /* Send it back */
50  *Buffer = (PVOID)BufferPosition;
51 
52  /* Return the hostent */
53  return Hostent;
54 }
signed char * PCHAR
Definition: retypes.h:7
char ** h_addr_list
Definition: winsock.h:138
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
char ** h_aliases
Definition: winsock.h:135
uint32_t ULONG_PTR
Definition: typedefs.h:63
short h_length
Definition: winsock.h:137
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define PCHAR
Definition: match.c:90
unsigned short WORD
Definition: ntddk_ex.h:93
short h_addrtype
Definition: winsock.h:136
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
struct hostent * PHOSTENT
Definition: winsock.h:497

Referenced by SaBlob_CreateHostent().