Index: trunk/udplog/filters/SOPA-filter.c |
— | — | @@ -3,22 +3,22 @@ |
4 | 4 | #include <string.h> |
5 | 5 | |
6 | 6 | char * urls[] = { |
7 | | - "en.wikipedia.org/wiki/Special:CongressLookup", |
| 7 | + "en.wikipedia.org/wiki/Special:CongressLookup", |
8 | 8 | }; |
9 | 9 | |
10 | 10 | main() { |
11 | | - char line[65534]; |
| 11 | + char line[65534]; |
12 | 12 | char *t = 0; |
13 | | - |
14 | | - int i = 0; |
15 | | - |
16 | | - //calculate these up-front. |
17 | | - int filtercount = sizeof(urls)/sizeof(*urls); |
18 | | - int url_length[filtercount]; |
19 | | - for (i=0; i<filtercount; ++i){ |
20 | | - url_length[i] = strlen(urls[i]); |
21 | | - } |
22 | 13 | |
| 14 | + int i = 0; |
| 15 | + |
| 16 | + //calculate these up-front. |
| 17 | + int filtercount = sizeof(urls)/sizeof(*urls); |
| 18 | + int url_length[filtercount]; |
| 19 | + for (i=0; i<filtercount; ++i){ |
| 20 | + url_length[i] = strlen(urls[i]); |
| 21 | + } |
| 22 | + |
23 | 23 | while (!feof(stdin)) { |
24 | 24 | char *r; |
25 | 25 | r=fgets(line, 65534, stdin); |
— | — | @@ -36,23 +36,23 @@ |
37 | 37 | } |
38 | 38 | if (!t) |
39 | 39 | continue; |
40 | | - |
41 | | - t = strstr(t, "://"); |
42 | | - if (!t) |
43 | | - continue; |
44 | | - t += 3; |
45 | | - |
46 | | - int found = 0; |
47 | | - for (i = 0; i < filtercount; ++i) { |
48 | | - if (strncmp(t, urls[i], url_length[i]) == 0) { |
49 | | - found = 1; |
50 | | - break; |
51 | | - } |
52 | | - } |
53 | | - if (found) { |
54 | | - printf("%s", line); |
55 | | - } |
56 | 40 | |
| 41 | + t = strstr(t, "://"); |
| 42 | + if (!t) |
| 43 | + continue; |
| 44 | + t += 3; |
| 45 | + |
| 46 | + int found = 0; |
| 47 | + for (i = 0; i < filtercount; ++i) { |
| 48 | + if (strncmp(t, urls[i], url_length[i]) == 0) { |
| 49 | + found = 1; |
| 50 | + break; |
| 51 | + } |
| 52 | + } |
| 53 | + if (found) { |
| 54 | + printf("%s", line); |
| 55 | + } |
| 56 | + |
57 | 57 | } |
58 | 58 | |
59 | 59 | } |