summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/util.c b/util.c
index ced4d9d..3ed2f4d 100644
--- a/util.c
+++ b/util.c
@@ -1,4 +1,6 @@
#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -141,3 +143,17 @@ printutf8pad(FILE *fp, const char *s, size_t len, int pad)
for(; n < len; n++)
putc(pad, fp);
}
+
+int
+strtotime(const char *s, time_t *t)
+{
+ long l;
+
+ errno = 0;
+ l = strtol(s, NULL, 10);
+ if(errno != 0)
+ return -1;
+ *t = (time_t)l;
+
+ return 0;
+}