Esempio n. 1
0
/* Generate the thread data we need for this group.  We must call
** thread_close() before calling this again.
*/
void
thread_open()
{
    if (!msgid_hash)
	msgid_hash = hashcreate(201, msgid_cmp); /*TODO: pick a better size */
    if (ThreadedGroup) {
	/* Parse input and use msgid_hash for quick article lookups. */
	/* If cached but not threaded articles exist, set up to thread them. */
	if (first_subject) {
	    first_cached = firstart;
	    last_cached = firstart - 1;
	    parsed_art = 0;
	}
    }

    if (sel_mode == SM_ARTICLE)
	set_selector(sel_mode, sel_artsort);
    else
	set_selector(sel_threadmode, sel_threadsort);

#ifdef USE_MT
    if (try_mt && !first_subject)
	if (!mt_data())
	    return;
#endif
#ifdef USE_OV
    if (try_ov && first_cached > last_cached)
	if (thread_always)
	    (void) ov_data(absfirst, lastart, FALSE);
	else if (firstart > lastart) {
	    /* If no unread articles, see if ov. exists as quick as possible */
	    (void) ov_data(absfirst, absfirst, FALSE);
	    first_cached = last_cached+1;
	} else
	    (void) ov_data(firstart, lastart, FALSE);
#endif
#ifdef USE_NNTP
    if (!ov_opened)
	setmissingbits();
#endif

    if (last_cached > lastart) {
	toread[ng] += (ART_UNREAD)(last_cached-lastart);
	/* ensure getngsize() knows the new maximum */
	ngmax[ng] = lastart = last_cached;
    }
    thread_grow();	/* thread any new articles not yet in the database */
    added_articles = 0;
    sel_page_sp = 0;
    sel_page_app = 0;
}
Esempio n. 2
0
void
build_cache()
{
    if (cached_ng == ng && cached_absfirst == absfirst
     && time((time_t*)NULL) < cached_time + 6*60*60L) {
	grow_cache(lastart);
	rc_to_bits();
	if (sel_mode == SM_ARTICLE)
	    set_selector(sel_mode, sel_artsort);
	else
	    set_selector(sel_threadmode, sel_threadsort);
	thread_grow();
	return;
    }

    close_cache();

    cached_ng = ng;
    cached_absfirst = absfirst;
    cached_time = time((time_t*)NULL);
    cached_cnt = lastart-absfirst+2 + 5;
    article_list = (ARTICLE*)
	safemalloc((MEM_SIZE)(cached_cnt * sizeof (ARTICLE)));
    bzero((char*)article_list, cached_cnt * sizeof (ARTICLE));
    subj_hash = hashcreate(201, subject_cmp);	/*TODO: pick a better size */

    rc_to_bits();			/* sets firstart */
    first_cached = thread_always? absfirst : firstart;
    last_cached = first_cached-1;
    cached_all_in_range = FALSE;
#ifdef PENDING
    subj_to_get = xref_to_get = firstart;
#endif
#ifndef USE_NNTP
    setmissingbits();
#endif

    /* Cache as much data in advance as possible, possibly threading
    ** articles as we go. */
    thread_open();
}