diff options
Diffstat (limited to 'buffer.h')
-rw-r--r-- | buffer.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -56,6 +56,12 @@ struct buffer #endif }; +/* used by argv_x functions */ +struct argv { + size_t argc; + char **argv; +}; + /* for garbage collection */ struct gc_entry @@ -222,6 +228,33 @@ int openvpn_snprintf(char *str, size_t size, const char *format, ...) ; /* + * A printf-like function (that only recognizes a subset of standard printf + * format operators) that prints arguments to an argv list instead + * of a standard string. This is used to build up argv arrays for passing + * to execve. + */ +void argv_init (struct argv *a); +void argv_reset (struct argv *a); +size_t argv_argc (const char *format); +char *argv_term (const char **f); +const char *argv_str (const struct argv *a, struct gc_arena *gc, const unsigned int flags); + +#define APA_CAT (1<<0) /* concatentate onto existing struct argv list */ +void argv_printf_arglist (struct argv *a, const char *format, const unsigned int flags, va_list arglist); + +void argv_printf (struct argv *a, const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + ; + +void argv_printf_cat (struct argv *a, const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + ; + +/* * remove/add trailing characters */ |