popt  1.16
Macros | Functions | Variables
popt.c File Reference
#include "system.h"
#include <math.h>
#include "poptint.h"
Include dependency graph for popt.c:

Go to the source code of this file.

Macros

#define LLONG_MAX   9223372036854775807LL
 
#define LLONG_MIN   (-LLONG_MAX - 1LL)
 
#define DBL_EPSILON   2.2204460492503131e-16
 
#define POPT_ABS(a)   ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
 

Functions

static char * strerror (int errno)
 
void poptSetExecPath (poptContext con, const char *path, int allowAbsolute)
 Limit search for executables. More...
 
static void invokeCallbacksPRE (poptContext con, const struct poptOption *opt)
 
static void invokeCallbacksPOST (poptContext con, const struct poptOption *opt)
 
static void invokeCallbacksOPTION (poptContext con, const struct poptOption *opt, const struct poptOption *myOpt, const void *myData, int shorty)
 
poptContext poptGetContext (const char *name, int argc, const char **argv, const struct poptOption *options, unsigned int flags)
 Initialize popt context. More...
 
static void cleanOSE (struct optionStackEntry *os)
 
void poptResetContext (poptContext con)
 Reinitialize popt context. More...
 
static int handleExec (poptContext con, const char *longName, char shortName)
 
static int longOptionStrcmp (const struct poptOption *opt, const char *longName, size_t longNameLen)
 Compare long option for equality, adjusting for POPT_ARGFLAG_TOGGLE. More...
 
static int handleAlias (poptContext con, const char *longName, size_t longNameLen, char shortName, const char *nextArg)
 
static const char * findProgramPath (const char *argv0)
 Return absolute path to executable by searching PATH. More...
 
static int execCommand (poptContext con)
 
static const struct poptOptionfindOption (const struct poptOption *opt, const char *longName, size_t longNameLen, char shortName, poptCallbackType *callback, const void **callbackData, unsigned int argInfo)
 
static const char * findNextArg (poptContext con, unsigned argx, int delete_arg)
 
static const char * expandNextArg (poptContext con, const char *s)
 
static void poptStripArg (poptContext con, int which)
 
static int _poptBitsNew (poptBits *bitsp)
 
int poptBitsAdd (poptBits bits, const char *s)
 
int poptBitsChk (poptBits bits, const char *s)
 
int poptBitsClr (poptBits bits)
 
int poptBitsDel (poptBits bits, const char *s)
 
int poptBitsIntersect (poptBits *ap, const poptBits b)
 
int poptBitsUnion (poptBits *ap, const poptBits b)
 
int poptBitsArgs (poptContext con, poptBits *ap)
 
int poptSaveBits (poptBits *bitsp, unsigned int argInfo, const char *s)
 Save a string into a bit set (experimental). More...
 
int poptSaveString (const char ***argvp, unsigned int argInfo, const char *val)
 Add a string to an argv array. More...
 
int poptSaveLongLong (long long *arg, unsigned int argInfo, long long aLongLong)
 Save a long long, performing logical operation with value. More...
 
int poptSaveLong (long *arg, unsigned int argInfo, long aLong)
 Save a long, performing logical operation with value. More...
 
int poptSaveInt (int *arg, unsigned int argInfo, long aLong)
 Save an integer, performing logical operation with value. More...
 
int poptSaveShort (short *arg, unsigned int argInfo, long aLong)
 Save a short integer, performing logical operation with value. More...
 
static unsigned int poptArgInfo (poptContext con, const struct poptOption *opt)
 Return argInfo field, handling POPT_ARGFLAG_TOGGLE overrides. More...
 
static int poptParseInteger (long long *llp, unsigned int argInfo, const char *val)
 Parse an integer expression. More...
 
static int poptSaveArg (poptContext con, const struct poptOption *opt)
 Save the option argument through the (*opt->arg) pointer. More...
 
int poptGetNextOpt (poptContext con)
 Return value of next option found. More...
 
char * poptGetOptArg (poptContext con)
 Return next option argument (if any). More...
 
const char * poptGetArg (poptContext con)
 Return next argument. More...
 
const char * poptPeekArg (poptContext con)
 Peek at current argument. More...
 
const char ** poptGetArgs (poptContext con)
 Return remaining arguments. More...
 
static poptItem poptFreeItems (poptItem items, int nitems)
 
poptContext poptFreeContext (poptContext con)
 Destroy context. More...
 
int poptAddAlias (poptContext con, struct poptAlias alias, int flags)
 Add alias to context. More...
 
int poptAddItem (poptContext con, poptItem newItem, int flags)
 Add alias/exec item to context. More...
 
const char * poptBadOption (poptContext con, unsigned int flags)
 Return the option which caused the most recent error. More...
 
const char * poptStrerror (const int error)
 Return formatted error string for popt failure. More...
 
int poptStuffArgs (poptContext con, const char **argv)
 Add arguments to context. More...
 
const char * poptGetInvocationName (poptContext con)
 Return argv[0] from context. More...
 
int poptStrippedArgv (poptContext con, int argc, char **argv)
 Shuffle argv pointers to remove stripped args, returns new argc. More...
 

Variables

unsigned int _poptArgMask = 0x000000FFU
 
unsigned int _poptGroupMask = 0x0000FF00U
 
unsigned int _poptBitsN = 1024U
 
unsigned int _poptBitsM = ((3U * 1024U ) / 2U)
 
unsigned int _poptBitsK = 16U
 
static unsigned int seed = 0
 

Macro Definition Documentation

◆ DBL_EPSILON

#define DBL_EPSILON   2.2204460492503131e-16

Referenced by poptSaveArg().

◆ LLONG_MAX

#define LLONG_MAX   9223372036854775807LL

Referenced by poptSaveArg().

◆ LLONG_MIN

#define LLONG_MIN   (-LLONG_MAX - 1LL)

Referenced by poptSaveArg().

◆ POPT_ABS

#define POPT_ABS (   a)    ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))

Referenced by poptSaveArg().

Function Documentation

◆ _poptBitsNew()

static int _poptBitsNew ( poptBits bitsp)
static

< opt->arg should not be NULL

Definition at line 763 of file popt.c.

References _POPT_BITS_K, _POPT_BITS_M, _POPT_BITS_N, _poptBitsK, _poptBitsM, _poptBitsN, PBM_ALLOC, and POPT_ERROR_NULLARG.

Referenced by poptBitsArgs(), poptBitsIntersect(), poptBitsUnion(), and poptSaveBits().

◆ cleanOSE()

static void cleanOSE ( struct optionStackEntry os)
static

◆ execCommand()

static int execCommand ( poptContext  con)
static

< errno set, use strerror(errno)

< missing argument

< missing argument

< memory allocation failed

< missing argument

Definition at line 476 of file popt.c.

References poptItem_s::argc, poptItem_s::argv, poptContext_s::doExec, poptContext_s::execAbsolute, poptContext_s::execPath, poptContext_s::finalArgv, poptContext_s::finalArgvCount, findProgramPath(), poptContext_s::leftovers, poptContext_s::numLeftovers, POPT_ERROR_ERRNO, POPT_ERROR_MALLOC, POPT_ERROR_NOARG, and stpcpy().

Referenced by poptGetNextOpt().

◆ expandNextArg()

static const char* expandNextArg ( poptContext  con,
const char *  s 
)
static

Definition at line 686 of file popt.c.

References findNextArg(), and stpcpy().

Referenced by poptGetNextOpt().

◆ findNextArg()

static const char* findNextArg ( poptContext  con,
unsigned  argx,
int  delete_arg 
)
static

◆ findOption()

static const struct poptOption* findOption ( const struct poptOption opt,
const char *  longName,
size_t  longNameLen,
char  shortName,
poptCallbackType callback,
const void **  callbackData,
unsigned int  argInfo 
)
static

< allow -longoption

< arg points to table

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

< allow -longoption

< allow -longoption

< use data from the include line, not the subtable

Definition at line 579 of file popt.c.

References poptOption::arg, poptArg_u::cb, CBF_ISSET, poptOption::descrip, F_ISSET, LF_ISSET, poptOption::longName, longOptionStrcmp(), poptArg_u::opt, POPT_ARG_CALLBACK, POPT_ARG_INCLUDE_TABLE, poptArgType, poptSubstituteHelpI18N, poptArg_u::ptr, and poptOption::shortName.

Referenced by poptGetNextOpt().

◆ findProgramPath()

static const char* findProgramPath ( const char *  argv0)
static

Return absolute path to executable by searching PATH.

Parameters
argv0name of executable
Returns
(malloc'd) absolute path to executable (or NULL)

Definition at line 432 of file popt.c.

References _free(), stpcpy(), and xstrdup().

Referenced by execCommand().

◆ handleAlias()

static int handleAlias ( poptContext  con,
const char *  longName,
size_t  longNameLen,
char  shortName,
const char *  nextArg 
)
static

◆ handleExec()

static int handleExec ( poptContext  con,
const char *  longName,
char  shortName 
)
static

◆ invokeCallbacksOPTION()

static void invokeCallbacksOPTION ( poptContext  con,
const struct poptOption opt,
const struct poptOption myOpt,
const void *  myData,
int  shorty 
)
static

< arg points to table

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

< don't callback with option

< continue callbacks with option

Definition at line 122 of file popt.c.

References poptOption::arg, poptArg_u::cb, CBF_ISSET, poptOption::descrip, poptOption::longName, optionStackEntry::nextArg, poptArg_u::opt, poptContext_s::os, POPT_ARG_CALLBACK, POPT_ARG_INCLUDE_TABLE, POPT_CALLBACK_REASON_OPTION, poptArgType, poptSubstituteHelpI18N, poptArg_u::ptr, and poptOption::shortName.

Referenced by poptGetNextOpt().

◆ invokeCallbacksPOST()

static void invokeCallbacksPOST ( poptContext  con,
const struct poptOption opt 
)
static

< arg points to table

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

< call the callback after parse

Definition at line 98 of file popt.c.

References poptOption::arg, poptArg_u::cb, CBF_ISSET, poptOption::descrip, poptOption::longName, poptArg_u::opt, POPT_ARG_CALLBACK, POPT_ARG_INCLUDE_TABLE, POPT_CALLBACK_REASON_POST, poptArgType, poptSubstituteHelpI18N, poptArg_u::ptr, and poptOption::shortName.

Referenced by poptGetNextOpt().

◆ invokeCallbacksPRE()

static void invokeCallbacksPRE ( poptContext  con,
const struct poptOption opt 
)
static

< arg points to table

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

< call the callback before parse

Definition at line 74 of file popt.c.

References poptOption::arg, poptArg_u::cb, CBF_ISSET, poptOption::descrip, poptOption::longName, poptArg_u::opt, POPT_ARG_CALLBACK, POPT_ARG_INCLUDE_TABLE, POPT_CALLBACK_REASON_PRE, poptArgType, poptSubstituteHelpI18N, poptArg_u::ptr, and poptOption::shortName.

Referenced by poptGetContext().

◆ longOptionStrcmp()

static int longOptionStrcmp ( const struct poptOption opt,
const char *  longName,
size_t  longNameLen 
)
static

Compare long option for equality, adjusting for POPT_ARGFLAG_TOGGLE.

Parameters
optoption
longNamearg option
longNameLenarg option length
Returns
does long option match?

< permit –[no]opt prefix toggle

Definition at line 321 of file popt.c.

References F_ISSET, and poptOption::longName.

Referenced by findOption(), and handleAlias().

◆ poptAddAlias()

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

Add alias to context.

Todo:
Pass alias by reference, not value.
Deprecated:
Use poptAddItem instead.
Parameters
concontext
aliasalias to add
flags(unused)
Returns
0 on success

< don't show in help/usage

Definition at line 1636 of file popt.c.

References poptAlias::argc, poptAlias::argv, poptAlias::longName, POPT_ARGFLAG_DOC_HIDDEN, poptAddItem(), and poptAlias::shortName.

◆ poptAddItem()

int poptAddItem ( poptContext  con,
poptItem  newItem,
int  flags 
)

Add alias/exec item to context.

Parameters
concontext
newItemalias/exec item to add
flags0 for alias, 1 for exec
Returns
0 on success

Definition at line 1654 of file popt.c.

References poptContext_s::aliases, poptOption::arg, poptItem_s::argc, poptOption::argDescrip, poptOption::argInfo, poptItem_s::argv, poptOption::descrip, poptContext_s::execs, poptOption::longName, poptContext_s::numAliases, poptContext_s::numExecs, poptItem_s::option, poptOption::shortName, poptOption::val, and xstrdup().

Referenced by poptAddAlias(), and poptConfigLine().

◆ poptArgInfo()

static unsigned int poptArgInfo ( poptContext  con,
const struct poptOption opt 
)
static

Return argInfo field, handling POPT_ARGFLAG_TOGGLE overrides.

Parameters
concontext
optoption
Returns
argInfo

< permit –[no]opt prefix toggle

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be negated

Definition at line 1131 of file popt.c.

References poptOption::argInfo, optionStackEntry::argv, LF_ISSET, poptOption::longName, optionStackEntry::next, poptContext_s::os, POPT_ARGFLAG_AND, POPT_ARGFLAG_NOT, and POPT_ARGFLAG_OR.

Referenced by poptGetNextOpt(), and poptSaveArg().

◆ poptBadOption()

const char* poptBadOption ( poptContext  con,
unsigned int  flags 
)

Return the option which caused the most recent error.

Parameters
concontext
flags
Returns
offending option

< don't go into an alias

Definition at line 1697 of file popt.c.

References optionStackEntry::argv, optionStackEntry::next, poptContext_s::optionStack, poptContext_s::os, and POPT_BADOPTION_NOALIAS.

◆ poptBitsAdd()

int poptBitsAdd ( poptBits  bits,
const char *  s 
)

< opt->arg should not be NULL

Definition at line 785 of file popt.c.

References _poptBitsK, _poptBitsM, PBM_SET, POPT_ERROR_NULLARG, and poptJlu32lpair().

Referenced by poptBitsArgs(), and poptSaveBits().

◆ poptBitsArgs()

int poptBitsArgs ( poptContext  con,
poptBits ap 
)

< opt->arg should not be NULL

Definition at line 897 of file popt.c.

References _poptBitsNew(), poptContext_s::leftovers, poptContext_s::nextLeftover, poptContext_s::numLeftovers, POPT_ERROR_NULLARG, and poptBitsAdd().

◆ poptBitsChk()

int poptBitsChk ( poptBits  bits,
const char *  s 
)

< opt->arg should not be NULL

Definition at line 804 of file popt.c.

References _poptBitsK, _poptBitsM, PBM_ISSET, POPT_ERROR_NULLARG, and poptJlu32lpair().

Referenced by poptSaveBits().

◆ poptBitsClr()

int poptBitsClr ( poptBits  bits)

< opt->arg should not be NULL

Definition at line 827 of file popt.c.

References __PBM_IX, __PBM_NBITS, _poptBitsM, and POPT_ERROR_NULLARG.

◆ poptBitsDel()

int poptBitsDel ( poptBits  bits,
const char *  s 
)

< opt->arg should not be NULL

Definition at line 838 of file popt.c.

References _poptBitsK, _poptBitsM, PBM_CLR, POPT_ERROR_NULLARG, and poptJlu32lpair().

Referenced by poptSaveBits().

◆ poptBitsIntersect()

int poptBitsIntersect ( poptBits ap,
const poptBits  b 
)

< opt->arg should not be NULL

Definition at line 857 of file popt.c.

References __PBM_BITS, __PBM_IX, _poptBitsM, _poptBitsNew(), and POPT_ERROR_NULLARG.

◆ poptBitsUnion()

int poptBitsUnion ( poptBits ap,
const poptBits  b 
)

< opt->arg should not be NULL

Definition at line 877 of file popt.c.

References __PBM_BITS, __PBM_IX, _poptBitsM, _poptBitsNew(), and POPT_ERROR_NULLARG.

◆ poptFreeContext()

poptContext poptFreeContext ( poptContext  con)

◆ poptFreeItems()

static poptItem poptFreeItems ( poptItem  items,
int  nitems 
)
static

◆ poptGetArg()

const char* poptGetArg ( poptContext  con)

Return next argument.

Parameters
concontext
Returns
next argument, NULL if no argument is available

Definition at line 1563 of file popt.c.

References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.

◆ poptGetArgs()

const char** poptGetArgs ( poptContext  con)

Return remaining arguments.

Parameters
concontext
Returns
argument array, NULL terminated

Definition at line 1579 of file popt.c.

References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.

◆ poptGetContext()

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

Initialize popt context.

Parameters
namecontext name (usually argv[0] program name)
argcno. of arguments
argvargument array
optionsaddress of popt option table
flagsor'd POPT_CONTEXT_* bits
Returns
initialized popt context

< pay attention to argv[0]

< options can't follow args

Definition at line 168 of file popt.c.

References poptContext_s::aliases, poptContext_s::appName, poptContext_s::arg_strip, optionStackEntry::argb, optionStackEntry::argc, optionStackEntry::argv, poptContext_s::execAbsolute, poptContext_s::execs, poptContext_s::finalArgv, poptContext_s::finalArgvAlloced, poptContext_s::flags, invokeCallbacksPRE(), poptContext_s::leftovers, optionStackEntry::next, poptContext_s::numAliases, poptContext_s::numExecs, poptContext_s::options, poptContext_s::optionStack, poptContext_s::os, POPT_CONTEXT_KEEP_FIRST, POPT_CONTEXT_POSIXMEHARDER, and xstrdup().

Referenced by poptInit().

◆ poptGetInvocationName()

const char* poptGetInvocationName ( poptContext  con)

Return argv[0] from context.

Parameters
concontext
Returns
argv[0]

Definition at line 1760 of file popt.c.

References optionStackEntry::argv, and poptContext_s::os.

◆ poptGetNextOpt()

int poptGetNextOpt ( poptContext  con)

Return value of next option found.

Parameters
concontext
Returns
next option val, -1 on last item, POPT_ERROR_* on error

< unknown option

< options can't follow args

< return args as options with value 0

< unknown option

< allow -longoption

< allow -longoption

< unknown option

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

< unknown option

< unknown option

< no arg

< mutually exclusive logical operations requested

< arg should take value val

< mutually exclusive logical operations requested

< no arg

< arg may be missing

< missing argument

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

< arg may be missing

< arg should take value val

< allow -longoption

< no arg

< arg should take value val

< no arg

Definition at line 1299 of file popt.c.

References _free(), poptOption::arg, optionStackEntry::argb, optionStackEntry::argc, poptOption::argInfo, optionStackEntry::argv, cleanOSE(), poptContext_s::doExec, execCommand(), expandNextArg(), F_ISSET, poptContext_s::finalArgv, poptContext_s::finalArgvAlloced, poptContext_s::finalArgvCount, findOption(), poptContext_s::flags, handleAlias(), handleExec(), invokeCallbacksOPTION(), invokeCallbacksPOST(), poptContext_s::leftovers, LF_ISSET, poptOption::longName, poptContext_s::maincall, optionStackEntry::next, optionStackEntry::nextArg, optionStackEntry::nextCharArg, poptContext_s::numLeftovers, poptContext_s::options, poptContext_s::optionStack, poptContext_s::os, PBM_ISSET, POPT_ARG_NONE, POPT_ARG_VAL, POPT_ARGFLAG_ONEDASH, POPT_CONTEXT_ARG_OPTS, POPT_CONTEXT_POSIXMEHARDER, POPT_ERROR_BADOPERATION, POPT_ERROR_BADOPT, POPT_ERROR_NOARG, poptArgInfo(), poptArgType, poptSaveArg(), poptSaveInt(), poptStripArg(), poptContext_s::restLeftover, poptOption::shortName, stpcpy(), poptOption::val, and xstrdup().

◆ poptGetOptArg()

char* poptGetOptArg ( poptContext  con)

Return next option argument (if any).

Parameters
concontext
Returns
option argument, NULL if no argument is available

Definition at line 1553 of file popt.c.

References optionStackEntry::nextArg, and poptContext_s::os.

◆ poptParseInteger()

static int poptParseInteger ( long long *  llp,
unsigned int  argInfo,
const char *  val 
)
static

Parse an integer expression.

Return values
*llpinteger expression value
Parameters
argInfointeger expression type
valinteger expression string
Returns
0 on success, otherwise POPT_* error.

< invalid numeric value

Definition at line 1161 of file popt.c.

References POPT_ERROR_BADNUMBER.

Referenced by poptSaveArg().

◆ poptPeekArg()

const char* poptPeekArg ( poptContext  con)

Peek at current argument.

Parameters
concontext
Returns
current argument, NULL if no argument is available

Definition at line 1571 of file popt.c.

References poptContext_s::leftovers, poptContext_s::nextLeftover, and poptContext_s::numLeftovers.

◆ poptResetContext()

void poptResetContext ( poptContext  con)

◆ poptSaveArg()

static int poptSaveArg ( poptContext  con,
const struct poptOption opt 
)
static

Save the option argument through the (*opt->arg) pointer.

Parameters
concontext
optoption
Returns
0 on success, otherwise POPT_* error.

< arg ==> bit set

< dupe'd arg appended to realloc'd argv array.

< arg will be saved as string

< arg ==> int

< arg ==> short

< arg ==> long

< arg ==> long long

< arg ==> long long

< number too large or too small

< arg ==> long

< number too large or too small

< arg ==> int

< number too large or too small

< arg ==> short

< number too large or too small

< arg ==> float

< arg ==> double

< number too large or too small

< invalid numeric value

< arg ==> double

< arg ==> float

< number too large or too small

< EXPERIMENTAL: return (*arg) (argc, argv)

Definition at line 1185 of file popt.c.

References poptOption::arg, poptOption::argInfo, poptArg_u::argv, DBL_EPSILON, poptArg_u::doublep, poptArg_u::floatp, poptArg_u::intp, LLONG_MAX, LLONG_MIN, poptArg_u::longlongp, poptArg_u::longp, poptContext_s::maincall, optionStackEntry::nextArg, poptContext_s::os, POPT_, POPT_ABS, POPT_ARG_ARGV, POPT_ARG_BITSET, POPT_ARG_DOUBLE, POPT_ARG_FLOAT, POPT_ARG_INT, POPT_ARG_LONG, POPT_ARG_LONGLONG, POPT_ARG_MAINCALL, POPT_ARG_SHORT, POPT_ARG_STRING, POPT_ERROR_BADNUMBER, POPT_ERROR_OVERFLOW, poptArgInfo(), poptArgType, poptParseInteger(), poptSaveBits(), poptSaveInt(), poptSaveLong(), poptSaveLongLong(), poptSaveShort(), poptSaveString(), poptArg_u::ptr, poptArg_u::shortp, and xstrdup().

Referenced by poptGetNextOpt().

◆ poptSaveBits()

int poptSaveBits ( poptBits bitsp,
unsigned int  argInfo,
const char *  s 
)

Save a string into a bit set (experimental).

Return values
*bitsbit set (lazily malloc'd if NULL)
Parameters
argInfological operation (see POPT_ARGFLAG_*)
sstring to add to bit set
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

Definition at line 918 of file popt.c.

References _free(), _poptBitsNew(), POPT_ERROR_NULLARG, poptBitsAdd(), poptBitsChk(), poptBitsDel(), and xstrdup().

Referenced by poptSaveArg().

◆ poptSaveInt()

int poptSaveInt ( int *  arg,
unsigned int  argInfo,
long  aLong 
)

Save an integer, performing logical operation with value.

Warning
Alignment check may be too strict on certain platorms.
Parameters
arginteger pointer, aligned on int boundary.
argInfological operation (see POPT_ARGFLAG_*)
aLongvalue to use
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

< random value in [1,arg]

< mutually exclusive logical operations requested

< arg will be negated

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< mutually exclusive logical operations requested

Definition at line 1056 of file popt.c.

References LF_ISSET, POPT_ARGFLAG_AND, POPT_ARGFLAG_OR, POPT_ARGFLAG_XOR, POPT_ERROR_BADOPERATION, and POPT_ERROR_NULLARG.

Referenced by poptGetNextOpt(), and poptSaveArg().

◆ poptSaveLong()

int poptSaveLong ( long *  arg,
unsigned int  argInfo,
long  aLong 
)

Save a long, performing logical operation with value.

Warning
Alignment check may be too strict on certain platorms.
Parameters
arginteger pointer, aligned on int boundary.
argInfological operation (see POPT_ARGFLAG_*)
aLongvalue to use
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

< random value in [1,arg]

< mutually exclusive logical operations requested

< arg will be negated

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< mutually exclusive logical operations requested

Definition at line 1023 of file popt.c.

References LF_ISSET, POPT_ARGFLAG_AND, POPT_ARGFLAG_OR, POPT_ARGFLAG_XOR, POPT_ERROR_BADOPERATION, and POPT_ERROR_NULLARG.

Referenced by poptSaveArg().

◆ poptSaveLongLong()

int poptSaveLongLong ( long long *  arg,
unsigned int  argInfo,
long long  aLongLong 
)

Save a long long, performing logical operation with value.

Warning
Alignment check may be too strict on certain platorms.
Parameters
arginteger pointer, aligned on int boundary.
argInfological operation (see POPT_ARGFLAG_*)
aLongLongvalue to use
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

< random value in [1,arg]

< mutually exclusive logical operations requested

< arg will be negated

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< mutually exclusive logical operations requested

Definition at line 978 of file popt.c.

References LF_ISSET, POPT_ARGFLAG_AND, POPT_ARGFLAG_OR, POPT_ARGFLAG_XOR, POPT_ERROR_BADOPERATION, and POPT_ERROR_NULLARG.

Referenced by poptSaveArg().

◆ poptSaveShort()

int poptSaveShort ( short *  arg,
unsigned int  argInfo,
long  aLong 
)

Save a short integer, performing logical operation with value.

Warning
Alignment check may be too strict on certain platorms.
Parameters
argshort pointer, aligned on short boundary.
argInfological operation (see POPT_ARGFLAG_*)
aLongvalue to use
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

< random value in [1,arg]

< mutually exclusive logical operations requested

< arg will be negated

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< arg will be or'ed

< arg will be and'ed

< arg will be xor'ed

< mutually exclusive logical operations requested

Definition at line 1089 of file popt.c.

References LF_ISSET, POPT_ARGFLAG_AND, POPT_ARGFLAG_OR, POPT_ARGFLAG_XOR, POPT_ERROR_BADOPERATION, and POPT_ERROR_NULLARG.

Referenced by poptSaveArg().

◆ poptSaveString()

int poptSaveString ( const char ***  argvp,
unsigned int  argInfo,
const char *  val 
)

Add a string to an argv array.

Return values
*argvpargv array
Parameters
argInfo(unused)
valstring arg to add (using strdup)
Returns
0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION

< opt->arg should not be NULL

Definition at line 953 of file popt.c.

References optionStackEntry::argc, POPT_ERROR_NULLARG, xrealloc(), and xstrdup().

Referenced by poptSaveArg().

◆ poptSetExecPath()

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

Limit search for executables.

Parameters
concontext
pathsingle path to search for executables
allowAbsoluteabsolute paths only?

Definition at line 66 of file popt.c.

References _free(), poptContext_s::execAbsolute, poptContext_s::execPath, and xstrdup().

◆ poptStrerror()

const char* poptStrerror ( const int  error)

Return formatted error string for popt failure.

Parameters
errorpopt error
Returns
error string

< missing argument

< unknown option

< mutually exclusive logical operations requested

< opt->arg should not be NULL

< aliases nested too deeply

< error in paramter quoting

< invalid numeric value

< number too large or too small

< memory allocation failed

< config file failed sanity test

< errno set, use strerror(errno)

Definition at line 1707 of file popt.c.

References POPT_, POPT_ERROR_BADCONFIG, POPT_ERROR_BADNUMBER, POPT_ERROR_BADOPERATION, POPT_ERROR_BADOPT, POPT_ERROR_BADQUOTE, POPT_ERROR_ERRNO, POPT_ERROR_MALLOC, POPT_ERROR_NOARG, POPT_ERROR_NULLARG, POPT_ERROR_OPTSTOODEEP, POPT_ERROR_OVERFLOW, and strerror().

◆ poptStripArg()

static void poptStripArg ( poptContext  con,
int  which 
)
static

◆ poptStrippedArgv()

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

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

Parameters
concontext
argcno. of args
argvarg vector
Returns
new argc

Definition at line 1765 of file popt.c.

References poptContext_s::arg_strip, optionStackEntry::argc, and PBM_ISSET.

◆ poptStuffArgs()

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

Add arguments to context.

Parameters
concontext
argvargument array, NULL terminated
Returns
0 on success, POPT_ERROR_OPTSTOODEEP on failure

< aliases nested too deeply

Definition at line 1737 of file popt.c.

References optionStackEntry::argb, optionStackEntry::argc, optionStackEntry::argv, optionStackEntry::currAlias, optionStackEntry::next, optionStackEntry::nextArg, optionStackEntry::nextCharArg, poptContext_s::optionStack, poptContext_s::os, POPT_ERROR_OPTSTOODEEP, POPT_OPTION_DEPTH, poptDupArgv(), and optionStackEntry::stuffed.

◆ strerror()

static char* strerror ( int  errno)
static

Variable Documentation

◆ _poptArgMask

unsigned int _poptArgMask = 0x000000FFU

Definition at line 34 of file popt.c.

◆ _poptBitsK

unsigned int _poptBitsK = 16U

Definition at line 760 of file popt.c.

Referenced by _poptBitsNew(), poptBitsAdd(), poptBitsChk(), and poptBitsDel().

◆ _poptBitsM

unsigned int _poptBitsM = ((3U * 1024U ) / 2U)

◆ _poptBitsN

unsigned int _poptBitsN = 1024U

Definition at line 756 of file popt.c.

Referenced by _poptBitsNew().

◆ _poptGroupMask

unsigned int _poptGroupMask = 0x0000FF00U

Definition at line 36 of file popt.c.

◆ seed

unsigned int seed = 0
static

Definition at line 976 of file popt.c.


Generated for popt by  doxygen 1.8.13