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