Tweaked some whitespace to match the latest version from autoconf.
[rsync/rsync.git] / popt / poptint.h
CommitLineData
cc248aae
WD
1/** \ingroup popt
2 * \file popt/poptint.h
3 */
4
5/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
b348deae 6 file accompanying popt source distributions, available from
cc248aae 7 ftp://ftp.rpm.org/pub/rpm/dist. */
b348deae
MP
8
9#ifndef H_POPTINT
10#define H_POPTINT
11
cc248aae
WD
12/**
13 * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
14 * @param p memory to free
15 * @retval NULL always
16 */
17/*@unused@*/ static inline /*@null@*/ void *
18_free(/*@only@*/ /*@null@*/ const void * p)
19 /*@modifies p @*/
20{
21 if (p != NULL) free((void *)p);
22 return NULL;
23}
24
b348deae
MP
25/* Bit mask macros. */
26typedef unsigned int __pbm_bits;
27#define __PBM_NBITS (8 * sizeof (__pbm_bits))
28#define __PBM_IX(d) ((d) / __PBM_NBITS)
cc248aae 29#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
b348deae
MP
30typedef struct {
31 __pbm_bits bits[1];
32} pbm_set;
33#define __PBM_BITS(set) ((set)->bits)
34
35#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
cc248aae 36#define PBM_FREE(s) _free(s);
b348deae
MP
37#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
38#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
39#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
40
41struct optionStackEntry {
42 int argc;
cc248aae
WD
43/*@only@*/ /*@null@*/ const char ** argv;
44/*@only@*/ /*@null@*/ pbm_set * argb;
b348deae 45 int next;
cc248aae
WD
46/*@only@*/ /*@null@*/ const char * nextArg;
47/*@keep@*/ /*@null@*/ const char * nextCharArg;
48/*@dependent@*/ /*@null@*/ poptItem currAlias;
b348deae
MP
49 int stuffed;
50};
51
b348deae
MP
52struct poptContext_s {
53 struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
cc248aae
WD
54/*@dependent@*/ struct optionStackEntry * os;
55/*@owned@*/ /*@null@*/ const char ** leftovers;
b348deae
MP
56 int numLeftovers;
57 int nextLeftover;
cc248aae 58/*@keep@*/ const struct poptOption * options;
b348deae 59 int restLeftover;
cc248aae
WD
60/*@only@*/ /*@null@*/ const char * appName;
61/*@only@*/ /*@null@*/ poptItem aliases;
b348deae
MP
62 int numAliases;
63 int flags;
cc248aae 64/*@owned@*/ /*@null@*/ poptItem execs;
b348deae 65 int numExecs;
cc248aae 66/*@only@*/ /*@null@*/ const char ** finalArgv;
b348deae
MP
67 int finalArgvCount;
68 int finalArgvAlloced;
cc248aae
WD
69/*@dependent@*/ /*@null@*/ poptItem doExec;
70/*@only@*/ const char * execPath;
b348deae 71 int execAbsolute;
cc248aae
WD
72/*@only@*/ const char * otherHelp;
73/*@null@*/ pbm_set * arg_strip;
b348deae
MP
74};
75
b348deae
MP
76#ifdef HAVE_LIBINTL_H
77#include <libintl.h>
78#endif
79
80#if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
81#define _(foo) gettext(foo)
82#else
cc248aae 83#define _(foo) foo
b348deae
MP
84#endif
85
86#if defined(HAVE_DGETTEXT) && !defined(__LCLINT__)
87#define D_(dom, str) dgettext(dom, str)
88#define POPT_(foo) D_("popt", foo)
89#else
cc248aae
WD
90#define D_(dom, str) str
91#define POPT_(foo) foo
b348deae
MP
92#endif
93
cc248aae 94#define N_(foo) foo
b348deae
MP
95
96#endif