summaryrefslogtreecommitdiff
path: root/lib/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-04 11:55:59 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-04 11:55:59 +0200
commitca7b7c15c5ecd344e844411e4b8409e552a3b06d (patch)
tree7bebbde8559d67e1f5450657f8a44ab05e48feac /lib/include
parent352a9060b6813c41527f0c5da43f0c86aecfde2a (diff)
Merge argument substitution into rdline
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/include')
-rw-r--r--lib/include/util.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/include/util.h b/lib/include/util.h
index 6943567..e99be3b 100644
--- a/lib/include/util.h
+++ b/lib/include/util.h
@@ -55,8 +55,17 @@ typedef struct {
it with a backslash.
- If a second, coresponding '"' is not found, processing fails with
errno set to EILSEQ.
+ - If a '%' character is encountered, the next character is expected
+ to be a single digit index into argv. If it is not a digit or
+ outside the bounds set by argc, processing fails and sets errno
+ to EINVAL. On success, the argv value is inserted and processed
+ as described above.
+ - A '%' character can be escaped by writing '%%' or, if inside
+ a double quite string, by writing \%.
+ - An attempt to use such an indexed argument inside an argument
+ expansion, results in failure with errno set to ELOOP.
*/
-char *rdline(int fd);
+char *rdline(int fd, int argc, const char *const *argv);
/*
Split a line of the shape "key = value" into key and value part.
@@ -88,12 +97,5 @@ const enum_map_t *enum_by_name(const enum_map_t *map, const char *name);
*/
const char *enum_to_name(const enum_map_t *map, int value);
-/*
- Create a copy of the input string inp, but replace all occourances
- of %<number> with argv[number] if the number is within the bounds
- specified by argc.
-*/
-char *strexpand(const char *inp, size_t argc, const char *const *argv);
-
#endif /* UTIL_H */