18static void nomem() { logmsg(
WHO,111,FATAL,
"out of memory"); }
19static void die_read() { logmsg(
WHO,110,ERROR,
"unable to read input: "); }
20static void die_write() { logmsg(
WHO,110,ERROR,
"unable to write output: "); }
21static void die_write5() { logmsg(
WHO,111,FATAL,
"unable to write fd 5: "); }
23static void out(
char *
buf,
int len)
35static void out5(
char *
buf,
int len)
37 if (buffer_put(&
bo5,
buf,len) == -1)
40static void outs5(
char *
buf)
42 if (buffer_puts(&
bo5,
buf) == -1)
47GEN_ALLOC_ready(ulongalloc,
unsigned long,u,len,a,i,n,x,30,ulongalloc_ready)
66static int msg_find(
unsigned long m)
69 for (i = 0; i <
nummsg; ++i)
70 if (
msg.u[i] ==
m)
return i;
74static int msg_add(
unsigned long m)
77 for (i = 0; i <
nummsg; ++i)
78 if (
msg.u[i] ==
m)
return i;
93static void msg_kill(
int i)
117static int del_find(
unsigned long d)
120 for (i = 0; i <
numdel; ++i)
121 if (
del.u[i] ==
d)
return i;
125static int del_add(
unsigned long d)
128 for (i = 0; i <
numdel; ++i)
129 if (
del.u[i] ==
d)
return i;
140static void del_kill(
int i)
164 for (i = 0; i <
nummsg; ++i) {
165 x = pool.s +
birth.u[i];
175 for (i = 0; i <
numdel; ++i) {
180 x = pool.s +
dchan.u[i];
208static void starting()
221 dstart.u[dpos] = pool.len;
223 if (!stralloc_0(&pool))
nomem();
225 dchan.u[dpos] = pool.len;
227 if (!stralloc_0(&pool))
nomem();
229 drecip.u[dpos] = pool.len;
231 if (!stralloc_0(&pool))
nomem();
232 case_lowers(pool.s +
drecip.u[dpos]);
249 if (dpos == -1)
return;
254 if (str_start(
line.s +
field[3],
"succ")) {
259 else if (str_start(
line.s +
field[3],
"fail")) {
264 else if (str_start(
line.s +
field[3],
"defer")) {
269 else if (str_start(
line.s +
field[3],
"report")) {
272 reason =
"report_mangled";
310 if (
mpos == -1)
return;
322 if (
mpos == -1)
return;
357 if (!stralloc_0(&pool))
nomem();
361 if (!stralloc_0(&pool))
nomem();
374 if (
mpos == -1)
return;
385 for (i = 0; i <
nummsg; ++i) {
386 outs5(pool.s +
birth.u[i]);
392 outs5(pool.s +
sender.u[i]);
398 outs5(pool.s +
birth.u[i]);
410 for (i = 0; i <
numdel; ++i) {
411 outs5(pool.s +
dstart.u[i]);
412 outs5(
" starting delivery ");
417 outs5(pool.s +
dchan.u[i]);
419 outs5(pool.s +
drecip.u[i]);
424 if (buffer_flush(&
bo5) == -1) die_write5();
437 if (!ulongalloc_ready(&
msg,1))
nomem();
439 if (!ulongalloc_ready(&
qp,1))
nomem();
440 if (!ulongalloc_ready(&
uid,1))
nomem();
444 if (!ulongalloc_ready(&
del,1))
nomem();
453 for (i = 0; i <
line.len; ++i) {
455 if ((ch ==
'\n') || (ch ==
' ') || (ch ==
'\t'))
line.s[i] = 0;
458 for (i = 0; i <
FIELDS; ++i) {
459 while (
j <
line.len)
if (
line.s[
j])
break;
else ++
j;
461 while (
j <
line.len)
if (!
line.s[
j])
break;
else ++
j;
465 if (str_equal(
line.s +
field[1],
"status:")) ;
466 else if (str_equal(
line.s +
field[1],
"starting")) starting();
468 else if (str_equal(
line.s +
field[1],
"new")) newmsg();
469 else if (str_equal(
line.s +
field[1],
"end")) endmsg();
470 else if (str_equal(
line.s +
field[1],
"info")) info();
471 else if (str_equal(
line.s +
field[1],
"extra")) extra();
472 else if (str_equal(
line.s +
field[1],
"running")) clear();
473 else if (str_equal(
line.s +
field[1],
"exiting")) clear();
474 else if (str_equal(
line.s +
field[1],
"number")) ;
475 else if (str_equal(
line.s +
field[1],
"local")) ;
476 else if (str_equal(
line.s +
field[1],
"remote")) ;
485 if (buffer_flush(buffer_1) == -1)
die_write();
int stralloc_copys(stralloc *, char const *)
GEN_ALLOC_typedef(GEN_ALLOC_ready(ulongalloc, GEN_ALLOC_ready(unsigned long, GEN_ALLOC_ready(u, GEN_ALLOC_ready(len, GEN_ALLOC_ready(a)
GEN_ALLOC_readyplus(prioq, struct prioq_elt, p, len, a, i, n, x, 100, prioq_readyplus)
GEN_ALLOC_ready(GEN_ALLOC_readyplus(token822_alloc, GEN_ALLOC_readyplus(struct token822, GEN_ALLOC_readyplus(t, GEN_ALLOC_readyplus(len, GEN_ALLOC_readyplus(a, GEN_ALLOC_readyplus(i, GEN_ALLOC_readyplus(n, GEN_ALLOC_readyplus(x, GEN_ALLOC_readyplus(30, token822_ready)