]>
git.scottworley.com Git - tl-append/blob - common.c
2 * tl-append: time-logger appending shell
3 * Copyright (C) 2023 Scott Worley <scottworley@scottworley.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 #define _POSIX_C_SOURCE 2
24 const char *const FILENAME
= "tl.log";
26 void die(const char *message
) {
27 fputs(message
, stderr
);
32 void die_err(const char *message
) {
37 char *encode_time(time_t t
) {
40 const size_t size
= 20;
41 char *out
= (char *)malloc(size
);
42 if (strftime(out
, size
, "%Y %m %d %H %M %S", &tm
) != size
- 1)
43 die("Couldn't format time");