Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
#License - #Source code - #Example Use -
#include <librock/exec.h> int librock_prsargv_split(const char *line, char ***argvp); void librock_prsargv_free(char ***argvp); char * librock_prsargv_glom(const char **av);
There is no recognition of quote, escape, or other special characters. It considers newlines and other characters to be non-spaces. librock_decbe could be helpful to the caller.
librock_prsargv_glom mallocs and creates a string by contatenating all strings in a array terminated by NULL, inserting a single space between elements. The return value is NULL on error. Return value on success should eventually be given to free().
Typical use is to break lines read from files, such as configuration files, into a list for making function calls.
#ifdef librock_TYPICAL_USE_prsargv_split #include <librock/exec.h> char **testargv = 0; /* Be sure to initialize to 0! */ int cnt; cnt = librock_prsargv_split("This is a test",&testargv); if (cnt < 0) { /* Error handling */ } else { /* Process */ int i = 0; while(i < cnt) { printf("%d: '%s'\n",i,testargv[i]); i++; } } /* . . . */ librock_prsargv_free(&testargv); #endif
malloc free strlen strcpy librock_countbl();
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.