Moved definition of DBL_EPSILON.
[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 25/* Bit mask macros. */
bc93ee84 26/*@-exporttype -redef @*/
b348deae 27typedef unsigned int __pbm_bits;
bc93ee84 28/*@=exporttype =redef @*/
b348deae
MP
29#define __PBM_NBITS (8 * sizeof (__pbm_bits))
30#define __PBM_IX(d) ((d) / __PBM_NBITS)
cc248aae 31#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
bc93ee84 32/*@-exporttype -redef @*/
b348deae
MP
33typedef struct {
34 __pbm_bits bits[1];
35} pbm_set;
bc93ee84 36/*@=exporttype =redef @*/
b348deae
MP
37#define __PBM_BITS(set) ((set)->bits)
38
39#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
cc248aae 40#define PBM_FREE(s) _free(s);
b348deae
MP
41#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
42#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
43#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
44
45struct optionStackEntry {
46 int argc;
bc93ee84
WD
47/*@only@*/ /*@null@*/
48 const char ** argv;
49/*@only@*/ /*@null@*/
50 pbm_set * argb;
b348deae 51 int next;
bc93ee84
WD
52/*@only@*/ /*@null@*/
53 const char * nextArg;
54/*@observer@*/ /*@null@*/
55 const char * nextCharArg;
56/*@dependent@*/ /*@null@*/
57 poptItem currAlias;
b348deae
MP
58 int stuffed;
59};
60
b348deae
MP
61struct poptContext_s {
62 struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
bc93ee84
WD
63/*@dependent@*/
64 struct optionStackEntry * os;
65/*@owned@*/ /*@null@*/
66 const char ** leftovers;
b348deae
MP
67 int numLeftovers;
68 int nextLeftover;
bc93ee84
WD
69/*@keep@*/
70 const struct poptOption * options;
b348deae 71 int restLeftover;
bc93ee84
WD
72/*@only@*/ /*@null@*/
73 const char * appName;
74/*@only@*/ /*@null@*/
75 poptItem aliases;
b348deae
MP
76 int numAliases;
77 int flags;
bc93ee84
WD
78/*@owned@*/ /*@null@*/
79 poptItem execs;
b348deae 80 int numExecs;
bc93ee84
WD
81/*@only@*/ /*@null@*/
82 const char ** finalArgv;
b348deae
MP
83 int finalArgvCount;
84 int finalArgvAlloced;
bc93ee84
WD
85/*@dependent@*/ /*@null@*/
86 poptItem doExec;
87/*@only@*/
88 const char * execPath;
b348deae 89 int execAbsolute;
bc93ee84
WD
90/*@only@*/ /*@relnull@*/
91 const char * otherHelp;
92/*@null@*/
93 pbm_set * arg_strip;
b348deae
MP
94};
95
b348deae
MP
96#ifdef HAVE_LIBINTL_H
97#include <libintl.h>
98#endif
99
100#if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
101#define _(foo) gettext(foo)
102#else
cc248aae 103#define _(foo) foo
b348deae
MP
104#endif
105
bc93ee84 106#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
b348deae
MP
107#define D_(dom, str) dgettext(dom, str)
108#define POPT_(foo) D_("popt", foo)
109#else
cc248aae
WD
110#define D_(dom, str) str
111#define POPT_(foo) foo
b348deae
MP
112#endif
113
cc248aae 114#define N_(foo) foo
b348deae
MP
115
116#endif