ReactOS  0.4.15-dev-499-g1f31905
precomp.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS System Libraries
4  * FILE: lib/dnsapi/precomp.h
5  * PURPOSE: Win32 DNS API Library Header
6  * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7  */
8 
9 #ifndef _DNSAPI_H
10 #define _DNSAPI_H
11 
12 /* INCLUDES ******************************************************************/
13 
14 #include <stdarg.h>
15 
16 /* PSDK/NDK Headers */
17 #define WIN32_NO_STATUS
18 #define _INC_WINDOWS
19 #define COM_NO_WINDOWS_H
20 #include <windef.h>
21 #include <winbase.h>
22 #include <winnls.h>
23 #include <windns.h>
24 #include <reactos/windns_undoc.h>
25 #define NTOS_MODE_USER
26 #include <ndk/rtlfuncs.h>
27 
28 #include <dnsrslvr_c.h>
29 
30 #include <adns.h>
31 
32 typedef struct
33 {
36 
37 static inline LPWSTR dns_strdup_uw( const char *str )
38 {
39  LPWSTR ret = NULL;
40  if (str)
41  {
42  DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
43  if ((ret = HeapAlloc(GetProcessHeap(),0,( len * sizeof(WCHAR) ))))
44  MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
45  }
46  return ret;
47 }
48 
49 static inline LPWSTR dns_strdup_aw( LPCSTR str )
50 {
51  LPWSTR ret = NULL;
52  if (str)
53  {
54  DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
55  if ((ret = HeapAlloc(GetProcessHeap(), 0, ( len * sizeof(WCHAR) ))))
56  MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
57  }
58  return ret;
59 }
60 
61 static inline LPSTR dns_strdup_a( LPCSTR src )
62 {
63  LPSTR dst;
64 
65  if (!src) return NULL;
66  dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenA( src ) + 1) * sizeof(char) );
67  if (dst) lstrcpyA( dst, src );
68  return dst;
69 }
70 
71 static inline char *dns_strdup_u( const char *src )
72 {
73  char *dst;
74 
75  if (!src) return NULL;
76  dst = HeapAlloc(GetProcessHeap(), 0, (strlen( src ) + 1) * sizeof(char) );
77  if (dst) strcpy( dst, src );
78  return dst;
79 }
80 
81 static inline LPWSTR dns_strdup_w( LPCWSTR src )
82 {
83  LPWSTR dst;
84 
85  if (!src) return NULL;
86  dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenW( src ) + 1) * sizeof(WCHAR) );
87  if (dst) lstrcpyW( dst, src );
88  return dst;
89 }
90 
91 static inline LPSTR dns_strdup_wa( LPCWSTR str )
92 {
93  LPSTR ret = NULL;
94  if (str)
95  {
96  DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
97  if ((ret = HeapAlloc(GetProcessHeap(), 0, len )))
98  WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
99  }
100  return ret;
101 }
102 
103 static inline char *dns_strdup_wu( LPCWSTR str )
104 {
105  LPSTR ret = NULL;
106  if (str)
107  {
108  DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
109  if ((ret = HeapAlloc(GetProcessHeap(), 0, len )))
110  WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
111  }
112  return ret;
113 }
114 
115 static inline char *dns_strdup_au( LPCSTR src )
116 {
117  char *dst = NULL;
119 
120  if (ret)
121  {
122  dst = dns_strdup_wu( ret );
123  HeapFree( GetProcessHeap(), 0, ret );
124  }
125  return dst;
126 }
127 
128 static inline LPSTR dns_strdup_ua( const char *src )
129 {
130  LPSTR dst = NULL;
132 
133  if (ret)
134  {
135  dst = dns_strdup_wa( ret );
136  HeapFree( GetProcessHeap(), 0, ret );
137  }
138  return dst;
139 }
140 
142 void DnsIntFreeRecordList(PDNS_RECORD ToFree);
143 
144 #endif /* _DNSAPI_H */
static char * dns_strdup_u(const char *src)
Definition: precomp.h:71
#define WideCharToMultiByte
Definition: compat.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static LPWSTR dns_strdup_w(LPCWSTR src)
Definition: precomp.h:81
static LPSTR dns_strdup_ua(const char *src)
Definition: precomp.h:128
static char * dns_strdup_au(LPCSTR src)
Definition: precomp.h:115
#define CP_ACP
Definition: compat.h:99
struct WINDNS_CONTEXT * PWINDNS_CONTEXT
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:416
static LPWSTR dns_strdup_uw(const char *str)
Definition: precomp.h:37
static LPSTR dns_strdup_wa(LPCWSTR str)
Definition: precomp.h:91
static LPSTR dns_strdup_a(LPCSTR src)
Definition: precomp.h:61
#define CP_UTF8
Definition: nls.h:20
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
static LPWSTR dns_strdup_aw(LPCSTR str)
Definition: precomp.h:49
DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS(int Status)
Definition: adns.c:17
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
Status
Definition: gdiplustypes.h:24
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define lstrcpyW
Definition: compat.h:415
static char * dns_strdup_wu(LPCWSTR str)
Definition: precomp.h:103
GLenum GLenum dst
Definition: glext.h:6340
void DnsIntFreeRecordList(PDNS_RECORD ToFree)
Definition: query.c:889
#define MultiByteToWideChar
Definition: compat.h:100
adns_state State
Definition: precomp.h:34
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define PDNS_RECORD
Definition: windns.h:636
#define HeapFree(x, y, z)
Definition: compat.h:403