xref: /titanic_44/usr/src/lib/libast/common/misc/optlib.h (revision a60349c89adffc0902b2353230891d8e7f2b24d9)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2010 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_minus		0x40
43 #define OPT_plus		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*			id;
61 	char*			catalog;
62 	unsigned char		version;
63 	unsigned char		prefix;
64 	unsigned char		flags;
65 	unsigned char		section;
66 } Optpass_t;
67 
68 typedef struct Optcache_s
69 {
70 	struct Optcache_s*	next;
71 	Optpass_t		pass;
72 	int			caching;
73 	unsigned char		flags[sizeof(OPT_FLAGS)];
74 } Optcache_t;
75 
76 typedef struct Optstate_s
77 {
78 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
79 	Sfio_t*		vp;		/* translation string stream	*/
80 	Sfio_t*		xp;		/* translation string stream	*/
81 	Sfio_t*		cp;		/* compatibility string stream	*/
82 	Optpass_t	pass[8];	/* optjoin() list		*/
83 	char*		argv[2];	/* initial argv copy		*/
84 	char*		strv[3];	/* optstr() argv		*/
85 	char*		str;		/* optstr() string		*/
86 	Sfio_t*		strp;		/* optstr() stream		*/
87 	int		force;		/* force this style		*/
88 	int		pindex;		/* prev index for backup	*/
89 	int		poffset;	/* prev offset for backup	*/
90 	int		npass;		/* # optjoin() passes		*/
91 	int		join;		/* optjoin() pass #		*/
92 	int		plus;		/* + ok				*/
93 	int		style;		/* default opthelp() style	*/
94 	int		width;		/* format line width		*/
95 	int		flags;		/* display flags		*/
96 	int		emphasis;	/* ansi term emphasis ok	*/
97 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
98 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
99 	Optcache_t*	cache;		/* OPT_cache cache		*/
100 } Optstate_t;
101 
102 #define _OPT_PRIVATE_ \
103 	char            pad[2*sizeof(void*)]; \
104 	Optstate_t*	state;
105 
106 #include <error.h>
107 
108 #endif
109