diff options
Diffstat (limited to 'daemon/logrotate.c')
-rw-r--r-- | daemon/logrotate.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/daemon/logrotate.c b/daemon/logrotate.c index d759f10..fdd20d5 100644 --- a/daemon/logrotate.c +++ b/daemon/logrotate.c @@ -133,16 +133,16 @@ static void do_rotate( const gchar* pathname, struct destination* destination ) TRACE_ENTER( "\n" ); /* construct destination pathname for backlogs */ - if( destination->olddir ) + if( destination->u.file.olddir ) { gchar *filename = g_path_get_basename( pathname ); - if( g_path_is_absolute( destination->olddir ) ) - dest_pathname = g_build_filename( destination->olddir, filename, NULL ); + if( g_path_is_absolute( destination->u.file.olddir ) ) + dest_pathname = g_build_filename( destination->u.file.olddir, filename, NULL ); else { gchar *prefix = g_path_get_dirname( __argv[0] ); - dest_pathname = g_build_filename( prefix, destination->olddir, filename, NULL ); + dest_pathname = g_build_filename( prefix, destination->u.file.olddir, filename, NULL ); g_free( prefix ); } g_free( filename ); @@ -151,12 +151,12 @@ static void do_rotate( const gchar* pathname, struct destination* destination ) dest_pathname = g_strdup( pathname ); /* remove earliest backlog */ - backlog = g_strdup_printf( "%s.%d", dest_pathname, destination->backlogs ); + backlog = g_strdup_printf( "%s.%d", dest_pathname, destination->u.file.backlogs ); DeleteFile( backlog ); g_free( backlog ); /* rotate backlogs */ - for( i = destination->backlogs; i > 1; i-- ) + for( i = destination->u.file.backlogs; i > 1; i-- ) { gchar *old_backlog = g_strdup_printf( "%s.%d", dest_pathname, i - 1 ); gchar *new_backlog = g_strdup_printf( "%s.%d", dest_pathname, i ); @@ -178,9 +178,10 @@ static void do_rotate( const gchar* pathname, struct destination* destination ) ERR( "Can't move %s to %s; error %lu\n", pathname, backlog, GetLastError() ); /* compress new backlog */ - if( destination->compresscmd ) + if( destination->u.file.compresscmd ) { - if( compress_backlog( destination->compresscmd, destination->compressoptions, backlog ) ) + if( compress_backlog( destination->u.file.compresscmd, + destination->u.file.compressoptions, backlog ) ) /* remove original uncompressed file */ DeleteFile( backlog ); } @@ -203,8 +204,8 @@ void rotate_logfile( const gchar* pathname, struct destination* destination ) TRACE_ENTER( "pathname=%s\n", pathname ); - if( 0 == destination->backlogs - || (RP_UNDEFINED == destination->rotate && 0 == destination->size) ) + if( 0 == destination->u.file.backlogs + || (RP_UNDEFINED == destination->u.file.rotate && 0 == destination->u.file.size) ) { TRACE_LEAVE( "no conditions for rotation\n" ); return; @@ -217,21 +218,21 @@ void rotate_logfile( const gchar* pathname, struct destination* destination ) goto done; } - if( destination->size ) + if( destination->u.file.size ) { - if( fst.st_size > destination->size ) + if( fst.st_size > destination->u.file.size ) { do_rotate( pathname, destination ); rotated = TRUE; goto done; } - TRACE_2( "checked size: file=%d, max=%d\n", fst.st_size, destination->size ); + TRACE_2( "checked size: file=%d, max=%d\n", fst.st_size, destination->u.file.size ); } current_time = time(NULL); tm = gmtime( ¤t_time ); TRACE_2( "checking time: creation=%d, modification=%d\n", fst.st_ctime, fst.st_mtime ); - switch( destination->rotate ) + switch( destination->u.file.rotate ) { case RP_DAILY: if( fst.st_mtime - (fst.st_ctime - fst.st_ctime % (24 * 3600)) > 24 * 3600 ) @@ -256,7 +257,7 @@ void rotate_logfile( const gchar* pathname, struct destination* destination ) goto done; } - if( fst.st_size || destination->ifempty ) + if( fst.st_size || destination->u.file.ifempty ) { do_rotate( pathname, destination ); rotated = TRUE; |