4 * Copyright 2006 Hans Leidekker
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.
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.
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
21 #include "wine/heap.h"
23 static inline char *strdup_a( const char *src
)
26 if (!src
) return NULL
;
27 dst
= heap_alloc( (lstrlenA( src
) + 1) * sizeof(char) );
28 if (dst
) lstrcpyA( dst
, src
);
32 static inline char *strdup_u( const char *src
)
35 if (!src
) return NULL
;
36 dst
= heap_alloc( (strlen( src
) + 1) * sizeof(char) );
37 if (dst
) strcpy( dst
, src
);
41 static inline WCHAR
*strdup_w( const WCHAR
*src
)
44 if (!src
) return NULL
;
45 dst
= heap_alloc( (lstrlenW( src
) + 1) * sizeof(WCHAR
) );
46 if (dst
) lstrcpyW( dst
, src
);
50 static inline WCHAR
*strdup_aw( const char *str
)
55 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
56 if ((ret
= heap_alloc( len
* sizeof(WCHAR
) )))
57 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
62 static inline WCHAR
*strdup_uw( const char *str
)
67 DWORD len
= MultiByteToWideChar( CP_UTF8
, 0, str
, -1, NULL
, 0 );
68 if ((ret
= heap_alloc( len
* sizeof(WCHAR
) )))
69 MultiByteToWideChar( CP_UTF8
, 0, str
, -1, ret
, len
);
74 static inline char *strdup_wa( const WCHAR
*str
)
79 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
80 if ((ret
= heap_alloc( len
)))
81 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
86 static inline char *strdup_wu( const WCHAR
*str
)
91 DWORD len
= WideCharToMultiByte( CP_UTF8
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
92 if ((ret
= heap_alloc( len
)))
93 WideCharToMultiByte( CP_UTF8
, 0, str
, -1, ret
, len
, NULL
, NULL
);
98 static inline char *strdup_au( const char *src
)
101 WCHAR
*ret
= strdup_aw( src
);
104 dst
= strdup_wu( ret
);
110 static inline char *strdup_ua( const char *src
)
113 WCHAR
*ret
= strdup_uw( src
);
116 dst
= strdup_wa( ret
);
122 extern const char *type_to_str( unsigned short ) DECLSPEC_HIDDEN
;
124 extern DNS_STATUS CDECL
resolv_get_serverlist( IP4_ARRAY
*, DWORD
* ) DECLSPEC_HIDDEN
;
125 extern DNS_STATUS CDECL
resolv_query( const char *, WORD
, DWORD
, DNS_RECORDA
** ) DECLSPEC_HIDDEN
;
126 extern DNS_STATUS CDECL
resolv_set_serverlist( const IP4_ARRAY
* ) DECLSPEC_HIDDEN
;
130 DNS_STATUS (CDECL
*get_serverlist
)( IP4_ARRAY
*addrs
, DWORD
*len
);
131 DNS_STATUS (CDECL
*query
)( const char *name
, WORD type
, DWORD options
, DNS_RECORDA
**result
);
132 DNS_STATUS (CDECL
*set_serverlist
)( const IP4_ARRAY
*addrs
);
135 extern const struct resolv_funcs
*resolv_funcs
;