29#define WHO "ezmlm-idx"
37int rename(
const char *,
const char *);
39char strnum[FMT_ULONG];
59static char inbuf[1024];
75static void die_usage(
void) {
logmsg(
WHO,100,USAGE,
"ezmlm-idx [-dDF] [-f msg] dir"); }
103 if (getln(&
bi,&line,&
match,
'\n') == -1)
108 if (*line.s ==
' ' || *line.s ==
'\t') {
116 if (!foundsubject && case_startb(line.s,line.len,
"Subject:")) {
120 }
else if (!foundfrom && case_startb(line.s,line.len,
"From:")) {
124 }
else if (!
flagdate && !foundreceived &&
125 case_startb(line.s,line.len,
"Received:")) {
126 pos = byte_chr(line.s,line.len,
';');
128 if (!stralloc_copyb(&
received,line.s+pos+2,line.len - pos - 3))
131 }
else if (
flagdate && !foundreceived &&
132 case_startb(line.s,line.len,
"Date:")) {
133 if (line.len < 22)
continue;
134 pos = 6 + byte_chr(line.s+6,line.len-6,
',');
138 while (line.s[pos] ==
' ' || line.s[pos] ==
'\t') ++pos;
140 while (++pos1 < line.len && line.s[pos1] !=
' ');
142 if (!stralloc_copyb(&
received,line.s+pos,pos1 - pos))
144 if (pos1 + 2 < line.len) {
145 if (line.s[pos1 + 2] ==
' ') {
146 if (line.s[pos1] >=
'7') {
152 if (pos < line.len) {
153 pos += byte_chr(line.s+pos,line.len-pos,
' ');
154 if (pos < line.len) {
156 while (line.s[pos] !=
' ' && line.s[pos] !=
'\n') ++pos;
159 if (!stralloc_catb(&
received,line.s+pos1,pos - pos1))
187 unsigned long msgnum = 0L;
188 unsigned long msgmax;
191 while ((
opt = getoptb(argc,argv,
"dDf:FvV")) != opteof)
195 case 'f':
if (optarg) scan_ulong(optarg,&
msgnum);
break;
199 default: die_usage();
202 if (!
dir) die_usage();
204 if (chdir(
dir) == -1)
218 switch (openreadclose(
"num",&
num,32)) {
223 scan_ulong(
num.s,&msgmax);
224 if (
msgnum > msgmax) _exit(0);
228 while (++
msgnum <= msgmax) {
240 if (mkdir(
fnadir.s,0755) == -1)
255 if (!stralloc_catb(&
fnaf,strnum,
262 }
else if (fstat(
fd,&st) == -1 || (!(st.st_mode & 0100)))
271 if (!stralloc_copyb(&line,strnum,fmt_ulong(strnum,
msgnum)))
die_nomem();
272 if (!stralloc_cats(&line,
": "))
die_nomem();
275 if (!stralloc_cats(&line,
" "))
die_nomem();
277 if (!stralloc_cats(&line,
"Re: "))
die_nomem();
279 if (!stralloc_cats(&line,
"\n\t"))
die_nomem();
281 if (!stralloc_cats(&line,
";"))
die_nomem();
292 if (!stralloc_cats(&line,
" "))
die_nomem();
294 if (!stralloc_cats(&line,
"\n"))
die_nomem();
295 if (buffer_put(&
bx,line.s,line.len) == -1)
299 if (!((
msgnum + 1) % 100) ||
301 if (buffer_flush(&
bx) == -1)
313 fd = open_append(
"indexed");
void concat_hdr(char *indata, unsigned int n, stralloc *outdata)
unsigned int author_name(char **sout, char *s, unsigned int l)
int getconf_line(stralloc *sa, const char *fn, int flagrequired, const char *dir)
int rename(const char *, const char *)
int idx_get_trimsubject(void)
reads an open message from 'fd', extracts the subject (if any), and returns the subject in 'sub',...
void mkauthhash(const char *s, unsigned int len, char *h)
void makehash(const char *indata, unsigned int inlen, char *hash)
const char auto_version[]
int lockfile(const char *)
int unfold_hdr(char *, unsigned long, stralloc *, const char *, stralloc *, int)
Error messages. If you translate these, I would urge you to keep the English version as well....
void decode_hdr(const char *indata, unsigned int n, stralloc *outdata)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)