899
916
if(js_qissame("fqdn4",text_rtype) == 1) {
919
/* Obscure RR types follow */
920
/* Obscure RFC1035 RR types */
921
if(js_qissame("hinfo",text_rtype) == 1) {
924
if(js_qissame("wks",text_rtype) == 1) {
927
if(js_qissame("mb",text_rtype) == 1) {
930
if(js_qissame("md",text_rtype) == 1) {
933
if(js_qissame("mf",text_rtype) == 1) {
936
if(js_qissame("mg",text_rtype) == 1) {
939
if(js_qissame("mr",text_rtype) == 1) {
942
if(js_qissame("minfo",text_rtype) == 1) {
945
/* Obscure RFC1183 data types follow */
946
if(js_qissame("afsdb",text_rtype) == 1) {
949
if(js_qissame("rp",text_rtype) == 1) {
952
if(js_qissame("x25",text_rtype) == 1) {
955
if(js_qissame("isdn",text_rtype) == 1) {
958
if(js_qissame("rt",text_rtype) == 1) {
961
/* Obscure RFC1706 RRs follow */
962
if(js_qissame("nsap",text_rtype) == 1) {
965
if(js_qissame("nsap-ptr",text_rtype) == 1) {
968
/* Obscure RFC2163 RR */
969
if(js_qissame("px",text_rtype) == 1) {
972
/* Obscure RFC1712 RR */
973
if(js_qissame("gpos",text_rtype) == 1) {
976
/* Almost obscure RFC1876 RR */
977
if(js_qissame("loc",text_rtype) == 1) {
942
/* Get a number from the stream; return a -1 on error */
1020
/* Get a number from the stream; return a -1 on error, -2 if they
1021
* specified '/serial' */
943
1022
int32 csv2_get_num(csv2_read *stream) {
947
if(csv2_get_1st(stream,csv2_is_number,0) != JS_SUCCESS) {
1026
if(csv2_get_1st(stream,csv2_is_number_orslash,0) != JS_SUCCESS) {
1030
/* '/serial' gets special treatment and returns -2 */
1031
if(csv2_justread(stream) == '/') {
1032
if(csv2_read_unicode(stream) != 's') {
1035
if(csv2_read_unicode(stream) != 'e') {
1038
if(csv2_read_unicode(stream) != 'r') {
1041
if(csv2_read_unicode(stream) != 'i') {
1044
if(csv2_read_unicode(stream) != 'a') {
1047
if(csv2_read_unicode(stream) != 'l') {
1050
if(!csv2_is_delimiter(csv2_read_unicode(stream))) {
950
1056
if((num = process_number(stream)) == 0) {
978
1109
return csv2_get_hostname(stream,0,1);
981
/* Get a mx record; 0 is error */
1112
/* Get a mx record; 0 is error. Pref makes this record more flexible;
1113
* if this number is 0 or higher, instead of reading the pref from the
1114
* zone file, the pref is set to the value given the function. If pref
1115
* is -1, this is treated as a normal MX record. Is pref is -2, we read
1116
* two instead of one host label (for the obscure PX record) */
983
js_string *csv2_get_mx(csv2_read *stream, js_string *zone) {
1118
js_string *csv2_get_mx(csv2_read *stream, js_string *zone, int pref) {
988
1123
/* Get the priority */
989
if((num = csv2_get_num(stream)) < 0) {
1125
if((num = csv2_get_num(stream)) < 0) {
992
1131
if((out = js_create(256,1)) == 0) {
1079
1227
if(state->zone == 0) {
1080
1228
return JS_ERROR;
1085
/* The host name must be at the begining of a line (or the file) */
1086
q = csv2_get_1st(stream, csv2_is_starwhitis,1);
1230
if(state->origin == 0) {
1234
zone = state->origin;
1236
/* We read look for the beginning of the host name; this is made
1237
* more complicated that the "host name" may actually be a
1238
* special command, such as on that changes the origin (hostname
1239
* to substitute '%' with) or TTL */
1244
/* The host name must be at the begining of a line
1246
q = csv2_get_1st(stream, csv2_is_starwhitis_orslash,1);
1256
/* Process the slash commands (currently only '/origin' and
1258
if(csv2_justread(stream) == '/') {
1261
look = csv2_read_unicode(stream);
1264
} else if(look == 'o') {
1265
cmd = 2; /* origin */
1266
} else if(look == 'r') {
1269
csv2_error(stream,"Invalid slash command");
1270
return -1; /* error */
1273
look = csv2_read_unicode(stream);
1274
if(cmd == 2 && look == 'p') { /* opush/opop */
1275
cmd = 3; /* opush */
1276
} else if((cmd == 1 && look != 't') || (cmd == 2 &&
1277
look != 'r') || (cmd == 5 && look != 'e')) {
1278
csv2_error(stream,"Invalid slash command");
1282
look = csv2_read_unicode(stream);
1283
if(cmd == 3 && look == 'o') {
1285
} else if((cmd == 1 && look != 'l') || (cmd == 2 &&
1286
look != 'i') || (cmd == 3 && look != 'u') ||
1287
(cmd == 5 && look != 'a')) {
1288
csv2_error(stream,"Invalid slash command");
1292
look = csv2_read_unicode(stream);
1293
if(cmd == 1 && csv2_is_delimiter(look)) {
1295
newttl = csv2_get_num(stream);
1298
"Invalid slash command");
1301
state->default_ttl = newttl;
1302
} else if(cmd == 2 && look == 'g') {
1304
if(csv2_read_unicode(stream) != 'i') {
1306
"Invalid slash command");
1309
if(csv2_read_unicode(stream) != 'n') {
1311
"Invalid slash command");
1314
look = csv2_read_unicode(stream);
1315
if(!csv2_is_delimiter(look)) {
1317
"Invalid slash command");
1320
if(csv2_get_1st(stream,csv2_is_dchar,0) !=
1323
"Invalid argument for /origin");
1326
n = process_1stchar(stream,
1327
csv2_is_starwhitis,0);
1330
"Error processing /origin");
1333
n = js_append_dname(n, stream, 3);
1334
if(csv2_convert_percent(n,state->origin)
1337
"Problem running convert_percent");
1342
"Invalid argument for /origin");
1345
js_destroy(state->origin);
1348
} else if(cmd == 3 && look == 's') {
1351
if(csv2_read_unicode(stream) != 'h') {
1353
"Invalid slash command");
1356
look = csv2_read_unicode(stream);
1357
if(!csv2_is_delimiter(look)) {
1359
"Invalid slash command");
1362
if(csv2_get_1st(stream,csv2_is_dchar,0) !=
1365
"Invalid argument for /opush");
1368
n = process_1stchar(stream,
1369
csv2_is_starwhitis,0);
1372
"Error processing /opush");
1375
n = js_append_dname(n, stream, 3);
1376
if(csv2_convert_percent(n,state->origin)
1379
"Problem running convert_percent");
1384
"Invalid argument for /opush");
1387
/* Now, see if there is room on the stack */
1388
if(state->ostack_height > 7 ||
1389
state->ostack_height < 0) {
1391
"origin stack too high");
1394
/* OK, there is room; push the current
1395
* origin on the stack and replace it with
1397
state->ostack_height++;
1399
c = js_alloc(1,sizeof(csv2_origin));
1405
c->origin = state->origin;
1409
zone = state->origin;
1410
} else if(cmd == 4 && look == 'p') {
1412
look = csv2_read_unicode(stream);
1413
if(!csv2_is_delimiter(look)) {
1415
"Invalid slash command");
1418
if(state->ostack_height < 1 ||
1419
state->ostack_height > 8) {
1421
"origin stack too low");
1424
if(state->ostack == 0) {
1426
"origin stack empty");
1429
/* OK, pop the top value from the origin
1430
* stack and make it the origin value */
1432
js_destroy(state->origin);
1433
state->ostack = o->next;
1434
state->origin = o->origin;
1435
zone = state->origin;
1437
} else if(cmd == 5 && look == 'd') {
1438
js_string *filename;
1439
look = csv2_read_unicode(stream);
1440
if(!csv2_is_delimiter(look)) {
1442
"Invalid slash command");
1445
filename = csv2_get_filename(stream);
1446
csv2_push_file(stream,filename);
1447
js_destroy(filename);
1449
csv2_error(stream,"Invalid slash command");
1455
} while(slash_command == 1);
1096
1457
/* If star records are allowed at the end of
1097
1458
* hostnames, we make the third argument of csv2_get_hostname have
1181
1542
rddata = csv2_get_aaaa(stream);
1184
rddata = csv2_get_soa(stream,zone);
1545
rddata = csv2_get_soa(stream,zone,state);
1187
rddata = csv2_get_mx(stream,zone);
1550
rddata = csv2_get_mx(stream,zone,-1);
1190
1553
rddata = csv2_get_srv(stream,zone);
1194
rddata = csv2_get_txt(stream);
1559
rddata = csv2_get_txt(stream,0);
1563
rddata = csv2_get_mbox(stream,zone,1);
1567
rddata = csv2_get_mbox(stream,zone,2);
1199
1574
if(csv2_get_1st(stream,csv2_is_dchar,0) !=
1207
1582
* PTR record */
1208
1583
rddata = csv2_get_a(stream);
1585
/* Obscure RRs follow */
1587
rddata = csv2_get_txt(stream,2);
1590
rddata = csv2_get_wks(stream);
1593
/* As per RFC1035 §3.3.4; handle this as an MX with
1595
rddata = csv2_get_mx(stream,zone,0);
1599
/* As per RFC1035 §3.3.5; handle this as an MX with
1601
rddata = csv2_get_mx(stream,zone,10);
1605
rddata = csv2_get_hex(stream);
1608
rddata = csv2_get_mx(stream,zone,-2);
1611
rddata = csv2_get_txt(stream,3);
1614
rddata = csv2_get_loc(stream);
1211
1618
if(rtype >= 100000 && rtype <= 165535) {
1212
1619
rtype -= 100000;
1213
1620
if(rtype == RR_ANY) {
1214
1621
csv2_error(stream,
1215
1622
"ANY (255) record type isn't for data");
1216
} else if(rtype == 251) {
1623
} else if(rtype == RR_IXFR) {
1217
1624
csv2_error(stream,
1218
1625
"IXFR (251) record type isn't for data");
1219
} else if(rtype == 252) {
1626
} else if(rtype == RR_AXFR) {
1220
1627
csv2_error(stream,
1221
1628
"AXFR (252) record type isn't for data");
1629
} else if(rtype == RR_MAILB) {
1631
"MAILB record type isn't for data");
1632
} else if(rtype == RR_MAILA) {
1634
"MAILA record type isn't for data");
1635
} else if(rtype == RR_A6) {
1637
"MaraDNS doesn't allow A6 records");
1638
} else if(rtype == RR_DNAME) {
1640
"MaraDNS doesn't allow DNAME records");
1641
} else if(rtype == RR_OPT) {
1643
"OPT record type isn't for zone files");
1223
1645
rddata = csv2_get_raw(stream);