27#define WHO "ezmlm-split"
41stralloc outhost = {0};
42stralloc outlocal = {0};
51char strnum[FMT_ULONG];
55static void die_usage() {
logmsg(
WHO,100,USAGE,
"ezmlm-split [-dD] dir [splitfile]"); }
60 strnum[fmt_ulong(strnum,
lineno)] =
'\0';
61 logmsg(
WHO,111,FATAL,B(
"syntax error line :",line.s,
"[",strnum,
"]"));
76buffer
bq = BUFFER_INIT(
bqrite,-1,qqbuf,(
int)
sizeof(qqbuf));
86 char *cpat, *
cp, *cp1, *cp2, *cplast;
91 unsigned int pos, pos_name, pos_hi;
103 while ((ch = *
cp++)) {
104 h = (h + (h << 5)) ^ (uint32) ch;
113 cplast = cpat + str_len(cpat) - 1;
114 if (*cplast ==
'.') --cplast;
115 cp1 = cpat + byte_rchr(cpat,cplast - cpat,
'.');
118 cp2 = cpat + byte_rchr(cpat, cp1 - cpat,
'.');
119 if (cp2 == cp1) cp2 = cpat;
127 if ((
fd = open_read(
split)) == -1)
134 if (getln(&
bi,&line,&
match,
'\n') == -1)
139 if (line.s[0] ==
'#')
continue;
140 line.s[line.len - 1] =
'\0';
141 if (!line.s[pos = str_chr(line.s,
':')])
144 if (pos == 0 || (case_starts(
domain.s,line.s))) {
146 pos_hi = pos + str_chr(line.s + pos,
':');
149 scan_ulong(line.s + pos, &u);
151 scan_ulong(line.s + pos_hi, &u);
153 pos_name = pos_hi + str_chr(line.s + pos_hi,
':');
154 if (pos_hi == pos_name)
hash_hi = 52L;
155 if (line.s[pos_name]) pos_name++;
159 cpname = line.s + pos_name;
160 while (*cpname && (*cpname ==
' ' || *cpname ==
'\t'))
164 while (pos && (line.s[pos] ==
'\n' || line.s[pos] ==
' ' || line.s[pos] ==
'\t'))
165 line.s[pos--] =
'\0';
201 dir = argv[optind++];
202 if (!
dir) die_usage();
207 if (!(
dir = argv[optind++])) die_usage();
209 if (!(
split = argv[optind]))
212 if (chdir(
dir) == -1)
219 sender = env_get(
"SENDER");
223 if (!sender[str_chr(sender,
'@')])
225 if (str_equal(sender,
"#@[]"))
228 action = env_get(
"DEFAULT");
230 if (!stralloc_copys(&target,sender))
die_nomem();
236 i = byte_rchr(target.s,target.len,
'=');
254 if (
name.s[i = str_rchr(
name.s,
'@')]) {
262 if (target.s[i = str_rchr(target.s,
'@')])
268 dtline = env_get(
"DTLINE");
274 if (buffer_copy(&
bq,buffer_0) != 0)
290 if (getln(buffer_0,&line,&
match,
'\n') == -1)
293 if (line.len == 1)
continue;
294 if (line.s[0] ==
'#')
continue;
295 if (!stralloc_copy(&target,&line))
die_nomem();
296 target.s[target.len - 1] =
'\0';
301 if (buffer_put(buffer_1,
name.s,
name.len) == -1)
304 if (buffer_flush(buffer_1) == -1)
int getconf_line(stralloc *sa, const char *fn, int flagrequired, const char *dir)
ssize_t bqrite(int fd, char *buf, size_t len)
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
#define ACTION_UNSUBSCRIBE
Error messages. If you translate these, I would urge you to keep the English version as well....
#define ERR_TMP_QMAIL_QUEUE
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)