mirror of https://github.com/dirtbags/moth.git
Use epoch time for timestamps
This commit is contained in:
parent
8e1dfbd0da
commit
c74c457136
28
src/common.c
28
src/common.c
|
@ -7,25 +7,6 @@
|
|||
#include <time.h>
|
||||
#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,7 +41,6 @@ team_exists(char *teamhash)
|
|||
int
|
||||
award_points(char *teamhash, char *category, int points)
|
||||
{
|
||||
char now[40];
|
||||
char line[100];
|
||||
int linelen;
|
||||
int fd;
|
||||
|
@ -70,13 +50,9 @@ award_points(char *teamhash, char *category, int points)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue