1*d73cf48cSkre /* $NetBSD: exec.h,v 1.28 2024/07/12 07:30:30 kre Exp $ */ 249f0ad86Scgd 361f28255Scgd /*- 437ed7877Sjtc * Copyright (c) 1991, 1993 537ed7877Sjtc * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * This code is derived from software contributed to Berkeley by 861f28255Scgd * Kenneth Almquist. 961f28255Scgd * 1061f28255Scgd * Redistribution and use in source and binary forms, with or without 1161f28255Scgd * modification, are permitted provided that the following conditions 1261f28255Scgd * are met: 1361f28255Scgd * 1. Redistributions of source code must retain the above copyright 1461f28255Scgd * notice, this list of conditions and the following disclaimer. 1561f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1661f28255Scgd * notice, this list of conditions and the following disclaimer in the 1761f28255Scgd * documentation and/or other materials provided with the distribution. 18b5b29542Sagc * 3. Neither the name of the University nor the names of its contributors 1961f28255Scgd * may be used to endorse or promote products derived from this software 2061f28255Scgd * without specific prior written permission. 2161f28255Scgd * 2261f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2361f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2461f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2561f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2661f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2761f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2861f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2961f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3061f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3161f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3261f28255Scgd * SUCH DAMAGE. 3361f28255Scgd * 34a45947b2Schristos * @(#)exec.h 8.3 (Berkeley) 6/8/95 3561f28255Scgd */ 3661f28255Scgd 3761f28255Scgd /* values of cmdtype */ 3861f28255Scgd #define CMDUNKNOWN -1 /* no entry in table for command */ 3961f28255Scgd #define CMDNORMAL 0 /* command is an executable program */ 40c02b3bbdSchristos #define CMDFUNCTION 1 /* command is a shell function */ 41c02b3bbdSchristos #define CMDBUILTIN 2 /* command is a shell builtin */ 42c02b3bbdSchristos #define CMDSPLBLTIN 3 /* command is a special shell builtin */ 4361f28255Scgd 4461f28255Scgd 4561f28255Scgd struct cmdentry { 46727a69dcSkre short cmdtype; 47727a69dcSkre short lno_frel; /* for functions: Line numbers count from 1 */ 48727a69dcSkre int lineno; /* for functions: Abs line number of defn */ 4961f28255Scgd union param { 5061f28255Scgd int index; 51c02b3bbdSchristos int (*bltin)(int, char**); 52c7c0722aSkre struct funcdef *func; 5361f28255Scgd } u; 5461f28255Scgd }; 5561f28255Scgd 5661f28255Scgd 57e314f958Sdsl /* action to find_command() */ 58e314f958Sdsl #define DO_ERR 0x01 /* prints errors */ 59e314f958Sdsl #define DO_ABS 0x02 /* checks absolute paths */ 60e314f958Sdsl #define DO_NOFUNC 0x04 /* don't return shell functions, for command */ 61e314f958Sdsl #define DO_ALTPATH 0x08 /* using alternate path */ 62e314f958Sdsl #define DO_ALTBLTIN 0x20 /* %builtin in alt. path */ 63c996803cSchristos 643d424690Schristos extern const char *pathopt; /* set by padvance */ 6561f28255Scgd 6666dd2755Sjoerg void shellexec(char **, char **, const char *, int, int) __dead; 671676135eSkre char *padvance(const char **, const char *, int); 68c02b3bbdSchristos void find_command(char *, struct cmdentry *, int, const char *); 69c02b3bbdSchristos int (*find_builtin(char *))(int, char **); 70c02b3bbdSchristos int (*find_splbltin(char *))(int, char **); 71c02b3bbdSchristos void hashcd(void); 72*d73cf48cSkre void changepath(char *, int); 73c02b3bbdSchristos void deletefuncs(void); 74c02b3bbdSchristos void getcmdentry(char *, struct cmdentry *); 75c7c0722aSkre union node; 76727a69dcSkre void defun(char *, union node *, int); 77c02b3bbdSchristos int unsetfunc(char *); 78c02b3bbdSchristos void hash_special_builtins(void); 79