ReactOS  0.4.13-dev-242-g611e6d7
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 #define NTOS_MODE_USER
25 #include <ndk/rtlfuncs.h>
26 
27 /* Internal DNSAPI Headers */
28 #include <internal/windns.h>
29 
30 static inline LPWSTR dns_strdup_uw( const char *str )
31 {
32  LPWSTR ret = NULL;
33  if (str)
34  {
35  DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
36  if ((ret = HeapAlloc(GetProcessHeap(),0,( len * sizeof(WCHAR) ))))
37  MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
38  }
39  return ret;
40 }
41 
42 static inline LPWSTR dns_strdup_aw( LPCSTR str )
43 {
44  LPWSTR ret = NULL;
45  if (str)
46  {
47  DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
48  if ((ret = HeapAlloc(GetProcessHeap(), 0, ( len * sizeof(WCHAR) ))))
49  MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
50  }
51  return ret;
52 }
53 
54 static inline LPSTR dns_strdup_a( LPCSTR src )
55 {
56  LPSTR dst;
57 
58  if (!src) return NULL;
59  dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenA( src ) + 1) * sizeof(char) );
60  if (dst) lstrcpyA( dst, src );
61  return dst;
62 }
63 
64 static inline char *dns_strdup_u( const char *src )
65 {
66  char *dst;
67 
68  if (!src) return NULL;
69  dst = HeapAlloc(GetProcessHeap(), 0, (strlen( src ) + 1) * sizeof(char) );
70  if (dst) strcpy( dst, src );
71  return dst;
72 }
73 
74 static inline LPWSTR dns_strdup_w( LPCWSTR src )
75 {
76  LPWSTR dst;
77 
78  if (!src) return NULL;
79  dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenW( src ) + 1) * sizeof(WCHAR) );
80  if (dst) lstrcpyW( dst, src );
81  return dst;
82 }
83 
84 static inline LPSTR dns_strdup_wa( LPCWSTR str )
85 {
86  LPSTR ret = NULL;
87  if (str)
88  {
89  DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
90  if ((ret = HeapAlloc(GetProcessHeap(), 0, len )))
91  WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
92  }
93  return ret;
94 }
95 
96 static inline char *dns_strdup_wu( LPCWSTR str )
97 {
98  LPSTR ret = NULL;
99  if (str)
100  {
101  DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
102  if ((ret = HeapAlloc(GetProcessHeap(), 0, len )))
103  WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
104  }
105  return ret;
106 }
107 
108 static inline char *dns_strdup_au( LPCSTR src )
109 {
110  char *dst = NULL;
112 
113  if (ret)
114  {
115  dst = dns_strdup_wu( ret );
116  HeapFree( GetProcessHeap(), 0, ret );
117  }
118  return dst;
119 }
120 
121 static inline LPSTR dns_strdup_ua( const char *src )
122 {
123  LPSTR dst = NULL;
125 
126  if (ret)
127  {
128  dst = dns_strdup_wa( ret );
129  HeapFree( GetProcessHeap(), 0, ret );
130  }
131  return dst;
132 }
133 
134 #endif /* _DNSAPI_H */
static LPWSTR dns_strdup_aw(LPCSTR str)
Definition: precomp.h:42
#define WideCharToMultiByte
Definition: compat.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:407
#define CP_UTF8
Definition: nls.h:20
static char * dns_strdup_u(const char *src)
Definition: precomp.h:64
static LPSTR dns_strdup_a(LPCSTR src)
Definition: precomp.h:54
static LPWSTR dns_strdup_w(LPCWSTR src)
Definition: precomp.h:74
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
static LPWSTR dns_strdup_uw(const char *str)
Definition: precomp.h:30
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static char * dns_strdup_au(LPCSTR src)
Definition: precomp.h:108
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
GLenum GLsizei len
Definition: glext.h:6722
static char * dns_strdup_wu(LPCWSTR str)
Definition: precomp.h:96
GLenum src
Definition: glext.h:6340
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define lstrcpyW
Definition: compat.h:406
GLenum GLenum dst
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:100
static LPSTR dns_strdup_ua(const char *src)
Definition: precomp.h:121
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static LPSTR dns_strdup_wa(LPCWSTR str)
Definition: precomp.h:84
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394