summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-05-08 11:57:06 -0400
committerTavian Barnes <tavianator@tavianator.com>2021-09-15 12:31:33 -0400
commitb2d85ea84c930ebcfefc6449414ed64cd80e2f89 (patch)
tree889ffeb0c2cdd67791a7ceefd2cc8b915b18a1d7 /util.h
parentea1aa067aeaf41db8e463eb95d64ebdac6002851 (diff)
downloadbfs-b2d85ea84c930ebcfefc6449414ed64cd80e2f89.tar.xz
util: Wrap getdelim() instead of open coding it
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.h b/util.h
index 1a34fba..be38db5 100644
--- a/util.h
+++ b/util.h
@@ -26,6 +26,7 @@
#include <regex.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdio.h>
#include <sys/types.h>
// Some portability concerns
@@ -274,4 +275,17 @@ size_t xwrite(int fd, const void *buf, size_t nbytes);
*/
char *xconfstr(int name);
+/**
+ * Convenience wrapper for getdelim().
+ *
+ * @param file
+ * The file to read.
+ * @param delim
+ * The delimiter character to split on.
+ * @return
+ * The read chunk (without the delimiter), allocated with malloc().
+ * NULL is returned on error (errno != 0) or end of file (errno == 0).
+ */
+char *xgetdelim(FILE *file, char delim);
+
#endif // BFS_UTIL_H