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