Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

popt/poptparse.c File Reference

More...

#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)
int poptParseArgvString (const char *s, int *argcPtr, const char ***argvPtr)
int poptConfigFileToString (FILE *fp, char **argstrp, int flags)


Detailed Description

Definition in file poptparse.c.


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:
fp  file handle to read
argstrp  return string of options (malloc'd)
flags  unused
Returns:
0 on success
See also:
poptParseArgvString

Definition at line 129 of file poptparse.c.

References 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:
argc  no. of arguments
argv  argument array
Return values:
argcPtr  address of returned no. of arguments
argvPtr  address of returned argument array
Returns:
0 on success, POPT_ERROR_NOARG on failure

Definition at line 14 of file poptparse.c.

References argv, 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:
s  string to parse
Return values:
argcPtr  address of returned no. of arguments
argvPtr  address of returned argument array

Definition at line 57 of file poptparse.c.

References alloca(), argv, POPT_ARGV_ARRAY_GROW_DELTA, POPT_ERROR_BADQUOTE, POPT_ERROR_MALLOC, and poptDupArgv().

Referenced by addOrAppendListEntry(), checkPassPhrase(), configLine(), doScript(), doSetupMacro(), handlePreambleTag(), ignoreDep(), makeGPGSignature(), makePGPSignature(), open_dso(), parseDescription(), parseFiles(), parseScript(), rpmfcExec(), and rpmGlob().


Generated on Sun Oct 26 13:02:06 2003 for rpm by doxygen1.2.18