xref: /titanic_41/usr/src/lib/libast/common/misc/optlib.h (revision cde2885fdf538266ee2a3b08dee2d5075ce8fa2b)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2008 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
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_numeric		0x10
41 #define OPT_old			0x20
42 #define OPT_plus		0x40
43 #define OPT_proprietary		0x80
44 
45 #define OPT_cache_flag		0x01
46 #define OPT_cache_invert	0x02
47 #define OPT_cache_numeric	0x04
48 #define OPT_cache_optional	0x08
49 #define OPT_cache_string	0x10
50 
51 #define OPT_CACHE		128
52 #define OPT_FLAGS		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
53 
54 struct Optdisc_s;
55 
56 typedef struct Optpass_s
57 {
58 	char*			opts;
59 	char*			oopts;
60 	char*			catalog;
61 	unsigned char		version;
62 	unsigned char		prefix;
63 	unsigned char		flags;
64 	unsigned char		section;
65 } Optpass_t;
66 
67 typedef struct Optcache_s
68 {
69 	struct Optcache_s*	next;
70 	Optpass_t		pass;
71 	int			caching;
72 	unsigned char		flags[sizeof(OPT_FLAGS)];
73 } Optcache_t;
74 
75 typedef struct Optstate_s
76 {
77 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
78 	Sfio_t*		vp;		/* translation string stream	*/
79 	Sfio_t*		xp;		/* translation string stream	*/
80 	Sfio_t*		cp;		/* compatibility string stream	*/
81 	Optpass_t	pass[8];	/* optjoin() list		*/
82 	char*		argv[2];	/* initial argv copy		*/
83 	char*		strv[3];	/* optstr() argv		*/
84 	char*		str;		/* optstr() string		*/
85 	Sfio_t*		strp;		/* optstr() stream		*/
86 	int		force;		/* force this style		*/
87 	int		pindex;		/* prev index for backup	*/
88 	int		poffset;	/* prev offset for backup	*/
89 	int		npass;		/* # optjoin() passes		*/
90 	int		join;		/* optjoin() pass #		*/
91 	int		plus;		/* + ok				*/
92 	int		style;		/* default opthelp() style	*/
93 	int		width;		/* format line width		*/
94 	int		flags;		/* display flags		*/
95 	int		emphasis;	/* ansi term emphasis ok	*/
96 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
97 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
98 	Optcache_t*	cache;		/* OPT_cache cache		*/
99 } Optstate_t;
100 
101 #define _OPT_PRIVATE_ \
102 	char            pad[2*sizeof(void*)]; \
103 	Optstate_t*	state;
104 
105 #include <error.h>
106 
107 #endif
108