17#define WHO "newinclude"
23 logmsg(
WHO,111,FATAL,
"out of memory");
27 logmsg(
WHO,100,USAGE,
"newinclude list");
44 logmsg(
WHO,111,FATAL,B(
"unable to read: ",
fnlist));
48 logmsg(
WHO,111,FATAL,B(
"unable to write to ",
fntmp));
51static void out(
char *s,
int len)
56static void doincl(
char *
buf,
int len)
59 logmsg(
WHO,111,FATAL,
"empty :include: filenames not permitted");
60 if (byte_chr(
buf,len,
'\n') != len)
61 logmsg(
WHO,111,FATAL,
"newlines not permitted in :include: filenames");
62 if (byte_chr(
buf,len,
'\0') != len)
63 logmsg(
WHO,111,FATAL,
"NUL not permitted in :include: filenames");
64 if ((
buf[0] !=
'.') && (
buf[0] !=
'/'))
70static void dorecip(
char *
buf,
int len)
73 logmsg(
WHO,111,FATAL,
"empty recipient addresses not permitted");
74 if (byte_chr(
buf,len,
'\n') != len)
75 logmsg(
WHO,111,FATAL,
"newlines not permitted in recipient addresses");
76 if (byte_chr(
buf,len,
'\0') != len)
77 logmsg(
WHO,111,FATAL,
"NUL not permitted in recipient addresses");
79 logmsg(
WHO,111,FATAL,
"addresses must be under 800 bytes");
80 if ((
buf[len - 1] ==
' ') || (
buf[len - 1] ==
'\t'))
81 logmsg(
WHO,111,FATAL,
"spaces and tabs not permitted at ends of addresses");
90 logmsg(
WHO,111,FATAL,
"unable to read controls");
104 fddir = open_read(
".");
106 logmsg(
WHO,111,FATAL,
"unable to open current directory");
118 x = env_get(
"QMAILDEFAULTDOMAIN");
124 x = env_get(
"QMAILDEFAULTHOST");
130 x = env_get(
"QMAILPLUSDOMAIN");
133 if (fchdir(fddir) == -1)
134 logmsg(
WHO,111,FATAL,
"unable to set current directory");
160 for (i = 0;i <
tokaddr.len;++i)
171 logmsg(
WHO,111,FATAL,B(
"file delivery for ",
address.s,
" not supported"));
176 logmsg(
WHO,111,FATAL,B(
"program delivery for ",
address.s,
" not supported"));
202static void parseerr()
205 logmsg(
WHO,111,FATAL,B(
"unable to parse this line: ",
line.s));
208static void parseline()
226 while (t > beginning)
227 switch ((--t)->
type) {
231 if (t >= beginning + 2)
235 if (!byte_diff(t[-1].
s,7,
"include")) {
245 if (t <= beginning) parseerr();
252 if (!wordok)
if (
tokaddr.len) gotaddr();
272int main(
int argc,
char *
const *argv)
282 if (!stralloc_cats(&
bin,
".bin"))
nomem();
286 if (!stralloc_cats(&
tmp,
".tmp"))
nomem();
290 if (
fd == -1) readerr();
299 if (!
line.len)
break;
300 if (
line.s[0] !=
'#') parseline();
309 logmsg(
WHO,111,FATAL,B(
"unable to move ",
fntmp,
" to: ",
fnbin));
int control_readline(stralloc *sa, char *fn)
int stralloc_copys(stralloc *, char const *)
int rename(const char *, const char *)
char tmpbuf[BUFSIZE_LINE]
char listbuf[BUFSIZE_LINE]
int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf)
int token822_append(token822_alloc *, struct token822 *)
int token822_unquote(stralloc *, token822_alloc *)
void token822_reverse(token822_alloc *)
int token822_readyplus(token822_alloc *, unsigned int)