36#define WHO "ezmlm-request"
45static void die_usage() {
logmsg(
WHO,100,USAGE,
"ezmlm-request [-f lists.cfg] dir"); }
48char strnum[FMT_ULONG];
57stralloc outhost = {0};
58stralloc outlocal = {0};
88 "subscribe\\unsubscribe\\index\\"
90 "sub\\unsub\\remove\\signoff\\"
92 "ind\\rev\\review\\recipients\\"
103const int cmdxlate[] = { 0,1,2,3,4,5,6,7,8,3,4,4,4,-13,-14,5,7,7,7,7,7,1,1 };
111const int noargsxlate[] = { 0,1,-2,3,4,5,-2,-13,-14,9,10,11,12,13,14,15,16,17,
117#define EZREQ_LISTS 13
118#define EZREQ_WHICH 14
134buffer
bq = BUFFER_INIT(
qqwrite,-1,qqbuf,(
int)
sizeof(qqbuf));
173 while ((ch = *
cp++)) {
174 if (ch >=
'a' && ch <=
'z')
176 if (ch >=
'0' && ch <=
'9')
178 if (ch ==
'.' || ch ==
'-' || ch ==
'_' || ch ==
'+')
180 if (ch >=
'A' && ch <=
'Z')
continue;
219 if (*cp1 ==
'\t') *cp1 =
' ';
223 if (outlocal.len < str_len(
cp) &&
cp[outlocal.len -1] ==
'-' &&
224 case_starts(
cp,outlocal.s)) {
229 while (*cp1 && *cp1 !=
'-')
235 cp1 = cp1 + str_rchr(cp1,
'@');
244 if (str_chr(
cp,
'@') < str_chr(
cp,
' '))
248 cp1 =
cp + str_chr(
cp,
' ');
251 while (*cp1 && *cp1 ==
' ')
256 cp2 = cp1 + str_chr(cp1,
' ');
258 while (*cp2 && *cp2 ==
' ')
265 cp3 = cp2 + str_chr(cp2,
' ');
277 cp2 += str_chr(cp2,
'@');
285 cp1 += str_chr(cp1,
'@');
313 int flagmultipart = 0;
316 unsigned int pos,pos1,
len,last;
321 while ((
opt = getoptb(argc,argv,
"f:F:vV")) != opteof)
324 case 'f':
if (optarg)
cfname = optarg;
break;
327 default: die_usage();
331 if (!
dir) die_usage();
333 if (chdir(
dir) == -1)
339 def = env_get(
"DEFAULT");
343 local = env_get(
"LOCAL");
346 if (
len >= 8 && !case_diffb(
local +
len - 8,8,
"-return-")) {
347 action = (
char*)
"return-";
370 sender = env_get(
"SENDER");
374 if (!sender[str_chr(sender,
'@')])
376 if (str_equal(sender,
"#@[]"))
383 "Delivered-To: request processor for "))
die_nomem();
393 if (str_start(
action,
"return"))
395 pos = 1 + str_chr(
action + 1,
'-');
407 if (getln(&
bi,&line,&
match,
'\n') == -1)
411 if ((line.s[0] !=
' ') && (line.s[0] !=
'\t')) {
414 if (case_startb(line.s,line.len,
"mailing-list:")) {
416 }
else if (case_startb(line.s,line.len,
"Subject:")) {
420 while (line.s[last] ==
' ' || line.s[last] ==
'\t') --last;
421 while (pos <= last && (line.s[pos] ==
' ' || line.s[pos] ==
'\t'))
424 }
else if (case_startb(line.s,line.len,
"content-type:")) {
425 pos = 13; last = line.len - 2;
426 while (pos <= last && (line.s[pos] ==
' ' || line.s[pos] ==
'\t'))
428 if (case_startb(line.s+pos,line.len - pos,
"multipart/"))
430 }
else if (line.len ==
mydtline.len)
431 if (!byte_diff(line.s,line.len,
mydtline.s))
436 while (line.s[
len] ==
' ' || line.s[
len] ==
'\t')
438 while (pos <
len && (line.s[pos] ==
' ' || line.s[pos] ==
'\t'))
450 if ((ch <=
'z' && ch >=
'a') || (ch <=
'Z' && ch >=
'A')) {
455 if (
cfname || flagnosubject) {
457 if (getln(&
bi,&line,&
match,
'\n') == -1)
460 if (line.len == 1 && flagmultipart != 2)
continue;
463 if (flagmultipart == 1) {
464 if (*line.s !=
'-' || line.s[1] !=
'-')
continue;
467 }
else if (flagmultipart == 2) {
468 if (line.len != 1)
continue;
471 }
else if (flagmultipart == 3) {
472 if (*line.s ==
'-' && line.s[1] ==
'-') {
481 if (line.len == 1 || !((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z')))
497 if (*psz ==
'\\') *psz =
'\0';
513 if (cmdidx < 0 && !
cfname) {
542 buffer_init(&bt,buffer_unixread,
fd,textbuf,
sizeof(textbuf));
545 if (getln(&bt,&line,&
match,
'\n') == -1)
549 if (line.len <= 1 || line.s[0] ==
'#')
551 if ((pos < line.len) && (line.s[pos] ==
'@') && !byte_diff(line.s,pos,
listlocal)) {
552 last = byte_chr(line.s,line.len,
':');
553 if (!stralloc_copyb(&
lhost,line.s + pos + 1,last - pos - 1))
die_nomem();
590 if (!stralloc_cats(&
to,constmap_get(&
commandmap,cmdidx)))
610 if (seek_begin(0) == -1)
615 if (getln(&
bi,&line,&
match,
'\n') == -1)
618 if (flaginheader &&
match) {
621 if ((line.s[0] !=
' ') && (line.s[0] !=
'\t')) {
627 if (!(flaginheader && flagbadfield))
671 hdr_adds(
"Mailing-List: ezmlm-request");
673 hdr_add2(
"List-ID: ",line.s,line.len);
699 buffer_init(&bt,buffer_unixread,
fd,textbuf,
sizeof(textbuf));
702 if (getln(&bt,&line,&
match,
'\n') == -1)
706 if (line.len <= 1 || line.s[0] ==
'#')
709 pos = str_chr(line.s,
':');
714 pos1 = pos + str_chr(line.s + pos,
':');
725 if (pos1)
code_qput(line.s + pos1,line.len - 2 - pos1);
748 hdr_adds(
"Content-Disposition: inline; filename=request.msg");
755 if (seek_begin(0) == -1)
757 if (buffer_copy(&
bq,&
bj) != 0)
int issub()
Returns (char *) to match if userhost is in the subscriber database dbname, 0 otherwise....
int quote2(stralloc *sa, const char *s)
const char auto_version[]
Error messages. If you translate these, I would urge you to keep the English version as well....
#define ERR_TMP_QMAIL_QUEUE
const char * qmail_close(struct qmail *)
void qmail_puts(struct qmail *, const char *)
void qmail_put(struct qmail *, const char *, int)
void qmail_from(struct qmail *, const char *)
void qmail_to(struct qmail *, const char *)
unsigned long qmail_qp(struct qmail *)
int qmail_open(struct qmail *, const stralloc *)
charset, outhost, outlocal and flagcd are shared
void closesql(void)
close connection to SQL server, if open
int getconf(stralloc *sa, const char *fn, int flagrequired, const char *dir)
int getconf_line(stralloc *sa, const char *fn, int flagrequired, const char *dir)
void ezcopy(struct qmail *qqp, const char *fn, char q)
void set_cpoutlocal(const stralloc *ln)
void set_cpouthost(const stralloc *ln)
void encode_qp(const char *indata, unsigned int n, stralloc *outdata)
void hdr_from(const char *append)
void hdr_boundary(int last)
struct constmap commandmap
ssize_t qqwrite(int fd, char *buf, unsigned int len)
struct constmap headerremovemap
int code_qput(char *s, unsigned int n)
void hdr_datemsgid(unsigned long when)
ssize_t qqwrite(int fd, char *buf, unsigned int len)
void hdr_add2(const char *start, const char *value, unsigned int len)
void hdr_adds(const char *line)
void hdr_ctboundary(void)
void encode_b64(const unsigned char *indata, unsigned int n, stralloc *outdata, int control)
void hdr_ctype(enum ctype ctype)
void hdr_mime(enum ctype ctype)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)