X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=quote.h;h=50ce1df976671b5e9fac83368ae5ea28211a432a;hb=380792390e05e744f9d7eefbc35d1db80e44e27a;hp=c8cfb3a12482b0a2398d7d9e164c37e5473b44b8;hpb=80bd6f3064a6009cd18a4dab9ce6d29681cec4af;p=git.git diff --git a/quote.h b/quote.h index c8cfb3a1..50ce1df9 100644 --- a/quote.h +++ b/quote.h @@ -1,10 +1,12 @@ #ifndef QUOTE_H #define QUOTE_H +#include /* Help to copy the thing properly quoted for the shell safety. - * any single quote is replaced with '\'', and the whole thing - * is enclosed in a single quote pair. + * any single quote is replaced with '\'', any exclamation point + * is replaced with '\!', and the whole thing is enclosed in a + * single quote pair. * * For example, if you are passing the result to system() as an * argument: @@ -19,8 +21,13 @@ * * Note that the above examples leak memory! Remember to free result from * sq_quote() in a real application. + * + * sq_quote_buf() writes to an existing buffer of specified size; it + * will return the number of characters that would have been written + * excluding the final null regardless of the buffer size. */ char *sq_quote(const char *src); +size_t sq_quote_buf(char *dst, size_t n, const char *src); #endif