1/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING 2 file accompanying popt source distributions, available from 3 ftp://ftp.redhat.com/pub/code/popt */ 4 5#ifndef H_POPTINT 6#define H_POPTINT 7 8/* Bit mask macros. */ 9typedef unsigned int __pbm_bits; 10#define __PBM_NBITS (8 * sizeof (__pbm_bits)) 11#define __PBM_IX(d) ((d) / __PBM_NBITS) 12#define __PBM_MASK(d) ((__pbm_bits) 1 << ((d) % __PBM_NBITS)) 13typedef struct { 14 __pbm_bits bits[1]; 15} pbm_set; 16#define __PBM_BITS(set) ((set)->bits) 17 18#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits)) 19#define PBM_FREE(s) free(s); 20#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d)) 21#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d)) 22#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0) 23 24struct optionStackEntry { 25 int argc; 26 /*@only@*/ const char ** argv; 27 /*@only@*/ pbm_set * argb; 28 int next; 29 /*@only@*/ const char * nextArg; 30 /*@keep@*/ const char * nextCharArg; 31 /*@dependent@*/ struct poptAlias * currAlias; 32 int stuffed; 33}; 34 35struct execEntry { 36 const char * longName; 37 char shortName; 38 const char * script; 39}; 40 41struct poptContext_s { 42 struct optionStackEntry optionStack[POPT_OPTION_DEPTH]; 43 /*@dependent@*/ struct optionStackEntry * os; 44 /*@owned@*/ const char ** leftovers; 45 int numLeftovers; 46 int nextLeftover; 47 /*@keep@*/ const struct poptOption * options; 48 int restLeftover; 49 /*@only@*/ const char * appName; 50 /*@only@*/ struct poptAlias * aliases; 51 int numAliases; 52 int flags; 53 struct execEntry * execs; 54 int numExecs; 55 /*@only@*/ const char ** finalArgv; 56 int finalArgvCount; 57 int finalArgvAlloced; 58 /*@dependent@*/ struct execEntry * doExec; 59 /*@only@*/ const char * execPath; 60 int execAbsolute; 61 /*@only@*/ const char * otherHelp; 62 pbm_set * arg_strip; 63}; 64 65#define xfree(_a) free((void *)_a) 66 67#define POPT_(foo) (foo) 68#define D_(dom, str) (str) 69#define N_(foo) (foo) 70 71#endif 72