Lines 16-21
Link Here
|
16 |
#include "auto_uids.h" |
16 |
#include "auto_uids.h" |
17 |
#include "date822fmt.h" |
17 |
#include "date822fmt.h" |
18 |
#include "fmtqfn.h" |
18 |
#include "fmtqfn.h" |
|
|
19 |
#include "stralloc.h" |
20 |
#include "constmap.h" |
19 |
|
21 |
|
20 |
#define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */ |
22 |
#define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */ |
21 |
#define ADDR 1003 |
23 |
#define ADDR 1003 |
Lines 25-30
Link Here
|
25 |
char outbuf[256]; |
27 |
char outbuf[256]; |
26 |
struct substdio ssout; |
28 |
struct substdio ssout; |
27 |
|
29 |
|
|
|
30 |
int tapok = 0; |
31 |
stralloc tap = {0}; |
32 |
struct constmap maptap; |
33 |
stralloc chkaddr = {0}; |
34 |
int tapped; |
35 |
stralloc tapaddr = {0}; |
36 |
stralloc controlfile = {0}; |
37 |
|
28 |
datetime_sec starttime; |
38 |
datetime_sec starttime; |
29 |
struct datetime dt; |
39 |
struct datetime dt; |
30 |
unsigned long mypid; |
40 |
unsigned long mypid; |
Lines 175-180
Link Here
|
175 |
|
185 |
|
176 |
alarm(DEATH); |
186 |
alarm(DEATH); |
177 |
|
187 |
|
|
|
188 |
stralloc_copys( &controlfile, auto_qmail); |
189 |
stralloc_cats( &controlfile, "/control/taps"); |
190 |
stralloc_0( &controlfile); |
191 |
tapok = control_readfile(&tap,controlfile.s,0); |
192 |
if (tapok == -1) die(65); |
193 |
if (!constmap_init(&maptap,tap.s,tap.len,0)) die(65); |
194 |
|
178 |
pidopen(); |
195 |
pidopen(); |
179 |
if (fstat(messfd,&pidst) == -1) die(63); |
196 |
if (fstat(messfd,&pidst) == -1) die(63); |
180 |
|
197 |
|
Lines 219-232
Link Here
|
219 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
236 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
220 |
if (ch != 'F') die(91); |
237 |
if (ch != 'F') die(91); |
221 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
238 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
|
|
239 |
stralloc_0(&chkaddr); |
222 |
for (len = 0;len < ADDR;++len) |
240 |
for (len = 0;len < ADDR;++len) |
223 |
{ |
241 |
{ |
|
|
242 |
if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); |
243 |
else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); |
224 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
244 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
225 |
if (substdio_put(&ssout,&ch,1) == -1) die_write(); |
245 |
if (substdio_put(&ssout,&ch,1) == -1) die_write(); |
226 |
if (!ch) break; |
246 |
if (!ch) break; |
227 |
} |
247 |
} |
228 |
if (len >= ADDR) die(11); |
248 |
if (len >= ADDR) die(11); |
229 |
|
249 |
|
|
|
250 |
/* check the from address */ |
251 |
stralloc_0(&chkaddr); |
252 |
if (tapped == 0 && tapcheck()==1 ) { |
253 |
tapped = 1; |
254 |
if ( tapaddr.len > 0 ) { |
255 |
if (substdio_bput(&ssout,"T",1) == -1) die_write(); |
256 |
if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); |
257 |
if (substdio_bput(&ssout,"",1) == -1) die_write(); |
258 |
} |
259 |
} |
260 |
|
230 |
if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); |
261 |
if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); |
231 |
|
262 |
|
232 |
for (;;) |
263 |
for (;;) |
Lines 237-246
Link Here
|
237 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
268 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
238 |
for (len = 0;len < ADDR;++len) |
269 |
for (len = 0;len < ADDR;++len) |
239 |
{ |
270 |
{ |
|
|
271 |
if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); |
272 |
else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); |
240 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
273 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
241 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
274 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
242 |
if (!ch) break; |
275 |
if (!ch) break; |
243 |
} |
276 |
} |
|
|
277 |
|
278 |
/* check the to address */ |
279 |
stralloc_0(&chkaddr); |
280 |
if (tapped == 0 && tapcheck()==1 ) { |
281 |
tapped = 1; |
282 |
if ( tapaddr.len > 0 ) { |
283 |
if (substdio_bput(&ssout,"T",1) == -1) die_write(); |
284 |
if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); |
285 |
if (substdio_bput(&ssout,"",1) == -1) die_write(); |
286 |
} |
287 |
} |
288 |
|
244 |
if (len >= ADDR) die(11); |
289 |
if (len >= ADDR) die(11); |
245 |
} |
290 |
} |
246 |
|
291 |
|
Lines 252-254
Link Here
|
252 |
triggerpull(); |
297 |
triggerpull(); |
253 |
die(0); |
298 |
die(0); |
254 |
} |
299 |
} |
|
|
300 |
|
301 |
int tapcheck() |
302 |
{ |
303 |
int i = 0; |
304 |
int j = 0; |
305 |
int x = 0; |
306 |
int negate = 0; |
307 |
stralloc curregex = {0}; |
308 |
char tmpbuf[200]; |
309 |
|
310 |
while (j < tap.len) { |
311 |
i = j; |
312 |
while ((tap.s[i] != ':') && (i < tap.len)) i++; |
313 |
if (tap.s[j] == '!') { |
314 |
negate = 1; |
315 |
j++; |
316 |
} |
317 |
stralloc_copys(&tapaddr, &tap.s[i+1]); |
318 |
|
319 |
stralloc_copyb(&curregex,tap.s + j,(i - j)); |
320 |
stralloc_0(&curregex); |
321 |
x = matchregex(chkaddr.s, curregex.s, tmpbuf); |
322 |
|
323 |
while ((tap.s[i] != '\0') && (i < tap.len)) i++; |
324 |
|
325 |
if ((negate) && (x == 0)) { |
326 |
return 1; |
327 |
} |
328 |
if (!(negate) && (x > 0)) { |
329 |
return 1; |
330 |
} |
331 |
j = i + 1; |
332 |
negate = 0; |
333 |
|
334 |
|
335 |
} |
336 |
return 0; |
337 |
} |
338 |
|