18.2.228. PMIx_Argv_split_inter
PMIx_Argv_split_inter — Split a string on a delimiter into a
NULL-terminated argv-style array, optionally retaining empty tokens.
18.2.228.1. SYNOPSIS
#include <pmix.h>
char **PMIx_Argv_split_inter(const char *src_string,
int delimiter,
bool include_empty);
18.2.228.1.1. Python Syntax
No Python equivalent
18.2.228.2. INPUT PARAMETERS
src_string: The string to tokenize. May beNULLor empty.delimiter: The character on which to split, passed as anint.include_empty: Iftrue, zero-length tokens are retained as empty-string ("") entries; iffalse, they are discarded.
18.2.228.3. DESCRIPTION
Break src_string into tokens separated by delimiter and return the
tokens as a freshly allocated, NULL-terminated argv-style array. Each
token is an independently allocated copy of the corresponding substring.
This is the common backing routine for
PMIx_Argv_split(3) (which calls it with
include_empty = false) and
PMIx_Argv_split_with_empty(3) (which
calls it with include_empty = true). Call it directly when the
empty-token policy is chosen at run time. The include_empty argument
controls whether runs of consecutive delimiters, and a leading delimiter,
generate empty-string entries.
The returned array and all of its strings are owned by the caller and must be released with PMIx_Argv_free(3).
18.2.228.4. RETURN VALUE
Returns a newly allocated NULL-terminated array of token strings. If
src_string is NULL or empty — or contains no tokens once the
include_empty policy is applied — the returned pointer is NULL.
NULL is also returned if an internal allocation fails.
18.2.228.5. EXAMPLES
bool keep = user_wants_empties();
char **argv = PMIx_Argv_split_inter("a::b", ':', keep);
/* keep == true -> { "a", "", "b", NULL } */
/* keep == false -> { "a", "b", NULL } */
PMIx_Argv_free(argv);