defs.h revision 965005c81e0f731867d47892b9fb677030b102df
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License, Version 1.0 only
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (the "License"). You may not use this file except in compliance
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * or http://www.opensolaris.org/os/licensing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* All Rights Reserved */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _DEFS_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _DEFS_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma ident "%Z%%M% %I% %E% SMI"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef __cplusplus
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern "C" {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * UNIX shell
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* execute flags */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define XEC_EXECED 01
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define XEC_LINKED 02
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define XEC_NOSTOP 04
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* endjobs flags */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define JOB_STOPPED 01
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define JOB_RUNNING 02
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* error exits from various parts of shell */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ERROR 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYNBAD 2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SIGFAIL 2000
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SIGFLG 0200
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* command tree */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FPIN 0x0100
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FPOU 0x0200
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FAMP 0x0400
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define COMMSK 0x00F0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define CNTMSK 0x000F
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TCOM 0x0000
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TPAR 0x0010
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TFIL 0x0020
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TLST 0x0030
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TIF 0x0040
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TWH 0x0050
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TUN 0x0060
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TSW 0x0070
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TAND 0x0080
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TORF 0x0090
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TFORK 0x00A0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TFOR 0x00B0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define TFND 0x00C0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* execute table */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSSET 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSCD 2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSEXEC 3
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef RES /* include login code */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSLOGIN 4
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSNEWGRP 4
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSTRAP 5
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSEXIT 6
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSSHFT 7
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSWAIT 8
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSCONT 9
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSBREAK 10
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSEVAL 11
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSDOT 12
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSRDONLY 13
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSTIMES 14
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSXPORT 15
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSNULL 16
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSREAD 17
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSTST 18
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RES /* exclude umask code */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSUMASK 20
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSULIMIT 21
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSECHO 22
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSHASH 23
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSPWD 24
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSRETURN 25
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSUNS 26
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSMEM 27
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSTYPE 28
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSGETOPT 29
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSJOBS 30
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSFGBG 31
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSKILL 32
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSSUSP 33
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define SYSSTOP 34
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* used for input and output of shell */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define INIO 19
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* io nodes */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define USERIO 10
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IOUFD 15
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IODOC 16
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz#define IOPUT 32
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IOAPP 64
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IOMOV 128
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IORDW 256
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define IOSTRIP 512
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define INPIPE 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define OTPIPE 1
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* arg list terminator */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define ENDARGS 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <unistd.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "mac.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "mode.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "name.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <signal.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <sys/types.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* id's */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern pid_t mypid;
extern pid_t mypgid;
extern pid_t mysid;
/* getopt */
extern int optind;
extern int opterr;
extern int _sp;
extern char *optarg;
/* use sh-private versions of memory allocation routines */
#define alloc malloc
/* result type declarations */
extern int handle();
extern void chktrap();
extern void done(int)
__NORETURN;
extern void sh_free();
extern unsigned char *make();
extern unsigned char *movstr();
extern unsigned char *movstrn();
extern unsigned char *cwdget();
extern struct trenod *cmd();
extern struct trenod *makefork();
extern struct namnod *lookup();
extern struct namnod *findnam();
extern struct dolnod *useargs();
extern float expr();
extern unsigned char *catpath();
extern unsigned char *getpath();
extern unsigned char *nextpath();
extern unsigned char **scan();
extern unsigned char *mactrim();
extern unsigned char *macro();
extern void exname(struct namnod *);
extern void printnam(struct namnod *);
extern void printro(struct namnod *);
extern void printexp(struct namnod *);
extern unsigned int readwc();
extern unsigned int nextwc();
extern unsigned char skipc();
extern unsigned char **local_setenv();
extern time_t time();
extern void exitsh(int)
__NORETURN;
extern void failed(unsigned char *, const char *) __NORETURN;
extern void prf();
extern void assign(struct namnod *, unsigned char *);
extern void setmode(int);
extern void trim(unsigned char *);
extern void preacct(unsigned char *);
#define attrib(n, f) (n->namflg |= f)
#define round(a, b) (((int)(((char *)(a)+b)-1))&~((b)-1))
#define closepipe(x) (close(x[INPIPE]), close(x[OTPIPE]))
#define eq(a, b) (cf(a, b) == 0)
#define max(a, b) ((a) > (b)?(a):(b))
#define assert(x)
/* temp files and io */
extern int output;
extern int ioset;
extern struct ionod *iotemp; /* files to be deleted sometime */
extern struct ionod *fiotemp; /* function files to be deleted sometime */
extern struct ionod *iopend; /* documents waiting to be read at NL */
extern struct fdsave fdmap[];
extern int savpipe;
/* substitution */
extern int dolc;
extern unsigned char **dolv;
extern struct dolnod *argfor;
extern struct argnod *gchain;
/* stak stuff */
#include "stak.h"
/*
* If non-ANSI C, make const go away. We bring it back
* at the end of the file to avoid side-effects.
*/
#ifndef __STDC__
#define const
#endif
/* string constants */
extern const char atline[];
extern const char readmsg[];
extern const char colon[];
extern const char minus[];
extern const char nullstr[];
extern const char sptbnl[];
extern const char unexpected[];
extern const char endoffile[];
extern const char synmsg[];
/* name tree and words */
extern const struct sysnod reserved[];
extern const int no_reserved;
extern const struct sysnod commands[];
extern const int no_commands;
extern int wdval;
extern int wdnum;
extern int fndef;
extern int nohash;
extern struct argnod *wdarg;
extern int wdset;
extern BOOL reserv;
/* prompting */
extern const char stdprompt[];
extern const char supprompt[];
extern const char profile[];
extern const char sysprofile[];
/* locale testing */
extern const char localedir[];
extern int localedir_exists;
/* built in names */
extern struct namnod fngnod;
extern struct namnod cdpnod;
extern struct namnod ifsnod;
extern struct namnod homenod;
extern struct namnod mailnod;
extern struct namnod pathnod;
extern struct namnod ps1nod;
extern struct namnod ps2nod;
extern struct namnod mchknod;
extern struct namnod acctnod;
extern struct namnod mailpnod;
/* special names */
extern unsigned char flagadr[];
extern unsigned char *pcsadr;
extern unsigned char *pidadr;
extern unsigned char *cmdadr;
/* names always present */
extern const char defpath[];
extern const char mailname[];
extern const char homename[];
extern const char pathname[];
extern const char cdpname[];
extern const char ifsname[];
extern const char ps1name[];
extern const char ps2name[];
extern const char mchkname[];
extern const char acctname[];
extern const char mailpname[];
/* transput */
extern unsigned char tmpout[];
extern int tmpout_offset;
extern unsigned int serial;
/*
* allow plenty of room for size for temp file name:
* "/tmp/sh"(7) + <pid> (<=6) + <unsigned int #> (<=10) + \0 (1)
*/
#define TMPOUTSZ 32
extern struct fileblk *standin;
#define input (standin->fdes)
#define eof (standin->feof)
extern int peekc;
extern int peekn;
extern unsigned char *comdiv;
extern
#ifdef __STDC__
const
#endif
char devnull[];
/* flags */
#define noexec 01
#define sysflg 01
#define intflg 02
#define prompt 04
#define setflg 010
#define errflg 020
#define ttyflg 040
#define forked 0100
#define oneflg 0200
#define rshflg 0400
#define subsh 01000
#define stdflg 02000
#define STDFLG 's'
#define execpr 04000
#define readpr 010000
#define keyflg 020000
#define hashflg 040000
#define nofngflg 0200000
#define exportflg 0400000
#define monitorflg 01000000
#define jcflg 02000000
#define privflg 04000000
#define forcexit 010000000
#define jcoff 020000000
#define pfshflg 040000000
extern long flags;
extern int rwait; /* flags read waiting */
/* error exits from various parts of shell */
#include <setjmp.h>
extern jmp_buf subshell;
extern jmp_buf errshell;
/* fault handling */
#include "brkincr.h"
extern unsigned brkincr;
#define MINTRAP 0
#define MAXTRAP NSIG
#define TRAPSET 2
#define SIGSET 4
#define SIGMOD 8
#define SIGIGN 16
extern BOOL trapnote;
/* name tree and words */
extern unsigned char **environ;
extern unsigned char numbuf[];
extern const char export[];
extern const char duperr[];
extern const char readonly[];
/* execflgs */
extern int exitval;
extern int retval;
extern BOOL execbrk;
extern int loopcnt;
extern int breakcnt;
extern int funcnt;
extern int tried_to_exit;
/* messages */
extern const char mailmsg[];
extern const char coredump[];
extern const char badopt[];
extern const char badparam[];
extern const char unset[];
extern const char badsub[];
extern const char nospace[];
extern const char nostack[];
extern const char notfound[];
extern const char badtrap[];
extern const char baddir[];
extern const char badshift[];
extern const char restricted[];
extern const char execpmsg[];
extern const char notid[];
extern const char badulimit[];
extern const char badresource[];
extern const char badscale[];
extern const char ulimit[];
extern const char wtfailed[];
extern const char badcreate[];
extern const char nofork[];
extern const char noswap[];
extern const char piperr[];
extern const char badopen[];
extern const char badnum[];
extern const char badsig[];
extern const char badid[];
extern const char arglist[];
extern const char txtbsy[];
extern const char toobig[];
extern const char badexec[];
extern const char badfile[];
extern const char badreturn[];
extern const char badexport[];
extern const char badunset[];
extern const char nohome[];
extern const char badperm[];
extern const char mssgargn[];
extern const char libacc[];
extern const char libbad[];
extern const char libscn[];
extern const char libmax[];
extern const char emultihop[];
extern const char nulldir[];
extern const char enotdir[];
extern const char enoent[];
extern const char eacces[];
extern const char enolink[];
extern const char exited[];
extern const char running[];
extern const char ambiguous[];
extern const char nosuchjob[];
extern const char nosuchpid[];
extern const char nosuchpgid[];
extern const char usage[];
extern const char nojc[];
extern const char killuse[];
extern const char jobsuse[];
extern const char stopuse[];
extern const char ulimuse[];
extern const char nocurjob[];
extern const char loginsh[];
extern const char jobsstopped[];
extern const char jobsrunning[];
/* 'builtin' error messages */
extern const char btest[];
extern const char badop[];
#ifndef __STDC__
#undef const /* bring back const */
#endif
/* fork constant */
#define FORKLIM 32
extern address end[];
#include "ctype.h"
#include <ctype.h>
#include <locale.h>
extern int eflag;
extern int ucb_builtins;
/*
* Find out if it is time to go away.
* `trapnote' is set to SIGSET when fault is seen and
* no trap has been set.
*/
#define sigchk() if (trapnote & SIGSET) \
exitsh(exitval ? exitval : SIGFAIL)
#define exitset() retval = exitval
/* Multibyte characters */
void setwidth();
unsigned char *readw();
#include <stdlib.h>
#include <limits.h>
#define MULTI_BYTE_MAX MB_LEN_MAX
#ifdef __cplusplus
}
#endif
#endif /* _DEFS_H */