From b9ccbdff485d560534a2a3784cf09858d48965aa Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 19 Aug 2021 21:21:51 +1000 Subject: Debug versions of shellMe sledjchisl internal functions. --- src/sledjchisl/sledjchisl.c | 139 +++++++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 47 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 15184d8..52c746f 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -539,53 +539,6 @@ qhashtbl_t *mimeTypes; qlist_t *dbRequests; -int shellMeFail(char *format, ...) -{ - va_list va, va2; - int len; - char *ret; - int result; - - va_start(va, format); - va_copy(va2, va); - // How long is it? - len = vsnprintf(0, 0, format, va); - len++; - va_end(va); - // Allocate and do the sprintf() - ret = xmalloc(len); - vsnprintf(ret, len, format, va2); - va_end(va2); - - result = !WIFEXITED(system(ret)); - free(ret); - return result; -} - -int shellMe(char *format, ...) -{ - va_list va, va2; - int len; - char *ret; - int result; - - va_start(va, format); - va_copy(va2, va); - // How long is it? - len = vsnprintf(0, 0, format, va); - len++; - va_end(va); - // Allocate and do the sprintf() - ret = xmalloc(len); - vsnprintf(ret, len, format, va2); - va_end(va2); - - result = system(ret); - free(ret); - return result; -} - - // TODO - log to file. The problem is we don't know where to log until after we have loaded the configs, and before that we are spewing log messages. // Now that we are using spawn-fcgi, all the logs are going to STDERR, which we can capture and write to a file. // Unfortunately spawn-fcgi in deamon mode sends all the output to /dev/null or something. @@ -654,6 +607,98 @@ void logMe(int v, char *format, ...) #define t(...) logMe(8, __VA_ARGS__) +int shellMeFailVf(char *format, ...) +{ + va_list va, va2; + int len; + char *ret; + int result = FALSE; + + va_start(va, format); + va_copy(va2, va); + // How long is it? + len = vsnprintf(0, 0, format, va); + len++; + va_end(va); + // Allocate and do the sprintf() + ret = xmalloc(len); + vsnprintf(ret, len, format, va2); + va_end(va2); + + V(ret); + free(ret); + return result; +} +int shellMeFailVt(char *format, ...) +{ + va_list va, va2; + int len; + char *ret; + int result = TRUE; + + va_start(va, format); + va_copy(va2, va); + // How long is it? + len = vsnprintf(0, 0, format, va); + len++; + va_end(va); + // Allocate and do the sprintf() + ret = xmalloc(len); + vsnprintf(ret, len, format, va2); + va_end(va2); + + V(ret); + free(ret); + return result; +} + +int shellMeFail(char *format, ...) +{ + va_list va, va2; + int len; + char *ret; + int result; + + va_start(va, format); + va_copy(va2, va); + // How long is it? + len = vsnprintf(0, 0, format, va); + len++; + va_end(va); + // Allocate and do the sprintf() + ret = xmalloc(len); + vsnprintf(ret, len, format, va2); + va_end(va2); + + result = !WIFEXITED(system(ret)); + free(ret); + return result; +} + +int shellMe(char *format, ...) +{ + va_list va, va2; + int len; + char *ret; + int result; + + va_start(va, format); + va_copy(va2, va); + // How long is it? + len = vsnprintf(0, 0, format, va); + len++; + va_end(va); + // Allocate and do the sprintf() + ret = xmalloc(len); + vsnprintf(ret, len, format, va2); + va_end(va2); + + result = system(ret); + free(ret); + return result; +} + + static void addStrL(qlist_t *list, char *s) { list->addlast(list, s, strlen(s) + 1); -- cgit v1.1