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,
"]"));
74buffer
bq = BUFFER_INIT(
bqrite,-1,qqbuf,(
int)
sizeof(qqbuf));
84 char *cpat, *
cp, *cp1, *cp2, *cplast;
89 unsigned int pos, pos_name, pos_hi;
101 while ((ch = *
cp++)) {
102 h = (h + (h << 5)) ^ (uint32) ch;
111 cplast = cpat + str_len(cpat) - 1;
112 if (*cplast ==
'.') --cplast;
113 cp1 = cpat + byte_rchr(cpat,cplast - cpat,
'.');
116 cp2 = cpat + byte_rchr(cpat, cp1 - cpat,
'.');
117 if (cp2 == cp1) cp2 = cpat;
125 if ((
fd = open_read(
split)) == -1)
132 if (getln(&
bi,&line,&
match,
'\n') == -1)
137 if (line.s[0] ==
'#')
continue;
138 line.s[line.len - 1] =
'\0';
139 if (!line.s[pos = str_chr(line.s,
':')])
142 if (pos == 0 || (case_starts(
domain.s,line.s))) {
144 pos_hi = pos + str_chr(line.s + pos,
':');
147 scan_ulong(line.s + pos, &u);
149 scan_ulong(line.s + pos_hi, &u);
151 pos_name = pos_hi + str_chr(line.s + pos_hi,
':');
152 if (pos_hi == pos_name)
hash_hi = 52L;
153 if (line.s[pos_name]) pos_name++;
157 cpname = line.s + pos_name;
158 while (*cpname && (*cpname ==
' ' || *cpname ==
'\t'))
162 while (pos && (line.s[pos] ==
'\n' || line.s[pos] ==
' ' || line.s[pos] ==
'\t'))
163 line.s[pos--] =
'\0';
199 dir = argv[optind++];
200 if (!
dir) die_usage();
205 if (!(
dir = argv[optind++])) die_usage();
207 if (!(
split = argv[optind]))
210 if (chdir(
dir) == -1)
217 sender = env_get(
"SENDER");
221 if (!sender[str_chr(sender,
'@')])
223 if (str_equal(sender,
"#@[]"))
226 action = env_get(
"DEFAULT");
228 if (!stralloc_copys(&target,sender))
die_nomem();
234 i = byte_rchr(target.s,target.len,
'=');
252 if (
name.s[i = str_rchr(
name.s,
'@')]) {
260 if (target.s[i = str_rchr(target.s,
'@')])
266 dtline = env_get(
"DTLINE");
272 if (buffer_copy(&
bq,buffer_0) != 0)
288 if (getln(buffer_0,&line,&
match,
'\n') == -1)
291 if (line.len == 1)
continue;
292 if (line.s[0] ==
'#')
continue;
293 if (!stralloc_copy(&target,&line))
die_nomem();
294 target.s[target.len - 1] =
'\0';
299 if (buffer_put(buffer_1,
name.s,
name.len) == -1)
302 if (buffer_flush(buffer_1) == -1)
#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 * 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)
ssize_t bqrite(int fd, char *buf, unsigned int len)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)