ntdll: Add ARM64 cpu info.
[wine] / dlls / dnsapi / dnsapi.h
1 /*
2  * DNS support
3  *
4  * Copyright 2006 Hans Leidekker
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_CONFIG_H
22 # error You must include config.h to use this header
23 #endif
24
25 static inline void *heap_alloc( SIZE_T size )
26 {
27     return HeapAlloc( GetProcessHeap(), 0, size );
28 }
29
30 static inline void *heap_alloc_zero( SIZE_T size )
31 {
32     return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
33 }
34
35 static inline BOOL heap_free( LPVOID mem )
36 {
37     return HeapFree( GetProcessHeap(), 0, mem );
38 }
39
40 static inline LPSTR dns_strdup_a( LPCSTR src )
41 {
42     LPSTR dst;
43
44     if (!src) return NULL;
45     dst = heap_alloc( (lstrlenA( src ) + 1) * sizeof(char) );
46     if (dst) lstrcpyA( dst, src );
47     return dst;
48 }
49
50 static inline char *dns_strdup_u( const char *src )
51 {
52     char *dst;
53
54     if (!src) return NULL;
55     dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) );
56     if (dst) strcpy( dst, src );
57     return dst;
58 }
59
60 static inline LPWSTR dns_strdup_w( LPCWSTR src )
61 {
62     LPWSTR dst;
63
64     if (!src) return NULL;
65     dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
66     if (dst) lstrcpyW( dst, src );
67     return dst;
68 }
69
70 static inline LPWSTR dns_strdup_aw( LPCSTR str )
71 {
72     LPWSTR ret = NULL;
73     if (str)
74     {
75         DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
76         if ((ret = heap_alloc( len * sizeof(WCHAR) )))
77             MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
78     }
79     return ret;
80 }
81
82 static inline LPWSTR dns_strdup_uw( const char *str )
83 {
84     LPWSTR ret = NULL;
85     if (str)
86     {
87         DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
88         if ((ret = heap_alloc( len * sizeof(WCHAR) )))
89             MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
90     }
91     return ret;
92 }
93
94 static inline LPSTR dns_strdup_wa( LPCWSTR str )
95 {
96     LPSTR ret = NULL;
97     if (str)
98     {
99         DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
100         if ((ret = heap_alloc( len )))
101             WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
102     }
103     return ret;
104 }
105
106 static inline char *dns_strdup_wu( LPCWSTR str )
107 {
108     LPSTR ret = NULL;
109     if (str)
110     {
111         DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
112         if ((ret = heap_alloc( len )))
113             WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
114     }
115     return ret;
116 }
117
118 static inline char *dns_strdup_au( LPCSTR src )
119 {
120     char *dst = NULL;
121     LPWSTR ret = dns_strdup_aw( src );
122
123     if (ret)
124     {
125         dst = dns_strdup_wu( ret );
126         heap_free( ret );
127     }
128     return dst;
129 }
130
131 static inline LPSTR dns_strdup_ua( const char *src )
132 {
133     LPSTR dst = NULL;
134     LPWSTR ret = dns_strdup_uw( src );
135
136     if (ret)
137     {
138         dst = dns_strdup_wa( ret );
139         heap_free( ret );
140     }
141     return dst;
142 }
143
144 const char *dns_type_to_str( unsigned short ) DECLSPEC_HIDDEN;
145
146 #ifdef HAVE_RESOLV
147 int dns_ns_initparse( const u_char *, int, ns_msg * ) DECLSPEC_HIDDEN;
148 int dns_ns_parserr( ns_msg *, ns_sect, int, ns_rr * ) DECLSPEC_HIDDEN;
149 int dns_ns_name_skip( const u_char **, const u_char * ) DECLSPEC_HIDDEN;
150 int dns_ns_name_uncompress( const u_char *, const u_char *, const u_char *, char *, size_t ) DECLSPEC_HIDDEN;
151 #endif