Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

POPT.


Files

file  findme.c
file  findme.h
file  popt.c
file  popt.h
file  poptconfig.c
file  popthelp.c
file  poptint.h
file  poptparse.c

Compounds

struct  poptAlias
struct  poptOption

Arg type identifiers

#define POPT_ARG_NONE   0

Arg modifiers

#define POPT_ARGFLAG_ONEDASH   0x80000000

Callback modifiers

#define POPT_CBFLAG_PRE   0x80000000

Error return values

#define POPT_ERROR_NOARG   -10

poptBadOption() flags

#define POPT_BADOPTION_NOALIAS   (1 << 0)

poptGetContext() flags

#define POPT_CONTEXT_NO_EXEC   (1 << 0)

Auto-generated help/usage

struct poptOption poptHelpOptions []

Functions

int poptReadConfigFile (poptContext con, const char * fn)
int poptReadDefaultConfig (poptContext con, int useEnv)
int poptDupArgv (int argc, const char **argv, int * argcPtr, const char *** argvPtr)
int poptParseArgvString (const char * s, int * argcPtr, const char *** argvPtr)
void poptPrintHelp (poptContext con, FILE * f, int flags)
void poptPrintUsage (poptContext con, FILE * f, int flags)
void poptSetOtherOptionHelp (poptContext con, const char * text)
poptContext poptGetContext (const char * name, int argc, const char ** argv, const struct poptOption * options, int flags)
void poptResetContext (poptContext con)
int poptGetNextOpt (poptContext con)
const char* poptGetOptArg (poptContext con)
const char* poptGetArg (poptContext con)
const char* poptPeekArg (poptContext con)
const char** poptGetArgs (poptContext con)
const char* poptBadOption (poptContext con, int flags)
void poptFreeContext (poptContext con)
int poptStuffArgs (poptContext con, const char ** argv)
int poptAddAlias (poptContext con, struct poptAlias newAlias, int flags)
const char* const poptStrerror (const int error)
void poptSetExecPath (poptContext con, const char * path, int allowAbsolute)
const char* poptGetInvocationName (poptContext con)
int poptStrippedArgv (poptContext con, int argc, char **argv)

Define Documentation

#define POPT_ARGFLAG_ONEDASH   0x80000000
 

allow -longoption

Definition at line 48 of file popt.h.

#define POPT_ARG_NONE   0
 

no arg

Definition at line 24 of file popt.h.

#define POPT_BADOPTION_NOALIAS   (1 << 0)
 

don't go into an alias

Definition at line 93 of file popt.h.

#define POPT_CBFLAG_PRE   0x80000000
 

call the callback before parse

Definition at line 67 of file popt.h.

#define POPT_CONTEXT_NO_EXEC   (1 << 0)
 

ignore exec expansions

Definition at line 100 of file popt.h.

#define POPT_ERROR_NOARG   -10
 

missing argument

Definition at line 79 of file popt.h.


Function Documentation

int poptAddAlias ( poptContext con,
struct poptAlias alias,
int flags )
 

Add alias to context.

Todo:
Pass alias by reference, not value.
Parameters:
con   context
alias   alias to add
flags   (unused)
Returns:
0 always

Definition at line 855 of file popt.c.

Referenced by configLine().

const char * poptBadOption ( poptContext con,
int flags )
 

Return the option which caused the most recent error.

Parameters:
con   context
Returns:
offending option

Definition at line 879 of file popt.c.

Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), and parseScript().

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 13 of file poptparse.c.

Referenced by handleAlias(), poptParseArgvString(), and poptStuffArgs().

void poptFreeContext ( poptContext con )
 

Destroy context.

Parameters:
con   context

Definition at line 827 of file popt.c.

Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), and parseScript().

const char * poptGetArg ( poptContext con )
 

Return current option's argument.

Parameters:
con   context
Returns:
option argument, NULL if no more options are available

Definition at line 806 of file popt.c.

Referenced by main(), parseDescription(), parseFiles(), and parseScript().

const char ** poptGetArgs ( poptContext con )
 

Return remaining arguments.

Parameters:
con   context
Returns:
argument array, terminated with NULL

Definition at line 818 of file popt.c.

Referenced by main().

poptContext poptGetContext ( const char * name,
int argc,
const char ** argv,
const struct poptOption * options,
int flags )
 

Initialize popt context.

Parameters:
name  
argc   no. of arguments
argv   argument array
options   address of popt option table
flags   or'd POPT_CONTEXT_* bits
Returns:
initialized popt context

Definition at line 102 of file popt.c.

Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), and parseScript().

const char * poptGetInvocationName ( poptContext con )
 

Return argv[0] from context.

Parameters:
con   context

Definition at line 934 of file popt.c.

int poptGetNextOpt ( poptContext con )
 

Return value of next option found.

Parameters:
con   context
Returns:
next option val, -1 on last item, POPT_ERROR_* on error

Definition at line 531 of file popt.c.

Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), and parseScript().

const char * poptGetOptArg ( poptContext con )
 

Parameters:
con   context

Definition at line 800 of file popt.c.

Referenced by doSetupMacro(), and main().

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 42 of file poptparse.c.

Referenced by addOrAppendListEntry(), configLine(), doScript(), doSetupMacro(), execCommand(), ftpGlob(), handlePreambleTag(), parseDescription(), parseFiles(), parseScript(), and rpmGlob().

const char * poptPeekArg ( poptContext con )
 

Peek at current option's argument.

Parameters:
con   context
Returns:
option argument

Definition at line 812 of file popt.c.

Referenced by main(), parseDescription(), parseFiles(), and parseScript().

void poptPrintHelp ( poptContext con,
FILE * f,
int flags )
 

Print detailed description of options.

Parameters:
con   context
f   ouput file handle
flags   (unused)

Definition at line 252 of file popthelp.c.

Referenced by displayArgs().

void poptPrintUsage ( poptContext con,
FILE * f,
int flags )
 

Print terse description of options.

Parameters:
con   context
f   ouput file handle
flags   (unused)

Definition at line 346 of file popthelp.c.

Referenced by displayArgs().

int poptReadConfigFile ( poptContext con,
const char * fn )
 

Read configuration file.

Parameters:
con   context
fn   file name to read
Returns:
0 on success, POPT_ERROR_ERRNO on failure

Definition at line 61 of file poptconfig.c.

Referenced by main(), and poptReadDefaultConfig().

int poptReadDefaultConfig ( poptContext con,
int useEnv )
 

Read default configuration from /etc/popt and $HOME/.popt.

Parameters:
con   context
useEnv   (unused)
Returns:
0 on success, POPT_ERROR_ERRNO on failure

Definition at line 121 of file poptconfig.c.

Referenced by main().

void poptResetContext ( poptContext con )
 

Reinitialize popt context.

Parameters:
con   context

Definition at line 156 of file popt.c.

Referenced by main(), and poptFreeContext().

void poptSetExecPath ( poptContext con,
const char * path,
int allowAbsolute )
 

Limit search for executables.

Parameters:
con   context
path   single path to search for executables
allowAbsolute   absolute paths only?

Definition at line 33 of file popt.c.

Referenced by main().

void poptSetOtherOptionHelp ( poptContext con,
const char * text )
 

Provide text to replace default "[OPTION...]" in help/usage output.

Parameters:
con   context
text   replacement text

Definition at line 363 of file popthelp.c.

const char *const poptStrerror ( const int error )
 

Return formatted error string for popt failure.

Parameters:
error   popt error
Returns:
error string

Definition at line 890 of file popt.c.

Referenced by doSetupMacro(), main(), parseDescription(), parseFiles(), and parseScript().

int poptStrippedArgv ( poptContext con,
int argc,
char ** argv )
 

Shuffle argv pointers to remove stripped args, returns new argc.

Parameters:
con   context
Returns:
new argc

Definition at line 938 of file popt.c.

int poptStuffArgs ( poptContext con,
const char ** argv )
 

Add arguments to context.

Parameters:
con   context
argv   argument array, NULL terminated
Returns:
0 on success, POPT_ERROR_OPTSTOODEEP on failure

Definition at line 913 of file popt.c.

Referenced by main().


Variable Documentation

struct poptOption poptHelpOptions[]
 

Initializer:

{
    { NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL, NULL },
    { "help", '?', 0, NULL, '?',  "Show this help message" , NULL },
    { "usage", '\0', 0, NULL, 'u',  "Display brief usage message" , NULL },
    POPT_TABLEEND
}

Definition at line 26 of file popthelp.c.


Generated at Sun Apr 8 18:43:08 2001 for rpm by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000