cmdarg.h revision 1
1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* David Korn <dgk@research.att.com> *
1N/A* Phong Vo <kpv@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A/*
1N/A * Glenn Fowler
1N/A * AT&T Research
1N/A *
1N/A * xargs/tw command arg list interface definitions
1N/A */
1N/A
1N/A#ifndef _CMDARG_H
1N/A#define _CMDARG_H
1N/A
1N/A#define CMD_CHECKED (1<<9) /* cmdopen() argv[0] ok */
1N/A#define CMD_EMPTY (1<<0) /* run once, even if no args */
1N/A#define CMD_EXACT (1<<1) /* last command must have argmax*/
1N/A#define CMD_IGNORE (1<<2) /* ignore EXIT_QUIT exit */
1N/A#define CMD_INSERT (1<<3) /* argpat for insertion */
1N/A#define CMD_MINIMUM (1<<4) /* argmax is a minimum */
1N/A#define CMD_NEWLINE (1<<5) /* echo separator is newline */
1N/A#define CMD_POST (1<<6) /* argpat is post arg position */
1N/A#define CMD_QUERY (1<<7) /* trace and query each command */
1N/A#define CMD_SILENT (1<<10) /* no error messages */
1N/A#define CMD_TRACE (1<<8) /* trace each command */
1N/A
1N/A#define CMD_USER (1<<12)
1N/A
1N/Atypedef struct /* cmd + args info */
1N/A{
1N/A struct
1N/A {
1N/A size_t args; /* total args */
1N/A size_t commands; /* total commands */
1N/A } total;
1N/A
1N/A int argcount; /* current arg count */
1N/A int argmax; /* max # args */
1N/A int echo; /* just an echo */
1N/A int flags; /* CMD_* flags */
1N/A int insertlen; /* strlen(insert) */
1N/A int offset; /* post arg offset */
1N/A
1N/A char** argv; /* exec argv */
1N/A char** firstarg; /* first argv file arg */
1N/A char** insertarg; /* argv before insert */
1N/A char** postarg; /* start of post arg list */
1N/A char** nextarg; /* next argv file arg */
1N/A char* nextstr; /* next string ends before here */
1N/A char* laststr; /* last string ends before here */
1N/A char* insert; /* replace with current arg */
1N/A char buf[1]; /* argv and arg buffer */
1N/A} Cmdarg_t;
1N/A
1N/A#if _BLD_ast && defined(__EXPORT__)
1N/A#define extern __EXPORT__
1N/A#endif
1N/A
1N/Aextern Cmdarg_t* cmdopen(char**, int, int, const char*, int);
1N/Aextern int cmdflush(Cmdarg_t*);
1N/Aextern int cmdarg(Cmdarg_t*, const char*, int);
1N/Aextern int cmdclose(Cmdarg_t*);
1N/A
1N/A#undef extern
1N/A
1N/A#endif