# popt/poptint.h

Go to the documentation of this file.

    00001
    00005 /* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
    00006    file accompanying popt source distributions, available from
    00007    ftp://ftp.rpm.org/pub/rpm/dist. */
    00008
    00009 #ifndef H_POPTINT
    00010 #define H_POPTINT
    00011
    00017 /*@unused@*/ static inline /*@null@*/ void *
    00018 _free(/*@only@*/ /*@null@*/ const void * p)
    00019         /*@modifies p @*/
    00020 {
    00021     if (p != NULL)      free((void *)p);
    00022     return NULL;
    00023 }
    00024
    00025 /* Bit mask macros. */
    00026 typedef unsigned int __pbm_bits;
    00027 #define __PBM_NBITS             (8 * sizeof (__pbm_bits))
    00028 #define __PBM_IX(d)             ((d) / __PBM_NBITS)
    00029 #define __PBM_MASK(d)           ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
    00030 typedef struct {
    00031     __pbm_bits bits[1];
    00032 } pbm_set;
    00033 #define __PBM_BITS(set) ((set)->bits)
    00034
    00035 #define PBM_ALLOC(d)    calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
    00036 #define PBM_FREE(s)     _free(s);
    00037 #define PBM_SET(d, s)   (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
    00038 #define PBM_CLR(d, s)   (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
    00039 #define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
    00040
    00041 struct optionStackEntry {
    00042     int argc;
    00043 /*@only@*/ /*@null@*/ const char ** argv;
    00044 /*@only@*/ /*@null@*/ pbm_set * argb;
    00045     int next;
    00046 /*@only@*/ /*@null@*/ const char * nextArg;
    00047 /*@keep@*/ /*@null@*/ const char * nextCharArg;
    00048 /*@dependent@*/ /*@null@*/ poptItem currAlias;
    00049     int stuffed;
    00050 };
    00051
    00052 struct poptContext_s {
    00053     struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
    00054 /*@dependent@*/ struct optionStackEntry * os;
    00055 /*@owned@*/ /*@null@*/ const char ** leftovers;
    00056     int numLeftovers;
    00057     int nextLeftover;
    00058 /*@keep@*/ const struct poptOption * options;
    00059     int restLeftover;
    00060 /*@only@*/ /*@null@*/ const char * appName;
    00061 /*@only@*/ /*@null@*/ poptItem aliases;
    00062     int numAliases;
    00063     int flags;
    00064 /*@owned@*/ /*@null@*/ poptItem execs;
    00065     int numExecs;
    00066 /*@only@*/ /*@null@*/ const char ** finalArgv;
    00067     int finalArgvCount;
    00068     int finalArgvAlloced;
    00069 /*@dependent@*/ /*@null@*/ poptItem doExec;
    00070 /*@only@*/ const char * execPath;
    00071     int execAbsolute;
    00072 /*@only@*/ const char * otherHelp;
    00073 /*@null@*/ pbm_set * arg_strip;
    00074 };
    00075
    00076 #ifdef HAVE_LIBINTL_H
    00077 #include <libintl.h>
    00078 #endif
    00079
    00080 #if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
    00081 #define _(foo) gettext(foo)
    00082 #else
    00083 #define _(foo) foo
    00084 #endif
    00085
    00086 #if defined(HAVE_DGETTEXT) && !defined(__LCLINT__)
    00087 #define D_(dom, str) dgettext(dom, str)
    00088 #define POPT_(foo) D_("popt", foo)
    00089 #else
    00090 #define D_(dom, str) str
    00091 #define POPT_(foo) foo
    00092 #endif
    00093
    00094 #define N_(foo) foo
    00095
    00096 #endif