2001-01-03 01:19:34 +08:00
|
|
|
/** \file popt/popt.h
|
|
|
|
* \ingroup popt
|
2000-08-28 03:40:35 +08:00
|
|
|
*/
|
|
|
|
|
2000-12-20 07:22:00 +08:00
|
|
|
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
|
1998-10-17 03:05:12 +08:00
|
|
|
file accompanying popt source distributions, available from
|
2000-12-20 07:22:00 +08:00
|
|
|
ftp://ftp.rpm.org/pub/rpm/dist. */
|
1998-10-17 03:05:12 +08:00
|
|
|
|
1997-01-17 08:24:36 +08:00
|
|
|
#ifndef H_POPT
|
|
|
|
#define H_POPT
|
|
|
|
|
1998-12-29 10:35:08 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1998-09-27 22:57:03 +08:00
|
|
|
#include <stdio.h> /* for FILE * */
|
|
|
|
|
1997-01-17 08:24:36 +08:00
|
|
|
#define POPT_OPTION_DEPTH 10
|
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* \name Arg type identifiers
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_ARG_NONE 0 /*!< no arg */
|
|
|
|
#define POPT_ARG_STRING 1 /*!< arg will be saved as string */
|
|
|
|
#define POPT_ARG_INT 2 /*!< arg will be converted to int */
|
|
|
|
#define POPT_ARG_LONG 3 /*!< arg will be converted to long */
|
|
|
|
#define POPT_ARG_INCLUDE_TABLE 4 /*!< arg points to table */
|
|
|
|
#define POPT_ARG_CALLBACK 5 /*!< table-wide callback... must be
|
1998-09-27 22:57:03 +08:00
|
|
|
set first in table; arg points
|
|
|
|
to callback, descrip points to
|
|
|
|
callback data to pass */
|
2001-01-03 01:19:34 +08:00
|
|
|
#define POPT_ARG_INTL_DOMAIN 6 /*!< set the translation domain
|
1998-10-30 06:52:03 +08:00
|
|
|
for this table and any
|
|
|
|
included tables; arg points
|
|
|
|
to the domain string */
|
2001-01-03 01:19:34 +08:00
|
|
|
#define POPT_ARG_VAL 7 /*!< arg should take value val */
|
|
|
|
#define POPT_ARG_FLOAT 8 /*!< arg will be converted to float */
|
|
|
|
#define POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */
|
2000-04-24 04:37:57 +08:00
|
|
|
|
1998-10-13 22:45:18 +08:00
|
|
|
#define POPT_ARG_MASK 0x0000FFFF
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* \name Arg modifiers
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_ARGFLAG_ONEDASH 0x80000000 /*!< allow -longoption */
|
|
|
|
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /*!< don't show in help/usage */
|
|
|
|
#define POPT_ARGFLAG_STRIP 0x20000000 /*!< strip this arg from argv(only applies to long args) */
|
|
|
|
#define POPT_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing */
|
|
|
|
|
|
|
|
#define POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed */
|
|
|
|
#define POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed */
|
|
|
|
#define POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed */
|
|
|
|
#define POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed */
|
|
|
|
#define POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed */
|
|
|
|
#define POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated */
|
2000-04-24 04:37:57 +08:00
|
|
|
#define POPT_ARGFLAG_LOGICALOPS \
|
|
|
|
(POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
|
2001-06-17 08:36:01 +08:00
|
|
|
|
|
|
|
#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
|
|
|
|
/*!< set arg bit(s) */
|
|
|
|
#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
|
|
|
|
/*!< clear arg bit(s) */
|
|
|
|
|
|
|
|
#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value in --help */
|
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@}*/
|
2000-04-24 04:37:57 +08:00
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* \name Callback modifiers
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_CBFLAG_PRE 0x80000000 /*!< call the callback before parse */
|
|
|
|
#define POPT_CBFLAG_POST 0x40000000 /*!< call the callback after parse */
|
|
|
|
#define POPT_CBFLAG_INC_DATA 0x20000000 /*!< use data from the include line,
|
1998-10-27 13:38:37 +08:00
|
|
|
not the subtable */
|
2001-01-03 01:19:34 +08:00
|
|
|
#define POPT_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option */
|
|
|
|
#define POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with option */
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* \name Error return values
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_ERROR_NOARG -10 /*!< missing argument */
|
|
|
|
#define POPT_ERROR_BADOPT -11 /*!< unknown option */
|
|
|
|
#define POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */
|
|
|
|
#define POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */
|
|
|
|
#define POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno) */
|
|
|
|
#define POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */
|
|
|
|
#define POPT_ERROR_OVERFLOW -18 /*!< number too large or too small */
|
|
|
|
#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */
|
2001-05-06 03:28:32 +08:00
|
|
|
#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */
|
|
|
|
#define POPT_ERROR_MALLOC -21 /*!< memory allocation failed */
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@}*/
|
1997-01-21 06:16:31 +08:00
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* \name poptBadOption() flags
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* \name poptGetContext() flags
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
#define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */
|
|
|
|
#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv[0] */
|
|
|
|
#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args */
|
2001-06-17 23:19:26 +08:00
|
|
|
#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
*/
|
1997-01-17 08:24:36 +08:00
|
|
|
struct poptOption {
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */
|
|
|
|
char shortName; /*!< may be '\0' */
|
1997-01-18 05:58:27 +08:00
|
|
|
int argInfo;
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@shared@*/ /*@null@*/ void * arg; /*!< depends on argInfo */
|
|
|
|
int val; /*!< 0 means don't return, just update flag */
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * descrip; /*!< description for autohelp -- may be NULL */
|
|
|
|
/*@observer@*/ /*@null@*/ const char * argDescrip; /*!< argument description for autohelp */
|
1997-01-17 08:24:36 +08:00
|
|
|
};
|
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
2001-07-08 03:15:17 +08:00
|
|
|
* A popt alias argument for poptAddAlias().
|
2001-01-03 01:19:34 +08:00
|
|
|
*/
|
1997-01-17 08:24:36 +08:00
|
|
|
struct poptAlias {
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@owned@*/ /*@null@*/ const char * longName; /*!< may be NULL */
|
|
|
|
char shortName; /*!< may be '\0' */
|
1997-01-17 08:24:36 +08:00
|
|
|
int argc;
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@owned@*/ const char ** argv; /*!< must be free()able */
|
1997-01-17 08:24:36 +08:00
|
|
|
};
|
|
|
|
|
2001-07-08 03:15:17 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* A popt alias or exec argument for poptAddItem().
|
|
|
|
*/
|
|
|
|
typedef struct poptItem_s {
|
|
|
|
struct poptOption option; /*!< alias/exec name(s) and description. */
|
|
|
|
int argc; /*!< (alias) no. of args. */
|
|
|
|
/*@owned@*/ const char ** argv; /*!< (alias) args, must be free()able. */
|
|
|
|
} * poptItem;
|
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* \name Auto-generated help/usage
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2001-07-08 03:15:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Empty table marker to enable displaying popt alias/exec options.
|
|
|
|
*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@observer@*/ /*@checked@*/
|
2001-07-08 03:15:17 +08:00
|
|
|
extern struct poptOption poptAliasOptions[];
|
|
|
|
#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
|
|
|
|
0, "Options implemented via popt alias/exec:", NULL },
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto help table options.
|
|
|
|
*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@observer@*/ /*@checked@*/
|
1998-09-27 22:57:03 +08:00
|
|
|
extern struct poptOption poptHelpOptions[];
|
|
|
|
#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
|
2001-01-02 07:14:47 +08:00
|
|
|
0, "Help options:", NULL },
|
2001-07-08 03:15:17 +08:00
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
|
2001-01-03 01:19:34 +08:00
|
|
|
/*@}*/
|
1998-09-27 22:57:03 +08:00
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
*/
|
2001-05-06 03:28:32 +08:00
|
|
|
typedef /*@abstract@*/ struct poptContext_s * poptContext;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
*/
|
1998-10-27 05:20:31 +08:00
|
|
|
#ifndef __cplusplus
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-typeuse@*/
|
1998-09-27 22:57:03 +08:00
|
|
|
typedef struct poptOption * poptOption;
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@=typeuse@*/
|
1998-10-27 05:20:31 +08:00
|
|
|
#endif
|
1998-09-27 22:57:03 +08:00
|
|
|
|
1998-10-22 05:44:18 +08:00
|
|
|
enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
|
|
|
|
POPT_CALLBACK_REASON_POST,
|
|
|
|
POPT_CALLBACK_REASON_OPTION };
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Table callback prototype.
|
|
|
|
* @param con context
|
|
|
|
* @param reason reason for callback
|
|
|
|
* @param opt option that triggered callback
|
|
|
|
* @param arg @todo Document.
|
|
|
|
* @param data @todo Document.
|
|
|
|
*/
|
|
|
|
typedef void (*poptCallbackType) (poptContext con,
|
2001-05-06 03:28:32 +08:00
|
|
|
enum poptCallbackReason reason,
|
|
|
|
/*@null@*/ const struct poptOption * opt,
|
|
|
|
/*@null@*/ const char * arg,
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@null@*/ const void * data)
|
|
|
|
/*@*/;
|
1997-01-17 08:24:36 +08:00
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* Initialize popt context.
|
|
|
|
* @param name
|
|
|
|
* @param argc no. of arguments
|
|
|
|
* @param argv argument array
|
|
|
|
* @param options address of popt option table
|
|
|
|
* @param flags or'd POPT_CONTEXT_* bits
|
|
|
|
* @return initialized popt context
|
|
|
|
*/
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@only@*/ /*@null@*/ poptContext poptGetContext(
|
2001-04-29 09:05:43 +08:00
|
|
|
/*@dependent@*/ /*@keep@*/ const char * name,
|
|
|
|
int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
|
|
|
|
/*@dependent@*/ /*@keep@*/ const struct poptOption * options,
|
2001-06-04 21:55:58 +08:00
|
|
|
int flags)
|
|
|
|
/*@*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Reinitialize popt context.
|
|
|
|
* @param con context
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
void poptResetContext(/*@null@*/poptContext con)
|
|
|
|
/*@modifies con @*/;
|
1997-01-17 08:24:36 +08:00
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* Return value of next option found.
|
|
|
|
* @param con context
|
|
|
|
* @return next option val, -1 on last item, POPT_ERROR_* on error
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
int poptGetNextOpt(/*@null@*/poptContext con)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem@*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies con, fileSystem @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-redecl@*/
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
2001-06-04 21:55:58 +08:00
|
|
|
* Return next option argument (if any).
|
2001-01-03 01:19:34 +08:00
|
|
|
* @param con context
|
2001-06-04 21:55:58 +08:00
|
|
|
* @return option argument, NULL if no more options are available
|
2001-01-03 01:19:34 +08:00
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Return current option's argument.
|
|
|
|
* @param con context
|
|
|
|
* @return option argument, NULL if no more options are available
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
2001-06-04 21:55:58 +08:00
|
|
|
* Peek at current option's argument.
|
2001-01-03 01:19:34 +08:00
|
|
|
* @param con context
|
|
|
|
* @return option argument
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
|
|
|
|
/*@*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Return remaining arguments.
|
|
|
|
* @param con context
|
|
|
|
* @return argument array, terminated with NULL
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Return the option which caused the most recent error.
|
|
|
|
* @param con context
|
|
|
|
* @return offending option
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
|
|
|
|
/*@*/;
|
|
|
|
/*@=redecl@*/
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Destroy context.
|
|
|
|
* @param con context
|
2001-06-04 21:55:58 +08:00
|
|
|
* @return NULL always
|
2001-01-03 01:19:34 +08:00
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Add arguments to context.
|
|
|
|
* @param con context
|
|
|
|
* @param argv argument array, NULL terminated
|
|
|
|
* @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Add alias to context.
|
|
|
|
* @todo Pass alias by reference, not value.
|
2001-07-08 03:15:17 +08:00
|
|
|
* @deprecated Use poptAddItem instead.
|
2001-01-03 01:19:34 +08:00
|
|
|
* @param con context
|
|
|
|
* @param alias alias to add
|
|
|
|
* @param flags (unused)
|
2001-07-08 03:15:17 +08:00
|
|
|
* @return 0 on success
|
2001-01-03 01:19:34 +08:00
|
|
|
*/
|
2001-07-08 03:15:17 +08:00
|
|
|
/*@unused@*/
|
2001-06-04 21:55:58 +08:00
|
|
|
int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
2001-07-08 03:15:17 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* Add alias/exec item to context.
|
|
|
|
* @param con context
|
|
|
|
* @param item alias/exec item to add
|
|
|
|
* @param flags 0 for alias, 1 for exec
|
|
|
|
* @return 0 on success
|
|
|
|
*/
|
|
|
|
int poptAddItem(poptContext con, poptItem newItem, int flags)
|
|
|
|
/*@modifies con @*/;
|
|
|
|
|
2001-01-03 01:19:34 +08:00
|
|
|
/** \ingroup popt
|
|
|
|
* Read configuration file.
|
|
|
|
* @param con context
|
|
|
|
* @param fn file name to read
|
|
|
|
* @return 0 on success, POPT_ERROR_ERRNO on failure
|
|
|
|
*/
|
2001-05-06 03:28:32 +08:00
|
|
|
int poptReadConfigFile(poptContext con, const char * fn)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem@*/
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@modifies fileSystem,
|
|
|
|
con->execs, con->numExecs @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Read default configuration from /etc/popt and $HOME/.popt.
|
|
|
|
* @param con context
|
|
|
|
* @param useEnv (unused)
|
|
|
|
* @return 0 on success, POPT_ERROR_ERRNO on failure
|
|
|
|
*/
|
2001-05-06 03:28:32 +08:00
|
|
|
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem@*/
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@modifies fileSystem,
|
|
|
|
con->execs, con->numExecs @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Duplicate an argument array.
|
|
|
|
* @note: The argument array is malloc'd as a single area, so only argv must
|
|
|
|
* be free'd.
|
|
|
|
*
|
|
|
|
* @param argc no. of arguments
|
|
|
|
* @param argv argument array
|
|
|
|
* @retval argcPtr address of returned no. of arguments
|
|
|
|
* @retval argvPtr address of returned argument array
|
|
|
|
* @return 0 on success, POPT_ERROR_NOARG on failure
|
|
|
|
*/
|
2001-05-06 03:28:32 +08:00
|
|
|
int poptDupArgv(int argc, /*@null@*/ const char **argv,
|
|
|
|
/*@null@*/ /*@out@*/ int * argcPtr,
|
|
|
|
/*@null@*/ /*@out@*/ const char *** argvPtr)
|
|
|
|
/*@modifies *argcPtr, *argvPtr @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param s string to parse
|
|
|
|
* @retval argcPtr address of returned no. of arguments
|
|
|
|
* @retval argvPtr address of returned argument array
|
|
|
|
*/
|
1999-10-05 03:40:03 +08:00
|
|
|
int poptParseArgvString(const char * s,
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
|
|
|
|
/*@modifies *argcPtr, *argvPtr @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Return formatted error string for popt failure.
|
|
|
|
* @param error popt error
|
|
|
|
* @return error string
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-redecl@*/
|
2001-05-06 03:28:32 +08:00
|
|
|
/*@observer@*/ const char *const poptStrerror(const int error)
|
|
|
|
/*@*/;
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@=redecl@*/
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Limit search for executables.
|
|
|
|
* @param con context
|
|
|
|
* @param path single path to search for executables
|
|
|
|
* @param allowAbsolute absolute paths only?
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
|
|
|
|
/*@modifies con @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Print detailed description of options.
|
|
|
|
* @param con context
|
2001-06-06 03:26:22 +08:00
|
|
|
* @param fp ouput file handle
|
2001-01-03 01:19:34 +08:00
|
|
|
* @param flags (unused)
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies *fp, fileSystem @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Print terse description of options.
|
|
|
|
* @param con context
|
2001-06-06 03:26:22 +08:00
|
|
|
* @param fp ouput file handle
|
2001-01-03 01:19:34 +08:00
|
|
|
* @param flags (unused)
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies *fp, fileSystem @*/;
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Provide text to replace default "[OPTION...]" in help/usage output.
|
|
|
|
* @param con context
|
|
|
|
* @param text replacement text
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-fcnuse@*/
|
|
|
|
void poptSetOtherOptionHelp(poptContext con, const char * text)
|
|
|
|
/*@modifies con @*/;
|
|
|
|
/*@=fcnuse@*/
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Return argv[0] from context.
|
|
|
|
* @param con context
|
2001-06-04 21:55:58 +08:00
|
|
|
* @return argv[0]
|
2001-01-03 01:19:34 +08:00
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-redecl -fcnuse@*/
|
|
|
|
/*@observer@*/ const char * poptGetInvocationName(poptContext con)
|
|
|
|
/*@*/;
|
|
|
|
/*@=redecl =fcnuse@*/
|
2001-01-03 01:19:34 +08:00
|
|
|
|
|
|
|
/** \ingroup popt
|
|
|
|
* Shuffle argv pointers to remove stripped args, returns new argc.
|
|
|
|
* @param con context
|
2001-06-04 21:55:58 +08:00
|
|
|
* @param argc no. of args
|
|
|
|
* @param argv arg vector
|
2001-01-03 01:19:34 +08:00
|
|
|
* @return new argc
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-fcnuse@*/
|
|
|
|
int poptStrippedArgv(poptContext con, int argc, char ** argv)
|
|
|
|
/*@modifies *argv @*/;
|
|
|
|
/*@=fcnuse@*/
|
1997-01-17 08:24:36 +08:00
|
|
|
|
1998-12-29 10:35:08 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-01-17 08:24:36 +08:00
|
|
|
#endif
|