]> git.scottworley.com Git - tl-append/blame_incremental - common.c
-C flag to specify directory
[tl-append] / common.c
... / ...
CommitLineData
1#define _POSIX_C_SOURCE 2
2#include "common.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6
7const char *const FILENAME = "tl.log";
8
9void die(const char *message) {
10 fputs(message, stderr);
11 fputc('\n', stderr);
12 exit(1);
13}
14
15void die_err(const char *message) {
16 perror(message);
17 exit(1);
18}
19
20const char *encode_time(time_t t) {
21 struct tm tm;
22 localtime_r(&t, &tm);
23 const size_t size = 20;
24 char *out = (char *)malloc(size);
25 if (strftime(out, size, "%Y %m %d %H %M %S", &tm) != size - 1)
26 die("Couldn't format time");
27 return out;
28}