1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * xargs/tw command arg list interface definitions
33 #define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */
34 #define CMD_EMPTY (1<<0) /* run once, even if no args */
35 #define CMD_EXACT (1<<1) /* last command must have argmax*/
36 #define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */
37 #define CMD_INSERT (1<<3) /* argpat for insertion */
38 #define CMD_MINIMUM (1<<4) /* argmax is a minimum */
39 #define CMD_NEWLINE (1<<5) /* echo separator is newline */
40 #define CMD_POST (1<<6) /* argpat is post arg position */
41 #define CMD_QUERY (1<<7) /* trace and query each command */
42 #define CMD_SILENT (1<<10) /* no error messages */
43 #define CMD_TRACE (1<<8) /* trace each command */
45 #define CMD_USER (1<<12)
47 typedef struct /* cmd + args info */
51 size_t args
; /* total args */
52 size_t commands
; /* total commands */
55 int argcount
; /* current arg count */
56 int argmax
; /* max # args */
57 int echo
; /* just an echo */
58 int flags
; /* CMD_* flags */
59 int insertlen
; /* strlen(insert) */
60 int offset
; /* post arg offset */
62 char** argv
; /* exec argv */
63 char** firstarg
; /* first argv file arg */
64 char** insertarg
; /* argv before insert */
65 char** postarg
; /* start of post arg list */
66 char** nextarg
; /* next argv file arg */
67 char* nextstr
; /* next string ends before here */
68 char* laststr
; /* last string ends before here */
69 char* insert
; /* replace with current arg */
70 char buf
[1]; /* argv and arg buffer */
73 #if _BLD_ast && defined(__EXPORT__)
74 #define extern __EXPORT__
77 extern Cmdarg_t
* cmdopen(char**, int, int, const char*, int);
78 extern int cmdflush(Cmdarg_t
*);
79 extern int cmdarg(Cmdarg_t
*, const char*, int);
80 extern int cmdclose(Cmdarg_t
*);