Commit Diff
Diff:
e312e4ddc777f13aa46481c2823982746d974482
6a6113d455532b4936354a6f7b4a2ce2010ff863
Commit:
6a6113d455532b4936354a6f7b4a2ce2010ff863
Tree:
4f6e037a294625ddb5e6ae1a9b78a829f2b7cf90
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Sun Apr 13 08:50:17 2014 UTC
Message:
* clean up #if's and add a debug if we printf Compiles on OpenBSD
blob - 0495194ba165df3ecfb3b7d5e713de40f24a4f80
blob + c2ff6a033dd0096e5097d1a2203b156e09eecf34
--- parse.y
+++ parse.y
@@ -65,7 +65,10 @@ static uint64_t confstatus = 0;
static DB *mydb;
YYSTYPE yylval;
+
extern int errno;
+extern int debug;
+
char *converted_name;
int converted_namelen;
DBT key, data;
@@ -233,9 +236,8 @@ axfrport:
quotednumber:
QUOTEDSTRING
{
-#if 0
- printf("quotednumber is %s\n", $$);
-#endif
+ if (debug)
+ printf("quotednumber is %s\n", $$);
}
;
@@ -267,9 +269,8 @@ includes:
quotedfilename:
QUOTEDSTRING
{
-#if 0
- printf("quotedfilename is %s\n", $$);
-#endif
+ if (debug)
+ printf("quotedfilename is %s\n", $$);
}
;
@@ -312,11 +313,11 @@ zonestatement:
return -1;
}
-#if 0
- printf("%s SOA\n", $1);
-#endif
+ if (debug)
+ printf("%s SOA\n", $1);
} else {
- printf("soa error\n");
+ if (debug)
+ printf("soa error\n");
return -1;
}
@@ -352,23 +353,25 @@ zonestatement:
return -1;
}
-#if 0
- printf("%s NS\n", $1);
-#endif
+ if (debug)
+ printf("%s NS\n", $1);
+
} else if (strcasecmp($3, "ptr") == 0) {
if (fill_ptr($1, $3, $5, $7) < 0) {
return -1;
}
-#if 0
- printf("%s PTR\n", $1);
-#endif
+
+ if(debug)
+ printf("%s PTR\n", $1);
+
} else if (strcasecmp($3, "cname") == 0) {
if (fill_cname($1, $3, $5, $7) < 0) {
return -1;
}
-#if 0
- printf("%s CNAME\n", $3);
-#endif
+
+ if (debug)
+ printf("%s CNAME\n", $3);
+
} else {
printf("%s other\n", $3);
return -1;
@@ -385,11 +388,12 @@ zonestatement:
return -1;
}
-#if 0
- printf("%s AAAA\n", $1);
-#endif
+ if (debug)
+ printf("%s AAAA\n", $1);
} else {
- printf("error AAAA\n");
+
+ if (debug)
+ printf("error AAAA\n");
return (-1);
}
free ($1);
@@ -404,19 +408,19 @@ zonestatement:
return -1;
}
-#if 0
- printf("%s A\n", $1);
-#endif
+ if (debug)
+ printf("%s A\n", $1);
+
} else if (strcasecmp($3, "balance") == 0) {
if (fill_balance($1, $3, $5, $7) < 0) {
return -1;
}
-#if 0
- printf("a balance record?\n");
-#endif
+ if (debug)
+ printf("a balance record?\n");
} else {
- printf("another a record?\n");
+ if (debug)
+ printf("another a record?\n");
return -1;
}
@@ -432,11 +436,12 @@ zonestatement:
return -1;
}
-#if 0
- printf("%s MX -> %d %s\n", $1, $7, $9);
-#endif
+ if (debug)
+ printf("%s MX -> %d %s\n", $1, $7, $9);
+
} else {
- printf("another record I don't know about?");
+ if (debug)
+ printf("another record I don't know about?");
return (-1);
}
@@ -452,11 +457,11 @@ zonestatement:
return -1;
}
-#if 0
- printf(" %s TXT -> %s\n", $1, $7);
-#endif
+ if (debug)
+ printf(" %s TXT -> %s\n", $1, $7);
} else {
- printf("another txt like record I don't know?\n");
+ if (debug)
+ printf("another txt like record I don't know?\n");
return (-1);
}
@@ -656,15 +661,13 @@ axfrstatement : ipcidr SEMICOLON CRLF
}
if (insert_axfr(dst, prefixlength) < 0) {
-#if 1
dolog(LOG_ERR, "insert_axfr, line %d\n", file->lineno);
-#endif
return (-1);
}
-#if 0
- printf("recurse inserted %s address\n", $1);
-#endif
+ if (debug)
+ printf("recurse inserted %s address\n", $1);
+
free (dst);
free ($1);
}
@@ -707,15 +710,12 @@ recursestatement : ipcidr SEMICOLON CRLF
}
if (insert_recurse(dst, prefixlength) < 0) {
-#if 1
dolog(LOG_ERR, "insert_recurse, line %d\n", file->lineno);
-#endif
return (-1);
}
-#if 0
- printf("recurse inserted %s address\n", $1);
-#endif
+ if (debug)
+ printf("recurse inserted %s address\n", $1);
free (dst);
free ($1);
@@ -761,16 +761,13 @@ wofstatement : ipcidr SEMICOLON CRLF
}
if (insert_wildcard(dst, prefixlength) < 0) {
-#if 1
dolog(LOG_ERR, "insert_wildcard, line %d\n", file->lineno);
-#endif
return (-1);
}
-#if 1
- printf("wildcard inserted %s address\n", $1);
+ if (debug)
+ printf("wildcard inserted %s address\n", $1);
-#endif
free (dst);
free ($1);
}
@@ -816,14 +813,12 @@ regionstatement : ipcidr SEMICOLON CRLF
}
if (insert_region(dst, prefixlength, region) < 0) {
-#if 1
dolog(LOG_ERR, "insert_region, line %d\n", file->lineno);
-#endif
return (-1);
}
-#if 0
- printf("%s ipv4 address\n", dst);
-#endif
+
+ if (debug)
+ printf("%s ipv4 address\n", dst);
free (dst);
free ($1);
@@ -908,7 +903,8 @@ yylex()
#ifdef LEXDEBUG
- printf("returning %s\n", "crlf");
+ if (debug)
+ printf("returning %s\n", "crlf");
#endif
return CRLF;
@@ -927,7 +923,8 @@ yylex()
exit(1);
}
#ifdef LEXDEBUG
- printf("returning %s\n", "IP");
+ if (debug)
+ printf("returning %s\n", "IP");
#endif
return (IP);
}
@@ -935,7 +932,8 @@ yylex()
default:
if (c == '}') {
#ifdef LEXDEBUG
- printf("returning %s\n", "ebrace");
+ if (debug)
+ printf("returning %s\n", "ebrace");
#endif
setupstate = 0;
state = 0;
@@ -946,21 +944,24 @@ yylex()
if (setupstate)
state = setupstate;
#ifdef LEXDEBUG
- printf("returning %s\n", "obrace");
+ if (debug)
+ printf("returning %s\n", "obrace");
#endif
return OBRACE;
}
if (c == '/') {
#ifdef LEXDEBUG
- printf("returning %s\n", "slash");
+ if (debug)
+ printf("returning %s\n", "slash");
#endif
return SLASH;
}
if (c == ',') {
#ifdef LEXDEBUG
- printf("returning %s\n", "comma");
+ if (debug)
+ printf("returning %s\n", "comma");
#endif
return COMMA;
}
@@ -970,7 +971,8 @@ yylex()
while ((c = lgetc(0)) != EOF && c != '\n');
lungetc(c);
#ifdef LEXDEBUG
- printf("returning %s\n", "semicolon");
+ if (debug)
+ printf("returning %s\n", "semicolon");
#endif
return SEMICOLON;
}
@@ -979,7 +981,8 @@ yylex()
while ((c = lgetc(0)) != EOF && c != '\n');
lungetc(c);
#ifdef LEXDEBUG
- printf("returning %s\n", "pound");
+ if (debug)
+ printf("returning %s\n", "pound");
#endif
return POUND;
}
@@ -1001,7 +1004,8 @@ yylex()
}
#ifdef LEXDEBUG
- printf("returning %s\n", "quotedstring");
+ if (debug)
+ printf("returning %s\n", "quotedstring");
#endif
return QUOTEDSTRING;
}
@@ -1014,7 +1018,8 @@ yylex()
exit(1);
}
#ifdef LEXDEBUG
- printf("returning %s\n", "string");
+ if (debug)
+ printf("returning %s\n", "string");
#endif
return STRING;
}
@@ -1032,7 +1037,8 @@ yylex()
p = lookup(cmdtab, buf);
if (p != NULL) {
#ifdef LEXDEBUG
- printf("returning %s\n", p->val);
+ if (debug)
+ printf("returning %s\n", p->val);
#endif
yylval.v.string = strdup(p->val);
if (yylval.v.string == NULL) {
@@ -1069,8 +1075,9 @@ yylex()
memset(&dst, 0, sizeof(dst));
if (strchr(buf, '.') != NULL &&
inet_net_pton(AF_INET, buf, &dst, sizeof(dst)) != -1){
-#if 1
- printf("returning %s\n", "IP");
+#if LEXDEBUG
+ if (debug)
+ printf("returning %s\n", "IP");
#endif
return IP;
}
@@ -1276,11 +1283,9 @@ fill_cname(char *name, char *type, int myttl, char *ho
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1295,16 +1300,12 @@ fill_cname(char *name, char *type, int myttl, char *ho
myname = dns_label(hostname, (int *)&len);
if (myname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
-#endif
return 0;
}
if (len > 0xff || len < 0) {
-#if 1
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
-#endif
return -1;
}
@@ -1315,9 +1316,7 @@ fill_cname(char *name, char *type, int myttl, char *ho
sdomain.flags |= DOMAIN_HAVE_CNAME;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1344,11 +1343,9 @@ fill_ptr(char *name, char *type, int myttl, char *host
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1363,16 +1360,12 @@ fill_ptr(char *name, char *type, int myttl, char *host
myname = dns_label(hostname, (int *)&len);
if (myname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
-#endif
return 0;
}
if (len > 0xff || len < 0) {
-#if 1
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
-#endif
return -1;
}
@@ -1383,9 +1376,7 @@ fill_ptr(char *name, char *type, int myttl, char *host
sdomain.flags |= DOMAIN_HAVE_PTR;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1407,9 +1398,7 @@ fill_txt(char *name, char *type, int myttl, char *msg)
}
if ((len = strlen(msg)) > 255) {
-#if 1
dolog(LOG_ERR, "TXT record too long line %d\n", file->lineno);
-#endif
return (-1);
}
@@ -1419,11 +1408,9 @@ fill_txt(char *name, char *type, int myttl, char *msg)
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1441,9 +1428,7 @@ fill_txt(char *name, char *type, int myttl, char *msg)
sdomain.flags |= DOMAIN_HAVE_TXT;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1471,11 +1456,9 @@ fill_srv(char *name, char *type, int myttl, int priori
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1487,9 +1470,7 @@ fill_srv(char *name, char *type, int myttl, int priori
sdomain.zonelen = converted_namelen;
if (sdomain.srv_count >= RECORD_COUNT) {
-#if 1
dolog(LOG_INFO, "%s: too many SRV records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
return (-1);
}
@@ -1501,10 +1482,8 @@ fill_srv(char *name, char *type, int myttl, int priori
srvname = dns_label(srvhost, &len);
if (srvname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal srv server, skipping line %d\n", file->lineno);
return (-1);
-#endif
}
@@ -1521,9 +1500,7 @@ fill_srv(char *name, char *type, int myttl, int priori
sdomain.flags |= DOMAIN_HAVE_SRV;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1551,11 +1528,9 @@ fill_mx(char *name, char *type, int myttl, int priorit
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1567,9 +1542,7 @@ fill_mx(char *name, char *type, int myttl, int priorit
sdomain.zonelen = converted_namelen;
if (sdomain.mx_count >= RECORD_COUNT) {
-#if 1
- dolog(LOG_INFO, "%s: too many A records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
+ dolog(LOG_INFO, "%s: too many MX records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
return (-1);
}
@@ -1578,10 +1551,8 @@ fill_mx(char *name, char *type, int myttl, int priorit
mxname = dns_label(mxhost, &len);
if (mxname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal mx server, skipping line %d\n", file->lineno);
return (-1);
-#endif
}
sdomain.mx[sdomain.mx_count].exchangelen = len;
@@ -1592,9 +1563,7 @@ fill_mx(char *name, char *type, int myttl, int priorit
sdomain.flags |= DOMAIN_HAVE_MX;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1623,11 +1592,9 @@ fill_balance(char *name, char *type, int myttl, char *
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1639,9 +1606,7 @@ fill_balance(char *name, char *type, int myttl, char *
sdomain.zonelen = converted_namelen;
if (sdomain.a_count >= RECORD_COUNT) {
-#if 1
dolog(LOG_INFO, "%s: too many BALANCE records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
return (-1);
}
@@ -1649,9 +1614,7 @@ fill_balance(char *name, char *type, int myttl, char *
ia = (in_addr_t *)&sdomain.a[sdomain.a_count];
if ((*ia = inet_addr(a)) == INADDR_ANY) {
-#if 1
dolog(LOG_INFO, "could not parse BALANCE record on line %d\n", file->lineno);
-#endif
return (-1);
}
@@ -1666,9 +1629,7 @@ fill_balance(char *name, char *type, int myttl, char *
sdomain.flags |= DOMAIN_HAVE_A;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1696,11 +1657,9 @@ fill_a(char *name, char *type, int myttl, char *a)
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1712,9 +1671,7 @@ fill_a(char *name, char *type, int myttl, char *a)
sdomain.zonelen = converted_namelen;
if (sdomain.a_count >= RECORD_COUNT) {
-#if 1
dolog(LOG_INFO, "%s: too many A records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
return (-1);
}
@@ -1722,9 +1679,7 @@ fill_a(char *name, char *type, int myttl, char *a)
ia = (in_addr_t *)&sdomain.a[sdomain.a_count];
if ((*ia = inet_addr(a)) == INADDR_ANY) {
-#if 1
dolog(LOG_INFO, "could not parse A record on line %d\n", file->lineno);
-#endif
return (-1);
}
@@ -1735,9 +1690,7 @@ fill_a(char *name, char *type, int myttl, char *a)
sdomain.flags |= DOMAIN_HAVE_A;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1767,11 +1720,9 @@ fill_aaaa(char *name, char *type, int myttl, char *aaa
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1783,18 +1734,14 @@ fill_aaaa(char *name, char *type, int myttl, char *aaa
sdomain.zonelen = converted_namelen;
if (sdomain.aaaa_count >= RECORD_COUNT) {
-#if 1
- dolog(LOG_INFO, "%s: too many aaaa records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
+ dolog(LOG_INFO, "%s: too many AAAA records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
return (-1);
}
sdomain.ttl = myttl;
ia6 = (struct in6_addr *)&sdomain.aaaa[sdomain.aaaa_count];
if (inet_pton(AF_INET6, (char *)aaaa, (char *)ia6) != 1) {
-#if 1
- dolog(LOG_INFO, "aaaa \"%s\" unparseable line %d\n", aaaa, file->lineno);
-#endif
+ dolog(LOG_INFO, "AAAA \"%s\" unparseable line %d\n", aaaa, file->lineno);
return -1;
}
@@ -1803,9 +1750,7 @@ fill_aaaa(char *name, char *type, int myttl, char *aaa
sdomain.flags |= DOMAIN_HAVE_AAAA;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1845,11 +1790,9 @@ fill_ns(char *name, char *type, int myttl, char *names
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
@@ -1861,9 +1804,7 @@ fill_ns(char *name, char *type, int myttl, char *names
sdomain.zonelen = converted_namelen;
if (sdomain.ns_count >= RECORD_COUNT) {
-#if 1
- dolog(LOG_INFO, "%s: too many ns records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
-#endif
+ dolog(LOG_INFO, "%s: too many NS records for zone \"%s\", skipping line %d\n", file->name, name, file->lineno);
return (-1);
}
@@ -1871,16 +1812,12 @@ fill_ns(char *name, char *type, int myttl, char *names
myname = dns_label(nameserver, (int *)&len);
if (myname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
-#endif
return 0;
}
if (len > 0xff || len < 0) {
-#if 1
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
-#endif
return -1;
}
@@ -1896,9 +1833,7 @@ fill_ns(char *name, char *type, int myttl, char *names
sdomain.flags |= DOMAIN_HAVE_NS;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -1928,13 +1863,10 @@ fill_soa(char *name, char *type, int myttl, char *auth
}
memset(&sdomain, 0, sizeof(sdomain));
-#if 1
if (get_record(&sdomain, converted_name, converted_namelen) < 0) {
return (-1);
}
-#endif
-
#ifdef __linux__
strncpy((char *)sdomain.zonename, (char *)&name, DNS_MAXNAME + 1);
sdomain.zonename[DNS_MAXNAME] = '\0';
@@ -1948,16 +1880,12 @@ fill_soa(char *name, char *type, int myttl, char *auth
myname = dns_label(auth, (int *)&len);
if (myname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
-#endif
return 0;
}
if (len > 0xff || len < 0) {
-#if 1
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
-#endif
return -1;
}
@@ -1968,16 +1896,12 @@ fill_soa(char *name, char *type, int myttl, char *auth
myname = dns_label(contact, (int *)&len);
if (myname == NULL) {
-#if 1
dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", file->lineno);
-#endif
return 0;
}
if (len > 0xff || len < 0) {
-#if 1
dolog(LOG_INFO, "illegal len value , line %d\n", file->lineno);
-#endif
return -1;
}
@@ -1994,9 +1918,7 @@ fill_soa(char *name, char *type, int myttl, char *auth
sdomain.flags |= DOMAIN_HAVE_SOA;
-#if 1
set_record(&sdomain, converted_name, converted_namelen);
-#endif
if (converted_name)
free (converted_name);
@@ -2026,18 +1948,14 @@ get_record(struct domain *sdomain, char *converted_nam
if (db->get(db, &key, &data, 0) == 0) {
#endif
if (data.size != sizeof(struct domain)) {
-#if 1
- /* if'ed out for sake of compiling */
dolog(LOG_INFO, "damaged btree database\n");
-#endif
return -1;
}
memcpy((char *)sdomain, (char *)data.data, data.size);
} else {
-#if 1
- dolog(LOG_INFO, "db->get: %s", strerror(errno));
-#endif
+ if (debug)
+ dolog(LOG_INFO, "db->get: %s\n", strerror(errno));
}
return 0;
@@ -2064,14 +1982,10 @@ set_record(struct domain *sdomain, char *converted_nam
#if DB_VERSION_MAJOR > 3
if ((ret = db->put(db, NULL, &key, &data, 0)) != 0) {
-#if 1
dolog(LOG_INFO, "db->put: %s\n" , db_strerror(ret));
-#endif
#else
if ((ret = db->put(db, &key, &data, 0)) == 0) {
-#if 1
dolog(LOG_INFO, "db->put: %s\n", db_strerror(ret));
-#endif
#endif
return;
}
repomaster@centroid.eu