17#define WHO "qmail-mfrules"
19int rename(
const char *,
const char *);
37 logmsg(
WHO,112,FATAL,
"out of memory");
42 logmsg(
WHO,100,ERROR,B(
"unable to parse this line: ",
line.s));
46 logmsg(
WHO,111,ERROR,
"unable to read control/mailfromrules");
50 logmsg(
WHO,111,ERROR,
"unable to write to control/mailfromrules.tmp");
75 left = byte_rchr(
address.s,i,
'.');
76 if (left == i) left = 0;
else ++left;
83 if (top > 255) top = 255;
89 case_lowerb(
key.s,
key.len);
115 fd = open_read(
"control/mailfromrules");
120 fdtemp = open_trunc(
"control/mailfromrules.tmp");
131 if (x[0] ==
'#')
continue;
132 if (x[0] ==
'\n')
continue;
136 if (ch !=
'\n')
if (ch !=
' ')
if (ch !=
'\t')
break;
141 amper = byte_chr(x,len,
'&');
143 if (amper)
if (amper == len || amper < 2)
die_parse();
148 x =
line.s + amper + 1; len =
line.len - amper - 1;
152 if ( *x ==
',' || *x ==
' ' || *x ==
'\t')
die_parse();
153 i = byte_chr(x,len,
',');
154 if (i > 0 && i < len) {
157 x += i + 1; len -= i + 1; }
169 if (
rename(
"control/mailfromrules.tmp",
"control/mailfromrules.cdb") == -1)
170 logmsg(
WHO,111,ERROR,
"unable to move control/mailfromrules.tmp to control/mailfromrules.cdb");
int stralloc_copys(stralloc *, char const *)
int rename(const char *, const char *)
void getnum(char *buf, int len, unsigned long *u)