Mercurial > noffle
comparison src/database.c @ 109:2bedacfe1ba7 noffle
[svn] Fix header line reading buf
author | bears |
---|---|
date | Mon, 19 Jun 2000 22:56:12 +0100 |
parents | 1a54e1702ea2 |
children | 3c71e28c8eef |
comparison
equal
deleted
inserted
replaced
108:8eb2975c8c1a | 109:2bedacfe1ba7 |
---|---|
1 /* | 1 /* |
2 database.c | 2 database.c |
3 | 3 |
4 $Id: database.c 144 2000-06-13 06:36:26Z bears $ | 4 $Id: database.c 149 2000-06-19 21:56:12Z 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). |
244 | 244 |
245 Bool | 245 Bool |
246 Db_storeArt( const char *msgId, const char *artTxt ) | 246 Db_storeArt( const char *msgId, const char *artTxt ) |
247 { | 247 { |
248 Str line, lineEx, field, value; | 248 Str line, lineEx, field, value; |
249 const char *startPos; | |
250 | 249 |
251 ASSERT( db.dbf ); | 250 ASSERT( db.dbf ); |
252 | 251 |
253 Log_dbg( "Store article %s", msgId ); | 252 Log_dbg( "Store article %s", msgId ); |
254 if ( ! loadArt( msgId ) ) | 253 if ( ! loadArt( msgId ) ) |
266 db.lastAccess = time( NULL ); | 265 db.lastAccess = time( NULL ); |
267 | 266 |
268 DynStr_clear( db.txt ); | 267 DynStr_clear( db.txt ); |
269 | 268 |
270 /* Read header */ | 269 /* Read header */ |
271 startPos = artTxt; | 270 while ( ( artTxt = Utl_getHeaderLn( lineEx, artTxt ) ) != NULL ) |
272 while ( TRUE ) | 271 { |
273 { | |
274 artTxt = Utl_getHeaderLn( lineEx, artTxt ); | |
275 if ( lineEx[ 0 ] == '\0' ) | 272 if ( lineEx[ 0 ] == '\0' ) |
276 { | 273 { |
277 DynStr_appLn( db.txt, lineEx ); | 274 DynStr_appLn( db.txt, lineEx ); |
278 break; | 275 break; |
279 } | 276 } |
297 && strcmp( field, "x-noffle-lastaccess" ) != 0 ) | 294 && strcmp( field, "x-noffle-lastaccess" ) != 0 ) |
298 DynStr_appLn( db.txt, lineEx ); | 295 DynStr_appLn( db.txt, lineEx ); |
299 } | 296 } |
300 } | 297 } |
301 | 298 |
299 if ( artTxt == NULL ) | |
300 { | |
301 Log_err( "Article %s malformed: missing body", msgId ); | |
302 return FALSE; | |
303 } | |
304 | |
302 /* Read body */ | 305 /* Read body */ |
303 while ( ( artTxt = Utl_getLn( line, artTxt ) ) ) | 306 while ( ( artTxt = Utl_getLn( line, artTxt ) ) != NULL ) |
304 if ( ! ( db.status & DB_NOT_DOWNLOADED ) ) | 307 if ( ! ( db.status & DB_NOT_DOWNLOADED ) ) |
305 DynStr_appLn( db.txt, line ); | 308 DynStr_appLn( db.txt, line ); |
306 | 309 |
307 return saveArt(); | 310 return saveArt(); |
308 } | 311 } |