static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm*)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm*)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm *)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
gettimeofday(&tval, NULL);
struct tm local_tm;
- tms = (struct tm *)localtime_r(&tval.tv_sec, &local_tm);
+ tms = (struct tm *)SCLocalTime(tval.tv_sec, &local_tm);
/* Calculate the Engine uptime */
int up_time = (int)difftime(tval.tv_sec, sc_start_time);
struct tm *tms;
gettimeofday(&tval, NULL);
struct tm local_tm;
- tms = (struct tm *)localtime_r(&tval.tv_sec, &local_tm);
+ tms = (struct tm *)SCLocalTime(tval.tv_sec, &local_tm);
fprintf(fp_engine_analysis_FD, "----------------------------------------------"
"---------------------\n");
fprintf(fp_engine_analysis_FD, "Date: %" PRId32 "/%" PRId32 "/%04d -- "
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm *)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm *)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm *)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm local_tm;
- struct tm *t = (struct tm *)localtime_r(&time, &local_tm);
+ struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
if (pl->mode == LOGMODE_SGUIL) {
struct tm local_tm;
- struct tm *tms = (struct tm *)localtime_r(&p->ts.tv_sec, &local_tm);
+ struct tm *tms = (struct tm *)SCLocalTime(p->ts.tv_sec, &local_tm);
if (tms->tm_mday != pl->prev_day) {
rotate = 1;
pl->prev_day = tms->tm_mday;
memset(&ts, 0x00, sizeof(struct timeval));
TimeGet(&ts);
struct tm local_tm;
- struct tm *tms = (struct tm *)localtime_r(&ts.tv_sec, &local_tm);
+ struct tm *tms = (struct tm *)SCLocalTime(ts.tv_sec, &local_tm);
pl->prev_day = tms->tm_mday;
*data = (void *)pl;
if (pl->mode == LOGMODE_SGUIL) {
struct tm local_tm;
- struct tm *tms = (struct tm *)localtime_r(&ts.tv_sec, &local_tm);
+ struct tm *tms = (struct tm *)SCLocalTime(ts.tv_sec, &local_tm);
char dirname[32], dirfull[PATH_MAX] = "";
gettimeofday(&tval, NULL);
struct tm local_tm;
- tms = localtime_r(&tval.tv_sec, &local_tm);
+ tms = SCLocalTime(tval.tv_sec, &local_tm);
cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - *msg),
"%s%d/%d/%04d -- %02d:%02d:%02d",
gettimeofday(&tval, NULL);
struct tm local_tm;
- tms = (struct tm *)localtime_r(&tval.tv_sec, &local_tm);
+ tms = (struct tm *)SCLocalTime(tval.tv_sec, &local_tm);
fprintf(fp, " ----------------------------------------------"
"----------------------------\n");
TimeSet(&tv);
}
+
+struct tm *SCLocalTime(time_t timep, struct tm *result)
+{
+ return localtime_r(&timep, result);
+}
void TimeModeSetLive(void);
void TimeModeSetOffline (void);
+struct tm *SCLocalTime(time_t timep, struct tm *result);
+
#endif /* __UTIL_TIME_H__ */