xref: /onnv-gate/usr/src/lib/libast/common/misc/optlib.h (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
184887Schin *                  David Korn <dgk@research.att.com>                   *
194887Schin *                   Phong Vo <kpv@research.att.com>                    *
204887Schin *                                                                      *
214887Schin ***********************************************************************/
224887Schin #pragma prototyped
234887Schin /*
244887Schin  * Glenn Fowler
254887Schin  * AT&T Research
264887Schin  *
274887Schin  * command line option parser and usage formatter private definitions
284887Schin  */
294887Schin 
304887Schin #ifndef _OPTLIB_H
314887Schin #define _OPTLIB_H
324887Schin 
334887Schin #include <ast.h>
344887Schin #include <cdt.h>
354887Schin 
364887Schin #define OPT_cache		0x01
374887Schin #define OPT_functions		0x02
384887Schin #define OPT_ignore		0x04
394887Schin #define OPT_long		0x08
408462SApril.Chin@Sun.COM #define OPT_numeric		0x10
418462SApril.Chin@Sun.COM #define OPT_old			0x20
4210898Sroland.mainz@nrubsig.org #define OPT_minus		0x40
4310898Sroland.mainz@nrubsig.org #define OPT_plus		0x80
444887Schin 
454887Schin #define OPT_cache_flag		0x01
464887Schin #define OPT_cache_invert	0x02
474887Schin #define OPT_cache_numeric	0x04
484887Schin #define OPT_cache_optional	0x08
494887Schin #define OPT_cache_string	0x10
504887Schin 
514887Schin #define OPT_CACHE		128
524887Schin #define OPT_FLAGS		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
534887Schin 
544887Schin struct Optdisc_s;
554887Schin 
564887Schin typedef struct Optpass_s
574887Schin {
584887Schin 	char*			opts;
594887Schin 	char*			oopts;
60*12068SRoger.Faulkner@Oracle.COM 	char*			id;
614887Schin 	char*			catalog;
624887Schin 	unsigned char		version;
634887Schin 	unsigned char		prefix;
644887Schin 	unsigned char		flags;
654887Schin 	unsigned char		section;
664887Schin } Optpass_t;
674887Schin 
684887Schin typedef struct Optcache_s
694887Schin {
704887Schin 	struct Optcache_s*	next;
714887Schin 	Optpass_t		pass;
724887Schin 	int			caching;
734887Schin 	unsigned char		flags[sizeof(OPT_FLAGS)];
744887Schin } Optcache_t;
754887Schin 
764887Schin typedef struct Optstate_s
774887Schin {
784887Schin 	Sfio_t*		mp;		/* opt_info.msg string stream	*/
794887Schin 	Sfio_t*		vp;		/* translation string stream	*/
804887Schin 	Sfio_t*		xp;		/* translation string stream	*/
814887Schin 	Sfio_t*		cp;		/* compatibility string stream	*/
824887Schin 	Optpass_t	pass[8];	/* optjoin() list		*/
834887Schin 	char*		argv[2];	/* initial argv copy		*/
844887Schin 	char*		strv[3];	/* optstr() argv		*/
854887Schin 	char*		str;		/* optstr() string		*/
864887Schin 	Sfio_t*		strp;		/* optstr() stream		*/
874887Schin 	int		force;		/* force this style		*/
884887Schin 	int		pindex;		/* prev index for backup	*/
894887Schin 	int		poffset;	/* prev offset for backup	*/
904887Schin 	int		npass;		/* # optjoin() passes		*/
914887Schin 	int		join;		/* optjoin() pass #		*/
924887Schin 	int		plus;		/* + ok				*/
934887Schin 	int		style;		/* default opthelp() style	*/
944887Schin 	int		width;		/* format line width		*/
954887Schin 	int		flags;		/* display flags		*/
964887Schin 	int		emphasis;	/* ansi term emphasis ok	*/
974887Schin 	Dtdisc_t	msgdisc;	/* msgdict discipline		*/
984887Schin 	Dt_t*		msgdict;	/* default ast.id catalog msgs	*/
994887Schin 	Optcache_t*	cache;		/* OPT_cache cache		*/
1004887Schin } Optstate_t;
1014887Schin 
1024887Schin #define _OPT_PRIVATE_ \
1034887Schin 	char            pad[2*sizeof(void*)]; \
1044887Schin 	Optstate_t*	state;
1054887Schin 
1064887Schin #include <error.h>
1074887Schin 
1084887Schin #endif
109