--- old/support/rotatelogs.c 2020-02-21 01:33:40.000000000 +0100 +++ new/support/rotatelogs.c 2020-04-07 10:10:41.002129514 +0200 @@ -29,6 +29,8 @@ #include "apr_poll.h" #endif +#include + #if APR_HAVE_STDLIB_H #include #endif @@ -558,6 +560,52 @@ return NULL; } +/* + * Get index of last modified file. + */ +int get_idx_last_file_mod(int num_file, const char *base_file) +{ + int file_name_len_max, last_idx_mod_file=0; + char *curr_file_name; + struct stat stat_info; + struct timespec time_mod_prev; + + time_mod_prev.tv_sec = time_mod_prev.tv_nsec = 0; + file_name_len_max = strlen(base_file) + 5; + curr_file_name = malloc(sizeof(char) * file_name_len_max); + if ( curr_file_name == NULL ) + { + return last_idx_mod_file; + } + memset(curr_file_name, 0, file_name_len_max); + if (num_file>1 && num_file<1000) + { + for (int curr_idx=0; curr_idx 1) + { + status.fileNum = get_idx_last_file_mod(config.num_files, config.szLogRoot); + } + config.use_strftime = (strchr(config.szLogRoot, '%') != NULL); if (config.use_strftime && config.num_files > 0) {