summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2004-01-30 15:01:54 +0000
committererdgeist <>2004-01-30 15:01:54 +0000
commit00c4316e69b9a61a7fe8eb7d06247d491055d10e (patch)
treeb7af6dc1df5b67508cb631dd84b7c5704048677c
parentb64fc98d48fd5c9831ee2e0fb12d92a548c4bd40 (diff)
mktime is too slow, store 64 bit time_t in log
-rwxr-xr-xvchat-ui.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/vchat-ui.c b/vchat-ui.c
index 03c7dd6..6afbe19 100755
--- a/vchat-ui.c
+++ b/vchat-ui.c
@@ -294,11 +294,8 @@ int writechan (unsigned char *str) {
294 time_t now = time(NULL); 294 time_t now = time(NULL);
295 tmp = sb_add(sb_pub,str,now); 295 tmp = sb_add(sb_pub,str,now);
296 296
297 if( getintoption( CF_KEEPLOG ) && vchat_logfile ) { 297 if( getintoption( CF_KEEPLOG ) && vchat_logfile )
298 char date[16]; 298 fprintf( vchat_logfile, "%016llX0%s\n", (signed long long)now, str);
299 strftime( date, sizeof(date), "%Y%m%d%H%M%S", localtime(&now));
300 fprintf( vchat_logfile, "%s0%s\n", date, str);
301 }
302 299
303 if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) { 300 if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) {
304 i = writescr(channel, tmp); 301 i = writescr(channel, tmp);
@@ -315,11 +312,8 @@ int writecf (formtstr id,unsigned char *str) {
315 snprintf(tmpstr,TMPSTRSIZE,getformatstr(id),str); 312 snprintf(tmpstr,TMPSTRSIZE,getformatstr(id),str);
316 tmp = sb_add(sb_pub,tmpstr,now); 313 tmp = sb_add(sb_pub,tmpstr,now);
317 314
318 if( getintoption( CF_KEEPLOG ) && vchat_logfile ) { 315 if( getintoption( CF_KEEPLOG ) && vchat_logfile )
319 char date[16]; 316 fprintf( vchat_logfile, "%016llX0%s\n", (unsigned long long)now, tmpstr);
320 strftime( date, sizeof(date), "%Y%m%d%H%M%S", localtime(&now));
321 fprintf( vchat_logfile, "%s0%s\n", date, tmpstr);
322 }
323 317
324 if ( (sb_pub->scroll == sb_pub->count) && 318 if ( (sb_pub->scroll == sb_pub->count) &&
325 ((filtertype == 0) || ( testfilter(tmp)))) { 319 ((filtertype == 0) || ( testfilter(tmp)))) {
@@ -339,9 +333,7 @@ int writepriv (unsigned char *str) {
339 tmp = sb_add(sb_priv,str,now); 333 tmp = sb_add(sb_priv,str,now);
340 334
341 if( getintoption( CF_KEEPLOG ) && vchat_logfile ) { 335 if( getintoption( CF_KEEPLOG ) && vchat_logfile ) {
342 char date[16]; 336 fprintf( vchat_logfile, "%016llX1%s\n", (unsigned long long)now, str);
343 strftime( date, sizeof(date), "%Y%m%d%H%M%S", localtime(&now));
344 fprintf( vchat_logfile, "%s1%s\n", date, str);
345 } 337 }
346 338
347 if ( !privwinhidden && (sb_priv->scroll == sb_priv->count) && 339 if ( !privwinhidden && (sb_priv->scroll == sb_priv->count) &&
@@ -1272,24 +1264,22 @@ initui (void)
1272 logfile = tilde_expand( logfile ); 1264 logfile = tilde_expand( logfile );
1273 vchat_logfile = fopen( logfile, "r+" ); 1265 vchat_logfile = fopen( logfile, "r+" );
1274 if( vchat_logfile ) { 1266 if( vchat_logfile ) {
1275 char date[16]; 1267 time_t now;
1276 time_t now; struct tm now_tm; 1268 long long now_;
1277 int dst, lenstr; 1269 char dst;
1270 int lenstr;
1278 while( !feof( vchat_logfile)) { 1271 while( !feof( vchat_logfile)) {
1279 if( (fread( date, 14, 1, vchat_logfile) == 1) && 1272 if( (fscanf( vchat_logfile, "%016llX%c", (unsigned long long*)&now_, &dst)) &&
1280 (strptime( date, "%Y%m%d%H%M%S", &now_tm)) && 1273 ((dst == '0') || (dst == '1')))
1281 (((dst = fgetc( vchat_logfile )) == '0') || (dst == '1')))
1282 { 1274 {
1275 now = (time_t)now_;
1283 if(fgets(tmpstr, TMPSTRSIZE, vchat_logfile)) { 1276 if(fgets(tmpstr, TMPSTRSIZE, vchat_logfile)) {
1284 lenstr = strlen( tmpstr ); 1277 lenstr = strlen( tmpstr );
1285 tmpstr[lenstr-1] = '\0'; 1278 tmpstr[lenstr-1] = '\0';
1286 now = mktime( &now_tm );
1287 sb_add( dst == '0' ? sb_pub : sb_priv, tmpstr, now); 1279 sb_add( dst == '0' ? sb_pub : sb_priv, tmpstr, now);
1288 } 1280 }
1289 } else { 1281 } else
1290 fseek( vchat_logfile, 0, SEEK_END); 1282 while( !feof( vchat_logfile) && ( fgetc( vchat_logfile ) != '\n'));
1291 fgetc( vchat_logfile );
1292 }
1293 } 1283 }
1294 } 1284 }
1295 } 1285 }