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