aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorRaymaekers Luca <luca@keyfried.com>2024-10-19 11:31:50 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-19 11:32:08 +0200
commit8cbbc5e672fb23f0d0050bc46abb41f5a3e6b508 (patch)
tree39b62d01627e67177e7b156e5eb0be1c3163a1ca /common.c
parent77fbdb3e31379c2ce1296bef10578543cfdc5ad4 (diff)
add shared code in common.c
Diffstat (limited to 'common.c')
-rw-r--r--common.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common.c b/common.c
new file mode 100644
index 0000000..b177987
--- /dev/null
+++ b/common.c
@@ -0,0 +1,20 @@
+#include "config.h"
+#include <stdarg.h>
+#include <strings.h>
+#include <unistd.h>
+
+// wrapper for write
+void writef(char *format, ...)
+{
+ va_list args;
+ char buf[BUF_MAX + 1];
+ va_start(args, format);
+
+ vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
+
+ int n = 0;
+ while (*(buf + n) != 0)
+ n++;
+ write(0, buf, n);
+}