#include "system.h"#include <math.h>#include "poptint.h"

Go to the source code of this file.
Defines | |
| #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. | |
| 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. | |
| static void | cleanOSE (struct optionStackEntry *os) |
| void | poptResetContext (poptContext con) |
| Reinitialize popt context. | |
| static int | handleExec (poptContext con, const char *longName, char shortName) |
| 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. | |
| static int | execCommand (poptContext con) |
| static struct poptOption * | findOption (const struct poptOption *opt, const char *longName, size_t longNameLen, char shortName, poptCallbackType *callback, const void **callbackData, int singleDash) |
| 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) |
| int | poptSaveString (const char ***argvp, unsigned int argInfo, const char *val) |
| Add a string to an argv array. | |
| int | poptSaveLongLong (long long *arg, unsigned int argInfo, long long aLongLong) |
| Save a long long, performing logical operation with value. | |
| int | poptSaveLong (long *arg, unsigned int argInfo, long aLong) |
| Save a long, performing logical operation with value. | |
| int | poptSaveInt (int *arg, unsigned int argInfo, long aLong) |
| Save an integer, performing logical operation with value. | |
| int | poptGetNextOpt (poptContext con) |
| Return value of next option found. | |
| char * | poptGetOptArg (poptContext con) |
| Return next option argument (if any). | |
| const char * | poptGetArg (poptContext con) |
| Return next argument. | |
| const char * | poptPeekArg (poptContext con) |
| Peek at current argument. | |
| const char ** | poptGetArgs (poptContext con) |
| Return remaining arguments. | |
| static poptItem | poptFreeItems (poptItem items, int nitems) |
| poptContext | poptFreeContext (poptContext con) |
| Destroy context. | |
| int | poptAddAlias (poptContext con, struct poptAlias alias, int flags) |
| Add alias to context. | |
| int | poptAddItem (poptContext con, poptItem newItem, int flags) |
| Add alias/exec item to context. | |
| const char * | poptBadOption (poptContext con, unsigned int flags) |
| Return the option which caused the most recent error. | |
| const char * | poptStrerror (const int error) |
| Return formatted error string for popt failure. | |
| int | poptStuffArgs (poptContext con, const char **argv) |
| Add arguments to context. | |
| const char * | poptGetInvocationName (poptContext con) |
| Return argv[0] from context. | |
| int | poptStrippedArgv (poptContext con, int argc, char **argv) |
| Shuffle argv pointers to remove stripped args, returns new argc. | |
Variables | |
| static unsigned int | seed = 0 |
Definition in file popt.c.
| #define DBL_EPSILON 2.2204460492503131e-16 |
| #define LLONG_MAX 9223372036854775807LL |
| #define LLONG_MIN (-LLONG_MAX - 1LL) |
| #define POPT_ABS | ( | a | ) | ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a)) |
| static void cleanOSE | ( | struct optionStackEntry * | os | ) | [static] |
Definition at line 220 of file popt.c.
References optionStackEntry::argb, poptContext_s::optionStack, poptContext_s::os, and PBM_FREE.
Referenced by poptGetNextOpt().
| static int execCommand | ( | poptContext | con | ) | [static] |
| static const char* expandNextArg | ( | poptContext | con, | |
| const char * | s | |||
| ) | [static] |
| static const char* findNextArg | ( | poptContext | con, | |
| unsigned | argx, | |||
| int | delete_arg | |||
| ) | [static] |
Definition at line 619 of file popt.c.
References optionStackEntry::argb, optionStackEntry::argc, optionStackEntry::argv, PBM_ALLOC, PBM_ISSET, and PBM_SET.
Referenced by expandNextArg().
| static struct poptOption* findOption | ( | const struct poptOption * | opt, | |
| const char * | longName, | |||
| size_t | longNameLen, | |||
| char | shortName, | |||
| poptCallbackType * | callback, | |||
| const void ** | callbackData, | |||
| int | singleDash | |||
| ) | [static, read] |
| static const char* findProgramPath | ( | const char * | argv0 | ) | [static] |
| static int handleAlias | ( | poptContext | con, | |
| const char * | longName, | |||
| size_t | longNameLen, | |||
| char | shortName, | |||
| const char * | nextArg | |||
| ) | [static] |
< aliases nested too deeply
Definition at line 324 of file popt.c.
References poptOption::longName, poptItem_s::option, and poptOption::shortName.
| static int handleExec | ( | poptContext | con, | |
| const char * | longName, | |||
| char | shortName | |||
| ) | [static] |
< ignore exec expansions
Definition at line 264 of file popt.c.
References poptContext_s::execs, poptOption::longName, poptItem_s::option, and poptOption::shortName.
| 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 124 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.
| 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 97 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.
| 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 70 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.
| int poptAddAlias | ( | poptContext | con, | |
| struct poptAlias | alias, | |||
| int | flags | |||
| ) |
Add alias to context.
| con | context | |
| alias | alias to add | |
| flags | (unused) |
< don't show in help/usage
| int poptAddItem | ( | poptContext | con, | |
| poptItem | newItem, | |||
| int | flags | |||
| ) |
Add alias/exec item to context.
| con | context | |
| newItem | alias/exec item to add | |
| flags | 0 for alias, 1 for exec |
Definition at line 1320 of file popt.c.
Referenced by configLine().
| const char* poptBadOption | ( | poptContext | con, | |
| unsigned int | flags | |||
| ) |
| poptContext poptFreeContext | ( | poptContext | con | ) |
Destroy context.
| con | context |
Definition at line 1276 of file popt.c.
Referenced by displayArgs().
| const char* poptGetArg | ( | poptContext | con | ) |
| const char** poptGetArgs | ( | poptContext | con | ) |
Return remaining arguments.
| con | context |
Definition at line 1242 of file popt.c.
References _free(), poptOption::argDescrip, poptItem_s::argv, poptOption::descrip, poptOption::longName, and poptItem_s::option.
| poptContext poptGetContext | ( | const char * | name, | |
| int | argc, | |||
| const char ** | argv, | |||
| const struct poptOption * | options, | |||
| unsigned int | flags | |||
| ) |
Initialize popt context.
| name | context name (usually argv[0] program name) | |
| argc | no. of arguments | |
| argv | argument array | |
| options | address of popt option table | |
| flags | or'd POPT_CONTEXT_* bits |
< pay attention to argv[0]
< options can't follow args
| const char* poptGetInvocationName | ( | poptContext | con | ) |
Return argv[0] from context.
| con | context |
Definition at line 1438 of file popt.c.
References poptContext_s::arg_strip, and PBM_ISSET.
| int poptGetNextOpt | ( | poptContext | con | ) |
Return value of next option found.
| con | context |
< unknown option
< options can't follow args
< return args as options with value 0
< unknown option
< 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
< dupe'd arg appended to realloc'd argv array.
< opt->arg should not be NULL
< mutually exclusive logical operations requested
< arg will be saved as string
< arg ==> int
< arg ==> long
< arg ==> long long
< invalid numeric value
< arg ==> long long
< number too large or too small
< mutually exclusive logical operations requested
< arg ==> long
< number too large or too small
< mutually exclusive logical operations requested
< arg ==> int
< number too large or too small
< mutually exclusive logical operations requested
< mutually exclusive logical operations requested
< arg ==> float
< arg ==> double
< number too large or too small
< invalid numeric value
< arg ==> double
< number too large or too small
< number too large or too small
< EXPERIMENTAL: return (*arg) (argc, argv)
< arg should take value val
< allow -longoption
< no arg
< arg should take value val
< no arg
Definition at line 868 of file popt.c.
References cleanOSE(), and poptContext_s::os.
| char* poptGetOptArg | ( | poptContext | con | ) |
| const char* poptPeekArg | ( | poptContext | con | ) |
| void poptResetContext | ( | poptContext | con | ) |
Reinitialize popt context.
| con | context |
Definition at line 230 of file popt.c.
References _free(), and poptContext_s::finalArgv.
| int poptSaveInt | ( | int * | arg, | |
| unsigned int | argInfo, | |||
| long | aLong | |||
| ) |
Save an integer, performing logical operation with value.
| arg | integer pointer, aligned on int boundary. | |
| argInfo | logical operation (see POPT_ARGFLAG_*) | |
| aLong | value to use |
< opt->arg should not be NULL
< 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
| int poptSaveLong | ( | long * | arg, | |
| unsigned int | argInfo, | |||
| long | aLong | |||
| ) |
Save a long, performing logical operation with value.
| arg | integer pointer, aligned on int boundary. | |
| argInfo | logical operation (see POPT_ARGFLAG_*) | |
| aLong | value to use |
< opt->arg should not be NULL
< 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
| int poptSaveLongLong | ( | long long * | arg, | |
| unsigned int | argInfo, | |||
| long long | aLongLong | |||
| ) |
Save a long long, performing logical operation with value.
| arg | integer pointer, aligned on int boundary. | |
| argInfo | logical operation (see POPT_ARGFLAG_*) | |
| aLongLong | value to use |
< opt->arg should not be NULL
< 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
| int poptSaveString | ( | const char *** | argvp, | |
| unsigned int | argInfo, | |||
| const char * | val | |||
| ) |
| void poptSetExecPath | ( | poptContext | con, | |
| const char * | path, | |||
| int | allowAbsolute | |||
| ) |
Limit search for executables.
| con | context | |
| path | single path to search for executables | |
| allowAbsolute | absolute paths only? |
Definition at line 61 of file popt.c.
References _free(), poptContext_s::execAbsolute, poptContext_s::execPath, and xstrdup.
| const char* poptStrerror | ( | const int | error | ) |
Return formatted error string for popt failure.
| error | popt error |
< 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
< errno set, use strerror(errno)
< no context
| static void poptStripArg | ( | poptContext | con, | |
| int | which | |||
| ) | [static] |
| int poptStrippedArgv | ( | poptContext | con, | |
| int | argc, | |||
| char ** | argv | |||
| ) |
Shuffle argv pointers to remove stripped args, returns new argc.
| con | context | |
| argc | no. of args | |
| argv | arg vector |
Definition at line 1443 of file popt.c.
References poptContext_s::arg_strip, and PBM_ISSET.
| int poptStuffArgs | ( | poptContext | con, | |
| const char ** | argv | |||
| ) |
| static char* strerror | ( | int | errno | ) | [static] |
1.5.5