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
#define POPT_ARG_STRING   1
#define POPT_ARG_INT   2
#define POPT_ARG_LONG   3
#define POPT_ARG_INCLUDE_TABLE   4
#define POPT_ARG_CALLBACK   5
#define POPT_ARG_INTL_DOMAIN   6
#define POPT_ARG_VAL   7
#define POPT_ARG_FLOAT   8
#define POPT_ARG_DOUBLE   9
#define POPT_ARG_MASK   0x0000FFFF

Arg modifiers

#define POPT_ARGFLAG_ONEDASH   0x80000000
#define POPT_ARGFLAG_DOC_HIDDEN   0x40000000
#define POPT_ARGFLAG_STRIP   0x20000000
#define POPT_ARGFLAG_OPTIONAL   0x10000000
#define POPT_ARGFLAG_OR   0x08000000
#define POPT_ARGFLAG_NOR   0x09000000
#define POPT_ARGFLAG_AND   0x04000000
#define POPT_ARGFLAG_NAND   0x05000000
#define POPT_ARGFLAG_XOR   0x02000000
#define POPT_ARGFLAG_NOT   0x01000000
#define POPT_ARGFLAG_LOGICALOPS

Callback modifiers

#define POPT_CBFLAG_PRE   0x80000000
#define POPT_CBFLAG_POST   0x40000000
#define POPT_CBFLAG_INC_DATA   0x20000000
#define POPT_CBFLAG_SKIPOPTION   0x10000000
#define POPT_CBFLAG_CONTINUE   0x08000000

Error return values

#define POPT_ERROR_NOARG   -10
#define POPT_ERROR_BADOPT   -11
#define POPT_ERROR_OPTSTOODEEP   -13
#define POPT_ERROR_BADQUOTE   -15
#define POPT_ERROR_ERRNO   -16
#define POPT_ERROR_BADNUMBER   -17
#define POPT_ERROR_OVERFLOW   -18
#define POPT_ERROR_BADOPERATION   -19

poptBadOption() flags

#define POPT_BADOPTION_NOALIAS   (1 << 0)

poptGetContext() flags

#define POPT_CONTEXT_NO_EXEC   (1 << 0)
#define POPT_CONTEXT_KEEP_FIRST   (1 << 1)
#define POPT_CONTEXT_POSIXMEHARDER   (1 << 2)

Auto-generated help/usage

struct poptOption poptHelpOptions []

Typedefs

typedef struct poptContext_spoptContext
typedef struct poptOption* poptOption
typedef void (* poptCallbackType )(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)

Functions

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 alias, int flags)
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)
const char* const poptStrerror (const int error)
void poptSetExecPath (poptContext con, const char *path, int allowAbsolute)
void poptPrintHelp (poptContext con, FILE *f, int flags)
void poptPrintUsage (poptContext con, FILE *f, int flags)
void poptSetOtherOptionHelp (poptContext con, const char *text)
const char* poptGetInvocationName (poptContext con)
int poptStrippedArgv (poptContext con, int argc, char **argv)

Define Documentation

#define POPT_ARGFLAG_AND   0x04000000
 

arg will be and'ed

Definition at line 55 of file popt.h.

#define POPT_ARGFLAG_DOC_HIDDEN   0x40000000
 

don't show in help/usage

Definition at line 49 of file popt.h.

#define POPT_ARGFLAG_LOGICALOPS
 

Value:

        (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)

Definition at line 59 of file popt.h.

#define POPT_ARGFLAG_NAND   0x05000000
 

arg will be nand'ed

Definition at line 56 of file popt.h.

#define POPT_ARGFLAG_NOR   0x09000000
 

arg will be nor'ed

Definition at line 54 of file popt.h.

#define POPT_ARGFLAG_NOT   0x01000000
 

arg will be negated

Definition at line 58 of file popt.h.

#define POPT_ARGFLAG_ONEDASH   0x80000000
 

allow -longoption

Definition at line 48 of file popt.h.

#define POPT_ARGFLAG_OPTIONAL   0x10000000
 

arg may be missing

Definition at line 51 of file popt.h.

#define POPT_ARGFLAG_OR   0x08000000
 

arg will be or'ed

Definition at line 53 of file popt.h.

#define POPT_ARGFLAG_STRIP   0x20000000
 

strip this arg from argv(only applies to long args)

Definition at line 50 of file popt.h.

#define POPT_ARGFLAG_XOR   0x02000000
 

arg will be xor'ed

Definition at line 57 of file popt.h.

#define POPT_ARG_CALLBACK   5
 

table-wide callback... must be set first in table; arg points to callback, descrip points to callback data to pass

Definition at line 29 of file popt.h.

#define POPT_ARG_DOUBLE   9
 

arg will be converted to double

Definition at line 39 of file popt.h.

#define POPT_ARG_FLOAT   8
 

arg will be converted to float

Definition at line 38 of file popt.h.

#define POPT_ARG_INCLUDE_TABLE   4
 

arg points to table

Definition at line 28 of file popt.h.

#define POPT_ARG_INT   2
 

arg will be converted to int

Definition at line 26 of file popt.h.

#define POPT_ARG_INTL_DOMAIN   6
 

set the translation domain for this table and any included tables; arg points to the domain string

Definition at line 33 of file popt.h.

#define POPT_ARG_LONG   3
 

arg will be converted to long

Definition at line 27 of file popt.h.

#define POPT_ARG_MASK   0x0000FFFF
 

Definition at line 41 of file popt.h.

#define POPT_ARG_NONE   0
 

no arg

Definition at line 24 of file popt.h.

#define POPT_ARG_STRING   1
 

arg will be saved as string

Definition at line 25 of file popt.h.

#define POPT_ARG_VAL   7
 

arg should take value val

Definition at line 37 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_CONTINUE   0x08000000
 

continue callbacks with option

Definition at line 72 of file popt.h.

#define POPT_CBFLAG_INC_DATA   0x20000000
 

use data from the include line, not the subtable

Definition at line 69 of file popt.h.

#define POPT_CBFLAG_POST   0x40000000
 

call the callback after parse

Definition at line 68 of file popt.h.

#define POPT_CBFLAG_PRE   0x80000000
 

call the callback before parse

Definition at line 67 of file popt.h.

#define POPT_CBFLAG_SKIPOPTION   0x10000000
 

don't callback with option

Definition at line 71 of file popt.h.

#define POPT_CONTEXT_KEEP_FIRST   (1 << 1)
 

pay attention to argv[0]

Definition at line 101 of file popt.h.

#define POPT_CONTEXT_NO_EXEC   (1 << 0)
 

ignore exec expansions

Definition at line 100 of file popt.h.

#define POPT_CONTEXT_POSIXMEHARDER   (1 << 2)
 

options can't follow args

Definition at line 102 of file popt.h.

#define POPT_ERROR_BADNUMBER   -17
 

invalid numeric value

Definition at line 84 of file popt.h.

#define POPT_ERROR_BADOPERATION   -19
 

mutually exclusive logical operations requested

Definition at line 86 of file popt.h.

#define POPT_ERROR_BADOPT   -11
 

unknown option

Definition at line 80 of file popt.h.

#define POPT_ERROR_BADQUOTE   -15
 

error in paramter quoting

Definition at line 82 of file popt.h.

#define POPT_ERROR_ERRNO   -16
 

errno set, use strerror(errno)

Definition at line 83 of file popt.h.

#define POPT_ERROR_NOARG   -10
 

missing argument

Definition at line 79 of file popt.h.

#define POPT_ERROR_OPTSTOODEEP   -13
 

aliases nested too deeply

Definition at line 81 of file popt.h.

#define POPT_ERROR_OVERFLOW   -18
 

number too large or too small

Definition at line 85 of file popt.h.


Typedef Documentation

typedef void(* poptCallbackType)(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
 

Table callback prototype.

Parameters:
con   context
reason   reason for callback
opt   option that triggered callback
arg  
Todo:
Document.

Document.

Parameters:
data  

Definition at line 158 of file popt.h.

typedef struct poptContext_s * poptContext
 

Definition at line 138 of file popt.h.

typedef struct poptOption * poptOption
 

Definition at line 143 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.

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.

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.

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.

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.

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.

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
 

Definition at line 130 of file popt.h.


Generated at Mon May 21 08:53:44 2001 for rpm by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001