summaryrefslogtreecommitdiff
path: root/src/strutil.h
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2024-02-01 22:59:38 +0100
committerLinnnus <[email protected]>2024-02-04 09:58:06 +0100
commitd38f82f6462af4e5aad6a2c776f5c00ce5b13c87 (patch)
tree01a222792dfb10473ae4370b4fc90f3a48e1a499 /src/strutil.h
feat: initial commit
Here is a small overview of the state of the project at this first commit. I have basic Git Repo -> HTML working, and a plan for how setting up an actual server would work (mainly, NGINX + a git hook to rebuild). The main thing I'm working on right now is parsing WikiCreole, though I am starting to wonder if this is the right langauge. WikiCreole is pretty irregular and has a lot of edge cases (e.g. around emphasis).
Diffstat (limited to 'src/strutil.h')
-rw-r--r--src/strutil.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/strutil.h b/src/strutil.h
new file mode 100644
index 0000000..03f8294
--- /dev/null
+++ b/src/strutil.h
@@ -0,0 +1,26 @@
+#ifndef STRUTIL_H
+#define STRUTIL_H
+
+//
+// Defines various utilities for working with strings.
+//
+
+#include "arena.h" // struct arena
+#include <stdbool.h> // bool
+#include <stdarg.h> // va_list
+
+// Like asprintf except the allocation is made inside the given arena.
+// Panics on allocation failure.
+int aprintf(struct arena *a, char **out, const char *fmt, ...);
+
+// Same as aprintf, except takes a varargs list.
+int vaprintf(struct arena *a, char **out, const char *fmt, va_list args);
+
+// Join the two paths with a directory separator.
+// Result is allocated in arena.
+char *joinpath(struct arena *a, const char *path_a, const char *path_b);
+
+// Returns boolean indicating if `haystack` ends with `needle`.
+bool endswith(const char *haystack, const char *needle);
+
+#endif