2006-05-17 04:04:09 +04:00
/** \ingroup popt
* \ file popt / poptint . h
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
2001-10-23 18:16:22 +04:00
file accompanying popt source distributions , available from
2006-05-17 04:04:09 +04:00
ftp : //ftp.rpm.org/pub/rpm/dist. */
2001-10-23 18:16:22 +04:00
# ifndef H_POPTINT
# define H_POPTINT
2006-05-17 04:04:09 +04:00
/**
* Wrapper to free ( 3 ) , hides const compilation noise , permit NULL , return NULL .
* @ param p memory to free
* @ retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
_free ( /*@only@*/ /*@null@*/ const void * p )
/*@modifies p @*/
{
if ( p ! = NULL ) free ( ( void * ) p ) ;
return NULL ;
}
2001-10-23 18:16:22 +04:00
/* Bit mask macros. */
2006-05-17 04:04:09 +04:00
/*@-exporttype -redef @*/
2001-10-23 18:16:22 +04:00
typedef unsigned int __pbm_bits ;
2006-05-17 04:04:09 +04:00
/*@=exporttype =redef @*/
2001-10-23 18:16:22 +04:00
# define __PBM_NBITS (8 * sizeof (__pbm_bits))
# define __PBM_IX(d) ((d) / __PBM_NBITS)
2006-05-17 04:04:09 +04:00
# define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
/*@-exporttype -redef @*/
2001-10-23 18:16:22 +04:00
typedef struct {
__pbm_bits bits [ 1 ] ;
} pbm_set ;
2006-05-17 04:04:09 +04:00
/*@=exporttype =redef @*/
2001-10-23 18:16:22 +04:00
# define __PBM_BITS(set) ((set)->bits)
# define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
2006-05-17 04:04:09 +04:00
# define PBM_FREE(s) _free(s);
2001-10-23 18:16:22 +04:00
# define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
# define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
# define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
struct optionStackEntry {
int argc ;
2006-05-17 04:04:09 +04:00
/*@only@*/ /*@null@*/
const char * * argv ;
/*@only@*/ /*@null@*/
pbm_set * argb ;
2001-10-23 18:16:22 +04:00
int next ;
2006-05-17 04:04:09 +04:00
/*@only@*/ /*@null@*/
const char * nextArg ;
/*@observer@*/ /*@null@*/
const char * nextCharArg ;
/*@dependent@*/ /*@null@*/
poptItem currAlias ;
2001-10-23 18:16:22 +04:00
int stuffed ;
} ;
struct poptContext_s {
struct optionStackEntry optionStack [ POPT_OPTION_DEPTH ] ;
2006-05-17 04:04:09 +04:00
/*@dependent@*/
struct optionStackEntry * os ;
/*@owned@*/ /*@null@*/
const char * * leftovers ;
2001-10-23 18:16:22 +04:00
int numLeftovers ;
int nextLeftover ;
2006-05-17 04:04:09 +04:00
/*@keep@*/
const struct poptOption * options ;
2001-10-23 18:16:22 +04:00
int restLeftover ;
2006-05-17 04:04:09 +04:00
/*@only@*/ /*@null@*/
const char * appName ;
/*@only@*/ /*@null@*/
poptItem aliases ;
2001-10-23 18:16:22 +04:00
int numAliases ;
int flags ;
2006-05-17 04:04:09 +04:00
/*@owned@*/ /*@null@*/
poptItem execs ;
2001-10-23 18:16:22 +04:00
int numExecs ;
2006-05-17 04:04:09 +04:00
/*@only@*/ /*@null@*/
const char * * finalArgv ;
2001-10-23 18:16:22 +04:00
int finalArgvCount ;
int finalArgvAlloced ;
2006-05-17 04:04:09 +04:00
/*@dependent@*/ /*@null@*/
poptItem doExec ;
/*@only@*/
const char * execPath ;
2001-10-23 18:16:22 +04:00
int execAbsolute ;
2006-05-17 04:04:09 +04:00
/*@only@*/
const char * otherHelp ;
/*@null@*/
2001-10-23 18:16:22 +04:00
pbm_set * arg_strip ;
} ;
2006-05-17 04:04:09 +04:00
# ifdef HAVE_LIBINTL_H
# include <libintl.h>
# endif
# if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
# define _(foo) gettext(foo)
# else
# define _(foo) foo
# endif
# if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
# define D_(dom, str) dgettext(dom, str)
# define POPT_(foo) D_("popt", foo)
# else
# define D_(dom, str) str
# define POPT_(foo) foo
# endif
2001-10-23 18:16:22 +04:00
2006-05-17 04:04:09 +04:00
# define N_(foo) foo
2001-10-23 18:16:22 +04:00
# endif