commit 139384d01e858483e30e73f2052c70adddc3550e
parent 7d57863dd99991563e949e86af2ac672ec45389c
Author: kocotian <kocotian@kocotian.pl>
Date: Thu, 8 Apr 2021 10:56:25 +0200
libstac
Diffstat:
4 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/assemble.h b/assemble.h
@@ -27,18 +27,12 @@
#include <sys/types.h>
#include <unistd.h>
+#include "libstac/libstac.h"
#include "str.h"
#include "util.h"
/* Macros */
-#define $(VARNAME) getVariableValue(#VARNAME)
-#define $$(VARNAME) write(fd, $(VARNAME).data, $(VARNAME).len);
-#define DECLVAR(VARNAME, VALUE) \
- (vs[vss].name.len = strlen(vs[vss].name.data = #VARNAME), \
- vs[vss].value.len = strlen(vs[vss].value.data = VALUE == NULL ? "<null>" : VALUE), \
- ++vss)
#define VS_MAX 256
-#define fd 1 /* stdout */
/* Types */
typedef struct {
diff --git a/config.mk b/config.mk
@@ -1,12 +1,12 @@
# basics
MAJORVERSION = 0
-SUBVERSION = 1
-PATCHLEVEL = 1
+SUBVERSION = 2
+PATCHLEVEL = 0
BUILDNAME = vanilla
VERSION = ${MAJORVERSION}.${SUBVERSION}.${PATCHLEVEL}-${BUILDNAME}
-# directories
+# directories (KEEP TRAILING SLASH!)
INDIR = in/
METADIR = meta/
OUTDIR = out/
diff --git a/libstac/libstac.c b/libstac/libstac.c
@@ -0,0 +1,19 @@
+#include "libstac.h"
+
+ssize_t
+print(char *what)
+{
+ return write(fd, what, strlen(what));
+}
+
+int
+lsprintf(char *fmt, ...)
+{
+ int x;
+ va_list ap;
+
+ va_start(ap, fmt);
+ x = vdprintf(fd, fmt, ap);
+ va_end(ap);
+ return x;
+}
diff --git a/libstac/libstac.h b/libstac/libstac.h
@@ -0,0 +1,25 @@
+#ifndef _LIBSTAC_H
+#define _LIBSTAC_H
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "../str.h"
+#include "../util.h"
+
+/* Macros */
+#define $(VARNAME) getVariableValue(#VARNAME)
+#define $$(VARNAME) write(fd, $(VARNAME).data, $(VARNAME).len);
+#define DECLVAR(VARNAME, VALUE) \
+ (vs[vss].name.len = strlen(vs[vss].name.data = #VARNAME), \
+ vs[vss].value.len = strlen(vs[vss].value.data = VALUE == NULL ? "<null>" : VALUE), \
+ ++vss)
+#define fd 1 /* stdout */
+
+#define echo(STRING) write(fd, (STRING), sizeof(STRING) - 1)
+
+ssize_t print(char *what);
+int lsprintf(char *fmt, ...);
+
+#endif