# popt/popt.c File Reference

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

Go to the source code of this file.

## Defines

#define | _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, 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, char shortName, const char *nextCharArg)
static int | execCommand (poptContext con)
static struct poptOption * | findOption (const struct poptOption *opt, const char *longName, 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)
static int | poptSaveLong (const struct poptOption *opt, long aLong)
static int | poptSaveInt (const struct poptOption *opt, long aLong)
int | poptGetNextOpt (poptContext con)
| Return value of next option found.
const char * | poptGetOptArg (poptContext con)
| Return next option argument (if any).
const char * | poptGetArg (poptContext con)
| Return current option's argument.
const char * | poptPeekArg (poptContext con)
| Peek at current option's argument.
const char ** | poptGetArgs (poptContext con)
| Return remaining arguments.
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, int flags)
| Return the option which caused the most recent error.
const char *const | 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.

## Detailed Description

Definition in file popt.c.

## Define Documentation

#define _ABS | ( | a |  | ) | ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))

## Function Documentation

static void cleanOSE | ( | struct optionStackEntry * | os | ) | `[static]`

Definition at line 195 of file popt.c.

static int execCommand | ( | poptContext | con | ) | `[static]`

< missing argument

< missing argument

< memory allocation failed

< missing argument

< missing argument

< errno set, use strerror(errno)

Definition at line 349 of file popt.c.

static const char* expandNextArg | ( | poptContext | con,
|  | const char * | s |
| ) |  |  | `[static]`

Definition at line 538 of file popt.c.

static const char* findNextArg | ( | poptContext | con,
|  | unsigned | argx,
|  | int | delete_arg |
| ) |  |  | `[static]`

Definition at line 500 of file popt.c.

static struct poptOption* findOption | ( | const struct poptOption * | opt,
|  | const char * | longName,
|  | char | shortName,
|  | poptCallbackType * | callback,
|  | const void ** | callbackData,
|  | int | singleDash |
| ) |  |  | `[static, read]`

< 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

< use data from the include line, not the subtable

Definition at line 434 of file popt.c.

static int handleAlias | ( | poptContext | con,
|  | const char * | longName,
|  | char | shortName,
|  | const char * | nextCharArg |
| ) |  |  | `[static]`

< aliases nested too deeply

Definition at line 297 of file popt.c.

static int handleExec | ( | poptContext | con,
|  | const char * | longName,
|  | char | shortName |
| ) |  |  | `[static]`

< ignore exec expansions

Definition at line 238 of file popt.c.

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 103 of file popt.c.

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 80 of file popt.c.

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 57 of file popt.c.

static int poptSaveInt | ( | const struct poptOption * | opt,
|  | long | aLong |
| ) |  |  | `[static]`

< 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

Definition at line 630 of file popt.c.

static int poptSaveLong | ( | const struct poptOption * | opt,
|  | long | aLong |
| ) |  |  | `[static]`

< 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

Definition at line 602 of file popt.c.

static void poptStripArg | ( | poptContext | con,
|  | int | which |
| ) |  |  | `[static]`

Definition at line 586 of file popt.c.

static char* strerror | ( | int | errno | ) | `[static]`

Definition at line 22 of file popt.c.