Mercurial > noffle
comparison src/database.c @ 185:fed1334d766b noffle
[svn] * src/client.c: Change variable only used on constant to 'const'.
* src/filter.c: Add a couple of 'return's after ASSERT() to remove
compiler warnings about functions needing returns.
* NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES,
docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c,
src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c,
src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c,
src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c:
Debug logging is always compiled and selected via noffle.conf. All debug
logs are classified as all, none, config, control, expire, fetch,
filter, newsbase, noffle, post, protocol, requests and server.
author | bears |
---|---|
date | Sun, 05 Aug 2001 09:24:22 +0100 |
parents | ad4490c377a4 |
children | 24d4cd032da5 |
comparison
equal
deleted
inserted
replaced
184:9854ea5f295f | 185:fed1334d766b |
---|---|
1 /* | 1 /* |
2 database.c | 2 database.c |
3 | 3 |
4 $Id: database.c 263 2001-02-28 19:01:33Z enz $ | 4 $Id: database.c 300 2001-08-05 08:24:22Z 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). |
78 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) | 78 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) |
79 { | 79 { |
80 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); | 80 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); |
81 return FALSE; | 81 return FALSE; |
82 } | 82 } |
83 Log_dbg( "%s opened for r/w", name ); | 83 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); |
84 | 84 |
85 if ( db.txt == NULL ) | 85 if ( db.txt == NULL ) |
86 db.txt = new_DynStr( 5000 ); | 86 db.txt = new_DynStr( 5000 ); |
87 | 87 |
88 gethostname( host, MAXCHAR ); | 88 gethostname( host, MAXCHAR ); |
93 | 93 |
94 void | 94 void |
95 Db_close( void ) | 95 Db_close( void ) |
96 { | 96 { |
97 ASSERT( db.dbf ); | 97 ASSERT( db.dbf ); |
98 Log_dbg( "Closing database" ); | 98 Log_dbg( LOG_DBG_NEWSBASE, "Closing database" ); |
99 gdbm_close( db.dbf ); | 99 gdbm_close( db.dbf ); |
100 db.dbf = NULL; | 100 db.dbf = NULL; |
101 del_DynStr( db.txt ); | 101 del_DynStr( db.txt ); |
102 db.txt = NULL; | 102 db.txt = NULL; |
103 Utl_cpyStr( db.msgId, "" ); | 103 Utl_cpyStr( db.msgId, "" ); |
126 } | 126 } |
127 val = gdbm_fetch( db.dbf, key ); | 127 val = gdbm_fetch( db.dbf, key ); |
128 dptr = val.dptr; | 128 dptr = val.dptr; |
129 if ( dptr == NULL ) | 129 if ( dptr == NULL ) |
130 { | 130 { |
131 Log_dbg( "database.c loadArt: gdbm_fetch found no entry" ); | 131 Log_dbg( LOG_DBG_NEWSBASE, |
132 "database.c loadArt: gdbm_fetch found no entry" ); | |
132 return FALSE; | 133 return FALSE; |
133 } | 134 } |
134 | 135 |
135 Utl_cpyStr( db.msgId, msgId ); | 136 Utl_cpyStr( db.msgId, msgId ); |
136 p = Utl_getLn( t, (char *)dptr ); | 137 p = Utl_getLn( t, (char *)dptr ); |
219 ASSERT( db.dbf ); | 220 ASSERT( db.dbf ); |
220 ASSERT( ov ); | 221 ASSERT( ov ); |
221 ASSERT( grp ); | 222 ASSERT( grp ); |
222 | 223 |
223 msgId = Ov_msgId( ov ); | 224 msgId = Ov_msgId( ov ); |
224 Log_dbg( "Preparing entry %s", msgId ); | 225 Log_dbg( LOG_DBG_NEWSBASE, "Preparing entry %s", msgId ); |
225 if ( Db_contains( msgId ) ) | 226 if ( Db_contains( msgId ) ) |
226 Log_err( "Preparing article twice: %s", msgId ); | 227 Log_err( "Preparing article twice: %s", msgId ); |
227 | 228 |
228 db.status = DB_NOT_DOWNLOADED; | 229 db.status = DB_NOT_DOWNLOADED; |
229 db.lastAccess = time( NULL ); | 230 db.lastAccess = time( NULL ); |
247 { | 248 { |
248 Str line, lineEx, field, value; | 249 Str line, lineEx, field, value; |
249 | 250 |
250 ASSERT( db.dbf ); | 251 ASSERT( db.dbf ); |
251 | 252 |
252 Log_dbg( "Store article %s", msgId ); | 253 Log_dbg( LOG_DBG_NEWSBASE, "Store article %s", msgId ); |
253 if ( ! loadArt( msgId ) ) | 254 if ( ! loadArt( msgId ) ) |
254 { | 255 { |
255 Log_err( "Cannot find info about '%s' in database", msgId ); | 256 Log_err( "Cannot find info about '%s' in database", msgId ); |
256 return FALSE; | 257 return FALSE; |
257 } | 258 } |
661 | 662 |
662 Utl_cpyStr( last, ctime( &lastAccess ) ); | 663 Utl_cpyStr( last, ctime( &lastAccess ) ); |
663 last[ strlen( last ) - 1 ] = '\0'; | 664 last[ strlen( last ) - 1 ] = '\0'; |
664 Utl_cpyStr( now, ctime( &nowTime ) ); | 665 Utl_cpyStr( now, ctime( &nowTime ) ); |
665 last[ strlen( now ) - 1 ] = '\0'; | 666 last[ strlen( now ) - 1 ] = '\0'; |
666 Log_dbg( "Expiring %s: last access %s, time now %s", | 667 Log_dbg( LOG_DBG_EXPIRE, |
668 "Expiring %s: last access %s, time now %s", | |
667 msgId, last, now ); | 669 msgId, last, now ); |
668 #endif | 670 #endif |
669 ++cntDel; | 671 ++cntDel; |
670 } | 672 } |
671 else if ( ( texpires != (time_t) -1 ) | 673 else if ( ( texpires != (time_t) -1 ) |
672 && nowTime > texpires ) | 674 && nowTime > texpires ) |
673 { | 675 { |
674 Log_dbg( "Expiring %s: Expires header activated", msgId ); | 676 Log_dbg( LOG_DBG_EXPIRE, |
677 "Expiring %s: Expires header activated", msgId ); | |
675 ++cntDel; | 678 ++cntDel; |
676 } | 679 } |
677 else | 680 else |
678 { | 681 { |
679 ++cntLeft; | 682 ++cntLeft; |