2 /* : : generated by proto : : */
3 /***********************************************************************
5 * This software is part of the ast package *
6 * Copyright (c) 1985-2010 AT&T Intellectual Property *
7 * and is licensed under the *
8 * Common Public License, Version 1.0 *
9 * by AT&T Intellectual Property *
11 * A copy of the License is available at *
12 * http://www.opensource.org/licenses/cpl1.0.txt *
13 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
15 * Information and Software Systems Research *
19 * Glenn Fowler <gsf@research.att.com> *
20 * David Korn <dgk@research.att.com> *
21 * Phong Vo <kpv@research.att.com> *
23 ***********************************************************************/
29 * command line option parse interface
33 #if !defined(__PROTO__)
34 #include <prototyped.h>
36 #if !defined(__LINKAGE__)
37 #define __LINKAGE__ /* 2004-08-11 transition */
44 #define OPT_VERSION 20070319L
46 #define OPT_USER (1L<<16) /* first user flag bit */
51 typedef int (*Optinfo_f
) __PROTO__((struct Opt_s
*, Sfio_t
*, const char*, struct Optdisc_s
*));
53 typedef struct Optdisc_s
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 */
61 /* NOTE: Opt_t member order fixed by a previous binary release */
64 #define _OPT_PRIVATE_ \
65 char pad[3*sizeof(__V_*)];
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];
86 #if _BLD_ast && defined(__EXPORT__)
88 #define __MANGLE__ __LINKAGE__ __EXPORT__
90 #if !_BLD_ast && defined(__IMPORT__)
92 #define __MANGLE__ __LINKAGE__ __IMPORT__
95 extern __MANGLE__ Opt_t
* _opt_infop_
;
97 #define opt_info (*_opt_infop_)
100 #define __MANGLE__ __LINKAGE__
102 #define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
104 #if _BLD_ast && defined(__EXPORT__)
106 #define __MANGLE__ __LINKAGE__ __EXPORT__
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
*));
118 #define __MANGLE__ __LINKAGE__