diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/vsprintf.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h index e006af200f..ed8a060ee1 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -329,6 +329,30 @@ char *strmhz(char *buf, unsigned long hz); void str_to_upper(const char *in, char *out, size_t len); /** + * str_to_list() - Convert a string to a list of string pointers + * + * Splits a string containing space-delimited substrings into a number of + * separate strings, e.g. "this is" becomes {"this", "is", NULL}. If @instr is + * empty then this returns just {NULL}. The string should have only a single + * space between items, with no leading or trailing spaces. + * + * @instr: String to process (this is alloced by this function) + * Returns: List of string pointers, terminated by NULL. Each entry points to + * a string. If @instr is empty, the list consists just of a single NULL entry. + * Note that the first entry points to the alloced string. + * Returns NULL if out of memory + */ +const char **str_to_list(const char *instr); + +/** + * str_free_list() - Free a string list + * + * @ptr: String list to free, as created by str_to_list(). This can also be + * NULL, in which case the function does nothing + */ +void str_free_list(const char **ptr); + +/** * vsscanf - Unformat a buffer into a list of arguments * @inp: input buffer * @fmt0: format of buffer |