Mercurial > noffle
comparison src/database.c @ 94:be450ac830b2 noffle
[svn] Observe Expires: header
author | bears |
---|---|
date | Fri, 19 May 2000 16:15:45 +0100 |
parents | adf0af5152f7 |
children | 1a54e1702ea2 |
comparison
equal
deleted
inserted
replaced
93:eb522db0d032 | 94:be450ac830b2 |
---|---|
1 /* | 1 /* |
2 database.c | 2 database.c |
3 | 3 |
4 $Id: database.c 67 2000-05-12 17:19:38Z enz $ | 4 $Id: database.c 113 2000-05-19 15:15:45Z bears $ |
5 | 5 |
6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was | 6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was |
7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs | 7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs |
8 (e.g. it is not recommended to delete or overwrite entries with | 8 (e.g. it is not recommended to delete or overwrite entries with |
9 overflow pages). | 9 overflow pages). |
615 time_t nowTime, lastAccess; | 615 time_t nowTime, lastAccess; |
616 const char *msgId; | 616 const char *msgId; |
617 Str name, tmpName; | 617 Str name, tmpName; |
618 GDBM_FILE tmpDbf; | 618 GDBM_FILE tmpDbf; |
619 datum key, val; | 619 datum key, val; |
620 Str expires; | |
621 time_t texpires; | |
620 | 622 |
621 if ( ! Db_open() ) | 623 if ( ! Db_open() ) |
622 return FALSE; | 624 return FALSE; |
623 snprintf( name, MAXCHAR, "%s/data/articles.gdbm", Cfg_spoolDir() ); | 625 snprintf( name, MAXCHAR, "%s/data/articles.gdbm", Cfg_spoolDir() ); |
624 snprintf( tmpName, MAXCHAR, "%s/data/articles.gdbm.new", Cfg_spoolDir() ); | 626 snprintf( tmpName, MAXCHAR, "%s/data/articles.gdbm.new", Cfg_spoolDir() ); |
636 if ( Db_first( &msgId ) ) | 638 if ( Db_first( &msgId ) ) |
637 do | 639 do |
638 { | 640 { |
639 expDays = calcExpireDays( msgId ); | 641 expDays = calcExpireDays( msgId ); |
640 lastAccess = Db_lastAccess( msgId ); | 642 lastAccess = Db_lastAccess( msgId ); |
643 if ( Prt_searchHeader( Db_header( msgId ), "Expires", expires ) ) | |
644 texpires = Utl_parseNewsDate( expires ); | |
645 else | |
646 texpires = (time_t) -1; | |
647 | |
641 if ( expDays == -1 ) | 648 if ( expDays == -1 ) |
642 Log_err( "Internal error: Failed expiry calculation on %s", | 649 Log_err( "Internal error: Failed expiry calculation on %s", |
643 msgId ); | 650 msgId ); |
644 else if ( lastAccess == -1 ) | 651 else if ( lastAccess == -1 ) |
645 Log_err( "Internal error: Getting lastAccess of %s failed", | 652 Log_err( "Internal error: Getting lastAccess of %s failed", |
658 Log_dbg( "Expiring %s: last access %s, time now %s", | 665 Log_dbg( "Expiring %s: last access %s, time now %s", |
659 msgId, last, now ); | 666 msgId, last, now ); |
660 #endif | 667 #endif |
661 ++cntDel; | 668 ++cntDel; |
662 } | 669 } |
670 else if ( ( texpires != (time_t) -1 ) | |
671 && nowTime > texpires ) | |
672 { | |
673 Log_dbg( "Expiring %s: Expires header activated", msgId ); | |
674 ++cntDel; | |
675 } | |
663 else | 676 else |
664 { | 677 { |
665 ++cntLeft; | 678 ++cntLeft; |
666 key.dptr = (void *)msgId; | 679 key.dptr = (void *)msgId; |
667 key.dsize = strlen( msgId ) + 1; | 680 key.dsize = strlen( msgId ) + 1; |