From 7082188a066427211d0b7ed779e4e55602913757 Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 17 Oct 2014 13:15:30 +0200 Subject: [PATCH] allow appendn hook without second argument --- core/hooks.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/core/hooks.c b/core/hooks.c index 4f79fab0..8ada89ba 100644 --- a/core/hooks.c +++ b/core/hooks.c @@ -233,17 +233,26 @@ static int uwsgi_hook_writen(char *arg) { static int uwsgi_hook_appendn(char *arg) { char *space = strchr(arg, ' '); - if (!space) { - uwsgi_log("invalid hook appendn syntax, must be: \n"); - return -1; - } - *space = 0; + if (space) + *space = 0; int fd = open(arg, O_WRONLY|O_CREAT|O_APPEND, 0666); if (fd < 0) { uwsgi_error_open(arg); - *space = ' '; + if (space) + *space = ' '; return -1; } + if (!space) { + // simple newline + if (write(fd, "\n", 1) != 1) { + uwsgi_error("uwsgi_hook_appendn()/write()"); + close(fd); + return -1; + } + close(fd); + return 0; + } + *space = ' '; size_t l = strlen(space+1); char *buf = uwsgi_malloc(l + 1);