xref: /titanic_44/usr/src/lib/libast/common/misc/optlib.h (revision e5ba14ff435beeefdaa2e6649e175c74afe02c76)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 /*
24  * Glenn Fowler
25  * AT&T Research
26  *
27  * command line option parser and usage formatter private definitions
28  */
29 
30 #ifndef _OPTLIB_H
31 #define _OPTLIB_H
32 
33 #include <ast.h>
34 #include <cdt.h>
35 
36 #define OPT_cache		0x01
37 #define OPT_functions		0x02
38 #define OPT_ignore		0x04
39 #define OPT_long		0x08
40 #define OPT_old			0x10
41 #define OPT_plus		0x20
42 #define OPT_proprietary		0x40
43 
44 #define OPT_cache_flag		0x01
45 #define OPT_cache_invert	0x02
46 #define OPT_cache_numeric	0x04
47 #define OPT_cache_optional	0x08
48 #define OPT_cache_string	0x10
49 
50 #define OPT_CACHE		128
51 #define OPT_FLAGS		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
52 
53 struct Optdisc_s;
54 
55 typedef struct Optpass_s
56 {
57 	char*			opts;
58 	char*			oopts;
59 	char*			catalog;
60 	unsigned char		version;
61 	unsigned char		prefix;
62 	unsigned char		flags;
63 	unsigned char		section;
64 } Optpass_t;
65 
66 typedef struct Optcache_s
67 {
68 	struct Optcache_s*	next;
69 	Optpass_t		pass;
70 	int			caching;
71 	unsigned char		flags[sizeof(OPT_FLAGS)];
72 } Optcache_t;
73 
74 typedef struct Optstate_s
75 {
76 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
77 	Sfio_t*		vp;		/* translation string stream	*/
78 	Sfio_t*		xp;		/* translation string stream	*/
79 	Sfio_t*		cp;		/* compatibility string stream	*/
80 	Optpass_t	pass[8];	/* optjoin() list		*/
81 	char*		argv[2];	/* initial argv copy		*/
82 	char*		strv[3];	/* optstr() argv		*/
83 	char*		str;		/* optstr() string		*/
84 	Sfio_t*		strp;		/* optstr() stream		*/
85 	int		force;		/* force this style		*/
86 	int		pindex;		/* prev index for backup	*/
87 	int		poffset;	/* prev offset for backup	*/
88 	int		npass;		/* # optjoin() passes		*/
89 	int		join;		/* optjoin() pass #		*/
90 	int		plus;		/* + ok				*/
91 	int		style;		/* default opthelp() style	*/
92 	int		width;		/* format line width		*/
93 	int		flags;		/* display flags		*/
94 	int		emphasis;	/* ansi term emphasis ok	*/
95 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
96 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
97 	Optcache_t*	cache;		/* OPT_cache cache		*/
98 } Optstate_t;
99 
100 #define _OPT_PRIVATE_ \
101 	char            pad[2*sizeof(void*)]; \
102 	Optstate_t*	state;
103 
104 #include <error.h>
105 
106 #endif
107