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