xref: /titanic_41/usr/src/lib/libast/i386/include/ast/option.h (revision 67dbe2be0c0f1e2eb428b89088bb5667e8f0b9f6)
1 
2 /* : : generated by proto : : */
3 /***********************************************************************
4 *                                                                      *
5 *               This software is part of the ast package               *
6 *          Copyright (c) 1985-2009 AT&T Intellectual Property          *
7 *                      and is licensed under the                       *
8 *                  Common Public License, Version 1.0                  *
9 *                    by AT&T Intellectual Property                     *
10 *                                                                      *
11 *                A copy of the License is available at                 *
12 *            http://www.opensource.org/licenses/cpl1.0.txt             *
13 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
14 *                                                                      *
15 *              Information and Software Systems Research               *
16 *                            AT&T Research                             *
17 *                           Florham Park NJ                            *
18 *                                                                      *
19 *                 Glenn Fowler <gsf@research.att.com>                  *
20 *                  David Korn <dgk@research.att.com>                   *
21 *                   Phong Vo <kpv@research.att.com>                    *
22 *                                                                      *
23 ***********************************************************************/
24 
25 /*
26  * Glenn Fowler
27  * AT&T Research
28  *
29  * command line option parse interface
30  */
31 
32 #ifndef _OPTION_H
33 #if !defined(__PROTO__)
34 #include <prototyped.h>
35 #endif
36 #if !defined(__LINKAGE__)
37 #define __LINKAGE__		/* 2004-08-11 transition */
38 #endif
39 
40 #define _OPTION_H
41 
42 #include <ast.h>
43 
44 #define OPT_VERSION	20070319L
45 
46 #define OPT_USER	(1L<<16)	/* first user flag bit		*/
47 
48 struct Opt_s;
49 struct Optdisc_s;
50 
51 typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*));
52 
53 typedef struct Optdisc_s
54 {
55 	unsigned long	version;	/* OPT_VERSION			*/
56 	unsigned long	flags;		/* OPT_* flags			*/
57 	char*		catalog;	/* error catalog id		*/
58 	Optinfo_f	infof;		/* runtime info function	*/
59 } Optdisc_t;
60 
61 /* NOTE: Opt_t member order fixed by a previous binary release */
62 
63 #ifndef _OPT_PRIVATE_
64 #define _OPT_PRIVATE_	\
65 	char		pad[3*sizeof(__V_*)];
66 #endif
67 
68 typedef struct Opt_s
69 {
70 	int		again;		/* see optjoin()		*/
71 	char*		arg;		/* {:,#} string argument	*/
72 	char**		argv;		/* most recent argv		*/
73 	int		index;		/* argv index			*/
74 	char*		msg;		/* error/usage message buffer	*/
75 	long		num;		/* OBSOLETE -- use number	*/
76 	int		offset;		/* char offset in argv[index]	*/
77 	char		option[8];	/* current flag {-,+} + option  */
78 	char		name[64];	/* current long name or flag	*/
79 	Optdisc_t*	disc;		/* user discipline		*/
80 	intmax_t	number;		/* # numeric argument		*/
81 	unsigned char	assignment;	/* option arg assigment op	*/
82 	unsigned char	pads[sizeof(__V_*)-1];
83 	_OPT_PRIVATE_
84 } Opt_t;
85 
86 #if _BLD_ast && defined(__EXPORT__)
87 #undef __MANGLE__
88 #define __MANGLE__ __LINKAGE__ __EXPORT__
89 #endif
90 #if !_BLD_ast && defined(__IMPORT__)
91 #undef __MANGLE__
92 #define __MANGLE__ __LINKAGE__ __IMPORT__
93 #endif
94 
95 extern __MANGLE__ Opt_t*		_opt_infop_;
96 
97 #define opt_info	(*_opt_infop_)
98 
99 #undef __MANGLE__
100 #define __MANGLE__ __LINKAGE__
101 
102 #define optinit(d,f)	(memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
103 
104 #if _BLD_ast && defined(__EXPORT__)
105 #undef __MANGLE__
106 #define __MANGLE__ __LINKAGE__		__EXPORT__
107 #endif
108 
109 extern __MANGLE__ int		optget __PROTO__((char**, const char*));
110 extern __MANGLE__ int		optjoin __PROTO__((char**, ...));
111 extern __MANGLE__ char*		opthelp __PROTO__((const char*, const char*));
112 extern __MANGLE__ char*		optusage __PROTO__((const char*));
113 extern __MANGLE__ int		optstr __PROTO__((const char*, const char*));
114 extern __MANGLE__ int		optesc __PROTO__((Sfio_t*, const char*, int));
115 extern __MANGLE__ Opt_t*		optctx __PROTO__((Opt_t*, Opt_t*));
116 
117 #undef __MANGLE__
118 #define __MANGLE__ __LINKAGE__
119 
120 #endif
121