1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1985-2012 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 /*
23da2e3ebdSchin  * Glenn Fowler
24da2e3ebdSchin  * AT&T Research
25da2e3ebdSchin  *
26da2e3ebdSchin  * command line option parser and usage formatter private definitions
27da2e3ebdSchin  */
28da2e3ebdSchin 
29da2e3ebdSchin #ifndef _OPTLIB_H
30*b30d1939SAndy Fiddaman #define _OPTLIB_H		1
31da2e3ebdSchin 
32da2e3ebdSchin #include <ast.h>
33da2e3ebdSchin #include <cdt.h>
34da2e3ebdSchin 
35da2e3ebdSchin #define OPT_cache		0x01
36da2e3ebdSchin #define OPT_functions		0x02
37da2e3ebdSchin #define OPT_ignore		0x04
38da2e3ebdSchin #define OPT_long		0x08
39*b30d1939SAndy Fiddaman #define OPT_old			0x10
40*b30d1939SAndy Fiddaman #define OPT_plus		0x20
41*b30d1939SAndy Fiddaman #define OPT_proprietary		0x40
42da2e3ebdSchin 
43da2e3ebdSchin #define OPT_cache_flag		0x01
44da2e3ebdSchin #define OPT_cache_invert	0x02
45da2e3ebdSchin #define OPT_cache_numeric	0x04
46da2e3ebdSchin #define OPT_cache_optional	0x08
47da2e3ebdSchin #define OPT_cache_string	0x10
48da2e3ebdSchin 
49da2e3ebdSchin #define OPT_CACHE		128
50da2e3ebdSchin #define OPT_FLAGS		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
51da2e3ebdSchin 
52da2e3ebdSchin struct Optdisc_s;
53da2e3ebdSchin 
54da2e3ebdSchin typedef struct Optpass_s
55da2e3ebdSchin {
56da2e3ebdSchin 	char*			opts;
57da2e3ebdSchin 	char*			oopts;
58da2e3ebdSchin 	char*			catalog;
59da2e3ebdSchin 	unsigned char		version;
60da2e3ebdSchin 	unsigned char		prefix;
61da2e3ebdSchin 	unsigned char		flags;
62da2e3ebdSchin 	unsigned char		section;
63da2e3ebdSchin } Optpass_t;
64da2e3ebdSchin 
65da2e3ebdSchin typedef struct Optcache_s
66da2e3ebdSchin {
67da2e3ebdSchin 	struct Optcache_s*	next;
68da2e3ebdSchin 	Optpass_t		pass;
69da2e3ebdSchin 	int			caching;
70da2e3ebdSchin 	unsigned char		flags[sizeof(OPT_FLAGS)];
71da2e3ebdSchin } Optcache_t;
72da2e3ebdSchin 
73da2e3ebdSchin typedef struct Optstate_s
74da2e3ebdSchin {
75da2e3ebdSchin 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
76da2e3ebdSchin 	Sfio_t*		vp;		/* translation string stream	*/
77da2e3ebdSchin 	Sfio_t*		xp;		/* translation string stream	*/
78da2e3ebdSchin 	Sfio_t*		cp;		/* compatibility string stream	*/
79da2e3ebdSchin 	Optpass_t	pass[8];	/* optjoin() list		*/
80da2e3ebdSchin 	char*		argv[2];	/* initial argv copy		*/
81da2e3ebdSchin 	char*		strv[3];	/* optstr() argv		*/
82da2e3ebdSchin 	char*		str;		/* optstr() string		*/
83da2e3ebdSchin 	Sfio_t*		strp;		/* optstr() stream		*/
84da2e3ebdSchin 	int		force;		/* force this style		*/
85da2e3ebdSchin 	int		pindex;		/* prev index for backup	*/
86da2e3ebdSchin 	int		poffset;	/* prev offset for backup	*/
87da2e3ebdSchin 	int		npass;		/* # optjoin() passes		*/
88da2e3ebdSchin 	int		join;		/* optjoin() pass #		*/
89da2e3ebdSchin 	int		plus;		/* + ok				*/
90da2e3ebdSchin 	int		style;		/* default opthelp() style	*/
91da2e3ebdSchin 	int		width;		/* format line width		*/
92da2e3ebdSchin 	int		flags;		/* display flags		*/
93da2e3ebdSchin 	int		emphasis;	/* ansi term emphasis ok	*/
94da2e3ebdSchin 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
95da2e3ebdSchin 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
96da2e3ebdSchin 	Optcache_t*	cache;		/* OPT_cache cache		*/
97da2e3ebdSchin } Optstate_t;
98da2e3ebdSchin 
99da2e3ebdSchin #define _OPT_PRIVATE_ \
100da2e3ebdSchin 	char            pad[2*sizeof(void*)]; \
101da2e3ebdSchin 	Optstate_t*	state;
102da2e3ebdSchin 
103da2e3ebdSchin #include <error.h>
104da2e3ebdSchin 
105da2e3ebdSchin #endif
106