1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 29 #if defined(sun) 30 #pragma ident "@(#)defs.c 1.13 05/09/13 SMI" 31 #endif 32 33 /* 34 * Copyright 2008-2018 J. Schilling 35 * 36 * @(#)defs.c 1.25 19/10/06 2008-2018 J. Schilling 37 */ 38 #ifdef SCHILY_INCLUDES 39 #include <schily/mconfig.h> 40 #endif 41 #ifndef lint 42 static UConst char sccsid[] = 43 "@(#)defs.c 1.25 19/10/06 2008-2018 J. Schilling"; 44 #endif 45 46 /* 47 * UNIX shell 48 */ 49 50 #ifdef SCHILY_INCLUDES 51 #include <schily/mconfig.h> 52 #include "mode.h" 53 #include "name.h" 54 #include <schily/param.h> 55 #include "defs.h" 56 #include <schily/wait.h> /* Needed for CLD_EXITED */ 57 #else 58 #include <setjmp.h> 59 #include "mode.h" 60 #include "name.h" 61 #include <sys/param.h> 62 #include "defs.h" 63 #include <sys/types.h> 64 #include <sys/wait.h> /* Needed for CLD_EXITED */ 65 #endif 66 #ifndef NOFILE 67 #define NOFILE 20 68 #endif 69 70 bosh_t bosh; 71 72 /* temp files and io */ 73 int output = STDERR_FILENO; 74 int ioset; 75 struct ionod *iotemp; /* files to be deleted sometime */ 76 struct ionod *xiotemp; /* limit for files to be deleted sometime */ 77 struct ionod *fiotemp; /* function files to be deleted sometime */ 78 struct ionod *iopend; /* documents waiting to be read at NL */ 79 struct fdsave fdmap[NOFILE]; 80 81 /* substitution */ 82 int dolc; 83 unsigned char **dolv; 84 struct dolnod *argfor; 85 struct argnod *gchain; 86 87 88 /* name tree and words */ 89 int wdval; 90 int wdnum; 91 int fndef; 92 int nohash; 93 struct argnod *wdarg; 94 int wdset; 95 BOOL reserv; 96 97 /* special names */ 98 unsigned char *pcsadr; 99 unsigned char *pidadr; 100 unsigned char *cmdadr; 101 102 /* transput */ 103 int tmpout_offset; 104 unsigned int serial; 105 int peekc; /* If set, return this by readwc() as next c */ 106 int peekn; /* If set, return this in favor of "peekc" */ 107 unsigned char *comdiv; 108 unsigned long flags; /* Flags for set(1) and more */ 109 unsigned long flags2; /* Second set of flags */ 110 int rwait; /* flags read waiting */ 111 #ifdef DO_POSIX_SET 112 int dashdash; /* flags set -- encountered */ 113 #endif 114 115 /* error exits from various parts of shell */ 116 jmp_buf subshell; 117 jmp_buf errshell; 118 jmps_t *dotshell; 119 120 /* fault handling */ 121 BOOL trapnote; 122 int traprecurse; 123 int trapsig; /* Last signal */ 124 125 /* execflgs */ 126 struct excode ex = { CLD_EXITED }; 127 struct excode retex = { CLD_EXITED }; 128 #ifdef DO_DOL_SLASH 129 int *excausep; 130 #endif 131 int exitval; 132 int retval; 133 BOOL execbrk; 134 BOOL dotbrk; 135 int loopcnt; 136 int breakcnt; 137 int funcnt; 138 int dotcnt; 139 void *localp; 140 int localcnt; 141 int eflag; 142 /* 143 * The following flag is set if you try to exit with stopped jobs. 144 * On the second try the exit will succeed. 145 */ 146 int tried_to_exit; 147 /* 148 * The following flag is set to true if /usr/ucb is found in the path 149 * before /usr/bin. This value is checked when executing the echo and test 150 * built-in commands. If true, the command behaves as in BSD systems. 151 */ 152 int ucb_builtins; 153 154 /* The following stuff is from stak.h */ 155 156 /* 157 * staktop = stakbot + local stak size 158 */ 159 unsigned char *stakbas; /* Stack base after addblok() */ 160 unsigned char *staktop; /* Points behind local stak */ 161 unsigned char *stakbot = 0; /* Bottom addr for local stak */ 162 unsigned char *brkend; /* The first invalid address */ 163