/***********************************************************************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* xargs/tw command arg list interface definitions27*/2829#ifndef _CMDARG_H30#define _CMDARG_H 13132#include <error.h>3334#define CMD_VERSION 20120411L3536#define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */37#define CMD_EMPTY (1<<0) /* run once, even if no args */38#define CMD_EXACT (1<<1) /* last command must have argmax*/39#define CMD_EXIT (1<<11) /* fatal error_info.exit() */40#define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */41#define CMD_INSERT (1<<3) /* argpat for insertion */42#define CMD_MINIMUM (1<<4) /* argmax is a minimum */43#define CMD_NEWLINE (1<<5) /* echo separator is newline */44#define CMD_POST (1<<6) /* argpat is post arg position */45#define CMD_QUERY (1<<7) /* trace and query each command */46#define CMD_SILENT (1<<10) /* no error messages */47#define CMD_TRACE (1<<8) /* trace each command */4849#define CMD_USER (1<<12)5051#define CMDDISC(d,f,e) (memset(d,0,sizeof(*(d))),(d)->version=CMD_VERSION,(d)->flags=(f),(d)->errorf=(e))5253struct Cmddisc_s;54typedef struct Cmddisc_s Cmddisc_t;5556typedef int (*Cmdrun_f)(int, char**, Cmddisc_t*);5758struct Cmddisc_s59{60uint32_t version; /* CMD_VERSION */61uint32_t flags; /* CMD_* flags */62Error_f errorf; /* optional error function */63Cmdrun_f runf; /* optional exec function */64};6566typedef struct Cmdarg_s /* cmdopen() handle */67{68const char* id; /* library id string */6970#ifdef _CMDARG_PRIVATE_71_CMDARG_PRIVATE_72#endif7374} Cmdarg_t;7576#if _BLD_ast && defined(__EXPORT__)77#define extern __EXPORT__78#endif7980#ifndef cmdopen81extern Cmdarg_t* cmdopen(char**, int, int, const char*, int);82#endif83extern Cmdarg_t* cmdopen_20110505(char**, int, int, const char*, int, Error_f);84extern Cmdarg_t* cmdopen_20120411(char**, int, int, const char*, Cmddisc_t*);85extern int cmdflush(Cmdarg_t*);86extern int cmdarg(Cmdarg_t*, const char*, int);87extern int cmdclose(Cmdarg_t*);8889#undef extern9091#endif929394