ReactOS 0.4.15-dev-7924-g5949c20
record.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for record.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define X(x)   case (x): return #x;
 

Functions

const chardns_type_to_str (unsigned short type)
 
static int dns_strcmpX (LPCVOID str1, LPCVOID str2, BOOL wide)
 
BOOL WINAPI DnsRecordCompare (PDNS_RECORD r1, PDNS_RECORD r2)
 
static LPVOID dns_strcpyX (LPCVOID src, DNS_CHARSET in, DNS_CHARSET out)
 
PDNS_RECORD WINAPI DnsRecordCopyEx (PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET out)
 
VOID WINAPI DnsRecordListFree (PDNS_RECORD list, DNS_FREE_TYPE type)
 
BOOL WINAPI DnsRecordSetCompare (PDNS_RECORD set1, PDNS_RECORD set2, PDNS_RECORD *diff1, PDNS_RECORD *diff2)
 
PDNS_RECORD WINAPI DnsRecordSetCopyEx (PDNS_RECORD src_set, DNS_CHARSET in, DNS_CHARSET out)
 
PDNS_RECORD WINAPI DnsRecordSetDetach (PDNS_RECORD set)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 23 of file record.c.

◆ X

#define X (   x)    case (x): return #x;

Function Documentation

◆ dns_strcmpX()

static int dns_strcmpX ( LPCVOID  str1,
LPCVOID  str2,
BOOL  wide 
)
static

Definition at line 92 of file record.c.

93{
94 if (wide)
95 return lstrcmpiW( str1, str2 );
96 else
97 return lstrcmpiA( str1, str2 );
98}
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194

Referenced by DnsRecordCompare().

◆ dns_strcpyX()

static LPVOID dns_strcpyX ( LPCVOID  src,
DNS_CHARSET  in,
DNS_CHARSET  out 
)
static

Definition at line 345 of file record.c.

346{
347 switch (in)
348 {
350 {
351 switch (out)
352 {
353 case DnsCharSetUnicode: return dns_strdup_w( src );
354 case DnsCharSetUtf8: return dns_strdup_wu( src );
355 case DnsCharSetAnsi: return dns_strdup_wa( src );
356 default:
357 DPRINT1( "unhandled target charset: %d\n", out );
358 break;
359 }
360 break;
361 }
362 case DnsCharSetUtf8:
363 switch (out)
364 {
365 case DnsCharSetUnicode: return dns_strdup_uw( src );
366 case DnsCharSetUtf8: return dns_strdup_u( src );
367 case DnsCharSetAnsi: return dns_strdup_ua( src );
368 default:
369 DPRINT1( "unhandled target charset: %d\n", out );
370 break;
371 }
372 break;
373 case DnsCharSetAnsi:
374 switch (out)
375 {
376 case DnsCharSetUnicode: return dns_strdup_aw( src );
377 case DnsCharSetUtf8: return dns_strdup_au( src );
378 case DnsCharSetAnsi: return dns_strdup_a( src );
379 default:
380 DPRINT1( "unhandled target charset: %d\n", out );
381 break;
382 }
383 break;
384 default:
385 DPRINT1( "unhandled source charset: %d\n", in );
386 break;
387 }
388 return NULL;
389}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
static LPSTR dns_strdup_a(LPCSTR src)
Definition: precomp.h:61
static LPWSTR dns_strdup_w(LPCWSTR src)
Definition: precomp.h:81
static char * dns_strdup_au(LPCSTR src)
Definition: precomp.h:115
static char * dns_strdup_u(const char *src)
Definition: precomp.h:71
static char * dns_strdup_wu(LPCWSTR str)
Definition: precomp.h:103
static LPWSTR dns_strdup_aw(LPCSTR str)
Definition: precomp.h:49
static LPWSTR dns_strdup_uw(const char *str)
Definition: precomp.h:37
static LPSTR dns_strdup_wa(LPCWSTR str)
Definition: precomp.h:91
static LPSTR dns_strdup_ua(const char *src)
Definition: precomp.h:128
GLenum src
Definition: glext.h:6340
GLuint in
Definition: glext.h:9616
static FILE * out
Definition: regtests2xml.c:44
@ DnsCharSetUnicode
Definition: windns.h:111
@ DnsCharSetUtf8
Definition: windns.h:112
@ DnsCharSetAnsi
Definition: windns.h:113

Referenced by DnsRecordCopyEx().

◆ dns_type_to_str()

const char * dns_type_to_str ( unsigned short  type)

Definition at line 26 of file record.c.

27{
28 switch (type)
29 {
30#define X(x) case (x): return #x;
87#undef X
88 default: { static char tmp[7]; sprintf( tmp, "0x%04x", type ); return tmp; }
89 }
90}
#define X(x)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DNS_TYPE_WINSR
Definition: windns.h:97
#define DNS_TYPE_TKEY
Definition: windns.h:87
#define DNS_TYPE_NSAPPTR
Definition: windns.h:63
#define DNS_TYPE_NSAP
Definition: windns.h:62
#define DNS_TYPE_MINFO
Definition: windns.h:54
#define DNS_TYPE_UNSPEC
Definition: windns.h:85
#define DNS_TYPE_MAILA
Definition: windns.h:92
#define DNS_TYPE_HINFO
Definition: windns.h:53
#define DNS_TYPE_EID
Definition: windns.h:71
#define DNS_TYPE_RT
Definition: windns.h:61
#define DNS_TYPE_GID
Definition: windns.h:84
#define DNS_TYPE_MX
Definition: windns.h:55
#define DNS_TYPE_ATMA
Definition: windns.h:74
#define DNS_TYPE_LOC
Definition: windns.h:69
#define DNS_TYPE_ANY
Definition: windns.h:94
#define DNS_TYPE_WKS
Definition: windns.h:51
#define DNS_TYPE_SIG
Definition: windns.h:64
#define DNS_TYPE_ISDN
Definition: windns.h:60
#define DNS_TYPE_TEXT
Definition: windns.h:56
#define DNS_TYPE_PTR
Definition: windns.h:52
#define DNS_TYPE_MB
Definition: windns.h:47
#define DNS_TYPE_X25
Definition: windns.h:59
#define DNS_TYPE_MG
Definition: windns.h:48
#define DNS_TYPE_KEY
Definition: windns.h:65
#define DNS_TYPE_SINK
Definition: windns.h:80
#define DNS_TYPE_CNAME
Definition: windns.h:45
#define DNS_TYPE_OPT
Definition: windns.h:81
#define DNS_TYPE_UINFO
Definition: windns.h:82
#define DNS_TYPE_NS
Definition: windns.h:42
#define DNS_TYPE_SOA
Definition: windns.h:46
#define DNS_TYPE_PX
Definition: windns.h:66
#define DNS_TYPE_ZERO
Definition: windns.h:40
#define DNS_TYPE_MD
Definition: windns.h:43
#define DNS_TYPE_KX
Definition: windns.h:76
#define DNS_TYPE_MF
Definition: windns.h:44
#define DNS_TYPE_AFSDB
Definition: windns.h:58
#define DNS_TYPE_CERT
Definition: windns.h:77
#define DNS_TYPE_MAILB
Definition: windns.h:91
#define DNS_TYPE_DNAME
Definition: windns.h:79
#define DNS_TYPE_UID
Definition: windns.h:83
#define DNS_TYPE_ADDRS
Definition: windns.h:86
#define DNS_TYPE_SRV
Definition: windns.h:73
#define DNS_TYPE_NAPTR
Definition: windns.h:75
#define DNS_TYPE_AAAA
Definition: windns.h:68
#define DNS_TYPE_NULL
Definition: windns.h:50
#define DNS_TYPE_TSIG
Definition: windns.h:88
#define DNS_TYPE_RP
Definition: windns.h:57
#define DNS_TYPE_A6
Definition: windns.h:78
#define DNS_TYPE_IXFR
Definition: windns.h:89
#define DNS_TYPE_WINS
Definition: windns.h:96
#define DNS_TYPE_MR
Definition: windns.h:49
#define DNS_TYPE_NXT
Definition: windns.h:70
#define DNS_TYPE_NIMLOC
Definition: windns.h:72
#define DNS_TYPE_GPOS
Definition: windns.h:67
#define DNS_TYPE_AXFR
Definition: windns.h:90
#define DNS_TYPE_A
Definition: windns.h:41

Referenced by DnsRecordCompare().

◆ DnsRecordCompare()

BOOL WINAPI DnsRecordCompare ( PDNS_RECORD  r1,
PDNS_RECORD  r2 
)

Definition at line 104 of file record.c.

105{
106 BOOL wide;
107 unsigned int i;
108
109 DPRINT( "(%p,%p)\n", r1, r2 );
110
111 if (r1->wType != r2->wType ||
113 r1->Flags.S.Section != r2->Flags.S.Section ||
114 r1->Flags.S.Delete != r2->Flags.S.Delete ||
115 r1->Flags.S.Unused != r2->Flags.S.Unused ||
117 r1->dwReserved != r2->dwReserved) return FALSE;
118
120 if (dns_strcmpX( r1->pName, r2->pName, wide )) return FALSE;
121
122 switch (r1->wType)
123 {
124 case DNS_TYPE_A:
125 {
126 if (r1->Data.A.IpAddress != r2->Data.A.IpAddress) return FALSE;
127 break;
128 }
129 case DNS_TYPE_SOA:
130 {
136 return FALSE;
138 r2->Data.SOA.pNamePrimaryServer, wide ) ||
140 r2->Data.SOA.pNameAdministrator, wide ))
141 return FALSE;
142 break;
143 }
144 case DNS_TYPE_PTR:
145 case DNS_TYPE_NS:
146 case DNS_TYPE_CNAME:
147 case DNS_TYPE_MB:
148 case DNS_TYPE_MD:
149 case DNS_TYPE_MF:
150 case DNS_TYPE_MG:
151 case DNS_TYPE_MR:
152 {
154 r2->Data.PTR.pNameHost, wide )) return FALSE;
155 break;
156 }
157 case DNS_TYPE_MINFO:
158 case DNS_TYPE_RP:
159 {
161 r2->Data.MINFO.pNameMailbox, wide ) ||
164 return FALSE;
165 break;
166 }
167 case DNS_TYPE_MX:
168 case DNS_TYPE_AFSDB:
169 case DNS_TYPE_RT:
170 {
172 return FALSE;
174 r2->Data.MX.pNameExchange, wide ))
175 return FALSE;
176 break;
177 }
178 case DNS_TYPE_HINFO:
179 case DNS_TYPE_ISDN:
180 case DNS_TYPE_TEXT:
181 case DNS_TYPE_X25:
182 {
184 return FALSE;
185 for (i = 0; i < r1->Data.TXT.dwStringCount; i++)
186 {
188 r2->Data.TXT.pStringArray[i], wide ))
189 return FALSE;
190 }
191 break;
192 }
193 case DNS_TYPE_NULL:
194 {
196 return FALSE;
197 if (memcmp( r1->Data.Null.Data,
199 return FALSE;
200 break;
201 }
202 case DNS_TYPE_AAAA:
203 {
204 for (i = 0; i < sizeof(IP6_ADDRESS)/sizeof(DWORD); i++)
205 {
208 }
209 break;
210 }
211 case DNS_TYPE_KEY:
212 {
213 if (r1->Data.KEY.wFlags != r2->Data.KEY.wFlags ||
216 return FALSE;
217 if (memcmp( r1->Data.KEY.Key, r2->Data.KEY.Key,
218 r1->wDataLength - sizeof(DNS_KEY_DATA) + 1 ))
219 return FALSE;
220 break;
221 }
222 case DNS_TYPE_SIG:
223 {
225 r2->Data.SIG.pNameSigner, wide ))
226 return FALSE;
234 return FALSE;
236 r1->wDataLength - sizeof(DNS_SIG_DATAA) + 1 ))
237 return FALSE;
238 break;
239 }
240 case DNS_TYPE_ATMA:
241 {
243 return FALSE;
244 for (i = 0; i < DNS_ATMA_MAX_ADDR_LENGTH; i++)
245 {
246 if (r1->Data.ATMA.Address[i] != r2->Data.ATMA.Address[i])
247 return FALSE;
248 }
249 break;
250 }
251 case DNS_TYPE_NXT:
252 {
254 r2->Data.NXT.pNameNext, wide )) return FALSE;
255 if (r1->Data.NXT.wNumTypes != r2->Data.NXT.wNumTypes) return FALSE;
257 r1->wDataLength - sizeof(DNS_NXT_DATAA) + sizeof(WORD) ))
258 return FALSE;
259 break;
260 }
261 case DNS_TYPE_SRV:
262 {
264 r2->Data.SRV.pNameTarget, wide )) return FALSE;
265 if (r1->Data.SRV.wPriority != r2->Data.SRV.wPriority ||
268 return FALSE;
269 break;
270 }
271 case DNS_TYPE_TKEY:
272 {
274 r2->Data.TKEY.pNameAlgorithm, wide ))
275 return FALSE;
278 r1->Data.TKEY.wMode != r2->Data.TKEY.wMode ||
284 return FALSE;
285
286 /* FIXME: ignoring pAlgorithmPacket field */
288 r1->Data.TKEY.wKeyLength ) ||
290 r1->Data.TKEY.wOtherLength )) return FALSE;
291 break;
292 }
293 case DNS_TYPE_TSIG:
294 {
296 r2->Data.TSIG.pNameAlgorithm, wide ))
297 return FALSE;
306 return FALSE;
307
308 /* FIXME: ignoring pAlgorithmPacket field */
310 r1->Data.TSIG.wSigLength ) ||
312 r1->Data.TSIG.wOtherLength )) return FALSE;
313 break;
314 }
315 case DNS_TYPE_WINS:
316 {
321 return FALSE;
323 r1->wDataLength - sizeof(DNS_WINS_DATA) + sizeof(IP4_ADDRESS) ))
324 return FALSE;
325 break;
326 }
327 case DNS_TYPE_WINSR:
328 {
332 return FALSE;
335 return FALSE;
336 break;
337 }
338 default:
339 DPRINT1( "unknown type: %s\n", dns_type_to_str( r1->wType ) );
340 return FALSE;
341 }
342 return TRUE;
343}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const char * dns_type_to_str(unsigned short type)
Definition: record.c:26
static int dns_strcmpX(LPCVOID str1, LPCVOID str2, BOOL wide)
Definition: record.c:92
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38
#define DPRINT
Definition: sndvol32.h:71
DNS_IP6_ADDRESS Ip6Address
Definition: windns.h:250
BYTE Address[DNS_ATMA_MAX_ADDR_LENGTH]
Definition: windns.h:255
BYTE AddressType
Definition: windns.h:254
IP4_ADDRESS IpAddress
Definition: windns.h:246
BYTE chProtocol
Definition: windns.h:260
BYTE chAlgorithm
Definition: windns.h:261
BYTE Key[1]
Definition: windns.h:262
WORD wFlags
Definition: windns.h:259
LPWSTR pNameMailbox
Definition: windns.h:281
LPWSTR pNameErrorsMailbox
Definition: windns.h:282
WORD wPreference
Definition: windns.h:293
LPWSTR pNameExchange
Definition: windns.h:292
DWORD dwByteCount
Definition: windns.h:298
BYTE Data[1]
Definition: windns.h:299
LPWSTR pNameNext
Definition: windns.h:309
WORD wTypes[1]
Definition: windns.h:311
WORD wNumTypes
Definition: windns.h:310
LPWSTR pNameHost
Definition: windns.h:319
LPWSTR pNameSigner
Definition: windns.h:336
BYTE chAlgorithm
Definition: windns.h:338
WORD wTypeCovered
Definition: windns.h:337
WORD wKeyTag
Definition: windns.h:343
DWORD dwOriginalTtl
Definition: windns.h:340
BYTE Signature[1]
Definition: windns.h:345
DWORD dwTimeSigned
Definition: windns.h:342
DWORD dwExpiration
Definition: windns.h:341
BYTE chLabelCount
Definition: windns.h:339
LPWSTR pNameAdministrator
Definition: windns.h:360
LPWSTR pNamePrimaryServer
Definition: windns.h:359
DWORD dwRetry
Definition: windns.h:363
DWORD dwExpire
Definition: windns.h:364
DWORD dwRefresh
Definition: windns.h:362
DWORD dwDefaultTtl
Definition: windns.h:365
DWORD dwSerialNo
Definition: windns.h:361
WORD wPriority
Definition: windns.h:378
WORD wPort
Definition: windns.h:380
LPWSTR pNameTarget
Definition: windns.h:377
WORD wWeight
Definition: windns.h:379
WORD wMode
Definition: windns.h:416
LPWSTR pNameAlgorithm
Definition: windns.h:410
PBYTE pOtherData
Definition: windns.h:413
WORD wError
Definition: windns.h:417
WORD wOtherLength
Definition: windns.h:419
PBYTE pKey
Definition: windns.h:412
UCHAR cAlgNameLength
Definition: windns.h:420
WORD wKeyLength
Definition: windns.h:418
DWORD dwExpireTime
Definition: windns.h:415
BOOL bPacketPointers
Definition: windns.h:421
DWORD dwCreateTime
Definition: windns.h:414
LONGLONG i64CreateTime
Definition: windns.h:444
BOOL bPacketPointers
Definition: windns.h:451
LPWSTR pNameAlgorithm
Definition: windns.h:440
WORD wSigLength
Definition: windns.h:448
PBYTE pSignature
Definition: windns.h:442
WORD wError
Definition: windns.h:447
WORD wFudgeTime
Definition: windns.h:445
WORD wOtherLength
Definition: windns.h:449
UCHAR cAlgNameLength
Definition: windns.h:450
WORD wOriginalXid
Definition: windns.h:446
PBYTE pOtherData
Definition: windns.h:443
DWORD dwStringCount
Definition: windns.h:390
LPWSTR pStringArray[1]
Definition: windns.h:391
DWORD dwMappingFlag
Definition: windns.h:470
DWORD dwCacheTimeout
Definition: windns.h:472
DWORD dwLookupTimeout
Definition: windns.h:471
LPWSTR pNameResultDomain
Definition: windns.h:473
DWORD dwCacheTimeout
Definition: windns.h:457
DWORD dwMappingFlag
Definition: windns.h:455
IP4_ADDRESS WinsServers[1]
Definition: windns.h:459
DWORD dwLookupTimeout
Definition: windns.h:456
DWORD cWinsServerCount
Definition: windns.h:458
DWORD IP6Dword[4]
Definition: windns.h:165
DWORD Delete
Definition: windns.h:239
DWORD Unused
Definition: windns.h:241
DWORD Reserved
Definition: windns.h:242
DWORD CharSet
Definition: windns.h:240
DWORD Section
Definition: windns.h:238
DNS_NULL_DATA Null
Definition: windns.h:615
union _DnsRecordW::@3309 Flags
WORD wType
Definition: windns.h:600
DNS_ATMA_DATA ATMA
Definition: windns.h:620
DNS_WINSR_DATAW WINSR
Definition: windns.h:626
DNS_SRV_DATAW SRV
Definition: windns.h:622
LPWSTR pName
Definition: windns.h:599
DNS_KEY_DATA KEY
Definition: windns.h:618
DNS_TSIG_DATAW TSIG
Definition: windns.h:624
DNS_A_DATA A
Definition: windns.h:609
union _DnsRecordW::@3310 Data
DNS_WINS_DATA WINS
Definition: windns.h:625
DNS_AAAA_DATA AAAA
Definition: windns.h:617
DNS_RECORD_FLAGS S
Definition: windns.h:604
DNS_TXT_DATAW TXT
Definition: windns.h:614
DNS_MINFO_DATAW MINFO
Definition: windns.h:612
DNS_TKEY_DATAW TKEY
Definition: windns.h:623
DNS_SIG_DATAW SIG
Definition: windns.h:619
DNS_NXT_DATAW NXT
Definition: windns.h:621
WORD wDataLength
Definition: windns.h:601
DWORD dwReserved
Definition: windns.h:607
DNS_PTR_DATAW PTR
Definition: windns.h:611
DNS_MX_DATAW MX
Definition: windns.h:613
DNS_SOA_DATAW SOA
Definition: windns.h:610
DWORD IP4_ADDRESS
Definition: windns.h:36
@ DnsCharSetUnknown
Definition: windns.h:110
#define DNS_ATMA_MAX_ADDR_LENGTH
Definition: windns.h:105

Referenced by DnsRecordSetCompare(), and test_DnsRecordCompare().

◆ DnsRecordCopyEx()

PDNS_RECORD WINAPI DnsRecordCopyEx ( PDNS_RECORD  src,
DNS_CHARSET  in,
DNS_CHARSET  out 
)

Definition at line 395 of file record.c.

396{
398 unsigned int i, size;
399
400 DPRINT( "(%p,%d,%d)\n", src, in, out );
401
402 size = FIELD_OFFSET(DNS_RECORD, Data) + src->wDataLength;
404 if (!dst) return NULL;
405
406 memcpy( dst, src, size );
407
408 if (src->Flags.S.CharSet == DnsCharSetUtf8 ||
409 src->Flags.S.CharSet == DnsCharSetAnsi ||
410 src->Flags.S.CharSet == DnsCharSetUnicode) in = src->Flags.S.CharSet;
411
412 dst->Flags.S.CharSet = out;
413 dst->pName = dns_strcpyX( src->pName, in, out );
414 if (!dst->pName) goto error;
415
416 switch (src->wType)
417 {
418 case DNS_TYPE_HINFO:
419 case DNS_TYPE_ISDN:
420 case DNS_TYPE_TEXT:
421 case DNS_TYPE_X25:
422 {
423 for (i = 0; i < src->Data.TXT.dwStringCount; i++)
424 {
425 dst->Data.TXT.pStringArray[i] =
426 dns_strcpyX( src->Data.TXT.pStringArray[i], in, out );
427
428 if (!dst->Data.TXT.pStringArray[i])
429 {
430 while (i > 0) HeapFree( GetProcessHeap(), 0, dst->Data.TXT.pStringArray[--i] );
431 goto error;
432 }
433 }
434 break;
435 }
436 case DNS_TYPE_MINFO:
437 case DNS_TYPE_RP:
438 {
439 dst->Data.MINFO.pNameMailbox =
440 dns_strcpyX( src->Data.MINFO.pNameMailbox, in, out );
441 if (!dst->Data.MINFO.pNameMailbox) goto error;
442
443 dst->Data.MINFO.pNameErrorsMailbox =
444 dns_strcpyX( src->Data.MINFO.pNameErrorsMailbox, in, out );
445 if (!dst->Data.MINFO.pNameErrorsMailbox)
446 {
447 HeapFree( GetProcessHeap(), 0, dst->Data.MINFO.pNameMailbox );
448 goto error;
449 }
450 break;
451 }
452 case DNS_TYPE_AFSDB:
453 case DNS_TYPE_RT:
454 case DNS_TYPE_MX:
455 {
456 dst->Data.MX.pNameExchange =
457 dns_strcpyX( src->Data.MX.pNameExchange, in, out );
458 if (!dst->Data.MX.pNameExchange) goto error;
459 break;
460 }
461 case DNS_TYPE_NXT:
462 {
463 dst->Data.NXT.pNameNext =
464 dns_strcpyX( src->Data.NXT.pNameNext, in, out );
465 if (!dst->Data.NXT.pNameNext) goto error;
466 break;
467 }
468 case DNS_TYPE_CNAME:
469 case DNS_TYPE_MB:
470 case DNS_TYPE_MD:
471 case DNS_TYPE_MF:
472 case DNS_TYPE_MG:
473 case DNS_TYPE_MR:
474 case DNS_TYPE_NS:
475 case DNS_TYPE_PTR:
476 {
477 dst->Data.PTR.pNameHost =
478 dns_strcpyX( src->Data.PTR.pNameHost, in, out );
479 if (!dst->Data.PTR.pNameHost) goto error;
480 break;
481 }
482 case DNS_TYPE_SIG:
483 {
484 dst->Data.SIG.pNameSigner =
485 dns_strcpyX( src->Data.SIG.pNameSigner, in, out );
486 if (!dst->Data.SIG.pNameSigner) goto error;
487 break;
488 }
489 case DNS_TYPE_SOA:
490 {
491 dst->Data.SOA.pNamePrimaryServer =
492 dns_strcpyX( src->Data.SOA.pNamePrimaryServer, in, out );
493 if (!dst->Data.SOA.pNamePrimaryServer) goto error;
494
495 dst->Data.SOA.pNameAdministrator =
496 dns_strcpyX( src->Data.SOA.pNameAdministrator, in, out );
497 if (!dst->Data.SOA.pNameAdministrator)
498 {
499 HeapFree( GetProcessHeap(), 0, dst->Data.SOA.pNamePrimaryServer );
500 goto error;
501 }
502 break;
503 }
504 case DNS_TYPE_SRV:
505 {
506 dst->Data.SRV.pNameTarget =
507 dns_strcpyX( src->Data.SRV.pNameTarget, in, out );
508 if (!dst->Data.SRV.pNameTarget) goto error;
509 break;
510 }
511 default:
512 break;
513 }
514 return dst;
515
516error:
517 HeapFree( GetProcessHeap(), 0, dst->pName );
518 HeapFree( GetProcessHeap(), 0, dst );
519 return NULL;
520}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static LPVOID dns_strcpyX(LPCVOID src, DNS_CHARSET in, DNS_CHARSET out)
Definition: record.c:345
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum dst
Definition: glext.h:6340
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define DNS_RECORD
Definition: windns.h:635

Referenced by DnsRecordSetCompare(), and DnsRecordSetCopyEx().

◆ DnsRecordListFree()

VOID WINAPI DnsRecordListFree ( PDNS_RECORD  list,
DNS_FREE_TYPE  type 
)

Definition at line 526 of file record.c.

527{
528 DNS_RECORD *r, *next;
529 unsigned int i;
530
531 DPRINT( "(%p,%d)\n", list, type );
532
533 if (!list) return;
534
535 switch (type)
536 {
538 {
539 for (r = list; (list = r); r = next)
540 {
541 HeapFree( GetProcessHeap(), 0, r->pName );
542
543 switch (r->wType)
544 {
545 case DNS_TYPE_HINFO:
546 case DNS_TYPE_ISDN:
547 case DNS_TYPE_TEXT:
548 case DNS_TYPE_X25:
549 {
550 for (i = 0; i < r->Data.TXT.dwStringCount; i++)
551 HeapFree( GetProcessHeap(), 0, r->Data.TXT.pStringArray[i] );
552
553 break;
554 }
555 case DNS_TYPE_MINFO:
556 case DNS_TYPE_RP:
557 {
558 HeapFree( GetProcessHeap(), 0, r->Data.MINFO.pNameMailbox );
559 HeapFree( GetProcessHeap(), 0, r->Data.MINFO.pNameErrorsMailbox );
560 break;
561 }
562 case DNS_TYPE_AFSDB:
563 case DNS_TYPE_RT:
564 case DNS_TYPE_MX:
565 {
566 HeapFree( GetProcessHeap(), 0, r->Data.MX.pNameExchange );
567 break;
568 }
569 case DNS_TYPE_NXT:
570 {
571 HeapFree( GetProcessHeap(), 0, r->Data.NXT.pNameNext );
572 break;
573 }
574 case DNS_TYPE_CNAME:
575 case DNS_TYPE_MB:
576 case DNS_TYPE_MD:
577 case DNS_TYPE_MF:
578 case DNS_TYPE_MG:
579 case DNS_TYPE_MR:
580 case DNS_TYPE_NS:
581 case DNS_TYPE_PTR:
582 {
583 HeapFree( GetProcessHeap(), 0, r->Data.PTR.pNameHost );
584 break;
585 }
586 case DNS_TYPE_SIG:
587 {
588 HeapFree( GetProcessHeap(), 0, r->Data.SIG.pNameSigner );
589 break;
590 }
591 case DNS_TYPE_SOA:
592 {
593 HeapFree( GetProcessHeap(), 0, r->Data.SOA.pNamePrimaryServer );
594 HeapFree( GetProcessHeap(), 0, r->Data.SOA.pNameAdministrator );
595 break;
596 }
597 case DNS_TYPE_SRV:
598 {
599 HeapFree( GetProcessHeap(), 0, r->Data.SRV.pNameTarget );
600 break;
601 }
602 default:
603 break;
604 }
605
606 next = r->pNext;
607 HeapFree( GetProcessHeap(), 0, r );
608 }
609 break;
610 }
611 case DnsFreeFlat:
613 {
614 DPRINT1( "unhandled free type: %d\n", type );
615 break;
616 }
617 default:
618 DPRINT1( "unknown free type: %d\n", type );
619 break;
620 }
621}
Definition: list.h:37
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static unsigned __int64 next
Definition: rand_nt.c:6
@ DnsFreeFlat
Definition: windns.h:138
@ DnsFreeRecordList
Definition: windns.h:139
@ DnsFreeParsedMessageFields
Definition: windns.h:140

Referenced by DisplayDnsRecord(), DnsIntCacheRemoveEntryItem(), DnsRecordSetCompare(), DnsRecordSetCopyEx(), main(), NSP_GetHostByNameHeapAllocW(), SaBlob_Query(), test_DnsRecordSetCompare(), and TestHostName().

◆ DnsRecordSetCompare()

BOOL WINAPI DnsRecordSetCompare ( PDNS_RECORD  set1,
PDNS_RECORD  set2,
PDNS_RECORD diff1,
PDNS_RECORD diff2 
)

Definition at line 627 of file record.c.

629{
630 BOOL ret = TRUE;
631 DNS_RECORD *r, *t, *u;
632 DNS_RRSET rr1, rr2;
633
634 DPRINT( "(%p,%p,%p,%p)\n", set1, set2, diff1, diff2 );
635
636 if (!set1 && !set2) return FALSE;
637
638 if (diff1) *diff1 = NULL;
639 if (diff2) *diff2 = NULL;
640
641 if (set1 && !set2)
642 {
643 if (diff1) *diff1 = DnsRecordSetCopyEx( set1, 0, set1->Flags.S.CharSet );
644 return FALSE;
645 }
646 if (!set1 && set2)
647 {
648 if (diff2) *diff2 = DnsRecordSetCopyEx( set2, 0, set2->Flags.S.CharSet );
649 return FALSE;
650 }
651
652 DNS_RRSET_INIT( rr1 );
653 DNS_RRSET_INIT( rr2 );
654
655 for (r = set1; r; r = r->pNext)
656 {
657 for (t = set2; t; t = t->pNext)
658 {
659 u = DnsRecordCopyEx( r, r->Flags.S.CharSet, t->Flags.S.CharSet );
660 if (!u) goto error;
661
662 if (!DnsRecordCompare( t, u ))
663 {
664 DNS_RRSET_ADD( rr1, u );
665 ret = FALSE;
666 }
668 }
669 }
670
671 for (t = set2; t; t = t->pNext)
672 {
673 for (r = set1; r; r = r->pNext)
674 {
675 u = DnsRecordCopyEx( t, t->Flags.S.CharSet, r->Flags.S.CharSet );
676 if (!u) goto error;
677
678 if (!DnsRecordCompare( r, u ))
679 {
680 DNS_RRSET_ADD( rr2, u );
681 ret = FALSE;
682 }
684 }
685 }
686
687 DNS_RRSET_TERMINATE( rr1 );
688 DNS_RRSET_TERMINATE( rr2 );
689
690 if (diff1) *diff1 = rr1.pFirstRR;
692
693 if (diff2) *diff2 = rr2.pFirstRR;
695
696 return ret;
697
698error:
699 DNS_RRSET_TERMINATE( rr1 );
700 DNS_RRSET_TERMINATE( rr2 );
701
704
705 return FALSE;
706}
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
PDNS_RECORD WINAPI DnsRecordSetCopyEx(PDNS_RECORD src_set, DNS_CHARSET in, DNS_CHARSET out)
Definition: record.c:712
PDNS_RECORD WINAPI DnsRecordCopyEx(PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET out)
Definition: record.c:395
BOOL WINAPI DnsRecordCompare(PDNS_RECORD r1, PDNS_RECORD r2)
Definition: record.c:104
GLdouble GLdouble t
Definition: gl.h:2047
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static void set1(uint8 *data, int x, int y)
Definition: nanoxwin.c:811
PDNS_RECORD pFirstRR
Definition: windns.h:640
int ret
#define DNS_RRSET_TERMINATE(rrset)
Definition: windns.h:659
#define DNS_RRSET_ADD(rrset, pnewRR)
Definition: windns.h:651
#define DNS_RRSET_INIT(rrset)
Definition: windns.h:644

Referenced by test_DnsRecordSetCompare().

◆ DnsRecordSetCopyEx()

PDNS_RECORD WINAPI DnsRecordSetCopyEx ( PDNS_RECORD  src_set,
DNS_CHARSET  in,
DNS_CHARSET  out 
)

Definition at line 712 of file record.c.

713{
714 DNS_RRSET dst_set;
715 DNS_RECORD *src, *dst;
716
717 DPRINT( "(%p,%d,%d)\n", src_set, in, out );
718
719 DNS_RRSET_INIT( dst_set );
720
721 for (src = src_set; (src_set = src); src = src_set->pNext)
722 {
724 if (!dst)
725 {
726 DNS_RRSET_TERMINATE( dst_set );
728 return NULL;
729 }
730 DNS_RRSET_ADD( dst_set, dst );
731 }
732
733 DNS_RRSET_TERMINATE( dst_set );
734 return dst_set.pFirstRR;
735}

Referenced by DnsIntCacheAddEntry(), DnsIntCacheGetEntryByName(), and DnsRecordSetCompare().

◆ DnsRecordSetDetach()

PDNS_RECORD WINAPI DnsRecordSetDetach ( PDNS_RECORD  set)

Definition at line 741 of file record.c.

742{
743 DNS_RECORD *r, *s;
744
745 DPRINT( "(%p)\n", set );
746
747 for (r = set; (set = r); r = set->pNext)
748 {
749 if (r->pNext && !r->pNext->pNext)
750 {
751 s = r->pNext;
752 r->pNext = NULL;
753 return s;
754 }
755 }
756 return NULL;
757}
Definition: _set.h:50
GLdouble s
Definition: gl.h:2039

Referenced by test_DnsRecordSetDetach().