14887Schin 24887Schin /* : : generated by proto : : */ 34887Schin /*********************************************************************** 44887Schin * * 54887Schin * This software is part of the ast package * 6*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 74887Schin * and is licensed under the * 84887Schin * Common Public License, Version 1.0 * 98462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 104887Schin * * 114887Schin * A copy of the License is available at * 124887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 134887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 144887Schin * * 154887Schin * Information and Software Systems Research * 164887Schin * AT&T Research * 174887Schin * Florham Park NJ * 184887Schin * * 194887Schin * Glenn Fowler <gsf@research.att.com> * 204887Schin * David Korn <dgk@research.att.com> * 214887Schin * Phong Vo <kpv@research.att.com> * 224887Schin * * 234887Schin ***********************************************************************/ 244887Schin 254887Schin /* 264887Schin * Glenn Fowler 274887Schin * AT&T Research 284887Schin * 294887Schin * command line option parse interface 304887Schin */ 314887Schin 324887Schin #ifndef _OPTION_H 334887Schin #if !defined(__PROTO__) 344887Schin #include <prototyped.h> 354887Schin #endif 364887Schin #if !defined(__LINKAGE__) 374887Schin #define __LINKAGE__ /* 2004-08-11 transition */ 384887Schin #endif 394887Schin 404887Schin #define _OPTION_H 414887Schin 424887Schin #include <ast.h> 434887Schin 444887Schin #define OPT_VERSION 20070319L 454887Schin 464887Schin #define OPT_USER (1L<<16) /* first user flag bit */ 474887Schin 484887Schin struct Opt_s; 494887Schin struct Optdisc_s; 504887Schin 514887Schin typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*)); 524887Schin 534887Schin typedef struct Optdisc_s 544887Schin { 554887Schin unsigned long version; /* OPT_VERSION */ 564887Schin unsigned long flags; /* OPT_* flags */ 574887Schin char* catalog; /* error catalog id */ 584887Schin Optinfo_f infof; /* runtime info function */ 594887Schin } Optdisc_t; 604887Schin 614887Schin /* NOTE: Opt_t member order fixed by a previous binary release */ 624887Schin 634887Schin #ifndef _OPT_PRIVATE_ 644887Schin #define _OPT_PRIVATE_ \ 654887Schin char pad[3*sizeof(__V_*)]; 664887Schin #endif 674887Schin 684887Schin typedef struct Opt_s 694887Schin { 704887Schin int again; /* see optjoin() */ 714887Schin char* arg; /* {:,#} string argument */ 724887Schin char** argv; /* most recent argv */ 734887Schin int index; /* argv index */ 744887Schin char* msg; /* error/usage message buffer */ 754887Schin long num; /* OBSOLETE -- use number */ 764887Schin int offset; /* char offset in argv[index] */ 774887Schin char option[8]; /* current flag {-,+} + option */ 784887Schin char name[64]; /* current long name or flag */ 794887Schin Optdisc_t* disc; /* user discipline */ 804887Schin intmax_t number; /* # numeric argument */ 814887Schin unsigned char assignment; /* option arg assigment op */ 824887Schin unsigned char pads[sizeof(__V_*)-1]; 834887Schin _OPT_PRIVATE_ 844887Schin } Opt_t; 854887Schin 864887Schin #if _BLD_ast && defined(__EXPORT__) 874887Schin #undef __MANGLE__ 884887Schin #define __MANGLE__ __LINKAGE__ __EXPORT__ 894887Schin #endif 904887Schin #if !_BLD_ast && defined(__IMPORT__) 914887Schin #undef __MANGLE__ 924887Schin #define __MANGLE__ __LINKAGE__ __IMPORT__ 934887Schin #endif 944887Schin 954887Schin extern __MANGLE__ Opt_t* _opt_infop_; 964887Schin 974887Schin #define opt_info (*_opt_infop_) 984887Schin 994887Schin #undef __MANGLE__ 1004887Schin #define __MANGLE__ __LINKAGE__ 1014887Schin 1024887Schin #define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d)) 1034887Schin 1044887Schin #if _BLD_ast && defined(__EXPORT__) 1054887Schin #undef __MANGLE__ 1064887Schin #define __MANGLE__ __LINKAGE__ __EXPORT__ 1074887Schin #endif 1084887Schin 1094887Schin extern __MANGLE__ int optget __PROTO__((char**, const char*)); 1104887Schin extern __MANGLE__ int optjoin __PROTO__((char**, ...)); 1114887Schin extern __MANGLE__ char* opthelp __PROTO__((const char*, const char*)); 1124887Schin extern __MANGLE__ char* optusage __PROTO__((const char*)); 1134887Schin extern __MANGLE__ int optstr __PROTO__((const char*, const char*)); 1144887Schin extern __MANGLE__ int optesc __PROTO__((Sfio_t*, const char*, int)); 1158462SApril.Chin@Sun.COM extern __MANGLE__ Opt_t* optctx __PROTO__((Opt_t*, Opt_t*)); 1164887Schin 1174887Schin #undef __MANGLE__ 1184887Schin #define __MANGLE__ __LINKAGE__ 1194887Schin 1204887Schin #endif 121