2006-04-09 18:35:48 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-09 18:35:48 +02:00
|
|
|
*/
|
|
|
|
|
2018-01-30 23:40:59 +01:00
|
|
|
#include "wine/heap.h"
|
2006-04-09 18:35:48 +02:00
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_a( const char *src )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
char *dst;
|
2006-05-01 16:29:14 +02:00
|
|
|
if (!src) return NULL;
|
2007-11-28 00:11:14 +01:00
|
|
|
dst = heap_alloc( (lstrlenA( src ) + 1) * sizeof(char) );
|
2006-05-01 16:29:14 +02:00
|
|
|
if (dst) lstrcpyA( dst, src );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_u( const char *src )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
|
|
|
char *dst;
|
|
|
|
if (!src) return NULL;
|
2007-11-28 00:11:14 +01:00
|
|
|
dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) );
|
2006-05-01 16:29:14 +02:00
|
|
|
if (dst) strcpy( dst, src );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline WCHAR *strdup_w( const WCHAR *src )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
WCHAR *dst;
|
2006-05-01 16:29:14 +02:00
|
|
|
if (!src) return NULL;
|
2007-11-28 00:11:14 +01:00
|
|
|
dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
|
2006-05-01 16:29:14 +02:00
|
|
|
if (dst) lstrcpyW( dst, src );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline WCHAR *strdup_aw( const char *str )
|
2006-04-09 18:35:48 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
WCHAR *ret = NULL;
|
2006-04-09 18:35:48 +02:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
|
2007-11-28 00:11:14 +01:00
|
|
|
if ((ret = heap_alloc( len * sizeof(WCHAR) )))
|
2006-04-09 18:35:48 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2006-05-01 16:29:14 +02:00
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline WCHAR *strdup_uw( const char *str )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
WCHAR *ret = NULL;
|
2006-05-01 16:29:14 +02:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
|
2007-11-28 00:11:14 +01:00
|
|
|
if ((ret = heap_alloc( len * sizeof(WCHAR) )))
|
2006-05-01 16:29:14 +02:00
|
|
|
MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_wa( const WCHAR *str )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
char *ret = NULL;
|
2006-05-01 16:29:14 +02:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
|
2007-11-28 00:11:14 +01:00
|
|
|
if ((ret = heap_alloc( len )))
|
2006-05-01 16:29:14 +02:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_wu( const WCHAR *str )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
char *ret = NULL;
|
2006-05-01 16:29:14 +02:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
|
2007-11-28 00:11:14 +01:00
|
|
|
if ((ret = heap_alloc( len )))
|
2006-05-01 16:29:14 +02:00
|
|
|
WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_au( const char *src )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
|
|
|
char *dst = NULL;
|
2021-03-30 10:35:27 +02:00
|
|
|
WCHAR *ret = strdup_aw( src );
|
2006-05-01 16:29:14 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
dst = strdup_wu( ret );
|
2007-11-28 00:11:14 +01:00
|
|
|
heap_free( ret );
|
2006-05-01 16:29:14 +02:00
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:35:27 +02:00
|
|
|
static inline char *strdup_ua( const char *src )
|
2006-05-01 16:29:14 +02:00
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
char *dst = NULL;
|
|
|
|
WCHAR *ret = strdup_uw( src );
|
2006-05-01 16:29:14 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
2021-03-30 10:35:27 +02:00
|
|
|
dst = strdup_wa( ret );
|
2007-11-28 00:11:14 +01:00
|
|
|
heap_free( ret );
|
2006-05-01 16:29:14 +02:00
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
2006-05-29 12:47:19 +02:00
|
|
|
|
2021-03-30 10:35:28 +02:00
|
|
|
extern const char *type_to_str( unsigned short ) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
extern DNS_STATUS CDECL resolv_get_serverlist( IP4_ARRAY *, DWORD * ) DECLSPEC_HIDDEN;
|
|
|
|
extern DNS_STATUS CDECL resolv_query( const char *, WORD, DWORD, DNS_RECORDA ** ) DECLSPEC_HIDDEN;
|
|
|
|
extern DNS_STATUS CDECL resolv_set_serverlist( const IP4_ARRAY * ) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
struct resolv_funcs
|
|
|
|
{
|
|
|
|
DNS_STATUS (CDECL *get_serverlist)( IP4_ARRAY *addrs, DWORD *len );
|
|
|
|
DNS_STATUS (CDECL *query)( const char *name, WORD type, DWORD options, DNS_RECORDA **result );
|
|
|
|
DNS_STATUS (CDECL *set_serverlist)( const IP4_ARRAY *addrs );
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct resolv_funcs *resolv_funcs;
|