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 { 34 adns_state State; 35 } WINDNS_CONTEXT, *PWINDNS_CONTEXT; 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; 118 LPWSTR ret = dns_strdup_aw( src ); 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; 131 LPWSTR ret = dns_strdup_uw( src ); 132 133 if (ret) 134 { 135 dst = dns_strdup_wa( ret ); 136 HeapFree( GetProcessHeap(), 0, ret ); 137 } 138 return dst; 139 } 140 141 DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS(int Status); 142 void DnsIntFreeRecordList(PDNS_RECORD ToFree); 143 144 #endif /* _DNSAPI_H */ 145