1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5da2e3ebdSchin *                      and is licensed under the                       *
6*b30d1939SAndy Fiddaman *                 Eclipse Public License, Version 1.0                  *
77c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
8da2e3ebdSchin *                                                                      *
9da2e3ebdSchin *                A copy of the License is available at                 *
10*b30d1939SAndy Fiddaman *          http://www.eclipse.org/org/documents/epl-v10.html           *
11*b30d1939SAndy Fiddaman *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12da2e3ebdSchin *                                                                      *
13da2e3ebdSchin *              Information and Software Systems Research               *
14da2e3ebdSchin *                            AT&T Research                             *
15da2e3ebdSchin *                           Florham Park NJ                            *
16da2e3ebdSchin *                                                                      *
17da2e3ebdSchin *                 Glenn Fowler <gsf@research.att.com>                  *
18da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
19da2e3ebdSchin *                   Phong Vo <kpv@research.att.com>                    *
20da2e3ebdSchin *                                                                      *
21da2e3ebdSchin ***********************************************************************/
22da2e3ebdSchin #pragma prototyped
23da2e3ebdSchin /*
24da2e3ebdSchin  * Glenn Fowler
25da2e3ebdSchin  * AT&T Research
26da2e3ebdSchin  *
27da2e3ebdSchin  * command line option parser and usage formatter private definitions
28da2e3ebdSchin  */
29da2e3ebdSchin 
30da2e3ebdSchin #ifndef _OPTLIB_H
31da2e3ebdSchin #define _OPTLIB_H
32da2e3ebdSchin 
33da2e3ebdSchin #include <ast.h>
34da2e3ebdSchin #include <cdt.h>
35da2e3ebdSchin 
36*b30d1939SAndy Fiddaman #define OPT_append		0x001
37*b30d1939SAndy Fiddaman #define OPT_cache		0x002
38*b30d1939SAndy Fiddaman #define OPT_functions		0x004
39*b30d1939SAndy Fiddaman #define OPT_ignore		0x008
40*b30d1939SAndy Fiddaman #define OPT_long		0x010
41*b30d1939SAndy Fiddaman #define OPT_minus		0x020
42*b30d1939SAndy Fiddaman #define OPT_module		0x040
43*b30d1939SAndy Fiddaman #define OPT_numeric		0x080
44*b30d1939SAndy Fiddaman #define OPT_old			0x100
45*b30d1939SAndy Fiddaman #define OPT_plus		0x200
46da2e3ebdSchin 
47*b30d1939SAndy Fiddaman #define OPT_cache_flag		0x001
48*b30d1939SAndy Fiddaman #define OPT_cache_invert	0x002
49*b30d1939SAndy Fiddaman #define OPT_cache_numeric	0x004
50*b30d1939SAndy Fiddaman #define OPT_cache_optional	0x008
51*b30d1939SAndy Fiddaman #define OPT_cache_string	0x010
52da2e3ebdSchin 
53da2e3ebdSchin #define OPT_CACHE		128
54da2e3ebdSchin #define OPT_FLAGS		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
55da2e3ebdSchin 
56da2e3ebdSchin struct Optdisc_s;
57da2e3ebdSchin 
58da2e3ebdSchin typedef struct Optpass_s
59da2e3ebdSchin {
60da2e3ebdSchin 	char*			opts;
61da2e3ebdSchin 	char*			oopts;
623e14f97fSRoger A. Faulkner 	char*			id;
63da2e3ebdSchin 	char*			catalog;
64*b30d1939SAndy Fiddaman 	char*			release;
65*b30d1939SAndy Fiddaman 	char			section[4];
66da2e3ebdSchin 	unsigned char		version;
67da2e3ebdSchin 	unsigned char		prefix;
68*b30d1939SAndy Fiddaman 	unsigned short		flags;
69da2e3ebdSchin } Optpass_t;
70da2e3ebdSchin 
71da2e3ebdSchin typedef struct Optcache_s
72da2e3ebdSchin {
73da2e3ebdSchin 	struct Optcache_s*	next;
74da2e3ebdSchin 	Optpass_t		pass;
75da2e3ebdSchin 	int			caching;
76da2e3ebdSchin 	unsigned char		flags[sizeof(OPT_FLAGS)];
77da2e3ebdSchin } Optcache_t;
78da2e3ebdSchin 
79da2e3ebdSchin typedef struct Optstate_s
80da2e3ebdSchin {
81da2e3ebdSchin 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
82da2e3ebdSchin 	Sfio_t*		vp;		/* translation string stream	*/
83da2e3ebdSchin 	Sfio_t*		xp;		/* translation string stream	*/
84da2e3ebdSchin 	Sfio_t*		cp;		/* compatibility string stream	*/
85da2e3ebdSchin 	Optpass_t	pass[8];	/* optjoin() list		*/
86da2e3ebdSchin 	char*		argv[2];	/* initial argv copy		*/
87da2e3ebdSchin 	char*		strv[3];	/* optstr() argv		*/
88da2e3ebdSchin 	char*		str;		/* optstr() string		*/
89da2e3ebdSchin 	Sfio_t*		strp;		/* optstr() stream		*/
90da2e3ebdSchin 	int		force;		/* force this style		*/
91da2e3ebdSchin 	int		pindex;		/* prev index for backup	*/
92da2e3ebdSchin 	int		poffset;	/* prev offset for backup	*/
93da2e3ebdSchin 	int		npass;		/* # optjoin() passes		*/
94da2e3ebdSchin 	int		join;		/* optjoin() pass #		*/
95da2e3ebdSchin 	int		plus;		/* + ok				*/
96da2e3ebdSchin 	int		style;		/* default opthelp() style	*/
97da2e3ebdSchin 	int		width;		/* format line width		*/
98da2e3ebdSchin 	int		flags;		/* display flags		*/
99da2e3ebdSchin 	int		emphasis;	/* ansi term emphasis ok	*/
100*b30d1939SAndy Fiddaman 	int		localized;	/* locale initialized		*/
101da2e3ebdSchin 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
102da2e3ebdSchin 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
103da2e3ebdSchin 	Optcache_t*	cache;		/* OPT_cache cache		*/
104*b30d1939SAndy Fiddaman 	char**		conformance;	/* conformance id vector	*/
105da2e3ebdSchin } Optstate_t;
106da2e3ebdSchin 
107da2e3ebdSchin #define _OPT_PRIVATE_ \
108da2e3ebdSchin 	char            pad[2*sizeof(void*)]; \
109da2e3ebdSchin 	Optstate_t*	state;
110da2e3ebdSchin 
111da2e3ebdSchin #include <error.h>
112da2e3ebdSchin 
113*b30d1939SAndy Fiddaman extern Optstate_t*	optstate(Opt_t*);
114*b30d1939SAndy Fiddaman 
115da2e3ebdSchin #endif
116