From b2d85ea84c930ebcfefc6449414ed64cd80e2f89 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 8 May 2021 11:57:06 -0400 Subject: util: Wrap getdelim() instead of open coding it --- util.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'util.h') diff --git a/util.h b/util.h index 1a34fba..be38db5 100644 --- a/util.h +++ b/util.h @@ -26,6 +26,7 @@ #include #include #include +#include #include // 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 -- cgit v1.2.3