Index: trunk/debs/squid/redirector.c |
— | — | @@ -2,15 +2,15 @@ |
3 | 3 | * |
4 | 4 | * Squid Redirect Helper - reads from stdin, outputs 302 to $1.m.wikipedia.org/$2 |
5 | 5 | * if original matches "^http:\\/\\/(\\w+)\\.wikipedia\\.org[:\\d]*\\/(.*)" |
6 | | - * A new base url in place of m.wikiedpia.org may be provided as the only argument. |
| 6 | + * A new base url in place of m.wikipedia.org may be provided as the only argument. |
7 | 7 | * |
8 | 8 | * To compile: gcc -O3 -o redirector -lpcre redirector.c |
9 | 9 | * |
10 | 10 | */ |
11 | 11 | |
12 | 12 | #include <stdio.h> |
13 | | -#include<stdlib.h> |
14 | | -#include<string.h> |
| 13 | +#include <stdlib.h> |
| 14 | +#include <string.h> |
15 | 15 | #include <pcre.h> |
16 | 16 | |
17 | 17 | #define MAX_BUFF 8256 |
— | — | @@ -108,13 +108,20 @@ |
109 | 109 | |
110 | 110 | if (rc < 0) { |
111 | 111 | switch(rc) { |
112 | | - case PCRE_ERROR_NOMATCH: printf("%s\n", in_buff->url); break; |
113 | | - default: printf("Matching error %d\n", rc); break; |
| 112 | + case PCRE_ERROR_NOMATCH: |
| 113 | + printf("%s\n", in_buff->url); |
| 114 | + fflush(stdout); |
| 115 | + |
| 116 | + break; |
| 117 | + default: |
| 118 | + fprintf(stderr, "Matching error %d\n", rc); |
| 119 | + break; |
114 | 120 | } |
| 121 | + continue; |
115 | 122 | } |
116 | 123 | |
117 | 124 | char lang[20] = ""; |
118 | | - char path[MAX_BUFF] = ""; |
| 125 | + char path[MAX_BUFF] = ""; |
119 | 126 | |
120 | 127 | for (i = 0; i < rc; i++) { |
121 | 128 | |