int needsRotate;
int reason;
int tLogEnd;
- int now;
int nMessCount;
};
exit(1);
}
-static int get_now(int use_localtime, int utc_offset)
+static int get_now(rotate_config_t *config)
{
apr_time_t tNow = apr_time_now();
- if (use_localtime) {
+ int utc_offset = config->utc_offset;
+ if (config->use_localtime) {
/* Check for our UTC offset before using it, since it might
* change if there's a switch between standard and daylight
* savings time.
return (int)apr_time_sec(tNow) + utc_offset;
}
-void closeFile(apr_pool_t *pool, apr_file_t *file) {
+static void closeFile(apr_pool_t *pool, apr_file_t *file)
+{
if (file != NULL) {
apr_file_close(file);
if (pool) {
}
}
-void checkRotate(rotate_config_t *config, rotate_status_t *status) {
+static void checkRotate(rotate_config_t *config, rotate_status_t *status)
+{
if (status->nLogFD == NULL) {
status->needsRotate = 1;
status->needsRotate = 1;
}
else if (config->tRotation) {
- status->now = get_now(config->use_localtime, config->utc_offset);
- if (status->now >= status->tLogEnd) {
+ if (get_now(config) >= status->tLogEnd) {
status->needsRotate = 1;
}
}
return;
}
-void doRotate(rotate_config_t *config, rotate_status_t *status) {
+static void doRotate(rotate_config_t *config, rotate_status_t *status)
+{
+ int now = get_now(config);
int tLogStart;
apr_status_t rv;
status->nLogFD = NULL;
status->pfile_prev = status->pfile;
- status->now = get_now(config->use_localtime, config->utc_offset);
if (config->tRotation) {
int tLogEnd;
- tLogStart = (status->now / config->tRotation) * config->tRotation;
+ tLogStart = (now / config->tRotation) * config->tRotation;
tLogEnd = tLogStart + config->tRotation;
/*
* Check if rotation was forced and the last rotation
* of the time interval boundary for the file name then.
*/
if ((status->reason == REASON_FORCE) && (tLogStart < status->tLogEnd)) {
- tLogStart = status->now;
+ tLogStart = now;
}
status->tLogEnd = tLogEnd;
}
else {
- tLogStart = status->now;
+ tLogStart = now;
}
if (config->use_strftime) {
status.tLogEnd = 0;
status.needsRotate = 0;
status.reason = REASON_LOG;
- status.now = 0;
status.nMessCount = 0;
apr_pool_create(&status.pool, NULL);
usage(argv[0], NULL /* specific error message already issued */ );
}
- if (opt->ind + 2 != argc && opt->ind + 3 != argc) {
+ if ((argc - opt->ind < 2) || (argc - opt->ind > 3) ) {
usage(argv[0], "Incorrect number of arguments");
}