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 <time.h>
|
||||||
#include "common.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
|
int
|
||||||
team_exists(char *teamhash)
|
team_exists(char *teamhash)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +41,6 @@ team_exists(char *teamhash)
|
||||||
int
|
int
|
||||||
award_points(char *teamhash, char *category, int points)
|
award_points(char *teamhash, char *category, int points)
|
||||||
{
|
{
|
||||||
char now[40];
|
|
||||||
char line[100];
|
char line[100];
|
||||||
int linelen;
|
int linelen;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -70,13 +50,9 @@ award_points(char *teamhash, char *category, int points)
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = timestamp(now, sizeof(now));
|
|
||||||
if (-1 == ret) {
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
linelen = snprintf(line, sizeof(line),
|
linelen = snprintf(line, sizeof(line),
|
||||||
"%s %s %s %d\n",
|
"%u %s %s %d\n",
|
||||||
now, teamhash, category, points);
|
time(NULL), teamhash, category, points);
|
||||||
if (sizeof(line) == linelen) {
|
if (sizeof(line) == linelen) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#define teamdir "/var/lib/ctf/teams"
|
#define teamdir "/var/lib/ctf/teams"
|
||||||
#define pointslog "/var/lib/ctf/points.log"
|
#define pointslog "/var/lib/ctf/points.log"
|
||||||
|
|
||||||
int timestamp(char *now, size_t nowlen);
|
|
||||||
int team_exists(char *teamhash);
|
int team_exists(char *teamhash);
|
||||||
int award_points(char *teamhash, char *category, int point);
|
int award_points(char *teamhash, char *category, int point);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue