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
|
|
|
*/
|
|
|
|
|
2021-11-02 16:59:59 +01:00
|
|
|
#include <stdlib.h>
|
2021-11-02 16:54:28 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "wine/unixlib.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;
|
2021-11-02 16:59:59 +01:00
|
|
|
dst = malloc( (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;
|
2021-11-02 16:59:59 +01:00
|
|
|
dst = malloc( (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;
|
2021-11-02 16:59:59 +01:00
|
|
|
dst = malloc( (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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
if ((ret = malloc( 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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
if ((ret = malloc( 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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
if ((ret = malloc( 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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
if ((ret = malloc( 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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
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 );
|
2021-11-02 16:59:59 +01:00
|
|
|
free( ret );
|
2006-05-01 16:29:14 +02:00
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
2006-05-29 12:47:19 +02:00
|
|
|
|
2021-11-02 12:45:10 +01:00
|
|
|
extern const char *debugstr_type( unsigned short ) DECLSPEC_HIDDEN;
|
2021-03-30 10:35:28 +02:00
|
|
|
|
2021-11-02 16:54:28 +01:00
|
|
|
struct get_searchlist_params
|
2021-03-30 10:35:28 +02:00
|
|
|
{
|
2021-11-02 16:54:28 +01:00
|
|
|
DNS_TXT_DATAW *list;
|
|
|
|
DWORD *len;
|
2021-03-30 10:35:28 +02:00
|
|
|
};
|
|
|
|
|
2021-11-02 16:54:28 +01:00
|
|
|
struct get_serverlist_params
|
|
|
|
{
|
|
|
|
USHORT family;
|
|
|
|
DNS_ADDR_ARRAY *addrs;
|
|
|
|
DWORD *len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct query_params
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
WORD type;
|
|
|
|
DWORD options;
|
|
|
|
void *buf;
|
|
|
|
DWORD *len;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum unix_funcs
|
|
|
|
{
|
|
|
|
unix_get_searchlist,
|
|
|
|
unix_get_serverlist,
|
|
|
|
unix_set_serverlist,
|
|
|
|
unix_query,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern unixlib_handle_t resolv_handle;
|
|
|
|
|
|
|
|
#define RESOLV_CALL( func, params ) __wine_unix_call( resolv_handle, unix_ ## func, params )
|