fix ucspi-tcp compile
[openwrt/svn-archive/archive.git] / net / djbdns / patches / 260-djbdns-1.05-dnsfilter-replace.patch
1 --- a/dnsfilter.c Thu Feb 15 21:29:28 2001
2 +++ b/dnsfilter.c Thu Feb 15 21:57:36 2001
3 @@ -41,6 +41,7 @@
4 iopause_fd *inio;
5 int flag0 = 1;
6
7 +int opt_replace = 0;
8 iopause_fd *io;
9 int iolen;
10
11 @@ -51,12 +52,16 @@
12 void errout(int i)
13 {
14 int j;
15 -
16 - if (!stralloc_copys(&x[i].middle,":")) nomem();
17 - if (!stralloc_cats(&x[i].middle,error_str(errno))) nomem();
18 - for (j = 0;j < x[i].middle.len;++j)
19 - if (x[i].middle.s[j] == ' ')
20 - x[i].middle.s[j] = '-';
21 +
22 + if (opt_replace)
23 + x[i].middle.len=0;
24 + else {
25 + if (!stralloc_copys(&x[i].middle,":")) nomem();
26 + if (!stralloc_cats(&x[i].middle,error_str(errno))) nomem();
27 + for (j = 0;j < x[i].middle.len;++j)
28 + if (x[i].middle.s[j] == ' ')
29 + x[i].middle.s[j] = '-';
30 + }
31 }
32
33 int main(int argc,char **argv)
34 @@ -69,7 +74,7 @@
35 int j;
36 int r;
37
38 - while ((opt = getopt(argc,argv,"c:l:")) != opteof)
39 + while ((opt = getopt(argc,argv,"c:l:r")) != opteof)
40 switch(opt) {
41 case 'c':
42 scan_ulong(optarg,&u);
43 @@ -83,8 +88,11 @@
44 if (u > 1000000) u = 1000000;
45 xmax = u;
46 break;
47 + case 'r':
48 + opt_replace = 1;
49 + break;
50 default:
51 - strerr_die1x(111,"dnsfilter: usage: dnsfilter [ -c concurrency ] [ -l lines ]");
52 + strerr_die1x(111,"dnsfilter: usage: dnsfilter [ -c concurrency ] [ -l lines ] [-r]");
53 }
54
55 x = (struct line *) alloc(xmax * sizeof(struct line));
56 @@ -140,8 +148,13 @@
57 else if (r == 1) {
58 if (dns_name_packet(&x[i].middle,x[i].dt.packet,x[i].dt.packetlen) == -1)
59 errout(i);
60 - if (x[i].middle.len)
61 - if (!stralloc_cats(&x[i].left,"=")) nomem();
62 + if (x[i].middle.len) {
63 + if (opt_replace) {
64 + if (!stralloc_copys(&x[i].left, "")) nomem();
65 + } else {
66 + if (!stralloc_cats(&x[i].left, "=")) nomem();
67 + }
68 + }
69 x[i].flagactive = 0;
70 --numactive;
71 }