![]() |
![]()
| ![]() |
![]()
NAMEPhkArgvParse , PhkArgvFree
—
parse argument string
SYNOPSIS#include <phk_argv.h>
char **
void
DESCRIPTIONThese functions can parse a string into argv[] style arguments.
The first element of the returned vector is non-NULL it contains an error message and the conversion was a failure. Otherwise the remainder of the vector contains the parsed arguments, terminated by a NULL element. The returned argv and the storage for the arguments are allocated
with
malloc(3)
but should only be freed with the If the comment argument is non-zero, any argument starting with a '#' character will terminate the parsing, rendering the remainder of the input string a comment. Arguments can be included in double quotes '"' and the usual backslash escapes are recognized and converted. EXAMPLES#include "phk_argv.h" [...] char **av; char *p; [...] av = PhkArgvParse(p, 0); if (av[0] != NULL) err(1, "Parse error: %s", av[0]); for (i = 1; av[i] != NULL; i++) printf("av[%d] = %s\n", i, av[i]); PhkArgvFree(av); SEE ALSOlibphk(3)HISTORYWritten by Poul-Henning Kamp, now part of libphk.
|