ref: 8e9d7d65c2d1374e5676f63e23bed794f1c00e45
parent: 1cb78fe44c9753cb58653fc575db36c740bb608f
author: mkf <mkf@cloud9p.org>
date: Wed Jul 3 08:02:05 EDT 2024
unix.c: portabltity layer
--- /dev/null
+++ b/unix.c
@@ -1,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+_Noreturn void
+sysfatal(char *fmt, ...)
+{
+ va_list arg;
+
+ va_start(arg, fmt);
+ vfprintf(stderr, fmt, arg);
+ fprintf(stderr, "\n");
+ va_end(arg);
+
+ exit(1);
+}
+
+int
+fprint(int fd, char *fmt, ...)
+{
+ int n;
+ FILE *f;
+
+ f = fdopen(fd, "w");
+
+ va_list arg;
+ va_start(arg, fmt);
+
+ n = vfprintf(fd, fmt, arg);
+ va_end(arg);
+
+ fdclose(f);
+ return n;
+}