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