From eadf16a660310162bcc3cadda26f44acd3b83077 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 9 Nov 2005 07:30:14 +0000 Subject: Removed annoying 'i' variable from add_option. Allow plugin and push directives to have multiple parameters specified instead of only 1 quoted parameter. Allow plugin and push directives to have multi-line parameter lists, such as: my-plugin.so parm1 parm2 git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@785 e7ae566f-a301-0410-adde-c780ea21d3b5 --- buffer.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'buffer.c') diff --git a/buffer.c b/buffer.c index 3b856bc..5ff6123 100644 --- a/buffer.c +++ b/buffer.c @@ -398,6 +398,19 @@ buf_chomp (struct buffer *buf) buf_null_terminate (buf); } +const char * +skip_leading_whitespace (const char *str) +{ + while (*str) + { + const char c = *str; + if (!(c == ' ' || c == '\t')) + break; + ++str; + } + return str; +} + /* * like buf_null_terminate, but operate on strings */ @@ -474,6 +487,42 @@ string_clear (char *str) } } +/* + * Return the length of a string array + */ +int +string_array_len (const char **array) +{ + int i = 0; + if (array) + { + while (array[i]) + ++i; + } + return i; +} + +char * +print_argv (const char **p, struct gc_arena *gc, const unsigned int flags) +{ + struct buffer out = alloc_buf_gc (256, gc); + int i = 0; + for (;;) + { + const char *cp = *p++; + if (!cp) + break; + if (i) + buf_printf (&out, " "); + if (flags & PA_BRACKET) + buf_printf (&out, "[%s]", cp); + else + buf_printf (&out, "%s", cp); + ++i; + } + return BSTR (&out); +} + /* * Allocate a string inside a buffer */ -- cgit