summaryrefslogtreecommitdiff
path: root/lib/include/util.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-11 15:57:01 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-11 15:57:01 +0200
commit4ee0ea9754d4c8103a623c90c03b68457c71581f (patch)
treea7b548acd56057c666d2ca5d1cc896115ef72305 /lib/include/util.h
parentdca72a4c778cbe55975508ebce22db2105c26ee0 (diff)
Split bulk of split_argv out into helper function
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/include/util.h')
-rw-r--r--lib/include/util.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/include/util.h b/lib/include/util.h
index c13b942..d824b22 100644
--- a/lib/include/util.h
+++ b/lib/include/util.h
@@ -100,13 +100,25 @@ int rdline(rdline_t *t);
int unescape(char *src);
/*
+ Replace spaces in 'str' with null bytes. Tread strings (started and
+ terminated with double-quotes which can be escaped) as a single block.
+ Such strings are run through unescap(). All elements are tightly
+ packed together and the function returns the number of consecutive
+ argument strings that are now inside 'str'.
+
+ Returns a negative value if unescape() fails, a string is not
+ termianted or two such strings touch each other without a white
+ space in between.
+*/
+int pack_argv(char *str);
+
+/*
Split a space seperated string into a sequence of null-terminated
strings. Return a NULL terminated array of strings pointing to the
start of each sub string.
- If a double quote is encountered, the entire string up to to the next,
- unescaped double quite is interpreted as a single sub string and
- fed through the unescape function.
+ It basically runs pack_argv on 'str' and then constructs the argv
+ vector from that, with each entry pointing into 'str'.
The returned array must be freed with free().
*/