1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1985-2012 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * Glenn Fowler <gsf@research.att.com> * 18 * David Korn <dgk@research.att.com> * 19 * Phong Vo <kpv@research.att.com> * 20 * * 21 ***********************************************************************/ 22 #pragma prototyped 23 /* 24 * Glenn Fowler 25 * AT&T Research 26 * 27 * xargs/tw command arg list interface definitions 28 */ 29 30 #ifndef _CMDARG_H 31 #define _CMDARG_H 1 32 33 #include <error.h> 34 35 #define CMD_VERSION 20120411L 36 37 #define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */ 38 #define CMD_EMPTY (1<<0) /* run once, even if no args */ 39 #define CMD_EXACT (1<<1) /* last command must have argmax*/ 40 #define CMD_EXIT (1<<11) /* fatal error_info.exit() */ 41 #define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */ 42 #define CMD_INSERT (1<<3) /* argpat for insertion */ 43 #define CMD_MINIMUM (1<<4) /* argmax is a minimum */ 44 #define CMD_NEWLINE (1<<5) /* echo separator is newline */ 45 #define CMD_POST (1<<6) /* argpat is post arg position */ 46 #define CMD_QUERY (1<<7) /* trace and query each command */ 47 #define CMD_SILENT (1<<10) /* no error messages */ 48 #define CMD_TRACE (1<<8) /* trace each command */ 49 50 #define CMD_USER (1<<12) 51 52 #define CMDDISC(d,f,e) (memset(d,0,sizeof(*(d))),(d)->version=CMD_VERSION,(d)->flags=(f),(d)->errorf=(e)) 53 54 struct Cmddisc_s; 55 typedef struct Cmddisc_s Cmddisc_t; 56 57 typedef int (*Cmdrun_f)(int, char**, Cmddisc_t*); 58 59 struct Cmddisc_s 60 { 61 uint32_t version; /* CMD_VERSION */ 62 uint32_t flags; /* CMD_* flags */ 63 Error_f errorf; /* optional error function */ 64 Cmdrun_f runf; /* optional exec function */ 65 }; 66 67 typedef struct Cmdarg_s /* cmdopen() handle */ 68 { 69 const char* id; /* library id string */ 70 71 #ifdef _CMDARG_PRIVATE_ 72 _CMDARG_PRIVATE_ 73 #endif 74 75 } Cmdarg_t; 76 77 #if _BLD_ast && defined(__EXPORT__) 78 #define extern __EXPORT__ 79 #endif 80 81 #ifndef cmdopen 82 extern Cmdarg_t* cmdopen(char**, int, int, const char*, int); 83 #endif 84 extern Cmdarg_t* cmdopen_20110505(char**, int, int, const char*, int, Error_f); 85 extern Cmdarg_t* cmdopen_20120411(char**, int, int, const char*, Cmddisc_t*); 86 extern int cmdflush(Cmdarg_t*); 87 extern int cmdarg(Cmdarg_t*, const char*, int); 88 extern int cmdclose(Cmdarg_t*); 89 90 #undef extern 91 92 #endif 93