158 unsigned long msg_from,
unsigned long msg_to,
159 unsigned long msg_latest,
int locked)
161 unsigned long idxlatest;
163 unsigned long endmsg;
164 unsigned long tmpmsg;
167 unsigned long ulmrange;
171 unsigned int authlen;
172 unsigned int pos,posa;
173 unsigned long submax;
179 int flagmissingindex;
185 unsigned int datepos,datemax;
186 unsigned int datetablesize,datetableunit;
187 unsigned int lastdate = 0;
188 unsigned int thisdate;
193 if (msg_to > msg_latest)
195 if (msg_to < msg_from)
196 logmsg(
WHO,100,FATAL,
"Program error: bad range in idx_mkthreads");
197 ulmrange = msg_to - msg_from + 1;
217 datetablesize = datetableunit;
219 if (!(*pdatetable = (
dateentry *) alloc(datetablesize)))
226 idxlatest = msg_latest / 100;
227 idxto = msg_to / 100;
229 psubnext = *psubtable;
232 psubt->
sub = (
char *)
" ";
236 pauthnext = *pauthtable;
243 for (idx = msg_from / 100; idx <= idxto; idx++) {
244 if (!stralloc_copys(&line,
"archive/"))
die_nomem();
245 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,idx)))
die_nomem();
246 if (!stralloc_cats(&line,
"/index"))
die_nomem();
248 if (!locked && idx == idxlatest)
250 flagmissingindex = 0;
251 fd = open_read(line.s);
253 if (errno == ENOENT) {
254 flagmissingindex = 1;
266 for (; msg <= endmsg; msg++) {
267 if (!flagmissingindex && (msg > tmpmsg)) {
269 if (getln(&
bi,&line,&
match,
'\n') == -1)
272 flagmissingindex = 1;
274 pos = scan_ulong(line.s,&tmpmsg);
275 if (line.s[pos++] ==
':') {
276 if (getln(&
bi,&authline,&
match,
'\n') == -1)
279 flagmissingindex = 1;
291 sublen = line.len - pos;
297 sublen = dummyind.len;
306 newsub(psubnext,
subject,sublen,msg);
312 }
else if (res > 0) {
314 psubt = psubt->
lower;
316 newsub(psubnext,
subject,sublen,msg);
317 psubt->
lower = psubnext;
331 pmsgt = *pmsgtable + msg - msg_from;
332 pmsgt->
subnum = (
unsigned int) (psubt - *psubtable + 1);
333 pmsgt->
date = lastdate;
336 while (authline.s[pos] && authline.s[pos] !=
' ')
338 if (authline.s[++pos]) {
340 if (thisdate) pmsgt->
date = thisdate;
341 if (pmsgt->
date > lastdate) {
342 lastdate = pmsgt->
date;
343 if (datepos >= datemax) {
345 if (!alloc_re((
void**)pdatetable,datetablesize,datetablesize+datetableunit))
348 (*pdatetable)[datepos].msg = msg;
349 (*pdatetable)[datepos].date = lastdate;
352 posa = byte_chr(authline.s,authline.len,
';');
353 if (authline.len > posa +
HASHLEN + 1 && authline.s[pos + 1] !=
' ') {
355 auth = authline.s + posa + 1;
356 authlen = authline.len - posa - 1;
359 authlen = dummyind.len;
371 newauth(pauthnext,auth,authlen,msg);
372 pautht->
higher = pauthnext;
377 }
else if (res > 0) {
379 pautht = pautht->
lower;
381 newauth(pauthnext,auth,authlen,msg);
382 pautht->
lower = pauthnext;
391 pmsgt->
authnum = (
unsigned int) (pautht - *pauthtable + 1);
392 pautht = *pauthtable;
400 if (!locked && idx == idxlatest)
403 psubnext->
sub = (
char *) 0;
404 pauthnext->
auth = (
char *) 0;
405 (*pdatetable)[datepos].msg = msg_to + 1;
406 (*pdatetable)[datepos].date = lastdate + 1;
425 unsigned long msg_from,
unsigned long msg_to,
unsigned long msg_master,
unsigned long msg_latest,
int locked)
429 unsigned long idxlatest;
433 unsigned long ulmrange;
438 unsigned int authlen;
447 if ((ulmrange = msg_to - msg_from +1) <= 0)
448 logmsg(
WHO,100,FATAL,
"Program error: bad range in idx_mkthreads");
465 pauthnext = *pauthtable;
468 pautht->
auth = (
char*)
" ";
472 idxlatest = msg_latest / 100;
473 idxto = msg_to / 100;
474 idx = msg_master / 100;
478 if (!stralloc_copys(&line,
"archive/"))
die_nomem();
479 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,idx)))
die_nomem();
480 if (!stralloc_cats(&line,
"/index"))
die_nomem();
483 if (!locked && idx == idxlatest)
485 fd = open_read(line.s);
496 if (getln(&
bi,&line,&
match,
'\n') == -1)
500 pos=scan_ulong(line.s,&msg);
501 if (line.s[pos++] ==
':') {
506 if (msg == msg_master) {
507 newsub(psubt,line.s + pos,line.len - pos,msg);
512 if (getln(&
bi,&line,&
match,
'\n') == -1)
520 if (!locked && idx == idxlatest)
525 for (idx = msg_from / 100; idx <= idxto; idx++) {
526 if (!stralloc_copys(&line,
"archive/"))
die_nomem();
527 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,idx)))
die_nomem();
528 if (!stralloc_cats(&line,
"/index"))
die_nomem();
530 if (!locked && idx == idxlatest)
533 fd = open_read(line.s);
542 if (getln(&
bi,&line,&
match,
'\n') == -1)
546 pos=scan_ulong(line.s,&msg);
547 if (line.s[pos++] ==
':') {
550 if (getln(&
bi,&authline,&
match,
'\n') == -1)
557 if (msg < msg_from)
continue;
558 if (msg > msg_to)
break;
560 if (!str_diffn(psubt->
sub,line.s + pos,
HASHLEN)) {
561 pmsgt = *pmsgtable + msg - msg_from;
571 pos = byte_chr(authline.s,authline.len,
';');
572 if (authline.len > pos +
HASHLEN + 1 && authline.s[pos+1] !=
' ') {
574 auth = authline.s + pos + 1;
575 authlen = authline.len - pos - 1;
578 authlen = dummyind.len;
587 newauth(pauthnext,auth,authlen,msg);
588 pautht->
higher = pauthnext;
593 }
else if (res > 0) {
595 pautht = pautht->
lower;
597 newauth(pauthnext,auth,authlen,msg);
598 pautht->
lower = pauthnext;
608 pmsgt->
authnum = (
unsigned int) (pautht - *pauthtable + 1);
609 pautht = *pauthtable;
616 if (!locked && idx == idxlatest)
unlock();
619 psubt->
sub = (
char *) 0;
620 pauthnext->
auth = (
char *) 0;
void idx_mkthread(msgentry **pmsgtable, subentry **psubtable, authentry **pauthtable, unsigned long msg_from, unsigned long msg_to, unsigned long msg_master, unsigned long msg_latest, int locked)
void idx_mklist(msgentry **pmsgtable, subentry **psubtable, authentry **pauthtable, unsigned long msg_from, unsigned long msg_to)
void idx_mkthreads(msgentry **pmsgtable, subentry **psubtable, authentry **pauthtable, dateentry **pdatetable, unsigned long msg_from, unsigned long msg_to, unsigned long msg_latest, int locked)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)