popt 1.13
|
#include "system.h"
Go to the source code of this file.
Defines | |
#define | POPT_ARGV_ARRAY_GROW_DELTA 5 |
Functions | |
int | poptDupArgv (int argc, const char **argv, int *argcPtr, const char ***argvPtr) |
Duplicate an argument array. | |
int | poptParseArgvString (const char *s, int *argcPtr, const char ***argvPtr) |
Parse a string into an argument array. | |
int | poptConfigFileToString (FILE *fp, char **argstrp, int flags) |
Parses an input configuration file and returns an string that is a command line. |
#define POPT_ARGV_ARRAY_GROW_DELTA 5 |
Definition at line 11 of file poptparse.c.
Referenced by poptParseArgvString().
int poptConfigFileToString | ( | FILE * | fp, |
char ** | argstrp, | ||
int | flags | ||
) |
Parses an input configuration file and returns an string that is a command line.
For use with popt. You must free the return value when done.
Given the file:
# this line is ignored # this one too aaa bbb ccc bla=bla this_is = fdsafdas bad_line= reall bad line reall bad line = again 5555= 55555 test = with lots of spaces
The result is:
--aaa --bbb --ccc --bla="bla" --this_is="fdsafdas" --5555="55555" --test="with lots of spaces"
Passing this to poptParseArgvString() yields an argv of:
'--aaa' '--bbb' '--ccc' '--bla=bla' '--this_is=fdsafdas' '--5555=55555' '--test=with lots of spaces'
NULL is returned if file line is too long.
Silently ignores invalid lines.
fp | file handle to read |
*argstrp | return string of options (malloc'd) |
flags | unused |
< opt->arg should not be NULL
< memory allocation failed
< number too large or too small
< memory allocation failed
< memory allocation failed
Definition at line 129 of file poptparse.c.
References _isspaceptr, POPT_ERROR_MALLOC, POPT_ERROR_NULLARG, and POPT_ERROR_OVERFLOW.
int poptDupArgv | ( | int | argc, |
const char ** | argv, | ||
int * | argcPtr, | ||
const char *** | argvPtr | ||
) |
Duplicate an argument array.
argc | no. of arguments |
argv | argument array |
argcPtr | address of returned no. of arguments |
argvPtr | address of returned argument array |
< missing argument
< missing argument
< memory allocation failed
Definition at line 13 of file poptparse.c.
References POPT_ERROR_MALLOC, and POPT_ERROR_NOARG.
Referenced by handleAlias(), poptParseArgvString(), and poptStuffArgs().
int poptParseArgvString | ( | const char * | s, |
int * | argcPtr, | ||
const char *** | argvPtr | ||
) |
Parse a string into an argument array.
The parse allows ', ", and \ quoting, but ' is treated the same as " and both may include \ quotes.
s | string to parse |
argcPtr | address of returned no. of arguments |
argvPtr | address of returned argument array |
< memory allocation failed
< error in paramter quoting
< error in paramter quoting
Definition at line 52 of file poptparse.c.
References _isspaceptr, POPT_ARGV_ARRAY_GROW_DELTA, POPT_ERROR_BADQUOTE, POPT_ERROR_MALLOC, and poptDupArgv().
Referenced by configLine().