From: Nathan Wagner Date: Sat, 15 Sep 2018 08:19:27 +0000 (+0000) Subject: add zpm program to quote strings for sqlite X-Git-Tag: v0.1.6~39 X-Git-Url: https://pd.if.org/git/?a=commitdiff_plain;h=4fb3f8f638558d96ebe4255e7e78e609bf2b67f6;p=zpackage add zpm program to quote strings for sqlite --- diff --git a/zpm-quote.c b/zpm-quote.c new file mode 100644 index 0000000..ea306b4 --- /dev/null +++ b/zpm-quote.c @@ -0,0 +1,28 @@ +#include + +#include "zpm.h" + +/* for quoting against the shell replace ' with '\'' and surround with + * single quotes + */ +int main(int ac, char **av) { + size_t n = 0; + size_t bufsize = 0; + char *buffer = 0; + int i; + + for (i=1;i bufsize) { + buffer = realloc(buffer, n+1); + if (buffer) { + bufsize = n+1; + } else { + exit(EXIT_FAILURE); + } + } + zpm_quote(av[i], buffer, bufsize); + printf("%s\n", buffer); + } + return 0; +}