# HG changeset patch # User enz # Date 958206446 -3600 # Node ID 2e47992d7f5c2c8663c7a9eae190ac575a5d7d98 # Parent 40a7493238e89c970efa0b582d576a6c73f1d730 [svn] Rewrote needsMark(): use itemlist.h, more debugging output. diff -r 40a7493238e8 -r 2e47992d7f5c src/client.c --- a/src/client.c Sat May 13 03:26:49 2000 +0100 +++ b/src/client.c Sat May 13 09:27:26 2000 +0100 @@ -1,7 +1,7 @@ /* client.c - $Id: client.c 67 2000-05-12 17:19:38Z enz $ + $Id: client.c 73 2000-05-13 08:27:26Z enz $ */ #if HAVE_CONFIG_H @@ -23,6 +23,7 @@ #include "content.h" #include "dynamicstring.h" #include "group.h" +#include "itemlist.h" #include "log.h" #include "over.h" #include "protocol.h" @@ -627,42 +628,50 @@ static Bool needsMark( const char *ref ) { - Bool done = FALSE, interesting; - char *p; - Str msgId; - int status, len; + Bool interesting, result; + const char *msgId; + int status; time_t lastAccess, nowTime; - double threadFollowTime, limit, age; + double threadFollowTime, secPerDay, maxTime, timeSinceLastAccess; + ItemList *itl; + Log_dbg( "Checking references '%s' for thread mode", ref ); + result = FALSE; + itl = new_Itl( ref, " \t" ); nowTime = time( NULL ); threadFollowTime = (double)Cfg_threadFollowTime(); - limit = threadFollowTime * 24. * 3600.; - while ( ! done ) + secPerDay = 24.0 * 3600.0; + maxTime = threadFollowTime * secPerDay; + Log_dbg( "Max time = %.0f", maxTime ); + for ( msgId = Itl_first( itl ); msgId != NULL; msgId = Itl_next( itl ) ) { - p = msgId; - while ( *ref != '<' ) - if ( *(ref++) == '\0' ) - return FALSE; - len = 0; - while ( *ref != '>' ) - { - if ( *ref == '\0' || ++len >= MAXCHAR - 1 ) - return FALSE; - *(p++) = *(ref++); - } - *(p++) = '>'; - *p = '\0'; + /* + References does not have to contain only Message IDs, + but often it does, so we look up every item in the database. + */ if ( Db_contains( msgId ) ) { status = Db_status( msgId ); lastAccess = Db_lastAccess( msgId ); interesting = ( status & DB_INTERESTING ); - age = difftime( nowTime, lastAccess ); - if ( interesting && age <= limit ) - return TRUE; + timeSinceLastAccess = difftime( nowTime, lastAccess ); + Log_dbg( "Msg ID '%s': since last access = %.0f, interesting = %s", + msgId, timeSinceLastAccess, ( interesting ? "y" : "n" ) ); + if ( interesting && timeSinceLastAccess <= maxTime ) + { + result = TRUE; + break; + } + } + else + { + Log_dbg( "MsgID '%s': not in database." ); } } - return FALSE; + del_Itl( itl ); + Log_dbg( "Article %s marking for download.", + ( result ? "needs" : "doesn't need" ) ); + return result; } static void