summaryrefslogtreecommitdiff
path: root/src/tai64nfrac.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
commita6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch)
treeb88cc7a8457658d67e0321718556ac807f6bccf3 /src/tai64nfrac.c
parent00be7622c428f279872f84569f098ce16150f8a8 (diff)
format files
Diffstat (limited to 'src/tai64nfrac.c')
-rw-r--r--src/tai64nfrac.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/tai64nfrac.c b/src/tai64nfrac.c
index f3db977..bb29b44 100644
--- a/src/tai64nfrac.c
+++ b/src/tai64nfrac.c
@@ -1,11 +1,11 @@
#include "buffer.h"
-#include "stralloc.h"
#include "exit.h"
-#include "readwrite.h"
-#include "open.h"
-#include "scan.h"
#include "fmt.h"
#include "getln.h"
+#include "open.h"
+#include "readwrite.h"
+#include "scan.h"
+#include "stralloc.h"
#define TAI64NLEN 24
@@ -16,11 +16,11 @@
*/
char outbuf[64];
-buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf));
+buffer bo = BUFFER_INIT(write, 1, outbuf, sizeof(outbuf));
static void outs(char *s)
{
- if (buffer_puts(&bo,s) == -1) _exit(1);
+ if (buffer_puts(&bo, s) == -1) _exit(1);
if (buffer_flush(&bo) == -1) _exit(1);
}
@@ -28,12 +28,12 @@ static void outi(int i)
{
char num[FMT_ULONG];
- if (buffer_put(&bo,num,fmt_ulong(num,(unsigned long) i)) == -1) _exit(1);
+ if (buffer_put(&bo, num, fmt_ulong(num, (unsigned long)i)) == -1) _exit(1);
if (buffer_flush(&bo) == -1) _exit(1);
}
char inbuf[1024];
-buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf));
+buffer bi = BUFFER_INIT(read, 0, inbuf, sizeof(inbuf));
int main(void)
{
@@ -41,23 +41,23 @@ int main(void)
int i;
int match;
unsigned long u;
- unsigned long seconds;
+ unsigned long seconds;
unsigned long nanoseconds;
stralloc line = {0};
-/* Read from stdin */
+ /* Read from stdin */
- buffer_init(&bi,read,0,inbuf,sizeof(inbuf));
+ buffer_init(&bi, read, 0, inbuf, sizeof(inbuf));
for (;;) {
- if (getln(&bi,&line,&match,'\n') != 0) _exit(1);
+ if (getln(&bi, &line, &match, '\n') != 0) _exit(1);
if (!match) break;
if (!stralloc_0(&line)) _exit(1);
seconds = 0;
nanoseconds = 0;
-
- if (line.s[0] == '@') { /* tai64 timestamp */
+
+ if (line.s[0] == '@') { /* tai64 timestamp */
for (i = 1; i <= TAI64NLEN; i++) {
c = (int)line.s[i];
u = c - '0';
@@ -74,9 +74,14 @@ int main(void)
}
seconds -= 4611686018427387914ULL;
seconds = seconds > 0 ? seconds : 0;
- outi(seconds); outs("."); outi(nanoseconds); outs(line.s + i); outs("\n");
+ outi(seconds);
+ outs(".");
+ outi(nanoseconds);
+ outs(line.s + i);
+ outs("\n");
} else {
- outs("tai64nfrac: fatal: Wrong TAI64N input format."); outs("\n");
+ outs("tai64nfrac: fatal: Wrong TAI64N input format.");
+ outs("\n");
_exit(1);
}
}