1
0

Source code upload

This commit is contained in:
calmsacibis995
2022-09-29 17:59:04 +03:00
parent 72fa9da3d7
commit 8fc8fa8089
33399 changed files with 11964078 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/brkincr.h 1.7.4.1"
/*
* UNIX shell
* S. R. Bourne
* Rewritten by David Korn
*
*/
#define ERRTRAP (MAXTRAP-2)
#define DEBUGTRAP (MAXTRAP-1)
#ifndef SIGCHLD
# ifdef SIGCLD
# define SIGCHLD SIGCLD
# endif
#endif
#define SIGBITS 8
#undef SIGIGNORE
#define SIGIGNORE 1 /* signal handler set to ignore */
#define TRAPSET 2 /* signal received and trap is set */
#define SIGSET 4 /* signal received and trap not set */
#define SIGMOD 8 /* modified signal handler */
#undef SIGCAUGHT
#define SIGCAUGHT 16 /* default action is to catch signal */
#undef SIGOFF
#define SIGOFF 32 /* signal ignored by parent */
#undef SIGDONE
#define SIGDONE 64 /* default action is clean up and exit */
#undef SIGFAULT
#define SIGFAULT 128 /* signal handler set to sh_fault */
#undef SIGFAIL
#define SIGSLOW 256 /* slow signal received */
#define SIGBEGIN 512 /* set during signal initialization */
#define SIGFAIL 0600
#undef SIGFLG
#define SIGFLG 0200
#define EXITMASK 0377
#ifdef PROTO
extern void sh_fault(int);
extern void sh_done(int);
extern void sh_chktrap(void);
extern void sh_exit(int);
extern void sig_clear(int);
extern int sig_ignore(int);
extern void sig_init(void);
extern void sig_ontrap(int);
extern void sig_reset(int);
#else
extern void sh_fault();
extern void sh_done();
extern void sh_chktrap();
extern void sh_exit();
extern void sig_clear();
extern int sig_ignore();
extern void sig_init();
extern void sig_ontrap();
extern void sig_reset();
extern void sig_funset();
#endif /* PROTO */
extern const char e_space[];
extern const struct sysmsgnod sig_messages[];
extern const struct sysnod sig_names[];

View File

@@ -0,0 +1,224 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/builtins.h 1.4.4.1"
#define SYSDECLARE 0x100
#define SYSLOGIN (sh.bltin_cmds)
#define SYSEXEC (sh.bltin_cmds+1)
#define SYSSET (sh.bltin_cmds+2)
#define SYSNULL (sh.bltin_cmds+3)
#define SYSTRUE (sh.bltin_cmds+4)
#define SYSNEWGRP (sh.bltin_cmds+5)
extern int b_login();
extern int b_exec();
extern int b_set();
extern int b_null();
#ifdef apollo
# ifndef LDYNAMIC
# define LDYNAMIC 1
# endif /* !LDYNAMIC */
extern int b_rootnode();
extern int b_ver();
#endif /* apollo */
#ifdef LDYNAMIC
extern int b_inlib();
# ifndef apollo
extern int b_builtin();
# endif /* !apollo */
#endif /* LDYNAMIC */
extern int b_dot();
extern int b_test();
extern int b_alias();
extern int b_hash();
extern int b_break();
extern int b_chdir();
extern int b_command();
extern int b_continue();
#ifndef ECHOPRINT
extern int b_echo();
#endif /* ECHOPRINT */
extern int b_ret_exit();
extern int b_export();
extern int b_eval();
extern int b_fc();
#ifdef JOBS
extern int b_jobs();
extern int b_kill();
# ifdef SIGTSTP
extern int b_bgfg();
# endif /* SIGTSTP */
#endif /* JOBS */
extern int b_let();
extern int b_print();
extern int b_pwd();
extern int b_read();
extern int b_readonly();
extern int b_shift();
extern int b_test();
extern int b_times();
extern int b_trap();
extern int b_typeset();
extern int b_ulimit();
extern int b_limit();
extern int b_unlimit();
extern int b_umask();
extern int b_unalias();
#ifdef UNIVERSE
extern int b_universe();
#endif /* UNIVERSE */
extern int b_unset();
extern int b_wait();
extern int b_whence();
extern int b_type();
extern int b_getopts();
#ifdef FS_3D
extern int b_vpath_map();
#endif /* FS_3D */
/* structure for builtin shell variable names and aliases */
struct name_value
{
#ifdef apollo
/* you can't readonly pointers */
const char nv_name[12];
const char nv_value[20];
#else
const char *nv_name;
const char *nv_value;
#endif /* apollo */
const unsigned short nv_flags;
};
#ifdef cray
/* The cray doesn't allow casting of function pointers to char* */
struct name_fvalue
{
const char *nv_name;
const int (*nv_value)();
const unsigned short nv_flags;
};
#endif /* cray */
/* The following defines are coordinated with data in msg.c */
#define PATHNOD (sh.bltin_nodes)
#define PS1NOD (sh.bltin_nodes+1)
#define PS2NOD (sh.bltin_nodes+2)
#define IFSNOD (sh.bltin_nodes+3)
#define PWDNOD (sh.bltin_nodes+4)
#define HOME (sh.bltin_nodes+5)
#define MAILNOD (sh.bltin_nodes+6)
#define REPLYNOD (sh.bltin_nodes+7)
#define SHELLNOD (sh.bltin_nodes+8)
#define EDITNOD (sh.bltin_nodes+9)
#define MCHKNOD (sh.bltin_nodes+10)
#define RANDNOD (sh.bltin_nodes+11)
#define ENVNOD (sh.bltin_nodes+12)
#define HISTFILE (sh.bltin_nodes+13)
#define HISTSIZE (sh.bltin_nodes+14)
#define FCEDNOD (sh.bltin_nodes+15)
#define CDPNOD (sh.bltin_nodes+16)
#define MAILPNOD (sh.bltin_nodes+17)
#define PS3NOD (sh.bltin_nodes+18)
#define OLDPWDNOD (sh.bltin_nodes+19)
#define VISINOD (sh.bltin_nodes+20)
#define COLUMNS (sh.bltin_nodes+21)
#define LINES (sh.bltin_nodes+22)
#define PPIDNOD (sh.bltin_nodes+23)
#define L_ARGNOD (sh.bltin_nodes+24)
#define TMOUTNOD (sh.bltin_nodes+25)
#define SECONDS (sh.bltin_nodes+26)
#define ERRNO (sh.bltin_nodes+27)
#ifdef apollo
# define LINENO (sh.bltin_nodes+28)
# define OPTIND (sh.bltin_nodes+29)
# define OPTARG (sh.bltin_nodes+30)
#else
/* LINENO is 28 */
/* OPTIND is 29 */
#define OPTARGNOD (sh.bltin_nodes+30)
#endif /* apollo */
#define PS4NOD (sh.bltin_nodes+31)
#define FPATHNOD (sh.bltin_nodes+32)
#define LANGNOD (sh.bltin_nodes+33)
#define LCTYPENOD (sh.bltin_nodes+34)
#ifdef VPIX
# define DOSPATHNOD (sh.bltin_nodes+35)
# define VPIXNOD (sh.bltin_nodes+36)
# define NVPIX 2
#else
# define NVPIX 0
#endif /* VPIX */
#ifdef ACCT
# define ACCTNOD (sh.bltin_nodes+35+NVPIX)
# define NACCT NVPIX+1
#else
# define NACCT NVPIX
#endif /* ACCT */
#ifdef MULTIBYTE
# define CSWIDTHNOD (sh.bltin_nodes+35+NACCT)
# define NMULTI NACCT+1
#else
# define NMULTI NACCT
#endif /* MULTIBYTE */
#ifdef apollo
# define SYSTYPENOD (sh.bltin_nodes+35+NMULTI)
#endif /* apollo */
#define is_rbuiltin(t) ((t)->com.comnamp && \
nam_istype((t)->com.comnamp,N_BLTIN|BLT_FSUB)==N_BLTIN)
extern const char e_unlimited[];
extern const char e_ulimit[];
extern const char e_notdir[];
extern const char e_direct[];
extern const char e_defedit[];
#ifdef EMULTIHOP
extern const char e_multihop[];
#endif /* EMULTIHOP */
#ifdef ENAMETOOLONG
extern const char e_longname[];
#endif /* ENAMETOOLONG */
#ifdef ENOLINK
extern const char e_link[];
#endif /* ENOLINK */
#ifdef VPIX
extern const char e_vpix[];
extern const char e_vpixdir[];
#endif /* VPIX */
#ifdef apollo
extern MSG e_rootnode;
extern MSG e_nover;
extern MSG e_badver;
#endif /* apollo */
#ifdef LDYNAMIC
extern MSG e_badinlib;
#endif /* LDYNAMIC */
extern const struct name_value node_names[];
extern const struct name_value alias_names[];
extern const struct name_value tracked_names[];
#ifdef cray
extern const struct name_fvalue built_ins[];
#else
extern const struct name_value built_ins[];
#endif /* cray */
#ifdef _sys_resource_
extern const struct sysmsgnod limit_names[];
extern const struct sys2msgnod blimit_names[];
#else
# ifdef VLIMIT
extern struct sysmsgnod limit_names[];
# endif /* VLIMIT */
#endif /* _sys_resource_ */

629
eoe/cmd/ksh/include/defs.h Normal file
View File

@@ -0,0 +1,629 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/defs.h 1.2.4.1"
/*
* UNIX shell
* S. R. Bourne
* Rewritten by David Korn
*
*/
#include "sh_config.h"
#include <setjmp.h>
#include <signal.h>
#include <string.h>
#include <locale.h>
#include <msgs/uxsgish.h>
#ifndef NSIG
# define NSIG 32
#endif /* NSIG */
#ifdef _unistd_h
# include <unistd.h>
#endif /* _unistd_h */
#ifdef _sys_times_
# include <sys/times.h>
#else
struct tms
{
time_t tms_utime;
time_t tms_stime;
time_t tms_cutime;
time_t tms_cstime;
};
#endif /* _sys_times */
struct sysnod /* readonly tables */
{
#ifdef apollo
/* pointers can not be in readonly sections */
const char sysnam[28];
#else
const char *sysnam;
#endif /* apollo */
unsigned sysval;
};
struct sysmsgnod /* readonly tables */
{
char const *sysmsgid;
#ifdef apollo
/* pointers can not be in readonly sections */
const char sysnam[28];
#else
const char *sysnam;
#endif /* apollo */
unsigned sysval;
};
struct sys2msgnod /* readonly tables */
{
const char *sysmsgid;
const char *sysnam;
const char *sys2msgid;
const char *sys2nam;
unsigned sysval;
};
/* typedefs used in the shell */
typedef const char MSG[];
typedef const struct sysnod SYSTAB[];
typedef const struct sysmsgnod SYSMSGTAB[];
typedef const struct sys2msgnod SYS2MSGTAB[];
#include "name.h"
#include "shnodes.h"
#include "stak.h"
#include "shtype.h"
/* error exits from various parts of shell */
#define ERROR 1
#define SYNBAD 2
#define CMDBAD 124 /* For wordexp: command substitution not allowed */
#define CTXBAD 125 /* For wordexp: special chars in bad context */
#define EXEBAD 126 /* File found but not executable */
#define FNDBAD 127 /* File not found */
#define PIDBAD 127 /* Process id not found for b_wait() */
#define BYTESPERWORD ((unsigned)sizeof(char *))
#define NIL ((char*)0)
#define ENDARGS NIL /* arg list terminator */
#ifndef NULL
# define NULL 0
#endif
#define NULLSTR ((char*)e_nullstr)
#define OPATH 2 /* path offset for path_join */
/* leaves room for _= */
#define round(a,b) ((sizeof(char*)==sizeof(int))?\
(((int)(((a)+b)-1))&~((b)-1)):\
(((long)(((a)+b)-1))&~((b)-1)))
#define eq(a,b) (strcmp(a,b)==0)
#define max(a,b) ((a)>(b)?(a):(b))
#define assert(x) ;
#define exitset() (sh.savexit=sh.exitval)
/* flags */
typedef long optflag;
#ifdef INT16
# ifndef pdp11
# define _OPTIM_ 1
# endif /* pdp11 */
#endif /* INT16 */
#ifdef _OPTIM_
# define _HIGH_ 1
# define _LOW_ 1-_HIGH_
# define is_option(x) ((x)&0xffffL?\
st.flags.i[_LOW_]&(unsigned int)(x):\
st.flags.i[_HIGH_]&(unsigned int)((x)>>16))
# define on_option(x) ((x)&0xffffL?\
(st.flags.i[_LOW_] |= (unsigned int)(x)):\
(st.flags.i[_HIGH_] |= (unsigned int)((x)>>16)))
# define off_option(x) ((x)&0xffffL?\
(st.flags.i[_LOW_] &= ~(unsigned int)(x)):\
(st.flags.i[_HIGH_] &= ~(unsigned int)((x)>>16)))
#else
# define is_option(x) (st.flags.l & (x))
# define on_option(x) (st.flags.l |= (x))
# define off_option(x) (st.flags.l &= ~(x))
#endif /* _OPTIM_ */
#define Fixflg 1
#define Errflg 2
#define Readpr 3
#define Monitor 4
#define Intflg 5
#define Rshflg 6
#define Execpr 7
#define Keyflg 8
#define Noset 9
#define Noglob 10
#define Allexp 11
#define Wordexp 12
#define Noeof 13
#define Noclob 14
#define Markdir 15
#define Bgnice 16
#define Editvi 17
#define Viraw 18
#define Oneflg 19
#define Hashall 20
#define Stdflg 21
#define Noexec 22
#define Notify 23
#define Gmacs 24
#define Emacs 25
#define Privmod 26
#ifdef apollo
# define Aphysical 27
#endif /* apollo */
#define Nolog 28
#define Cflag 29
#define Nocmdst 30
#define FIXFLG (1<<Fixflg) /* used also as a state */
#define ERRFLG (1<<Errflg) /* used also as a state */
#define READPR (1<<Readpr) /* used also as a state */
#define MONITOR (1<<Monitor)/* used also as a state */
#define INTFLG (1<<Intflg) /* used also as a state */
#define RSHFLG (1L<<Rshflg)
#define EXECPR (1L<<Execpr)
#define KEYFLG (1L<<Keyflg)
#define NOSET (1L<<Noset)
#define NOGLOB (1L<<Noglob)
#define ALLEXP (1L<<Allexp)
#define WORDEXP (1L<<Wordexp)
#define NOEOF (1L<<Noeof)
#define NOCLOB (1L<<Noclob)
#define EMACS (1L<<Emacs)
#define BGNICE (1L<<Bgnice)
#define EDITVI (1L<<Editvi)
#define VIRAW (1L<<Viraw)
#define ONEFLG (1L<<Oneflg)
#define HASHALL (1L<<Hashall)
#define STDFLG (1L<<Stdflg)
#define NOEXEC (1L<<Noexec)
#define NOTIFY (1L<<Notify)
#define GMACS (1L<<Gmacs)
#define MARKDIR (1L<<Markdir)
#define PRIVM (1L<<Privmod)
#ifdef apollo
# define PHYSICAL (1L<<Aphysical)
#endif /* apollo */
#define NOLOG (1L<<Nolog)
#define CFLAG (1L<<Cflag)
#define NOCMDST (1L<<Nocmdst) /* Disable command substitution with WORDEXP */
/* states */
/* low numbered states are same as flags */
#define GRACE 0x1
#define PROMPT INTFLG
#define FORKED 0x80
#define PROFILE 0x100 /* set when processing profiles */
#define IS_TMP 0x200 /* set when TMPFD is available */
#define WAITING 0x400 /* set when waiting for command input */
#define RM_TMP 0x800 /* temp files to remove on exit */
#define FUNCTION 0x1000 /* set when entering a function */
#define RWAIT 0x2000 /* set when waiting for a read */
#define BUILTIN 0x4000 /* set when processing built-in command */
#define LASTPIPE 0x8000 /* set for last element of a pipeline */
#ifdef VFORK
# define VFORKED 0x10000 /* only used with VFORK mode */
#else
# define VFORKED 0
#endif /* VFORK */
#define CMD_SPC 0x20000 /* For builtin 'command' special features */
#define NOFUNC 0x40000 /* Builtin 'command' disables function lookup */
#define COMSUB 0x80000 /* Command substitution parsing */
#define FORKLIM 32 /* fork constant */
#define MEMSIZE 32*sizeof(int)/* default associative memory size for shell.
Must be a power of 2 */
#define NL '\n'
#define SP ' '
#define HIGHBIT 0200
#define TO_PRINT 0100 /* bit to set for printing control char */
#define MINTRAP 0
#define MAXTRAP NSIG+3 /* maximum number of traps */
/* print interface routines */
#ifdef PROTO
extern void p_flush(void);
extern void p_list(int,char*[]);
extern void p_nchr(int,int);
extern void p_char(int);
extern void p_num(int,int);
extern void p_prp(const char*);
extern void p_setout(int);
extern void p_str(const char*,int);
extern void p_sub(int,int);
#ifdef sgi
#define p_time(x,y) lp_time(x,y)
extern void lp_time(clock_t,int);
#else
extern void p_time(clock_t,int);
#endif
#else
extern void p_flush();
extern void p_list();
extern void p_nchr();
extern void p_char();
extern void p_num();
extern void p_prp();
extern void p_setout();
extern void p_str();
extern void p_sub();
extern void p_time();
#endif /*PROTO */
/* argument processing routines */
#ifdef PROTO
extern char **arg_build(int*,struct comnod*);
extern void arg_clear(void);
extern char *arg_dolminus(void);
extern struct dolnod *arg_free(struct dolnod*,int);
extern struct dolnod *arg_new(char*[],struct dolnod**);
extern int arg_opts(int,char**,unsigned int);
extern void arg_reset(struct dolnod*,struct dolnod*);
extern void arg_set(char*[]);
extern struct dolnod *arg_use(void);
#else
extern char **arg_build();
extern void arg_clear();
extern char *arg_dolminus();
extern struct dolnod *arg_free();
extern struct dolnod *arg_new();
extern int arg_opts();
extern void arg_reset();
extern void arg_set();
extern struct dolnod *arg_use();
#endif /*PROTO */
extern char *opt_arg;
extern int opt_opt;
extern int opt_index;
extern int opt_sp;
extern int opt_plus;
/* routines for name/value pair environment */
#ifdef PROTO
extern void env_arrayset(struct namnod*,int,char*[]);
extern char **env_gen(void);
extern int env_init(void);
extern struct namnod *env_namset(char*,struct Amemory*,int);
extern void env_nolocal(struct namnod*);
extern void env_prattr(struct namnod*);
extern int env_prnamval(struct namnod*,int);
extern int env_readline(char**,int,int);
extern void env_setlist(struct argnod*,int);
extern void env_scan(int,int,struct Amemory*,int,int);
#else
extern void env_arrayset();
extern char **env_gen();
extern int env_init();
extern struct namnod *env_namset();
extern void env_nolocal();
extern void env_prattr();
extern int env_prnamval();
extern int env_readline();
extern void env_setlist();
extern void env_scan();
#endif /*PROTO */
/* pathname handling routines */
#ifdef PROTO
extern void path_alias(struct namnod*,char*);
extern char *path_absolute(const char*);
extern char *path_basename(const char*);
extern char *pathcanon(char*);
extern void path_exec(char*[],struct argnod*);
extern int path_open(const char*,char*);
extern char *path_get(const char*);
extern char *path_join(char*,const char*);
extern char *path_pwd(int);
extern int path_search(const char*,int);
# ifdef LSTAT
extern int path_physical(char*);
# endif /* LSTAT */
# ifndef INT16
extern char *path_relative(const char*);
# endif /* INT16 */
#else
extern void path_alias();
extern char *path_absolute();
extern char *path_basename();
extern char *pathcanon();
extern void path_exec();
extern int path_open();
extern char *path_get();
extern char *path_join();
extern char *path_pwd();
extern int path_search();
# ifdef LSTAT
extern int path_physical();
# endif /* LSTAT */
# ifndef INT16
extern char *path_relative();
# endif /* INT16 */
#endif /*PROTO */
/* error messages */
extern MSG e_access;
extern MSG e_alias;
extern MSG e_aliasspc;
extern MSG e_ambiguous;
extern MSG e_argexp;
extern MSG e_arglist;
extern MSG e_atline;
extern MSG e_badscale;
extern MSG e_bltfn;
extern MSG e_builtexec;
extern MSG e_colon;
extern MSG e_combo;
extern MSG e_defpath;
extern MSG e_done;
extern MSG e_dot;
#ifdef ECHO_N
extern MSG e_echobin;
extern MSG e_echoflag;
#endif /* ECHO_N */
extern MSG e_envmarker;
extern MSG e_exec;
extern MSG e_fnhdr;
extern MSG e_fork;
extern MSG e_found;
extern MSG e_function;
extern MSG e_getmap;
extern MSG e_getvers;
extern MSG e_heading;
extern MSG e_invalidnm;
#ifdef ELIBACC
extern MSG e_libacc;
extern MSG e_libbad;
extern MSG e_libscn;
extern MSG e_libmax;
#endif /* ELIBACC */
extern MSG e_logout;
extern MSG e_mailmsg;
extern MSG e_minus;
extern MSG e_nargs;
extern MSG e_nlorsemi;
extern MSG e_nosuchres;
extern MSG e_no_access;
extern MSG e_nullstr;
extern MSG e_off;
extern MSG e_on;
extern MSG e_option;
extern MSG e_pexists;
#ifdef FLOAT
extern MSG e_precision;
#endif /* FLOAT */
#ifdef SHELLMAGIC
extern MSG e_prohibited;
#endif /* SHELLMAGIC */
extern MSG e_pwd;
extern MSG e_query;
extern MSG e_real;
extern MSG e_restricted;
extern MSG e_setmap;
extern MSG e_setpwd;
extern MSG e_setvpath;
extern MSG e_sptbnl;
extern MSG e_stdprompt;
extern MSG e_subst;
extern MSG e_supprompt;
extern MSG e_swap;
extern MSG e_sys;
extern MSG e_trap;
extern MSG e_toobig;
extern MSG e_traceprompt;
extern MSG e_txtbsy;
extern MSG e_ulimit;
extern MSG e_undefsym;
extern MSG e_user;
extern MSG e_version;
extern MSG e_write;
extern MSG e_command;
extern MSG is_;
extern MSG is_alias;
extern MSG is_builtin;
extern MSG is_spc_builtin;
extern MSG is_function;
extern MSG is_reserved;
extern MSG is_talias;
extern MSG is_xalias;
extern MSG is_xfunction;
extern MSG is_ufunction;
extern MSG is_pathfound;
extern const char e_recursive[];
#ifdef sgi
extern MSG e_badmagic;
#endif
extern MSG sc_hours;
extern MSG sc_minutes;
extern MSG sc_seconds;
extern MSG sc_megabytes;
extern MSG sc_kbytes;
extern MSG e_cant;
extern MSG e_set;
extern MSG e_remove;
extern MSG e_hard;
extern MSG e_limit;
extern MSG e_malloc_freejobs;
extern MSG e_jobs;
/* frequently referenced routines */
#ifdef PROTO
extern unsigned alarm(unsigned);
extern void free(char*);
extern char *malloc(unsigned);
extern char *mac_expand(char*);
extern char *mac_trim(char*,int);
extern int mac_here(struct ionod*);
extern char *mac_try(char*);
extern int sh_access(char*,int);
extern void sh_cfail(MSG);
extern char *sh_copy(const char*,char*);
extern void sh_fail(const char*,MSG,int);
extern void sh_fail_why(const char*,MSG,int);
extern void sh_funct(union anynode*,char*[],int,struct argnod*);
extern char *sh_heap(const char*);
extern char *sh_itos(int);
extern int sh_lookup(const char*,SYSTAB);
extern char *sh_substitute(const char*,const char*,char*);
extern void sh_trim(char*);
extern int sh_whence(char**,int);
extern int strmatch(const char*,const char*);
extern time_t time(time_t*);
extern clock_t times(struct tms*);
# ifdef FLOAT
extern double sh_arith(char*);
#else
extern long long sh_arith(char*);
# endif /* FLOAT */
extern int xpg_compliant(void);
#else
#error always use proto now
#endif /* PROTO */
/*
* Saves the state of the shell
*/
struct sh_scoped
{
struct ionod *iotemp; /* link list of here doc files */
struct slnod *staklist; /* link list of function stacks */
unsigned states;
union
{
long l;
#ifdef _OPTIM_
int i[2];
#endif /* _OPTIM_ */
} flags;
jmp_buf jmpbuf;
int breakcnt;
int execbrk;
int loopcnt;
int fn_depth;
int dot_depth;
int peekn;
char *cmdadr;
VOID (*intfn)(); /* Interrupt handler */
int cmdline;
int firstline;
int exec_flag;
int subflag;
int dolc;
char **dolv;
struct ionod *iopend;
struct argnod *gchain;
int ioset;
int linked;
struct fileblk *standin;
int curin;
int standout;
char *trapcom[MAXTRAP];
unsigned char trapflg[MAXTRAP];
};
extern struct sh_scoped st;
#define opt_flags st.flags.l
struct sh_static
{
struct Amemory *alias_tree; /* for alias names */
struct Amemory *track_tree; /* for tracked aliases*/
struct Amemory *fun_tree; /* for function names */
struct Amemory *var_tree; /* for shell variables*/
struct namnod *bltin_nodes; /* pointer to built-in variables */
struct namnod *bltin_cmds; /* pointer to built-in commands */
char *shname; /* shell name */
char *shinvoke; /* invoking shell name */
char *cmdname; /* name of current command */
char *lastpath; /* last alsolute path found */
char *comdiv; /* points to sh -c argument */
uid_t userid; /* real user id */
uid_t euserid; /* effective user id */
gid_t groupid; /* real group id */
gid_t egroupid; /* effective group id */
jmp_buf subshell; /* jump here for subshell */
jmp_buf errshell; /* return here on failures */
jmp_buf *freturn; /* return for functions return or
fatal errors */
char *sigmsg[NSIG+1];/* pointers to signal messages */
int exitval;
char *lastarg;
char *pwd; /* present working directory */
int oldexit;
int curout; /* current output descriptor */
pid_t pid; /* process id of shell */
pid_t bckpid; /* background process id */
pid_t subpid; /* command substitution process id */
long ppid; /* parent process id of shell */
int savexit;
int topfd;
int trapnote;
char login_sh;
char nested_sub; /* for nested command substitution */
char heretrace; /* set when tracing here doc */
char intrap; /* set when processing trap */
char *readscript; /* set before reading a script */
int reserv; /* set when reserved word possible */
int wdset; /* states for lexical analyzer
see sym.h */
struct argnod *wdarg; /* points to current token */
int wdnum; /* number associated with token */
int wdval; /* type of current token */
int owdval; /* saved token type for EOF */
int olineno; /* linenumber of saved token */
int lastsig; /* last signal received */
union io_eval un; /* used for sh_eval */
int *inpipe; /* input pipe pointer */
int *outpipe; /* output pipe pointer */
int cpipe[2];
pid_t cpid;
struct fileblk *savio; /* top of io stack */
};
extern struct sh_static sh;
extern time_t sh_mailchk;
extern int errno;
extern int sh_numjobs;
#ifdef pdp11
# define ulong long
# ifndef INT16
# define INT16
# endif /* INT16 */
#else
# define ulong unsigned long
#endif /* pdp11 */
#ifdef INT16
# define path_relative(p) (p)
#endif /* INT16 */
struct sh_optget
{
int opt_index;
int opt_opt;
int opt_sp;
int opt_plus;
};

177
eoe/cmd/ksh/include/edit.h Normal file
View File

@@ -0,0 +1,177 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/edit.h 1.2.4.1"
/*
* edit.h - common data structure for vi and emacs edit options
*
* David Korn
* AT&T Bell Laboratories
* Room 3C-526B
* Murray Hill, N. J. 07974
* Tel. x7975
*
*/
#ifndef KSHELL
# include <setjmp.h>
# include <signal.h>
# include <ctype.h>
#endif /* KSHELL */
#define LOOKAHEAD 80
#ifdef VENIX
# define READAHEAD 1
#else
# define READAHEAD LOOKAHEAD
#endif /* VENIX */
#ifdef MULTIBYTE
# ifndef ESS_MAXCHAR
# include "national.h"
# endif /* ESS_MAXCHAR */
# if ESS_MAXCHAR<=2
typedef unsigned short genchar;
# else
typedef long genchar;
# endif
# define CHARSIZE 2
#else
typedef char genchar;
# define CHARSIZE 1
#endif /* MULTIBYTE */
#define TABSIZE 8
#define PRSIZE 80
#define SEARCHSIZE 80
struct edit
{
int e_kill;
int e_erase;
int e_eof;
int e_fchar;
char e_plen; /* length of prompt string */
char e_crlf; /* zero if cannot return to beginning of line */
jmp_buf e_env;
int e_llimit; /* line length limit */
int e_hline; /* current history line number */
int e_hloff; /* line number offset for command */
int e_hismin; /* minimum history line number */
int e_hismax; /* maximum history line number */
int e_raw; /* set when in raw mode or alt mode */
int e_cur; /* current line position */
int e_eol; /* end-of-line position */
int e_pcur; /* current physical line position */
int e_peol; /* end of physical line position */
int e_mode; /* edit mode */
int e_index; /* index in look-ahead buffer */
int e_repeat;
int e_saved;
int e_fcol; /* first column */
int e_ucol; /* column for undo */
int e_addnl; /* set if new-line must be added */
int e_wsize; /* width of display window */
char *e_outbase; /* pointer to start of output buffer */
char *e_outptr; /* pointer to position in output buffer */
char *e_outlast; /* pointer to end of output buffer */
genchar *e_inbuf; /* pointer to input buffer */
char *e_prompt; /* pointer to buffer containing the prompt */
genchar *e_ubuf; /* pointer to the undo buffer */
genchar *e_killbuf; /* pointer to delete buffer */
char e_search[SEARCHSIZE]; /* search string */
genchar *e_Ubuf; /* temporary workspace buffer */
genchar *e_physbuf; /* temporary workspace buffer */
int e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
int e_fd; /* file descriptor */
int e_ttyspeed; /* line speed, also indicates tty parms are valid */
int *e_globals; /* global variables */
genchar *e_window; /* display window image */
char e_inmacro; /* processing macro expansion */
#ifndef KSHELL
char e_prbuff[PRSIZE]; /* prompt buffer */
#endif /* KSHELL */
};
#define FEMAX 50 /* maximum number of file matches for q_expand */
#undef MAXWINDOW
#define MAXWINDOW 160 /* maximum width window */
#define MINWINDOW 15 /* minimum width window */
#define DFLTWINDOW 80 /* default window width */
#define MAXPAT 100 /* maximum length for pattern word */
#define YES 1
#define NO 0
#define FAST 2
#define SLOW 1
#define RAWMODE 1
#define ALTMODE 2
#define DELETE '\177'
#define BELL '\7'
#define ESC 033
#define UEOF -2 /* user eof char synonym */
#define UERASE -3 /* user erase char synonym */
#define UINTR -4 /* user intr char synonym */
#define UKILL -5 /* user kill char synonym */
#define UQUIT -6 /* user quit char synonym */
#define cntl(x) (x&037)
#ifndef KSHELL
# define STRIP 0377
# define TO_PRINT 0100
# define GMACS 1
# define EMACS 2
# define VIRAW 4
# define EDITVI 8
# define NOHIST 16
# define EDITMASK 15
# define is_option(m) (opt_flag&(m))
extern char opt_flag;
# ifdef SYSCALL
# define read(fd,buff,n) syscall(3,fd,buff,n)
# else
# define read(fd,buff,n) rEAd(fd,buff,n)
# endif /* SYSCALL */
#endif /* KSHELL */
extern struct edit editb;
#ifdef PROTO
extern void ed_crlf(void);
extern void ed_putchar(int);
extern void ed_ringbell(void);
extern void ed_setup(int);
extern void ed_flush(void);
extern int ed_getchar(void);
extern int ed_virt_to_phys(genchar*,genchar*,int,int,int);
extern int ed_window(void);
extern void ed_ungetchar(int);
# ifdef KSHELL
extern int ed_macro(int);
extern int ed_expand(char[],int*,int*,int);
# endif /* KSHELL */
#else
extern void ed_crlf();
extern void ed_putchar();
extern void ed_ringbell();
extern void ed_setup();
extern void ed_flush();
extern int ed_getchar();
extern int ed_virt_to_phys();
extern int ed_window();
extern void ed_ungetchar();
# ifdef KSHELL
extern int ed_macro();
extern int ed_expand();
# endif /* KSHELL */
#endif /* PROTO */
extern const char e_runvi[];
#ifndef KSHELL
extern const char e_version[];
#endif /* KSHELL */

View File

@@ -0,0 +1,32 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/flags.h 1.1.4.1"
#define R_FLAG 01
#define I_FLAG 02
#define U_FLAG 04
#define L_FLAG 010
#define Z_FLAG 020
#define W_FLAG 040
#define S_FLAG 0100
#define T_FLAG 0200
#define M_FLAG 0400
#define X_FLAG 01000
#define N_FLAG 02000
#define F_FLAG 04000
#define G_FLAG 010000
#define P_FLAG 020000
#define V_FLAG 040000
#define E_FLAG 0100000
#define A_FLAG 0200000
#define B_FLAG 0400000
#define C_FLAG 01000000
#define D_FLAG 02000000
#define H_FLAG 04000000

View File

@@ -0,0 +1,108 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/history.h 1.1.4.1"
/*
* UNIX shell
* Header File for history mechanism
* written by David Korn
*
*/
#ifndef IOBSIZE
# define IOBSIZE 1024
#endif
#define FC_CHAR '!'
#define HIS_DFLT 128 /* default size of history list */
#define HISMAX (sizeof(int)*IOBSIZE)
#define HISBIG (0100000-1024) /* 1K less than maximum short */
#define HISLINE 16 /* estimate of average sized history line */
#define MAXLINE 258 /* longest history line permitted */
#define H_UNDO 0201 /* invalidate previous command */
#define H_CMDNO 0202 /* next 3 bytes give command number */
#define H_VERSION 1 /* history file format version no. */
struct history
{
struct fileblk *fixfp; /* file descriptor for history file */
int fixfd; /* file number for history file */
char *fixname; /* name of history file */
off_t fixcnt; /* offset into history file */
int fixind; /* current command number index */
int fixmax; /* number of accessible history lines */
int fixflush; /* set if flushed outside of hflush() */
off_t fixcmds[1]; /* byte offset for recent commands */
};
typedef struct
{
short his_command;
short his_line;
} histloc;
extern struct history *hist_ptr;
#ifndef KSHELL
extern char *getenv();
extern void p_flush();
extern void p_setout();
extern void p_char();
extern void p_str();
# ifdef __STDC__
# define nam_strval(s) getenv(#s)
# else
# define nam_strval(s) getenv("s")
# endif /* __STDC__ */
# define NIL ((char*)0)
# define sh_fail ed_failed
# define sh_copy ed_movstr
#endif /* KSHELL */
/* the following are readonly */
extern const char hist_fname[];
extern const char e_history[];
/* these are the history interface routines */
#ifdef PROTO
extern int hist_open(void);
extern void hist_cancel(void);
extern void hist_close(void);
extern int hist_copy(char*,int,int);
extern void hist_eof(void);
extern histloc hist_find(char*,int,int,int);
extern void hist_flush(void);
extern void hist_list(off_t,int,char*);
extern int hist_match(off_t,char*,int);
extern off_t hist_position(int);
extern void hist_subst(const char*,int,char*);
extern char *hist_word(char*,int);
# ifdef ESH
extern histloc hist_locate(int,int,int);
# endif /* ESH */
#else
extern int hist_open();
extern void hist_cancel();
extern void hist_close();
extern int hist_copy();
extern void hist_eof();
extern histloc hist_find();
extern void hist_flush();
extern void hist_list();
extern int hist_match();
extern off_t hist_position();
extern void hist_subst();
extern char *hist_word();
# ifdef ESH
extern histloc hist_locate();
# endif /* ESH */
#endif /* PROTO */

300
eoe/cmd/ksh/include/io.h Normal file
View File

@@ -0,0 +1,300 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/io.h 1.2.4.1"
/*
* UNIX shell
* S. R. Bourne
* rewritten by David Korn
*
*/
#include "sh_config.h"
#include <sys/stat.h>
#ifdef _unistd_
# include <unistd.h>
#endif /* _unistd_ */
#ifdef _fcntl_
# include <fcntl.h>
#endif /* _fcntl_ */
#ifndef O_CREAT
# ifdef _sys_file_
# include <sys/file.h>
# endif /* _sys_file_ */
#endif /* O_CREAT */
#ifndef S_ISDIR
# define S_ISDIR(m) (((m)&S_IFMT)==S_IFDIR)
#endif /* S_ISDIR */
#ifndef S_ISREG
# define S_ISREG(m) (((m)&S_IFMT)==S_IFREG)
#endif /* S_ISREG */
#ifndef NFILE
# define NFILE 20
#endif /* NFILE */
#ifndef IOBSIZE
# define IOBSIZE 1024
#endif /* IOBSIZE */
#define EOF (-1)
#define MAXTRY 12
#ifdef SEVENBIT
# define STRIP 0177
#else
# define STRIP 0377
#endif /* SEVENBIT */
/* used for input and output of shell */
#define TMPSIZ 20
#define ERRIO 2
#define USERIO 10
#ifdef sgi
#define FCIO (nfile-1) /* history file */
#ifdef KSHELL
# define INIO (nfile-2) /* saved standard ioput */
# define TMPIO (nfile-3) /* used for command substitution */
# define CINPIPE (nfile-4) /* default inpipe for co-process */
# define CINPIPE2 (nfile-5) /* other end of inpipe for co-process */
# define COTPIPE (nfile-6) /* default output pipe for co-process */
# define MAXFILES (nfile-USERIO) /* maximum number of saved open files */
# define F_STRING (nfile) /* file number for incore files */
# define F_INFINITE 0x7fff /* effectively infinite */
extern int nfile;
#endif /* KSHELL */
#else /* !sgi */
#define FCIO (NFILE-1) /* history file */
#ifdef KSHELL
# define INIO (NFILE-2) /* saved standard ioput */
# define TMPIO (NFILE-3) /* used for command substitution */
# define CINPIPE (NFILE-4) /* default inpipe for co-process */
# define CINPIPE2 (NFILE-5) /* other end of inpipe for co-process */
# define COTPIPE (NFILE-6) /* default output pipe for co-process */
# define MAXFILES (NFILE-USERIO) /* maximum number of saved open files */
# define F_STRING ((unsigned char)NFILE) /* file number for incore files */
# define F_INFINITE 0x7fff /* effectively infinite */
#endif /* KSHELL */
#endif /* sgi */
/* SHELL file I/O structure */
struct fileblk
{
char *ptr;
char *base;
char *last;
off_t fseek;
int flag;
#ifdef sgi
int fdes;
#else
unsigned char fdes;
#endif
#ifdef KSHELL
char ftype;
int flast;
char **feval;
struct fileblk *fstak;
unsigned flin;
#endif /* KSHELL */
};
#define filenum(fp) ((int)(fp->fdes)) /* file number */
#define fnobuff(fp) ((fp)->flag&IONBF) /* file is unbuffered */
#define IOREAD 0001
#define IOWRT 0002
#define IONBF 0004
#define IOFREE 0010
#define IOEOF 0020
#define IOERR 0040
#define IORW 0100
#define IOSLOW 0200
#define IOEDIT 0400
#ifdef sgi
extern struct fileblk **io_ftable;
#else
extern struct fileblk *io_ftable[NFILE];
#endif
#ifdef FNDELAY
#ifndef sgi
# undef EAGAIN
# define EAGAIN EWOULDBLOCK
# ifndef O_NONBLOCK
# define O_NONBLOCK FNDELAY
# endif /* !O_NONBLOCK */
#endif
#endif /* FNDELAY */
#ifndef O_CREAT
# define O_CREAT 0400
# define O_TRUNC 01000
# define O_APPEND 010
#endif /* O_CREAT */
#ifndef O_RDWR
# define O_RDONLY 0
# define O_WRONLY 01
# define O_RDWR 02
#endif /* O_RDWR */
#ifdef NOFCNTL
# define open myopen
# define F_DUPFD 0
# define F_GETFD 1
# define F_SETFD 2
#endif /* F_DUPFD */
#ifndef R_OK
# define F_OK 0 /* does file exist */
# define X_OK 1 /* is it executable by caller */
# define W_OK 2 /* writable by caller */
# define R_OK 4 /* readable by caller */
#endif /* R_OK */
#ifndef SEEK_SET
# define SEEK_SET 0 /* absolute offset */
# define SEEK_CUR 1 /* relative offset */
# define SEEK_END 2 /* EOF offset */
#endif /* SEEK_SET */
#ifdef S_IRUSR
# define RW_ALL (S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH)
#else
# define RW_ALL 0666
#endif /* S_IRUSR */
/*io nodes*/
#define INPIPE 0
#define OTPIPE 1
#define DUPFLG 0100
/*
* The remainder of this file is only used when compiled with shell
*/
#ifdef KSHELL
/* possible values for ftype */
#define F_ISSTRING 1
#define F_ISFILE 2
#define F_ISALIAS 3
#define F_ISEVAL 4
#define F_ISEVAL2 5
/* The following union is used for argument to sh_eval */
union io_eval
{
int fd;
char **com;
};
#define io_unreadc(c) (st.peekn |= (c)|MARK)
#define input (st.curin)
#define output (sh.curout)
#define newline() p_char(NL)
#define fisopen(fd) (io_access(fd,F_OK)==0)
#define fiswrite(fd) (io_access(fd,W_OK)==0)
#define fisread(fd) (io_access(fd,R_OK)==0)
#define fiseof(fp) ((fp)->flag&IOEOF)
#define fiserror(fp) ((fp)->flag&IOERR)
#define nextchar(fp) (*((fp)->ptr))
#define finbuff(fp) ((fp)->last - (fp)->ptr)
#ifndef clearerr
# define clearerr(fp) ((fp)->flag &= ~(IOERR|IOEOF))
#endif
struct filesave
{
short org_fd;
short dup_fd;
};
#ifdef PROTO
extern off_t lseek(int,off_t,int);
extern void io_clear(struct fileblk*);
extern void io_fclose(int);
extern int io_getc(int);
extern void io_init(int,struct fileblk*,char*);
extern int io_intr(struct fileblk*);
extern void io_push(struct fileblk*);
extern int io_pop(int);
extern int io_mktmp(char*);
extern off_t io_seek(int,off_t,int);
extern int io_readbuff(struct fileblk*);
extern int io_readc(void);
extern int io_renumber(int,int);
extern void io_sync(void);
extern void io_popen(int[]);
extern void io_pclose(int[]);
extern void io_restore(int);
struct ionod;
extern int io_redirect(struct ionod*,int);
extern void io_save(int,int);
extern void io_linkdoc(struct ionod*);
extern void io_swapdoc(struct ionod*);
extern int io_fopen(const char*);
extern void io_sopen(char*);
extern int io_access(int,int);
extern int io_nextc(void);
extern int ispipe(int);
#else
extern off_t lseek();
extern void io_clear();
extern void io_fclose();
extern int io_getc();
extern void io_init();
extern int io_intr();
extern void io_push();
extern int io_pop();
extern int io_mktmp();
extern off_t io_seek();
extern int io_readbuff();
extern int io_readc();
extern int io_renumber();
extern void io_sync();
extern void io_popen();
extern void io_pclose();
extern void io_restore();
extern int io_redirect();
extern void io_save();
extern void io_rmtemp();
extern void io_linkdoc();
extern void io_swapdoc();
extern int io_fopen();
extern void io_sopen();
extern int io_access();
extern int io_nextc();
extern int ispipe();
#endif /* PROTO */
extern void io_settemp();
extern char _sibuf[];
extern char _sobuf[];
extern struct fileblk io_stdin;
extern struct fileblk io_stdout;
extern char io_tmpname[];
/* the following are readonly */
extern const char e_create[];
extern const char e_file[];
extern const char e_open[];
extern const char e_pipe[];
extern const char e_flimit[];
extern const char e_fexists[];
extern const char e_unknown[];
extern const char e_endoffile[];
extern const char e_devnull[];
extern const char e_profile[];
extern const char e_suidprofile[];
extern const char e_sysprofile[];
extern const char e_devfdNN[];
#ifdef SUID_EXEC
extern const char e_suidexec[];
#endif /* SUID_EXEC */
#endif /* KSHELL */

170
eoe/cmd/ksh/include/jobs.h Normal file
View File

@@ -0,0 +1,170 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/jobs.h 1.2.4.1"
/*
* UNIX shell
* S. R. Bourne
* rewritten by David Korn
*
*/
#define LOBYTE 0377
#define MAXMSG 25
#define JOBTTY 2
#include "sh_config.h"
#ifdef JOBS
# include "terminal.h"
# undef ESCAPE
# ifdef FIOLOOKLD
/* Ninth edition */
extern int tty_ld, ntty_ld;
# define OTTYDISC tty_ld
# define NTTYDISC ntty_ld
# define killpg(pgrp,sig) kill(-(pgrp),sig)
# endif /* FIOLOOKLD */
# define job_nonstop() (st.states &= ~MONITOR)
# define job_terminate() job_walk(job_kill,SIGHUP,(char**)0)
/* send a hang-up signal to each of the jobs */
#else
# undef SIGTSTP
# undef SIGCHLD
# undef SIGCLD
# undef MONITOR
# define MONITOR 0
# define job_nonstop()
# define job_set(x)
# define job_reset(x)
#endif /* JOBS */
#if defined(CHILD_MAX) && (CHILD_MAX>256)
# define MAXJ (CHILD_MAX-1)
#else
# define MAXJ 256
#endif /* CHILD_MAX */
/* JBYTES is the number of char's needed for MAXJ bits */
#define JBYTES (1+((MAXJ-1)/(8)))
struct process
{
struct process *p_nxtjob; /* next job structure */
struct process *p_nxtproc; /* next process in current job */
pid_t p_pid; /* process id */
pid_t p_pgrp; /* process group */
unsigned short p_job; /* job number of process */
pid_t p_fgrp; /* process group when stopped */
unsigned char p_flag; /* flags - see below */
unsigned short p_exit; /* exit value or signal number */
#ifdef JOBS
off_t p_name; /* history file offset for command */
struct termios p_stty; /* terminal state for job */
#endif /* JOBS */
};
/* Process states */
#define P_RUNNING 01
#define P_STOPPED 02
#define P_NOTIFY 04
#define P_SIGNALLED 010
#define P_STTY 020
#define P_DONE 040
#define P_COREDUMP 0100
#define P_BYNUM 0200
struct jobs
{
struct process *pwlist; /* head of process list */
pid_t curpgid; /* current process gid id */
pid_t parent; /* set by fork() */
pid_t mypid; /* process id of shell */
pid_t mypgid; /* process group id of shell */
pid_t mytgid; /* terminal group id of shell */
int numpost; /* number of posted jobs */
#ifdef JOBS
int suspend; /* suspend character */
int linedisc; /* line dicipline */
char jobcontrol; /* turned on for real job control */
#endif /* JOBS */
char pipeflag; /* set for pipelines */
char waitsafe; /* wait will not block */
unsigned char *freejobs; /* free jobs numbers */
};
extern struct jobs job;
#ifdef JOBS
extern const char e_jobusage[];
extern const char e_kill[];
extern const char e_Done[];
extern const char e_Running[];
extern const char e_coredump[];
extern const char e_killcolon[];
extern const char e_no_proc[];
extern const char e_no_job[];
extern const char e_running[];
extern const char e_nlspace[];
extern const char e_ambiguous[];
#ifdef SIGTSTP
extern const char e_no_start[];
extern const char e_terminate[];
extern const char e_no_jctl[];
#endif /* SIGTSTP */
#ifdef NTTYDISC
extern const char e_newtty[];
extern const char e_oldtty[];
#endif /* NTTYDISC */
#endif /* JOBS */
/*
* The following are defined in jobs.c
*/
#ifdef PROTO
extern void job_clear(void);
extern void job_bwait(char*[]);
extern int job_walk(int(*)(),int,char*[]);
extern int job_kill(struct process*,int);
#else
extern void job_clear();
extern int job_post();
extern void job_bwait();
extern int job_walk();
extern int job_kill();
#endif /* PROTO */
extern void job_wait();
extern int job_post();
extern int job_slot();
#ifdef JOBS
# ifdef PROTO
extern void job_init(int);
extern int job_close(void);
extern int job_list(struct process*,int);
# else
extern void job_init();
extern int job_close();
extern int job_list();
# endif /* PROTO */
#else
# define job_init(flag)
# define job_close() (0)
#endif /* JOBS */
#ifdef SIGTSTP
# ifdef PROTO
extern int job_switch(struct process*,int);
# else
extern int job_switch();
# endif /* PROTO */
#endif /* SIGTSTP */

262
eoe/cmd/ksh/include/name.h Normal file
View File

@@ -0,0 +1,262 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/name.h 1.2.4.1"
/*
* Definitions of structures for name-value pairs
* These structures are used for named variables, functions and aliases
*/
#include "sh_config.h"
#include "flags.h"
/* Nodes can have all kinds of values */
union Namval
{
char *cp;
int *ip;
char c;
int i;
unsigned u;
long *lp;
double *dp; /* for floating point arithmetic */
struct Namaray *aray; /* for array node */
union Namval *up; /* for indirect node */
struct Bfunction *fp; /* builtin-function like $RANDOM */
struct Ufunction *rp; /* shell user defined functions */
int (*ifp)(); /* integer function pointer */
};
/* each namnod and each array element has one of these */
struct Nodval
{
unsigned namflg; /* attributes */
union Namval namval; /* value field */
char *namenv; /* pointer to environment name */
short namsz; /* size of item */
};
#ifdef MULTIDIM
# define NDIM 7
#else
# define NDIM 1
#endif /* MULTIDIM */
/* This is an array template */
struct Namaray
{
unsigned short cur[NDIM+1]; /* current element */
unsigned short maxi; /* maximum index of array */
unsigned short nelem; /* number of elements */
struct Nodval *val[1]; /* array of value holders */
};
/* this bits are or'd with adot for a[*] and a[@] */
#define ARRAY_STAR 010000
#define ARRAY_AT 020000
#define ARRAY_UNDEF 040000
#define ARRAY_MASK 07777 /* ARRMAX cannot be larger than this */
#define ARRMAX 1024 /* maximum number of elements in an array */
#define ARRINCR 16 /* number of elements to grow when array bound exceeded
Must be a power of 2 */
/* These flags are used as options to array_get() */
#define A_ASSIGN 0
#define A_LOOKUP 1
#define A_DELETE 2
/* This is a template for a storage tree */
struct Amemory
{
struct Amemory *nexttree; /* search trees can be chained */
short memsize; /* number of listheads */
struct namnod *memhead[1]; /* listhead pointers */
};
/* This describes a named node */
struct namnod
{
struct namnod *namnxt; /* pointer to next namnod */
char *namid; /* pointer to name of item */
struct Nodval value; /* determines value of the item */
};
/* This describes a builtin function node */
struct Bfunction
{
long (*f_vp)(); /* value function */
int (*f_ap)(); /* assignment function */
};
/* This describes a user defined function node */
struct Ufunction
{
off_t hoffset; /* offset into history file */
int *ptree; /* address of parse tree */
};
#ifndef NULL
# define NULL 0
#endif
/* types of namenode items */
#define N_DEFAULT 0
#define N_INTGER I_FLAG /* integer type */
#define N_AVAIL B_FLAG /* node is logically non-existent, blocked */
#define N_CWRIT C_FLAG /* make copy of node on assignment */
#define N_ARRAY F_FLAG /* node is an array */
#define N_INDIRECT P_FLAG /* value is a pointer to a value node */
#define N_ALLOC V_FLAG /* don't allocate space for the value */
#define N_FREE G_FLAG /* don't free the space when releasing value */
#define N_LTOU U_FLAG /* convert to uppercase */
#define N_UTOL L_FLAG /* convert to lowercase */
#define N_ZFILL Z_FLAG /* right justify and fill with leading zeros */
#define N_RJUST W_FLAG /* right justify and blank fill */
#define N_LJUST S_FLAG /* left justify and blank fill */
#define N_HOST M_FLAG /* convert to host file name in non-unix */
#define N_EXPORT X_FLAG /* export bit */
#define N_RDONLY R_FLAG /* readonly bit */
#define N_RESTRICT V_FLAG /* restricted bit */
#define N_IMPORT N_FLAG /* imported from environment */
/* The following are used with INT_FLG */
#define N_BLTNOD S_FLAG /* builtin function flag */
#define N_DOUBLE M_FLAG /* for floating point */
#define N_EXPNOTE L_FLAG /* for scientific notation */
#define NO_LONG L_FLAG /* when integers are not long */
#define N_UNSIGN U_FLAG /* for unsigned quantities */
#define N_CPOINTER W_FLAG /* for pointer */
#define N_FUNCTION (N_INTGER|Z_FLAG)/* for function trees */
#define NO_CHANGE (N_EXPORT|N_IMPORT|N_RDONLY|E_FLAG|T_FLAG)
#define NO_PRINT (N_LTOU|N_UTOL)
#define NO_ALIAS (NO_PRINT|N_FLAG)
#define N_BLTIN (NO_PRINT|N_EXPORT)
#define BLT_SPC (G_FLAG) /* errors cause script to terminate */
#define BLT_FSUB (Z_FLAG) /* fork for command subsitution */
#define BLT_ENV (R_FLAG|Z_FLAG|M_FLAG) /* no separate environment */
#define BLT_DCL (S_FLAG) /* declaration command */
#define BLT_EXEC (V_FLAG) /* builtins that have exec version */
#define is_abuiltin(n) (nam_istype(n,N_BLTIN)==N_BLTIN)
#define is_afunction(n) (nam_istype(n,N_FUNCTION)==N_FUNCTION)
#define funtree(n) ((n)->value.namval.rp->ptree)
#define funptr(n) ((n)->value.namval.ifp)
/* namnod lookup options */
#define N_ADD 1 /* add node if not found */
#define N_NULL 2 /* null value returns NULL */
#define N_NOSCOPE G_FLAG /* look only in current scope */
/* NAMNOD MACROS */
/* ... for attributes */
#define namflag(n) (n)->value.namflg
#define nam_istype(n,f) (namflag(n) & (f))
#ifdef KSHELL
# define nam_ontype(n,f) ((n)->value.namflg |= f)
# define nam_typeset(n,f) ((n)->value.namflg = f)
# define nam_offtype(n,f) ((n)->value.namflg &= f)
# ifdef PROTO
extern char *nam_fstrval(struct namnod*);
# else
extern char *nam_fstrval();
# endif /* PROTO */
#else
# define nam_ontype(n,f) (nam_newtype (n, namflag(n)|(f)))
# define nam_typeset(n,f) (nam_newtype (n, f))
# define nam_offtype(n,f) (nam_newtype (n, namflag(n)&(f)))
#endif /* KSHELL */
/* ... etc */
#define isnull(n) ((n)->value.namval.cp == NULL) /* strings only */
#ifdef cray
# define _MARK_BIT_ 0x2000000000000000
#else
# define _MARK_BIT_ 01
#endif /* cray */
#define freeble(nv) (((int)(nv)) & _MARK_BIT_)
#define mrkfree(nv) ((struct Nodval*)(((int)(nv)) | _MARK_BIT_))
#define unmark(nv) ((struct Nodval*)(((int)(nv)) & ~_MARK_BIT_))
/* ... for arrays */
#define array_ptr(n) ((n)->value.namval.aray)
#define array_elem(n) array_ptr(n)->nelem
#ifdef PROTO
extern void array_dotset(struct namnod*,int);
extern struct Nodval *array_find(struct namnod*,int);
extern struct Namaray *array_grow(struct Namaray*,int);
extern char *array_subscript(struct namnod*,char*);
extern int array_next(struct namnod*);
#else
extern void array_dotset();
extern struct Nodval *array_find();
extern struct Namaray *array_grow();
extern char *array_subscript();
extern int array_next();
#endif /* PROTO */
#ifdef NAME_SCOPE
extern struct namnod *nam_copy();
#endif /* NAME_SCOPE */
#define new_of(type,x) ((type*)malloc((unsigned)sizeof(type)+(x)))
#ifdef PROTO
extern char *malloc(unsigned);
extern struct namnod *nam_alloc(const char*);
extern void nam_free(struct namnod*);
extern void nam_fputval(struct namnod*,char*);
extern int nam_hash(const char*);
extern void nam_init(void);
extern void nam_link(struct namnod*,struct Amemory*);
extern void nam_longput(struct namnod*,long);
extern void nam_newtype(struct namnod*,unsigned,int);
extern void nam_putval(struct namnod*,char*);
struct argnod; /* struct not declared yet */
extern void nam_scope(struct argnod*);
extern struct namnod *nam_search(const char*,struct Amemory*,int);
extern char *nam_strval(struct namnod*);
extern void nam_unscope(void);
#else
extern char *malloc();
extern struct namnod *nam_alloc();
extern void nam_free();
extern void nam_fputval();
extern int nam_hash();
extern void nam_init();
extern void nam_link();
extern void nam_longput();
extern void nam_newtype();
extern void nam_putval();
extern void nam_scope();
extern struct namnod *nam_search();
extern char *nam_strval();
extern void nam_unscope();
#endif /* PROTO */
extern const char e_synbad[];
extern const char e_subscript[];
extern const char e_number[];
extern const char e_nullset[];
extern const char e_notset[];
extern const char e_readonly[];
extern const char e_restricted[];
extern const char e_ident[];
extern const char e_intbase[];
extern const char e_format[];
extern const char e_aliname[];
extern int sh_lastbase;

View File

@@ -0,0 +1,66 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/national.h 1.1.4.1"
/* @(#)ksh:include/national.h 1.1.4.1 */
/*
* national.h - definitions for international character sets
*
* David Korn
* AT&T Bell Laboratories
* Room 5D-112
* Murray Hill, N. J. 07974
* Tel. x7975
*
*/
/*
* This data must be defined for each country in defs.c
*/
#ifndef HIGHBIT
# define HIGHBIT 0x80
#endif /* HIGHBIT */
#ifndef ESS_MAXCHAR /* allow multiple includes */
/*
* This section may change from country to country
*/
#define ESS_MAXCHAR 2 /* Maximum number of non-escape bytes
for any and all character sets */
#define CCS1_IN_SIZE 2
#define CCS1_OUT_SIZE 2
#define CCS2_IN_SIZE 1
#define CCS2_OUT_SIZE 1
#define CCS3_IN_SIZE 2
#define CCS3_OUT_SIZE 2
/*
* This part is generic
*/
#define MARKER 0x100 /* Must be invalid character */
#define ESS2 0x8e /* Escape to char set 2 */
#define ESS3 0x8f /* Escape to char set 3 */
#define ESS_SETMASK (3<<(7*ESS_MAXCHAR)) /* character set bits */
#define echarset(c) ((c)==ESS3?3:((c)==ESS2)?2:((c)>>7)&1)
#define icharset(i) ((i)>>(7*ESS_MAXCHAR)&3)
#define in_csize(s) int_charsize[s]
#define out_csize(s) int_charsize[s+4]
extern char int_charsize[8];
#endif /* ESS_MAXCHAR */

View File

@@ -0,0 +1,102 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/sh_config.h 1.6.4.5"
#ifndef _sh_config_
#define _sh_config_ 1
/*
* This has been generated from install/config
* The information is based on the compile time environment.
* It may be necessary to change values of some parameters for cross
* development environments.
*/
#include <sys/types.h>
#define _sys_acct_ 1
#define _dirent_ 1
#define _sys_dirent_ 1
#define _fcntl_ 1
#define _sys_fcntl_ 1
#define _sys_file_ 1
#define _sys_ioctl_ 1
#define _locale_ 1
#define _poll_ 1
#define _sys_stream_ 1
#define _sgtty_ 1
#define _sys_times_ 1
#define _termio_ 1
#define _sys_termio_ 1
#define _termios_ 1
#define _sys_wait_ 1
#define _unistd_ 1
#define _sys_utsname_ 1
#define _bin_grep_ 1
#define _usr_bin_lp_ 1
#define _usr_bin_vi_ 1
#define _bin_newgrp_ 1
#define _sys_resource_ 1
#ifdef __STDC__
#define VOID void
#define PROTO 1
#else
#ifdef PROTO
#undef PROTO
#endif
#define VOID char
#endif
#define SIG_NORESTART 1
#undef _sys_file_
#define signal sigset
#define sigrelease(s) sigrelse(s)
#define sig_begin()
#define NFILE 128
#define sh_rand() rand()
#define SETJMP setjmp
#define LONGJMP longjmp
#define PIPE_ERR 29
#define SHELLMAGIC 1
#define PATH_MAX 1024
#define HZ 100 /* 100 ticks/second of the clock */
#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
#define LSTAT 1
#define SYSCALL 1
#define DEVFD 1
#define JOBS 1
#define WINSIZE 1
#define _SELECT5_ 1
#define ESH 1
#define MULTIBYTE 1
#define NEWTEST 1
#define OLDTEST 1
#define VSH 1
#define SOCKET 1
#define ESHPLUS 1
#define POSIX 1
#define MULTIGROUPS 1
#define SETREUID 1
#define BRACEPAT 1
#define SUID_EXEC 1
#define YELLOWP 1
#endif
/*
** USL change:
** P_UID changed to PUID because of conflict with sys/procset.h
** PUID set for security
*/
#define PUID 1
/*
** USL change:
** ECHO_N set for BSD compat.
*/
#define ECHO_N 1

View File

@@ -0,0 +1,293 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/shnodes.h 1.2.4.2"
#ifndef _SHNODES_H
#define _SHNODES_H 1
/*
* UNIX shell
* Written by David Korn
*
*/
#include "stak.h"
#include "io.h"
#include "brkincr.h"
/* command tree for tretyp */
#define COMBITS 4
#define COMMSK ((1<<COMBITS)-1)
#define COMSCAN (01<<COMBITS)
#define FPRS (01<<COMBITS)
#define FINT (02<<COMBITS)
#define FAMP (04<<COMBITS)
#define FTMP (010<<COMBITS)
#define FPIN (020<<COMBITS)
#define FPOU (040<<COMBITS)
#define FPCL (0100<<COMBITS)
#define FCOMSUB (0200<<COMBITS)
#define FCOOP (0400<<COMBITS)
#define TNEGATE (01<<COMBITS)
#define TBINARY (02<<COMBITS)
#define TUNARY (04<<COMBITS)
#define TPAREN (010<<COMBITS)
#define TTEST (020<<COMBITS)
#define TSHIFT (COMBITS+5)
#define TCOM 0
#define TPAR 1
#define TFIL 2
#define TLST 3
#define TIF 4
#define TWH 5
#define TUN (TWH|COMSCAN)
#define TTST 6
#define TSW 7
#define TAND 8
#define TORF 9
#define TFORK 10
#define TFOR 11
#define TSELECT (TFOR|COMSCAN)
#define TARITH 12
#define TTIME 13
#define TSETIO 14
#define TPROC 15
struct slnod /* struct for link list of stacks */
{
struct slnod *slnext;
struct slnod *slchild;
Stak_t *slptr;
};
/* this node is a proforma for those that follow */
struct trenod
{
int tretyp;
struct ionod *treio;
};
struct dolnod
{
struct dolnod *dolnxt;
int doluse;
char *dolarg[1];
};
struct forknod
{
int forktyp;
struct ionod *forkio;
union anynode *forktre;
int forkline;
};
struct comnod
{
int comtyp;
struct ionod *comio;
struct argnod *comarg;
struct argnod *comset;
struct namnod *comnamp;
int comline;
};
struct ifnod
{
int iftyp;
union anynode *iftre;
union anynode *thtre;
union anynode *eltre;
};
struct whnod
{
int whtyp;
union anynode *whtre;
union anynode *dotre;
};
struct fornod
{
int fortyp;
union anynode *fortre;
char *fornam;
struct comnod *forlst;
};
struct swnod
{
int swtyp;
struct argnod *swarg;
struct regnod *swlst;
};
struct regnod
{
struct argnod *regptr;
union anynode *regcom;
struct regnod *regnxt;
char regflag;
};
struct parnod
{
int partyp;
union anynode *partre;
};
struct lstnod
{
int lsttyp;
union anynode *lstlef;
union anynode *lstrit;
};
struct procnod
{
int proctyp;
int procline;
union anynode *proctre;
char *procnam;
off_t procloc;
struct slnod *procstak;
};
struct ionod
{
int iofile;
char *ioname;
char *iolink;
struct ionod *ionxt;
struct ionod *iolst;
char *iodelim;
};
struct argnod
{
union
{
struct argnod *ap;
char *cp;
} argnxt;
struct argnod *argchn;
char argflag;
char argval[4];
};
struct arithnod
{
int artyp;
int arline;
struct argnod *arexpr;
};
/* The following should evaluate to the offset of argval in argnod */
#define ARGVAL ((unsigned)(((struct argnod*)(&sh))->argval-(char*)(&sh)))
/* mark for peek-ahead characters */
#define MARK 0200000
/* legal argument flags */
#define A_RAW 0x1 /* string needs no processing */
#define A_MAKE 0x2 /* bit set during argument expansion */
#define A_MAC 0x4 /* string needs macro expansion */
#define A_EXP 0x8 /* string needs file expansion */
#define A_SPLIT 0x10 /* string needs word splitting */
#define A_ALIAS 0x20 /* formal alias argument */
#define A_JOIN 0x40 /* join with next argument */
#ifdef sgi
/* types of ionodes */
#define IOUFD 0x3fffff /* mask back to index in file descriptor */
/* #if IOUFD < (nfile-1)
* this is a failure
* #endif
*/
#define IOPUT 0x400000
#define IOAPP 0x800000
#define IOMOV 0x1000000
#define IODOC 0x2000000
#define IOSTRIP 0x4000000
#define IOCLOB 0x8000000
#define IORDW 0x10000000
#define IORAW 0x20000000
#define IOSTRG 0x40000000
#else
/* types of ionodes */
#define IOUFD 0x7f /* mask back to index in file descriptor */
#if IOUFD != (NFILE-1)
this is a failure; abort here
#endif
#define IOPUT 0x80
#define IOAPP 0x100
#define IOMOV 0x200
#define IODOC 0x400
#define IOSTRIP 0x800
#define IOCLOB 0x1000
#define IORDW 0x2000
#define IORAW 0x4000
#define IOSTRG 0x8000
#endif /* sgi */
union anynode
{
struct argnod arg;
struct ionod io;
struct whnod wh;
struct swnod sw;
struct ifnod if_;
struct dolnod dol;
struct comnod com;
struct trenod tre;
struct forknod fork;
struct fornod for_;
struct regnod reg;
struct parnod par;
struct lstnod lst;
struct procnod proc;
struct arithnod ar;
};
#ifdef PROTO
extern union anynode *sh_mkfork(int,union anynode*);
extern union anynode *sh_parse(int,int);
extern int sh_lex(void);
extern void sh_freeup(void);
extern void sh_funstaks(struct slnod*,int);
extern void sh_eval(char*);
extern void sh_prompt(int);
extern void sh_syntax(void);
extern int sh_trace(char**,int);
extern int sh_exec(union anynode*,int);
#else
extern union anynode *sh_mkfork();
extern union anynode *sh_parse();
extern int sh_lex();
extern void sh_freeup();
extern void sh_funstaks();
extern void sh_eval();
extern void sh_prompt();
extern void sh_syntax();
extern int sh_trace();
extern int sh_exec();
#endif /* PROTO */
#endif /* _SHNODES_H */

View File

@@ -0,0 +1,115 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/shtype.h 1.2.4.1"
/*
* UNIX shell
*
* S. R. Bourne
* AT&T Bell Laboratories
*
*/
#include "sh_config.h"
/* table 1 */
#define QUOTE (~0177)
#define T_PSC 01 /* Special pattern characters, insert escape */
#define T_MET 02
#define T_SPC 04
#define T_DIP 010
#define T_EXP 020 /* characters which require expansion or substitution */
#define T_EOR 040
#define T_QOT 0100
#define T_ESC 0200
/* table 2 */
#define T_ALP 01 /* alpha, but not upper or lower */
#define T_DEF 02
#define T_PAT 04 /* special chars when preceding () */
#define T_DIG 010 /* digit */
#define T_UPC 020 /* uppercase only */
#define T_SHN 040 /* legal parameter characters */
#define T_LPC 0100 /* lowercase only */
#define T_SET 0200
/* for single chars */
#define _TAB (T_SPC)
#define _SPC (T_SPC)
#define _ALP (T_ALP)
#define _UPC (T_UPC)
#define _LPC (T_LPC)
#define _DIG (T_DIG)
#define _EOF (T_EOR)
#define _EOR (T_EOR)
#define _BAR (T_DIP|T_PSC)
#define _BRA (T_MET|T_DIP|T_EXP|T_PSC)
#define _KET (T_MET|T_PSC)
#define _AMP (T_DIP|T_PSC)
#define _SEM (T_DIP)
#define _LT (T_DIP)
#define _GT (T_DIP)
#define _LQU (T_QOT|T_ESC|T_EXP)
#define _QU1 T_EXP
#define _AST1 T_EXP
#define _BSL (T_ESC|T_PSC)
#define _DQU (T_QOT)
#define _DOL1 (T_ESC|T_EXP)
#define _CKT T_DEF
#define _AST (T_PAT|T_SHN)
#define _EQ (T_DEF)
#define _MIN (T_DEF|T_SHN)
#define _PCT (T_DEF|T_SET)
#define _PCS (T_SHN|T_PAT)
#define _NUM (T_DEF|T_SHN|T_SET)
#define _DOL2 (T_SHN|T_PAT)
#define _PLS (T_DEF|T_SET|T_PAT)
#define _AT (T_SHN|T_PAT)
#define _QU (T_DEF|T_SHN|T_PAT)
#define _LPAR T_SHN
#define _SS2 T_ALP
#define _SS3 T_ALP
/* abbreviations for tests */
#define _IDCH (T_UPC|T_LPC|T_DIG|T_ALP)
#define _META (T_SPC|T_DIP|T_MET|T_EOR)
extern const unsigned char _ctype1[];
/* these args are not call by value !!!! */
#define isblank(c) (_ctype1[c]&(T_SPC))
#define isspace(c) (_ctype1[c]&(T_SPC|T_EOR))
#define ismeta(c) (_ctype1[c]&(_META))
#define isqmeta(c) (_ctype1[c]&(_META|T_QOT))
#define qotchar(c) (_ctype1[c]&(T_QOT))
#define eolchar(c) (_ctype1[c]&(T_EOR))
#define dipchar(c) (_ctype1[c]&(T_DIP))
#define addescape(c) (_ctype1[c]&(T_PSC))
#define escchar(c) (_ctype1[c]&(T_ESC))
#define expchar(c) (_ctype1[c]&(T_EXP|_META|T_QOT))
#define isexp(c) (_ctype1[c]&T_EXP)
#define iochar(c) ((c)=='<'||(c)=='>')
extern const unsigned char _ctype2[];
#define isprint(c) (((c)&0340) && ((c)!=0177))
#define isdigit(c) (_ctype2[c]&(T_DIG))
#define dolchar(c) (_ctype2[c]&(_IDCH|T_SHN))
#define patchar(c) (_ctype2[c]&(T_PAT))
#define defchar(c) (_ctype2[c]&(T_DEF))
#define setchar(c) (_ctype2[c]&(T_SET))
#define isalpha(c) (_ctype2[c]&(T_UPC|T_LPC|T_ALP))
#define isalnum(c) (_ctype2[c]&(_IDCH))
#define isupper(c) (_ctype2[c]&(T_UPC))
#define islower(c) (_ctype2[c]&(T_LPC))
#define astchar(c) ((c)=='*'||(c)=='@')
#define toupper(c) ((c) + 'A' - 'a')
#define tolower(c) ((c) + 'a' - 'A')

View File

@@ -0,0 +1,67 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/stak.h 1.1.4.1"
#ifndef STAK_SMALL
/*
* David Korn
* AT&T Bell Laboratories
*
* Interface definitions for a stack-like storage library
*
*/
#if defined(__STDC__) || __cplusplus || c_plusplus
# define __ARGS(args) args
#else
# define const /*empty*/
# define __ARGS(args) ()
#endif
typedef struct _stak_
{
int stakleft; /* number of bytes left in frame */
char *staktop; /* current stack location */
char *stakbot; /* last returned stack location */
short stakref; /* reference count */
#ifdef _STAK_PRIVATE
_STAK_PRIVATE
#endif /* _STAK_PRIVATE */
} Stak_t;
#define STAK_SMALL 1 /* argument to stakcreate */
#if __cplusplus
extern "C"
{
#endif
extern Stak_t *stakcreate __ARGS((int));
extern Stak_t *stakinstall __ARGS((Stak_t*, char *(*)(int)));
extern int stakdelete __ARGS((Stak_t*));
extern char *stakalloc __ARGS((unsigned));
extern char *stakcopy __ARGS((const char*));
extern char *stakset __ARGS((char*, unsigned));
extern char *stakseek __ARGS((unsigned));
extern int stakputs __ARGS((const char*));
extern char *stakfreeze __ARGS((unsigned));
extern char *_stakgrow __ARGS((unsigned));
#if __cplusplus
}
#endif
extern Stak_t _stak_cur; /* used by macros */
#define staklink(sp) ((sp)->stakref++)
#define stakptr(n) (_stak_cur.stakbot+(n))
#define staktell() (_stak_cur.staktop-_stak_cur.stakbot)
#define stakputc(c) ((--_stak_cur.stakleft<0? _stakgrow(1):0), \
*_stak_cur.staktop++=(c))
#endif /* STAK_SMALL */

View File

@@ -0,0 +1,110 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/streval.h 1.1.4.1"
/*
* G. S. Fowler
* D. G. Korn
* AT&T Bell Laboratories
*
* long integer arithmetic expression evaluator
*/
/* The following only is needed for const */
#include "sh_config.h"
struct lval
{
char *value;
int flag;
};
#ifdef FLOAT
typedef double number;
#else
typedef long long number;
#endif /* FLOAT */
#define MAXPREC 15 /* maximum precision level */
#define SEQPOINT 0200 /* sequence point */
#define NOASSIGN 0100 /* assignment legal with this operator */
#define RASSOC 040 /* right associative */
#define NOFLOAT 020 /* illegal with floating point */
#define PRECMASK 017 /* precision bit mask */
#define DEFAULT 0
#define LPAREN 1
#define RPAREN 2
#define COMMA 3
#define ASSIGNMENT 4
#define MOD 5
#define LSHIFT 6
#define RSHIFT 7
#define PLUS 8
#define MINUS 9
#define DIVIDE 10
#define EQ 11
#define NEQ 12
#define LT 13
#define GT 14
#define LE 15
#define GE 16
#define AND 17
#define OR 18
#define XOR 19
#define ANDAND 20
#define OROR 21
#define DONE 22
#define NOT 23
#define QUEST 24
#define QCOLON 25
#define TIMES 26
#define ARROW 27
#define DOT 28
#define LBRACKET 29
#define RBRACKET 30
#define PLUSPLUS 31
#define MINUSMINUS 32
#define COLON 33
struct Optable
{
unsigned char opcode;
unsigned char precedence;
char name[2];
};
/* define error messages */
extern const char e_moretokens[];
extern const char e_paren[];
extern const char e_number[];
extern const char e_badcolon[];
extern const char e_recursive[];
extern const char e_divzero[];
extern const char e_synbad[];
extern const char e_notlvalue[];
#ifdef FLOAT
extern const char e_incompatible[];
#endif /* FLOAT */
/* function code for the convert function */
#define LOOKUP 0
#define ASSIGN 1
#define VALUE 2
#define ERRMSG 3
#ifdef PROTO
extern number streval(char*,char**,number(*)());
#else
extern number streval();
#endif /* PROTO */

94
eoe/cmd/ksh/include/sym.h Normal file
View File

@@ -0,0 +1,94 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/sym.h 1.3.4.1"
/*
* UNIX shell
* S. R. Bourne
* Rewritten by David Korn
*/
/* symbols for parsing */
#define NOTSYM '!'
#define DOSYM 0405
#define FISYM 0420
#define EFSYM 0422
#define ELSYM 0421
#define INSYM 0412
#define BRSYM 0406
#define KTSYM 0450
#define THSYM 0444
#define ODSYM 0441
#define ESSYM 0442
#define IFSYM 0436
#define FORSYM 0435
#define WHSYM 0433
#define UNSYM 0427
#define CASYM 0417
#define PROCSYM 0460
#define SELSYM 0470
#define TIMSYM 0474
#define BTSTSYM (SYMREP|'[')
#define ETSTSYM (SYMREP|']')
#define TESTUNOP 0466
#define TESTBINOP 0467
#define SYMREP 04000
#define ECSYM (SYMREP|';')
#define ANDFSYM (SYMREP|'&')
#define ORFSYM (SYMREP|'|')
#define APPSYM (SYMREP|'>')
#define DOCSYM (SYMREP|'<')
#define EXPRSYM (SYMREP|'(')
#define SYMALT1 01000
#define SYMALT2 010000
#define ECASYM (SYMALT1|'&')
#define COOPSYM (SYMALT1|'|')
#define IPROC (SYMALT1|'(')
#define OPROC (SYMALT2|'(')
#define EOFSYM 02000
#define SYMFLG 0400
/* arg to `sh_parse' */
#define NLFLG 1
#define MTFLG 2
/* odd chars */
#undef ESCAPE
#define DQUOTE '"'
#define SQUOTE '`'
#define DOLLAR '$'
#define LBRACE '{'
#define RBRACE '}'
#define LPAREN '('
#define RPAREN ')'
#define ESCAPE '\\'
#define COMCHAR '#' /* comment delimiter */
#define ENDOF 0
#define LITERAL '\'' /* single quote */
/* wdset flags */
/* KEYFLAG defined in defs.h, the others must have a different value */
#define IN_CASE 1
#define CAN_ALIAS 2
#define IN_TEST 4
#define TEST_OP1 8
#define TEST_OP2 16
extern SYSTAB tab_reserved;
extern SYSTAB tab_options;
extern SYSTAB tab_attributes;
extern const char e_unexpected[];
extern const char e_unmatched[];
#ifdef DEVFD
extern const char e_devfd[];
#endif /* DEVFD */

View File

@@ -0,0 +1,176 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/terminal.h 1.3.4.1"
/*
* terminal interface
*/
#ifndef _terminal_
#define _terminal_ 1
#ifdef _termios_
# include <termios.h>
# ifdef sgi /* special hack to eliminate ^M problem */
# undef ECHOCTL
# define ECHOCTL ECHOE
# ifndef CNSUSP
# define CNSUSP CNSWTCH
# endif /* CNSUSP */
# endif /* sgi */
#else
# ifdef _sys_termios_
# include <sys/termios.h>
# define _termios_
# endif /* _sys_termios_ */
#endif /* _termios_ */
#ifdef _termios_
# ifndef TCSANOW
# define TCSANOW TCSETS
# define TCSADRAIN TCSETSW
# define TCSAFLUSH TCSETSF
# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
# endif /* TCSANOW */
# if defined(TCADFLUSH) && !defined(TCAFLUSH)
# define TCAFLUSH TCADFLUSH
# endif
# undef TIOCGETC
# undef _termio_
# undef _sys_termio_
# undef _sgtty_
# undef _sys_ioctl_
# undef _sys_bsdtty_
#else
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
# undef OLDTERMIO
#endif /* _termios_ */
#ifdef _termio_
# include <termio.h>
#else
# ifdef _sys_termio_
# include <sys/termio.h>
# define _termio_ 1
# endif /* _sys_termio_ */
#endif /* _termio_ */
#ifdef _termio_
# define termios termio
# undef _sgtty_
# undef TIOCGETC
# undef _sys_ioctl_
# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
#endif /* _termio_ */
#ifdef _sys_bsdtty_
# include <sys/bsdtty.h>
#endif /* _sys_bsdtty_ */
#ifdef _sgtty_
# include <sgtty.h>
# ifdef _sys_nttyio_
# ifndef LPENDIN
# include <sys/nttyio.h>
# endif /* LPENDIN */
# endif /* _sys_nttyio_ */
# define termios sgttyb
# undef _sys_ioctl_
# ifdef TIOCSETN
# undef TCSETAW
# endif /* TIOCSETN */
# ifdef _SELECT_
# ifndef included_sys_time_
# ifdef _sys_Time_
# include <sys/time.h>
# endif /* _sys_Time_ */
# define included_sys_time_
# endif /* included_sys_time_ */
extern const int tty_speeds[];
# endif /* _SELECT_ */
# ifdef TIOCGETP
# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# else
# define tcgetattr(fd,tty) gtty(fd, tty)
# define tcsetattr(fd,action,tty) stty(fd, tty)
# endif /* TIOCGETP */
#endif /* _sgtty_ */
#ifndef TCSANOW
# ifdef TCSETAW
# define TCSANOW TCSETA
# ifdef u370
/* delays are too long, don't wait for output to drain */
# define TCSADRAIN TCSETA
# else
# define TCSADRAIN TCSETAW
# endif /* u370 */
# define TCSAFLUSH TCSETAF
# else
# ifdef TIOCSETN
# define TCSANOW TIOCSETN
# define TCSADRAIN TIOCSETN
# define TCSAFLUSH TIOCSETP
# endif /* TIOCSETN */
# endif /* TCSETAW */
#endif /* TCSANOW */
#endif /* _terminal_ */
/* set ECHOCTL if driver can echo control charaters as ^c */
#ifdef LCTLECH
# ifndef ECHOCTL
# define ECHOCTL LCTLECH
# endif /* !ECHOCTL */
#endif /* LCTLECH */
#ifdef LNEW_CTLECH
# ifndef ECHOCTL
# define ECHOCTL LNEW_CTLECH
# endif /* !ECHOCTL */
#endif /* LNEW_CTLECH */
#ifdef LNEW_PENDIN
# ifndef PENDIN
# define PENDIN LNEW_PENDIN
# endif /* !PENDIN */
#endif /* LNEW_PENDIN */
#ifndef ECHOCTL
# ifndef VEOL2
# define RAWONLY 1
# endif /* !VEOL2 */
#endif /* !ECHOCTL */
#ifdef _sys_filio_
# ifndef FIONREAD
# include <sys/filio.h>
# endif /* FIONREAD */
#endif /* _sys_filio_ */
/* set FIORDCHK if you can check for characters in input queue */
#ifdef FIONREAD
# ifndef FIORDCHK
# define FIORDCHK FIONREAD
# endif /* !FIORDCHK */
#endif /* FIONREAD */
#ifdef PROTO
extern int tty_alt(int);
extern void tty_cooked(int);
extern int tty_get(int,struct termios*);
extern int tty_raw(int);
extern int tty_check(int);
#else
extern int tty_alt();
extern void tty_cooked();
extern int tty_get();
extern int tty_raw();
extern int tty_check();
#endif /* PROTO */
extern int tty_set();

View File

@@ -0,0 +1,52 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/test.h 1.2.4.1"
/*
* UNIX shell
*
* David Korn
* AT&T Bell Laboratories
*
*/
/*
* These are the valid test operators
*/
#define TEST_ARITH 020 /* arithmetic operators */
#define TEST_BINOP 0200 /* binary operator */
#define TEST_PATTERN 040 /* turn off bit for pattern compares */
#define TEST_NE (TEST_ARITH|9)
#define TEST_EQ (TEST_ARITH|4)
#define TEST_GE (TEST_ARITH|5)
#define TEST_GT (TEST_ARITH|6)
#define TEST_LE (TEST_ARITH|7)
#define TEST_LT (TEST_ARITH|8)
#define TEST_OR (TEST_BINOP|1)
#define TEST_AND (TEST_BINOP|2)
#define TEST_SNE (TEST_PATTERN|1)
#define TEST_SEQ (TEST_PATTERN|13)
#define TEST_PNE 1
#define TEST_PEQ 13
#define TEST_EF 3
#define TEST_NT 10
#define TEST_OT 12
#define TEST_SLT 14
#define TEST_SGT 15
#define TEST_END 8
extern const char test_unops[];
extern const struct sysnod test_optable[];
extern const char e_test[];
extern const char e_bracket[];
extern const char e_paren[];
extern const char e_testop[];

View File

@@ -0,0 +1,24 @@
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "@(#)ksh:include/timeout.h 1.1.4.1"
/*
* UNIX shell
*
* S. R. Bourne
* AT&T Bell Laboratories
*
*/
#define TGRACE 60 /* grace period before termination */
/* The time_warn message contains this number */
extern long sh_timeout;
extern const char e_timeout[];
extern const char e_timewarn[];