Skip to content

Commit

Permalink
tinydns-get.c: Suppress verbose messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-dSn committed Dec 19, 2011
1 parent e39741d commit 60aa27d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
14 changes: 8 additions & 6 deletions printpacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

static char *d;

#define X(s) if (!stralloc_cats(out,s)) return 0;
#define NUM(u) if (!stralloc_catulong0(out,u,0)) return 0;
/* #define X(s) if (!stralloc_cats(out,s)) return 0;
#define NUM(u) if (!stralloc_catulong0(out,u,0)) return 0; */
#define X(s) ((void)0);
#define NUM(u) ((void)0);

unsigned int printpacket_cat(stralloc *out,char *buf,unsigned int len)
{
Expand Down Expand Up @@ -70,21 +72,21 @@ unsigned int printpacket_cat(stralloc *out,char *buf,unsigned int len)
uint16_unpack_big(data,&type);
NUM(type)
X(" ")
if (!dns_domain_todot_cat(out,d)) return 0;
/* if (!dns_domain_todot_cat(out,d)) return 0; */
}
X("\n")
}

for (;;) {
if (numanswers) { --numanswers; X("answer: ") }
else if (numauthority) { --numauthority; X("authority: ") }
else if (numglue) { --numglue; X("additional: ") }
/* else if (numauthority) { --numauthority; X("authority: ") }
else if (numglue) { --numglue; X("additional: ") } */
else break;

pos = printrecord_cat(out,buf,len,pos,0,0);
if (!pos) return 0;
}

if (pos != len) { errno = error_proto; return 0; }
/* if (pos != len) { errno = error_proto; return 0; } */
return 1;
}
24 changes: 12 additions & 12 deletions printrecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ unsigned int printrecord_cat(stralloc *out,const char *buf,unsigned int len,unsi
return newpos;
}

if (!dns_domain_todot_cat(out,d)) return 0;
/* if (!dns_domain_todot_cat(out,d)) return 0;
if (!stralloc_cats(out," ")) return 0;
uint32_unpack_big(misc + 4,&u32);
if (!stralloc_catulong0(out,u32,0)) return 0;
if (!stralloc_catulong0(out,u32,0)) return 0; */

if (byte_diff(misc + 2,2,DNS_C_IN)) {
if (!stralloc_cats(out," weird class\n")) return 0;
Expand All @@ -46,20 +46,20 @@ unsigned int printrecord_cat(stralloc *out,const char *buf,unsigned int len,unsi
if (byte_equal(misc,2,DNS_T_CNAME)) x = " CNAME ";
if (x) {
pos = dns_packet_getname(buf,len,pos,&d); if (!pos) return 0;
if (!stralloc_cats(out,x)) return 0;
/* if (!stralloc_cats(out,x)) return 0; */
if (!dns_domain_todot_cat(out,d)) return 0;
}
else if (byte_equal(misc,2,DNS_T_MX)) {
if (!stralloc_cats(out," MX ")) return 0;
/* if (!stralloc_cats(out," MX ")) return 0; */
pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0;
pos = dns_packet_getname(buf,len,pos,&d); if (!pos) return 0;
uint16_unpack_big(misc,&u16);
if (!stralloc_catulong0(out,u16,0)) return 0;
if (!stralloc_cats(out," ")) return 0;
/* if (!stralloc_catulong0(out,u16,0)) return 0;
if (!stralloc_cats(out," ")) return 0; */
if (!dns_domain_todot_cat(out,d)) return 0;
}
else if (byte_equal(misc,2,DNS_T_SOA)) {
if (!stralloc_cats(out," SOA ")) return 0;
/* if (!stralloc_cats(out," SOA ")) return 0; */
pos = dns_packet_getname(buf,len,pos,&d); if (!pos) return 0;
if (!dns_domain_todot_cat(out,d)) return 0;
if (!stralloc_cats(out," ")) return 0;
Expand All @@ -74,7 +74,7 @@ unsigned int printrecord_cat(stralloc *out,const char *buf,unsigned int len,unsi
}
else if (byte_equal(misc,2,DNS_T_A)) {
if (datalen != 4) { errno = error_proto; return 0; }
if (!stralloc_cats(out," A ")) return 0;
/* if (!stralloc_cats(out," A ")) return 0; */
pos = dns_packet_copy(buf,len,pos,misc,4); if (!pos) return 0;
for (i = 0;i < 4;++i) {
ch = misc[i];
Expand All @@ -83,7 +83,7 @@ unsigned int printrecord_cat(stralloc *out,const char *buf,unsigned int len,unsi
}
}
else if (byte_equal(misc,2,DNS_T_TXT)) {
if (!stralloc_cats(out," TXT ")) return 0;
/* if (!stralloc_cats(out," TXT ")) return 0; */
while (datalen) {
pos = dns_packet_copy(buf,len,pos,misc,1); if (!pos) return 0;
datalen--;
Expand All @@ -105,10 +105,10 @@ unsigned int printrecord_cat(stralloc *out,const char *buf,unsigned int len,unsi
}
}
else {
if (!stralloc_cats(out," ")) return 0;
/* if (!stralloc_cats(out," ")) return 0; */
uint16_unpack_big(misc,&u16);
if (!stralloc_catulong0(out,u16,0)) return 0;
if (!stralloc_cats(out," ")) return 0;
/* if (!stralloc_catulong0(out,u16,0)) return 0;
if (!stralloc_cats(out," ")) return 0; */
while (datalen--) {
pos = dns_packet_copy(buf,len,pos,misc,1); if (!pos) return 0;
if ((misc[0] >= 33) && (misc[0] <= 126) && (misc[0] != '\\')) {
Expand Down
4 changes: 2 additions & 2 deletions tinydns-get.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ int main(int argc,char **argv)
}

if (!stralloc_copys(&out,"")) oops();
uint16_unpack_big(type,&u16);
/* uint16_unpack_big(type,&u16);
if (!stralloc_catulong0(&out,u16,0)) oops();
if (!stralloc_cats(&out," ")) oops();
if (!dns_domain_todot_cat(&out,q)) oops();
if (!stralloc_cats(&out,":\n")) oops();
if (!stralloc_cats(&out,":\n")) oops(); */

if (!response_query(q,type,DNS_C_IN)) oops();
response[3] &= ~128;
Expand Down

0 comments on commit 60aa27d

Please sign in to comment.