exec.h revision 218324
1168404Spjd/*- 2168404Spjd * Copyright (c) 1991, 1993 3168404Spjd * The Regents of the University of California. All rights reserved. 4168404Spjd * 5168404Spjd * This code is derived from software contributed to Berkeley by 6168404Spjd * Kenneth Almquist. 7168404Spjd * 8168404Spjd * Redistribution and use in source and binary forms, with or without 9168404Spjd * modification, are permitted provided that the following conditions 10168404Spjd * are met: 11168404Spjd * 1. Redistributions of source code must retain the above copyright 12168404Spjd * notice, this list of conditions and the following disclaimer. 13168404Spjd * 2. Redistributions in binary form must reproduce the above copyright 14168404Spjd * notice, this list of conditions and the following disclaimer in the 15168404Spjd * documentation and/or other materials provided with the distribution. 16168404Spjd * 4. Neither the name of the University nor the names of its contributors 17168404Spjd * may be used to endorse or promote products derived from this software 18168404Spjd * without specific prior written permission. 19168404Spjd * 20168404Spjd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21168404Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22168404Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23219089Spjd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24219089Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25223623Smm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26236705Smm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27230438Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28226706Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29235216Smm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30168404Spjd * SUCH DAMAGE. 31168404Spjd * 32168404Spjd * @(#)exec.h 8.3 (Berkeley) 6/8/95 33168404Spjd * $FreeBSD: head/bin/sh/exec.h 218324 2011-02-05 14:08:51Z jilles $ 34168404Spjd */ 35168404Spjd 36168404Spjd/* values of cmdtype */ 37168404Spjd#define CMDUNKNOWN -1 /* no entry in table for command */ 38168404Spjd#define CMDNORMAL 0 /* command is an executable program */ 39168404Spjd#define CMDBUILTIN 1 /* command is a shell builtin */ 40185029Spjd#define CMDFUNCTION 2 /* command is a shell function */ 41168404Spjd 42168404Spjd/* values for typecmd_impl's third parameter */ 43168404Spjdenum { 44168404Spjd TYPECMD_SMALLV, /* command -v */ 45185029Spjd TYPECMD_BIGV, /* command -V */ 46185029Spjd TYPECMD_TYPE /* type */ 47185029Spjd}; 48185029Spjd 49209962Smmunion node; 50168404Spjdstruct cmdentry { 51219089Spjd int cmdtype; 52168404Spjd union param { 53168404Spjd int index; 54209962Smm struct funcdef *func; 55168404Spjd } u; 56168404Spjd int special; 57168404Spjd}; 58168404Spjd 59168404Spjd 60185029Spjd/* action to find_command() */ 61168404Spjd#define DO_ERR 0x01 /* prints errors */ 62209962Smm#define DO_NOFUNC 0x02 /* don't return shell functions, for command */ 63209962Smm 64168676Spjdextern const char *pathopt; /* set by padvance */ 65168404Spjdextern int exerrno; /* last exec error */ 66168404Spjd 67168404Spjdvoid shellexec(char **, char **, const char *, int) __dead2; 68168404Spjdchar *padvance(const char **, const char *); 69168404Spjdint hashcmd(int, char **); 70168404Spjdvoid find_command(const char *, struct cmdentry *, int, const char *); 71168404Spjdint find_builtin(const char *, int *); 72168404Spjdvoid hashcd(void); 73168404Spjdvoid changepath(const char *); 74168404Spjdvoid addcmdentry(const char *, struct cmdentry *); 75168404Spjdvoid defun(const char *, union node *); 76168404Spjdint unsetfunc(const char *); 77168404Spjdint typecmd_impl(int, char **, int, const char *); 78168404Spjdint typecmd(int, char **); 79168404Spjdvoid clearcmdentry(void); 80168404Spjd