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 |
|
195 |
stralloc_copys( &controlfile, auto_qmail); |
196 |
stralloc_cats( &controlfile, "/control/tapscopy"); |
197 |
stralloc_0( &controlfile); |
198 |
if ( control_readline(&tapaddr,controlfile.s) == -1 ) die(65); |
199 |
|
178 |
pidopen(); |
200 |
pidopen(); |
179 |
if (fstat(messfd,&pidst) == -1) die(63); |
201 |
if (fstat(messfd,&pidst) == -1) die(63); |
180 |
|
202 |
|
Lines 219-232
Link Here
|
219 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
241 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
220 |
if (ch != 'F') die(91); |
242 |
if (ch != 'F') die(91); |
221 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
243 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
|
|
244 |
stralloc_0(&chkaddr); |
222 |
for (len = 0;len < ADDR;++len) |
245 |
for (len = 0;len < ADDR;++len) |
223 |
{ |
246 |
{ |
|
|
247 |
if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); |
248 |
else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); |
224 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
249 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
225 |
if (substdio_put(&ssout,&ch,1) == -1) die_write(); |
250 |
if (substdio_put(&ssout,&ch,1) == -1) die_write(); |
226 |
if (!ch) break; |
251 |
if (!ch) break; |
227 |
} |
252 |
} |
228 |
if (len >= ADDR) die(11); |
253 |
if (len >= ADDR) die(11); |
229 |
|
254 |
|
|
|
255 |
/* check the from address */ |
256 |
stralloc_0(&chkaddr); |
257 |
if (tapped == 0 && tapcheck()==1 ) |
258 |
{ |
259 |
tapped = 1; |
260 |
if ( tapaddr.len > 0 ) |
261 |
{ |
262 |
if (substdio_bput(&ssout,"T",1) == -1) die_write(); |
263 |
if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); |
264 |
if (substdio_bput(&ssout,"",1) == -1) die_write(); |
265 |
} |
266 |
} |
267 |
|
230 |
if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); |
268 |
if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); |
231 |
|
269 |
|
232 |
for (;;) |
270 |
for (;;) |
Lines 237-246
Link Here
|
237 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
275 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
238 |
for (len = 0;len < ADDR;++len) |
276 |
for (len = 0;len < ADDR;++len) |
239 |
{ |
277 |
{ |
|
|
278 |
if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); |
279 |
else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); |
240 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
280 |
if (substdio_get(&ssin,&ch,1) < 1) die_read(); |
241 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
281 |
if (substdio_bput(&ssout,&ch,1) == -1) die_write(); |
242 |
if (!ch) break; |
282 |
if (!ch) break; |
243 |
} |
283 |
} |
|
|
284 |
|
285 |
/* check the to address */ |
286 |
stralloc_0(&chkaddr); |
287 |
if (tapped == 0 && tapcheck()==1 ) |
288 |
{ |
289 |
tapped = 1; |
290 |
if ( tapaddr.len > 0 ) |
291 |
{ |
292 |
if (substdio_bput(&ssout,"T",1) == -1) die_write(); |
293 |
if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); |
294 |
if (substdio_bput(&ssout,"",1) == -1) die_write(); |
295 |
} |
296 |
} |
297 |
|
244 |
if (len >= ADDR) die(11); |
298 |
if (len >= ADDR) die(11); |
245 |
} |
299 |
} |
246 |
|
300 |
|
Lines 252-254
Link Here
|
252 |
triggerpull(); |
306 |
triggerpull(); |
253 |
die(0); |
307 |
die(0); |
254 |
} |
308 |
} |
|
|
309 |
|
310 |
int tapcheck() |
311 |
{ |
312 |
int i = 0; |
313 |
int j = 0; |
314 |
int x = 0; |
315 |
int negate = 0; |
316 |
stralloc curregex = {0}; |
317 |
char tmpbuf[200]; |
318 |
|
319 |
while (j < tap.len) |
320 |
{ |
321 |
i = j; |
322 |
while ((tap.s[i] != '\0') && (i < tap.len)) i++; |
323 |
if (tap.s[j] == '!') |
324 |
{ |
325 |
negate = 1; |
326 |
j++; |
327 |
} |
328 |
stralloc_copyb(&curregex,tap.s + j,(i - j)); |
329 |
stralloc_0(&curregex); |
330 |
x = matchregex(chkaddr.s, curregex.s, tmpbuf); |
331 |
|
332 |
if ((negate) && (x == 0)) return 1; |
333 |
if (!(negate) && (x > 0)) return 1; |
334 |
j = i + 1; |
335 |
negate = 0; |
336 |
} |
337 |
return 0; |
338 |
} |