19#define WHO "qmail-qread"
23static void die(
int n) { buffer_flush(buffer_1);
_exit(n); }
25static void warn(
char *s1,
char *s2)
29 buffer_puts(buffer_1,s1);
30 buffer_puts(buffer_1,s2);
31 buffer_puts(buffer_1,
": ");
32 buffer_puts(buffer_1,x);
33 buffer_puts(buffer_1,
"\n");
36static void die_nomem() { logmsg(
WHO,111,FATAL,
"out of memory"); }
37static void die_chdir() { logmsg(
WHO,110,FATAL,
"unable to chdir"); }
38static void die_opendir(
char *
fn) { logmsg(
WHO,110,FATAL,B(
"unable to opendir ",
fn)); }
40static void err(
unsigned long id)
43 foo[fmt_ulong(
foo,
id)] = 0;
44 warn(
"warning: trouble with #",
foo);
61static unsigned int fmtstats(
char *s)
70 i = fmt_str(s,
" GMT #"); len += i;
if (s) s += i;
71 i = fmt_ulong(s,
id); len += i;
if (s) s += i;
72 i = fmt_str(s,
" "); len += i;
if (s) s += i;
73 i = fmt_ulong(s,
size); len += i;
if (s) s += i;
74 i = fmt_str(s,
" <"); len += i;
if (s) s += i;
75 i = fmt_str(s,
sender.s + 1); len += i;
if (s) s += i;
76 i = fmt_str(s,
"> "); len += i;
if (s) s += i;
78 i = fmt_str(s,
" bouncing"); len += i;
if (s) s += i;
86static void out(
char *s,
unsigned int n)
89 buffer_put(buffer_1,((*s >= 32) && (*s <= 126)) ? s :
"_",1);
94static void outs(
char *s) {
out(s,str_len(s)); }
95static void outok(
char *s) { buffer_puts(buffer_1,s); }
117 if (chdir(
"queue") == -1) die_chdir();
128 if (stat(
fnmess,&st) == -1) { err(
id);
continue; }
133 if (
fd == -1) { err(
id);
continue; }
136 if (fstat(
fd,&st) == -1) { close(
fd); err(
id);
continue; }
142 for (channel = 0; channel < 2; ++channel) {
145 if (errno != ENOENT) err(
id);
154 outok(channel ?
"\tremote\t" :
"\tlocal\t");
unsigned int date822fmt(char *s, struct datetime *dt)
void datetime_tai(struct datetime *dt, datetime_sec t)
unsigned int fmtqfn(char *s, char *dirslash, unsigned long id, int flagsplit)
int readsubdir_next(readsubdir *, unsigned long *)
void readsubdir_init(readsubdir *, char *, void(*)(char *))