From 104dabefd62952f2d892a2dcdfb5700d9379ac00 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 19 Oct 2024 11:31:50 +0200 Subject: add shared code in common.c --- common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 common.c (limited to 'common.c') 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 +#include +#include + +// 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); +} -- cgit v1.2.3