Allow backslash line continuation in catsit.conf
This commit is contained in:
parent
b5437a42f9
commit
909cbf3029
@ -1,4 +1,4 @@
|
|||||||
.Dd March 1, 2021
|
.Dd September 28, 2021
|
||||||
.Dt CATSIT.CONF 5
|
.Dt CATSIT.CONF 5
|
||||||
.Os
|
.Os
|
||||||
.
|
.
|
||||||
@ -13,6 +13,10 @@ file lists the services managed by the
|
|||||||
.Xr catsitd 8
|
.Xr catsitd 8
|
||||||
daemon.
|
daemon.
|
||||||
Leading whitespace is ignored.
|
Leading whitespace is ignored.
|
||||||
|
The current line
|
||||||
|
can be extended over multiple lines
|
||||||
|
using a backslash
|
||||||
|
.Pq Ql \e .
|
||||||
Each line of the file
|
Each line of the file
|
||||||
is one of the following:
|
is one of the following:
|
||||||
.
|
.
|
||||||
@ -82,7 +86,8 @@ pounce/tilde pounce ${0#*/}.conf
|
|||||||
pounce/libera pounce ${0#*/}.conf
|
pounce/libera pounce ${0#*/}.conf
|
||||||
|
|
||||||
# Privileged services:
|
# Privileged services:
|
||||||
@scooper kfcgi -d -U $USER -p ~/.local -- /bin/scooper
|
@scooper kfcgi -d -U $USER -p ~/.local -- \e
|
||||||
|
/bin/scooper /share/litterbox/litterbox.sqlite
|
||||||
.Ed
|
.Ed
|
||||||
.
|
.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
|
30
daemon.c
30
daemon.c
@ -49,6 +49,34 @@ static void signalHandler(int signal) {
|
|||||||
signals[signal] = 1;
|
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) {
|
static int parseConfig(const char *path) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t cap = 0;
|
size_t cap = 0;
|
||||||
@ -63,7 +91,7 @@ static int parseConfig(const char *path) {
|
|||||||
prependClear();
|
prependClear();
|
||||||
|
|
||||||
int line = 1;
|
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';
|
if (buf[len - 1] == '\n') buf[len - 1] = '\0';
|
||||||
|
|
||||||
char *ptr = &buf[strspn(buf, WS)];
|
char *ptr = &buf[strspn(buf, WS)];
|
||||||
|
Loading…
Reference in New Issue
Block a user