Mercurial > noffle
changeset 67:2e47992d7f5c noffle
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
author | enz |
---|---|
date | Sat, 13 May 2000 09:27:26 +0100 |
parents | 40a7493238e8 |
children | f76e8586fab6 |
files | src/client.c |
diffstat | 1 files changed, 34 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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