comparison src/database.c @ 275:0880d6edaaa5 noffle

[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c, src/pseudo.c,src/server.c: Ensure format string specifiers and passed data types match. As part of this, change some uses of size_t as a general data type to an appropriate base C type. Database status changes from int to unsigned.
author bears
date Sun, 10 Nov 2002 15:34:59 +0000
parents 3477050e8d10
children 16dad3488e9d
comparison
equal deleted inserted replaced
274:755e03bc7dcf 275:0880d6edaaa5
1 /* 1 /*
2 database.c 2 database.c
3 3
4 $Id: database.c 403 2002-11-10 11:32:17Z bears $ 4 $Id: database.c 407 2002-11-10 15:34:59Z 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).
160 { 160 {
161 Log_err( "Entry in database '%s' is corrupt (overview)", msgId ); 161 Log_err( "Entry in database '%s' is corrupt (overview)", msgId );
162 return FALSE; 162 return FALSE;
163 } 163 }
164 p = Utl_getHeaderLn( t, p ); 164 p = Utl_getHeaderLn( t, p );
165 if ( ! p || sscanf( t, "%u", &db.bytes ) != 1 ) 165 if ( ! p || sscanf( t, "%lu", &db.bytes ) != 1 )
166 { 166 {
167 Log_err( "Entry in database '%s' is corrupt (bytes)", msgId ); 167 Log_err( "Entry in database '%s' is corrupt (bytes)", msgId );
168 return FALSE; 168 return FALSE;
169 } 169 }
170 p = Utl_getHeaderLn( t, p ); 170 p = Utl_getHeaderLn( t, p );
171 if ( ! p || sscanf( t, "%u", &db.lines ) != 1 ) 171 if ( ! p || sscanf( t, "%lu", &db.lines ) != 1 )
172 { 172 {
173 Log_err( "Entry in database '%s' is corrupt (lines)", msgId ); 173 Log_err( "Entry in database '%s' is corrupt (lines)", msgId );
174 return FALSE; 174 return FALSE;
175 } 175 }
176 DynStr_clear( db.txt ); 176 DynStr_clear( db.txt );
195 DynStr_appLn( s, db.subj ); 195 DynStr_appLn( s, db.subj );
196 DynStr_appLn( s, db.from ); 196 DynStr_appLn( s, db.from );
197 DynStr_appLn( s, db.date ); 197 DynStr_appLn( s, db.date );
198 DynStr_appLn( s, db.ref ); 198 DynStr_appLn( s, db.ref );
199 DynStr_appLn( s, db.xref ); 199 DynStr_appLn( s, db.xref );
200 snprintf( t, MAXCHAR, "%u", db.bytes ); 200 snprintf( t, MAXCHAR, "%lu", db.bytes );
201 DynStr_appLn( s, t ); 201 DynStr_appLn( s, t );
202 snprintf( t, MAXCHAR, "%u", db.lines ); 202 snprintf( t, MAXCHAR, "%lu", db.lines );
203 DynStr_appLn( s, t ); 203 DynStr_appLn( s, t );
204 DynStr_appDynStr( s, db.txt ); 204 DynStr_appDynStr( s, db.txt );
205 205
206 key.dptr = (void *)db.msgId; 206 key.dptr = (void *)db.msgId;
207 key.dsize = strlen( db.msgId ) + 1; 207 key.dsize = strlen( db.msgId ) + 1;
444 appendLongHeader( s, "Subject:", db.subj ); 444 appendLongHeader( s, "Subject:", db.subj );
445 appendLongHeader( s, "From:", db.from ); 445 appendLongHeader( s, "From:", db.from );
446 appendLongHeader( s, "Date:", db.date ); 446 appendLongHeader( s, "Date:", db.date );
447 appendLongHeader( s, "References:", db.ref ); 447 appendLongHeader( s, "References:", db.ref );
448 DynStr_app( s, "Bytes: " ); 448 DynStr_app( s, "Bytes: " );
449 snprintf( t, MAXCHAR, "%u", db.bytes ); 449 snprintf( t, MAXCHAR, "%lu", db.bytes );
450 DynStr_appLn( s, t ); 450 DynStr_appLn( s, t );
451 DynStr_app( s, "Lines: " ); 451 DynStr_app( s, "Lines: " );
452 snprintf( t, MAXCHAR, "%u", db.lines ); 452 snprintf( t, MAXCHAR, "%lu", db.lines );
453 DynStr_appLn( s, t ); 453 DynStr_appLn( s, t );
454 appendLongHeader( s, db.xrefHost, db.xref ); 454 appendLongHeader( s, db.xrefHost, db.xref );
455 p = strstr( DynStr_str( db.txt ), "\n\n" ); 455 p = strstr( DynStr_str( db.txt ), "\n\n" );
456 if ( ! p ) 456 if ( ! p )
457 DynStr_appDynStr( s, db.txt ); 457 DynStr_appDynStr( s, db.txt );