39#define WHO "ezmlm-moderate"
50static void die_usage() {
logmsg(
WHO,100,USAGE,
"ezmlm-moderate [-cCmMrRvV] [-t replyto] " "dir [/path/ezmlm-send]"); }
54stralloc outhost = {0};
55stralloc outlocal = {0};
64stralloc sendopt = {0};
69char strnum[FMT_ULONG];
120 if (stat(
fnmsg.s,&st) == -1) {
129 if (stat(
fnmsg.s,&st) == -1) {
138 if (stat(
fnmsg.s,&st) == -1) {
170 if (case_startb(line.s,line.len,
"return-path:")) {
171 x = 12 + byte_chr(line.s + 12,line.len-12,
'<');
173 y = byte_rchr(line.s + x,line.len-x,
'>');
174 if (y + x != line.len) {
175 if (!stralloc_copyb(&
to,line.s+x+1,y-1))
die_nomem();
197 const char *replyto = (
char *) 0;
198 unsigned int start,confnum;
202 char *
cp, *cpnext, *cpfirst, *cplast, *cpafter;
208 if (!stralloc_copys(&sendopt,
"-"))
die_nomem();
210 while ((
opt = getoptb(argc,argv,
"cCmMrRt:T:vV")) != opteof)
221 case 'T':
if (optarg) replyto = optarg;
break;
224 default: die_usage();
227 dir = argv[optind++];
228 if (!
dir) die_usage();
230 sender = env_get(
"SENDER");
232 local = env_get(
"LOCAL");
234 def = env_get(
"DEFAULT");
239 if (!sender[str_chr(sender,
'@')])
241 if (str_equal(sender,
"#@[]"))
244 if (chdir(
dir) == -1)
247 switch (openreadclose(
"key",&key,32)) {
268 start = str_chr(
action,
'-');
270 confnum = 1 + start + str_chr(
action + start + 1,
'.');
272 confnum += 1 + str_chr(
action + confnum + 1,
'.');
274 if (!stralloc_copyb(&fnbase,
action+start+1,confnum-start-1))
die_nomem();
276 cookie(hash,key.s,key.len,fnbase.s,
"",
"a");
314 buffer_init(&bt,buffer_unixread,
fd,textbuf,
sizeof(textbuf));
316 if (getln(&bt,&line,&
match,
'\n') == -1 || !
match)
323 hdr_add2(
"List-ID: ",line.s,line.len);
358 if (getln(buffer_0,&line,&
match,
'\n') == -1)
362 if (case_startb(line.s,line.len,
"Content-Transfer-Encoding:")) {
364 while (line.s[pos] ==
' ' || line.s[pos] ==
'\t')
366 if (case_startb(line.s+pos,line.len-pos,
"base64"))
368 else if (case_startb(line.s+pos,line.len-pos,
"quoted-printable"))
386 if (!stralloc_copys(&line,
"\n>>>>> -------------------- >>>>>\n"))
392 while ((cpnext =
cp + byte_chr(
cp,cpafter-
cp,
'\n')) != cpafter) {
393 i = byte_chr(
cp,cpnext-
cp,
'%');
394 if (i <= 5 && cpnext-cp >= 8) {
395 if (
cp[i+1] ==
'%' &&
cp[i+2] ==
'%') {
396 if (!flaggoodfield) {
430 if (!stralloc_cats(&line,
"<<<<< -------------------- <<<<<\n"))
die_nomem();
442 if (seek_begin(
fd) == -1)
445 buffer_init(&bt,buffer_unixread,
fd,textbuf,
sizeof(textbuf));
446 if (buffer_copy(&
bq,&bt) != 0)
452 if (!stralloc_copy(&line,&outlocal))
die_nomem();
453 if (!stralloc_cats(&line,
"-return-@"))
die_nomem();
454 if (!stralloc_cat(&line,&outhost))
die_nomem();
489 buffer_init(&bt,buffer_unixread,
fd,textbuf,
sizeof(textbuf));
491 if (getln(&bt,&line,&
match,
'\n') == -1 || !
match)
495 env_put2(
"SENDER",
to.s);
496 if (seek_begin(
fd) == -1)
#define TXT_RETURNED_POST
const char auto_version[]
#define hdr_listsubject1(a)
void wrap_execsh(const char *command)
void wrap_exitcode(int pid)
void wrap_execbin(const char *program, struct stralloc *opts, const char *dir)
Error messages. If you translate these, I would urge you to keep the English version as well....
#define ERR_TMP_QMAIL_QUEUE
int lockfile(const char *)
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
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 decode_b64(const char *cpfrom, unsigned int n, stralloc *outdata)
void hdr_boundary(int last)
void hdr_datemsgid(unsigned long when)
void cookie(char *hash, const char *key, unsigned int keylen, const char *date, const char *addr, const char *action)
ssize_t qqwrite(int fd, char *buf, unsigned int len)
void hdr_transferenc(void)
ssize_t qqwrite(int fd, char *buf, unsigned int len)
void maketo()
expects line to be a return-path line. If it is and the format is valid to is set to to the sender....
void code_qput(char *s, unsigned int n)
void hdr_add2(const char *start, const char *value, unsigned int len)
void hdr_add2s(const char *start, const char *value)
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)
void decode_qp(const char *cpfrom, unsigned int n, stralloc *outdata)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)