249 unsigned char us, sl, ty;
252 fddata = open_read(
"data");
254 logmsg(
WHO,111,FATAL,
"unable to open data");
257 buffer_init(&
b,buffer_unixread,fddata,
bspace,
sizeof(
bspace));
259 fdcdb = open_trunc(
"data.tmp");
266 logmsg(
WHO,111,FATAL,
"unable to read line");
270 if ((ch !=
' ') && (ch !=
'\t') && (ch !=
'\n'))
break;
273 if (!
line.len)
continue;
274 if (
line.s[0] ==
'#')
continue;
275 if (
line.s[0] ==
'-')
continue;
281 if (!stralloc_copys(&f[i],
""))
nomem();
284 k = byte_chr(
line.s + j,
line.len - j,
'|');
285 if (!stralloc_copyb(&f[i],
line.s + j,k))
nomem();
294 if (!stralloc_copyb(&key,
"\0%",2))
nomem();
295 if (!stralloc_0(&f[1]))
nomem();
297 if (ipstring.len > 1)
298 if (!stralloc_catb(&key,ipstring.s,ipstring.len - 1))
nomem();
299 if (cdb_make_add(&
cdb,key.s,key.len,loc,2) == -1)
306 if (!stralloc_0(&f[3]))
nomem();
307 if (!scan_dnum(f[3].s,&u)) uint32_unpack_big(
defaultsoa,&u);
308 uint32_pack_big(soa,u);
309 if (!stralloc_0(&f[4]))
nomem();
310 if (!scan_dnum(f[4].s,&u)) uint32_unpack_big(
defaultsoa + 4,&u);
311 uint32_pack_big(soa + 4,u);
312 if (!stralloc_0(&f[5]))
nomem();
313 if (!scan_dnum(f[5].s,&u)) uint32_unpack_big(
defaultsoa + 8,&u);
314 uint32_pack_big(soa + 8,u);
315 if (!stralloc_0(&f[6]))
nomem();
316 if (!scan_dnum(f[6].s,&u)) uint32_unpack_big(
defaultsoa + 12,&u);
317 uint32_pack_big(soa + 12,u);
318 if (!stralloc_0(&f[7]))
nomem();
319 if (!scan_dnum(f[7].s,&u)) uint32_unpack_big(
defaultsoa + 16,&u);
320 uint32_pack_big(soa + 16,u);
322 if (!stralloc_0(&f[8]))
nomem();
338 if (!stralloc_0(&f[3]))
nomem();
339 if (!scan_dnum(f[3].s,&ttl)) ttl =
TTL_NS;
343 if (!stralloc_0(&f[1]))
nomem();
345 if (byte_chr(f[2].s,f[2].
len,
'.') >= f[2].
len) {
346 if (!stralloc_cats(&f[2],
".ns."))
nomem();
347 if (!stralloc_catb(&f[2],f[0].s,f[0].
len))
nomem();
351 if (
line.s[0] ==
'.') {
354 rr_add(
"\12hostmaster",11);
364 if (byte_chr(f[1].s,f[1].
len,
':') < f[1].
len) {
365 if (ip6_scan(f[1].s,
ip6)) {
371 if (ip4_scan(f[1].s,
ip4)) {
381 if (!stralloc_0(&f[2]))
nomem();
386 if (!stralloc_0(&f[1]))
nomem();
388 if (ip4_scan(f[1].s,
ip4)) {
393 if (
line.s[0] ==
'=') {
404 if (!stralloc_0(&f[2]))
nomem();
409 if (!stralloc_0(&f[1]))
nomem();
411 if (ip6_scan(f[1].s,
ip6)) {
416 if (
line.s[0] ==
':') {
427 if (!stralloc_0(&f[4]))
nomem();
432 if (!stralloc_0(&f[1]))
nomem();
434 if (byte_chr(f[2].s,f[2].
len,
'.') >= f[2].
len) {
435 if (!stralloc_cats(&f[2],
".mx."))
nomem();
436 if (!stralloc_catb(&f[2],f[0].s,f[0].
len))
nomem();
440 if (!stralloc_0(&f[3]))
nomem();
441 if (!scan_dnum(f[3].s,&u)) u = 0;
444 uint16_pack_big(
buf,u);
449 if (byte_chr(f[1].s,f[1].
len,
':') < f[1].
len) {
450 if (ip6_scan(f[1].s,
ip6))
451 if (!ip6_isv4mapped(
ip6)) {
457 if (ip4_scan(f[1].s,
ip4)) {
467 if (!stralloc_0(&f[2]))
nomem();
472 if (
line.s[0] ==
'C')
482 if (!stralloc_0(&f[2]))
nomem();
491 while (i < f[1].
len) {
507 if (!stralloc_0(&f[7]))
nomem();
515 if (!stralloc_copys(&f[8],
"v=DKIM1;"))
nomem();
518 if (!stralloc_cats(&f[8],
"k=rsa;"))
nomem();
520 if (!stralloc_cats(&f[8],
"k="))
nomem();
521 if (!stralloc_catb(&f[8],f[3].s,f[3].
len))
nomem();
522 if (!stralloc_cats(&f[8],
";"))
nomem();
526 if (!stralloc_cats(&f[8],
"h=sha256;"))
nomem();
528 if (!stralloc_cats(&f[8],
"h="))
nomem();
529 if (!stralloc_catb(&f[8],f[4].s,f[4].
len))
nomem();
530 if (!stralloc_cats(&f[8],
";"))
nomem();
534 if (!stralloc_cats(&f[8],
"s="))
nomem();
535 if (!stralloc_catb(&f[8],f[5].s,f[5].
len))
nomem();
536 if (!stralloc_cats(&f[8],
";"))
nomem();
540 if (!stralloc_cats(&f[8],
"t="))
nomem();
541 if (!stralloc_catb(&f[8],f[6].s,f[6].
len))
nomem();
542 if (!stralloc_cats(&f[8],
";"))
nomem();
549 if (!stralloc_cats(&f[8],
"p="))
nomem();
550 if (!stralloc_catb(&f[8],f[1].s,f[1].
len))
nomem();
556 if (!stralloc_copyb(&f[9],f[2].s,f[2].
len))
nomem();
557 if (!stralloc_cats(&f[9],
"."))
nomem();
559 if (!stralloc_cats(&f[9],
"default."))
nomem();
561 if (!stralloc_cats(&f[9],
"_domainkey."))
nomem();
562 if (!stralloc_catb(&f[9],f[0].s,f[0].
len))
nomem();
568 while (i < f[8].
len) {
584 if (!stralloc_0(&f[7]))
nomem();
589 if (!stralloc_0(&f[1]))
nomem();
590 if (!scan_dnum(f[1].s,&us)) us = 003;
591 if (!stralloc_0(&f[2]))
nomem();
592 if (!scan_dnum(f[2].s,&sl)) sl = 001;
595 if (f[3].
len == 64) ty = 001;
596 if (f[3].
len == 128) ty = 002;
598 if (f[4].
len == 0 && f[5].
len == 0 && f[6].
len == 0) {
599 if (!stralloc_copys(&f[2],
"_25._tcp.mail."))
nomem();
600 if (!stralloc_catb(&f[2],f[0].s,f[0].
len))
nomem();
601 }
else if (f[4].s[0] !=
'_') {
602 if (!stralloc_copys(&f[2],
"_"))
nomem();
604 if (!stralloc_catb(&f[2],f[5].s,f[5].
len))
nomem();
606 if (!stralloc_cats(&f[2],
"25"))
nomem();
607 if (!stralloc_cats(&f[2],
"._"))
nomem();
609 if (!stralloc_catb(&f[2],f[6].s,f[6].
len))
nomem();
611 if (!stralloc_cats(&f[2],
"tcp"))
nomem();
612 if (f[4].s[0] !=
'.')
613 if (!stralloc_cats(&f[2],
"."))
nomem();
614 if (!stralloc_catb(&f[2],f[4].s,f[4].
len))
nomem();
615 if (!stralloc_cats(&f[2],
"."))
nomem();
616 if (!stralloc_catb(&f[2],f[0].s,f[0].
len))
nomem();
618 if (!stralloc_copy(&f[2],&f[4]))
nomem();
631 case_lowerb(f[3].s,f[3].
len);
634 while (i < f[3].
len) {
647 if (!stralloc_0(&f[3]))
nomem();
652 if (!stralloc_0(&f[1]))
nomem();
653 scan_dnum(f[1].s,&u);
654 uint16_pack_big(
type,u);
657 if (byte_equal(
type,2,
"\0\0"))
685 if (
rename(
"data.tmp",
"data.cdb") == -1)
686 logmsg(
WHO,111,FATAL,
"unable to move data.tmp to data.cdb");
unsigned int dns_domain_length(const char *dn)