summary refs log tree commit diff
path: root/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--daemon.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/daemon.c b/daemon.c
index e4c3145..0086a3d 100644
--- a/daemon.c
+++ b/daemon.c
@@ -49,6 +49,34 @@ static void signalHandler(int signal) {
 	signals[signal] = 1;
 }
 
+static ssize_t getlinecont(char **line, size_t *lcap, FILE *file) {
+	size_t cap = 0;
+	char *buf = NULL;
+	ssize_t llen = getline(line, lcap, file);
+	while (llen > 1 && (*line)[llen - 1] == '\n' && (*line)[llen - 2] == '\\') {
+		llen -= 2;
+		ssize_t len = getline(&buf, &cap, file);
+		if (len < 0) {
+			llen = -1;
+			break;
+		}
+		size_t req = llen + len + 1;
+		if (req > *lcap) {
+			char *ptr = realloc(*line, req);
+			if (!ptr) {
+				llen = -1;
+				break;
+			}
+			*line = ptr;
+			*lcap = req;
+		}
+		strlcpy(*line + llen, buf, *lcap - llen);
+		llen += len;
+	}
+	free(buf);
+	return llen;
+}
+
 static int parseConfig(const char *path) {
 	int ret = -1;
 	size_t cap = 0;
@@ -63,7 +91,7 @@ static int parseConfig(const char *path) {
 	prependClear();
 
 	int line = 1;
-	for (ssize_t len; 0 <= (len = getline(&buf, &cap, file)); ++line) {
+	for (ssize_t len; 0 <= (len = getlinecont(&buf, &cap, file)); ++line) {
 		if (buf[len - 1] == '\n') buf[len - 1] = '\0';
 
 		char *ptr = &buf[strspn(buf, WS)];
40892a7415bb02c5463fe56dc79ad44724c770e9&follow=1'>Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe