From ca7b7c15c5ecd344e844411e4b8409e552a3b06d Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 4 Apr 2018 11:55:59 +0200 Subject: Merge argument substitution into rdline Signed-off-by: David Oberhollenzer --- lib/include/util.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/include') 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 % 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 */ -- cgit v1.2.3