/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2012 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Research25*26* command line option parse interface27*/2829#ifndef _OPTION_H30#define _OPTION_H 13132#include <ast.h>3334#define OPT_VERSION 20000401L3536#define opt_info _opt_info_3738#define OPT_USER (1L<<16) /* first user flag bit */3940struct Opt_s;41struct Optdisc_s;4243typedef int (*Optinfo_f)(struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*);4445typedef struct Optdisc_s46{47unsigned long version; /* OPT_VERSION */48unsigned long flags; /* OPT_* flags */49char* catalog; /* error catalog id */50Optinfo_f infof; /* runtime info function */51} Optdisc_t;5253/* NOTE: Opt_t member order fixed by a previous binary release */5455#ifndef _OPT_PRIVATE_56#define _OPT_PRIVATE_ void* _opt_private;57#endif5859typedef struct Opt_s60{61int again; /* see optjoin() */62char* arg; /* {:,#} string argument */63char** argv; /* most recent argv */64int index; /* argv index */65char* msg; /* error/usage message buffer */66long num; /* # numeric argument */67int offset; /* char offset in argv[index] */68char option[8]; /* current flag {-,+} + option */69char name[64]; /* current long name or flag */70Optdisc_t* disc; /* user discipline */71intmax_t number; /* # numeric argument */72unsigned char assignment; /* option arg assigment op */73unsigned char pads[sizeof(void*)-1];74_OPT_PRIVATE_75} Opt_t;7677#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))7879#if _BLD_ast && defined(__EXPORT__)80#define __PUBLIC_DATA__ __EXPORT__81#else82#if !_BLD_ast && defined(__IMPORT__)83#define __PUBLIC_DATA__ __IMPORT__84#else85#define __PUBLIC_DATA__86#endif87#endif8889extern __PUBLIC_DATA__ Opt_t opt_info;9091#undef __PUBLIC_DATA__9293#if _BLD_ast && defined(__EXPORT__)94#define extern __EXPORT__95#endif9697extern int optget(char**, const char*);98extern int optjoin(char**, ...);99extern char* opthelp(const char*, const char*);100extern char* optusage(const char*);101extern int optstr(const char*, const char*);102103#undef extern104105#endif106107108