widl: Strip last separator in append_namespaces if suffix is NULL.
[wine.git] / dlls / dnsapi / dnsapi.h
blob0b679731e913f6ec4cf927cd3782f08ec7ceb774
1 /*
2 * DNS support
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 #ifndef __WINE_CONFIG_H
22 # error You must include config.h to use this header
23 #endif
25 #include "wine/heap.h"
27 static inline LPSTR dns_strdup_a( LPCSTR src )
29 LPSTR dst;
31 if (!src) return NULL;
32 dst = heap_alloc( (lstrlenA( src ) + 1) * sizeof(char) );
33 if (dst) lstrcpyA( dst, src );
34 return dst;
37 static inline char *dns_strdup_u( const char *src )
39 char *dst;
41 if (!src) return NULL;
42 dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) );
43 if (dst) strcpy( dst, src );
44 return dst;
47 static inline LPWSTR dns_strdup_w( LPCWSTR src )
49 LPWSTR dst;
51 if (!src) return NULL;
52 dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
53 if (dst) lstrcpyW( dst, src );
54 return dst;
57 static inline LPWSTR dns_strdup_aw( LPCSTR str )
59 LPWSTR ret = NULL;
60 if (str)
62 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
63 if ((ret = heap_alloc( len * sizeof(WCHAR) )))
64 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
66 return ret;
69 static inline LPWSTR dns_strdup_uw( const char *str )
71 LPWSTR ret = NULL;
72 if (str)
74 DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
75 if ((ret = heap_alloc( len * sizeof(WCHAR) )))
76 MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
78 return ret;
81 static inline LPSTR dns_strdup_wa( LPCWSTR str )
83 LPSTR ret = NULL;
84 if (str)
86 DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
87 if ((ret = heap_alloc( len )))
88 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
90 return ret;
93 static inline char *dns_strdup_wu( LPCWSTR str )
95 LPSTR ret = NULL;
96 if (str)
98 DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
99 if ((ret = heap_alloc( len )))
100 WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
102 return ret;
105 static inline char *dns_strdup_au( LPCSTR src )
107 char *dst = NULL;
108 LPWSTR ret = dns_strdup_aw( src );
110 if (ret)
112 dst = dns_strdup_wu( ret );
113 heap_free( ret );
115 return dst;
118 static inline LPSTR dns_strdup_ua( const char *src )
120 LPSTR dst = NULL;
121 LPWSTR ret = dns_strdup_uw( src );
123 if (ret)
125 dst = dns_strdup_wa( ret );
126 heap_free( ret );
128 return dst;
131 const char *dns_type_to_str( unsigned short ) DECLSPEC_HIDDEN;
133 #ifdef HAVE_RESOLV
134 int dns_ns_initparse( const u_char *, int, ns_msg * ) DECLSPEC_HIDDEN;
135 int dns_ns_parserr( ns_msg *, ns_sect, int, ns_rr * ) DECLSPEC_HIDDEN;
136 int dns_ns_name_skip( const u_char **, const u_char * ) DECLSPEC_HIDDEN;
137 int dns_ns_name_uncompress( const u_char *, const u_char *, const u_char *, char *, size_t ) DECLSPEC_HIDDEN;
138 #endif