popt 1.13
Defines | Functions
poptparse.c File Reference
#include "system.h"
Include dependency graph for poptparse.c:

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 Documentation

#define POPT_ARGV_ARRAY_GROW_DELTA   5

Definition at line 11 of file poptparse.c.

Referenced by poptParseArgvString().


Function Documentation

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' 
Bug:

NULL is returned if file line is too long.

Silently ignores invalid lines.

Parameters:
fpfile handle to read
*argstrpreturn string of options (malloc'd)
flagsunused
Returns:
0 on success
See also:
poptParseArgvString

< 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.

Note:
: The argument array is malloc'd as a single area, so only argv must be free'd.
Parameters:
argcno. of arguments
argvargument array
Return values:
argcPtraddress of returned no. of arguments
argvPtraddress of returned argument array
Returns:
0 on success, POPT_ERROR_NOARG on failure

< 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.

Note:
: The argument array is malloc'd as a single area, so only argv must be free'd.
Parameters:
sstring to parse
Return values:
argcPtraddress of returned no. of arguments
argvPtraddress 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().


Generated for popt by  doxygen 1.7.4