From c74c457136aeffd983eccb03a186f74f41cd0da5 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 6 Sep 2010 21:39:59 -0600 Subject: [PATCH] Use epoch time for timestamps --- src/common.c | 36 ++++++------------------------------ src/common.h | 1 - 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/common.c b/src/common.c index d168b19..f82c0c5 100644 --- a/src/common.c +++ b/src/common.c @@ -7,25 +7,6 @@ #include #include "common.h" -int -timestamp(char *now, size_t nowlen) -{ - time_t t; - struct tm tmp; - - time(&t); - if (NULL == gmtime_r(&t, &tmp)) { - perror("gmtime_r"); - return -1; - } - - if (0 == strftime(now, nowlen, "%Y-%m-%dT%H:%M:%SZ", &tmp)) { - return -1; - } - - return 0; -} - int team_exists(char *teamhash) { @@ -60,23 +41,18 @@ team_exists(char *teamhash) int award_points(char *teamhash, char *category, int points) { - char now[40]; - char line[100]; - int linelen; - int fd; - int ret; + char line[100]; + int linelen; + int fd; + int ret; if (! team_exists(teamhash)) { return -2; } - ret = timestamp(now, sizeof(now)); - if (-1 == ret) { - return -3; - } linelen = snprintf(line, sizeof(line), - "%s %s %s %d\n", - now, teamhash, category, points); + "%u %s %s %d\n", + time(NULL), teamhash, category, points); if (sizeof(line) == linelen) { return -1; } diff --git a/src/common.h b/src/common.h index b8a238c..745b7c4 100644 --- a/src/common.h +++ b/src/common.h @@ -4,7 +4,6 @@ #define teamdir "/var/lib/ctf/teams" #define pointslog "/var/lib/ctf/points.log" -int timestamp(char *now, size_t nowlen); int team_exists(char *teamhash); int award_points(char *teamhash, char *category, int point);