defs.h revision 81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6a
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2008 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* David Korn
* AT&T Labs
*
* Shell interface private definitions
*
*/
#ifndef defs_h_defined
#define defs_h_defined
#include <ast.h>
#include <sfio.h>
#include <error.h>
#include <cdt.h>
#include <history.h>
#include "fault.h"
#include "argnod.h"
#include "name.h"
#define _SH_PRIVATE
#include <shcmd.h>
#ifndef pointerof
#define pointerof(x) ((void*)((char*)0+(x)))
#endif
#if SHOPT_ENV
# include <env.h>
#else
# define Env_t void
# define sh_envput(e,p) env_change()
# define env_delete(e,p) env_change()
#endif
/*
* note that the first few fields have to be the same as for
* Shscoped_t in <shell.h>
*/
struct sh_scoped
{
int dolc;
char **dolv;
char *cmdname;
char *filename;
char *funname;
int lineno;
int states;
int breakcnt;
int execbrk;
int loopcnt;
int firstline;
short optchar;
short opterror;
int ioset;
unsigned short trapmax;
char **trapcom;
char **otrapcom;
void *timetrap;
};
struct limits
{
long arg_max; /* max arg+env exec() size */
int open_max; /* maximum number of file descriptors */
int clk_tck; /* number of ticks per second */
int child_max; /* maxumum number of children */
int ngroups_max; /* maximum number of process groups */
unsigned char posix_version; /* posix version number */
unsigned char posix_jobcontrol;/* non-zero for job control systems */
unsigned char fs3d; /* non-zero for 3-d file system */
};
#define _SH_PRIVATE \
int **fdptrs; /* pointer to file numbers */ \
int savexit; \
char *lastarg; \
char *lastpath; /* last alsolute path found */ \
int path_err; /* last error on path search */ \
long timeout; /* read timeout */ \
short curenv; /* current subshell number */ \
short jobenv; /* subshell number for jobs */ \
int infd; /* input file descriptor */ \
int nextprompt; /* next prompt is PS<nextprompt> */ \
int bltin_nnodes; /* number of bltins nodes */ \
char *outbuff; /* pointer to output buffer */ \
char *errbuff; /* pointer to stderr buffer */ \
char *prompt; /* pointer to prompt string */ \
char *shname; /* shell name */ \
char *shpath; /* path name of shell */ \
char *user; /* name of real user for pfsh */ \
char *comdiv; /* points to sh -c argument */ \
char *prefix; /* prefix for compound assignment */ \
char **sigmsg; /* points to signal messages */ \
int oldexit; \
int topfd; \
int sigmax; /* maximum number of signals */ \
int savesig; \
unsigned char *sigflag; /* pointer to signal states */ \
char intrap; \
char login_sh; \
char lastbase; \
char forked; \
char binscript; \
char deftype; \
char funload; \
char used_pos; /* used postional parameter */\
char universe; \
char winch; \
char indebug; /* set when in debug trap */ \
unsigned char lastsig; /* last signal received */ \
char subshare; /* set when in ${..} comsub */ \
char *readscript; /* set before reading a script */ \
int *inpipe; /* input pipe pointer */ \
int *outpipe; /* output pipe pointer */ \
int cpipe[2]; \
int coutpipe; \
int inuse_bits; \
int fn_depth; \
int fn_reset; \
int dot_depth; \
int hist_depth; \
int xargmin; \
int xargmax; \
int xargexit; \
int nenv; \
long nforks; \
void *init_context; \
void *mac_context; \
void *lex_context; \
void *arg_context; \
void *ed_context; \
void *job_context; \
void *pathlist; \
void *defpathlist; \
void *cdpathlist; \
char **argaddr; \
void *optlist; \
char *cur_line; \
char *rcfile; \
char **login_files; \
int offsets[10]; \
unsigned char *fdstatus; \
const char *pwd; \
void *jmpbuffer; \
void *mktype; \
char ifstable[256]; \
unsigned char sigruntime[2]; \
unsigned long test; \
int *stats; \
#include <shell.h>
/* error exits from various parts of shell */
#ifndef SH_DICT
#endif
#ifndef SH_CMDLIB_DIR
#define SH_CMDLIB_DIR "/opt/ast/bin"
#endif
/* states */
/* low numbered states are same as options */
#define SH_NOFORK 0 /* set when fork not necessary, not a state */
#define SH_COMPLETE 0 /* set for command completion */
#define SH_BASH 41
#define SH_BRACEEXPAND 42
#define SH_POSIX 46
#define SH_MULTILINE 47
#define SH_NOPROFILE 78
#define SH_NOUSRPROFILE 79
#define SH_LOGIN_SHELL 67
#define SH_COMMANDLINE 0x100
#define SH_BASHEXTRA 0x200
#define SH_BASHOPT 0x400
/* defines for sh_type() */
#define SH_TYPE_SH 001
#define SH_TYPE_KSH 002
#define SH_TYPE_BASH 004
#define SH_TYPE_LOGIN 010
#define SH_TYPE_PROFILE 020
#define SH_TYPE_RESTRICTED 040
#if SHOPT_BASH
# ifndef SHOPT_HISTEXPAND
# define SHOPT_HISTEXPAND 1
# endif
/*
* define for all the bash options
*/
# define SH_CDABLE_VARS 51
# define SH_CDSPELL 52
# define SH_CHECKHASH 53
# define SH_CHECKWINSIZE 54
# define SH_CMDHIST 55
# define SH_DOTGLOB 56
# define SH_EXECFAIL 57
# define SH_EXPAND_ALIASES 58
# define SH_EXTGLOB 59
# define SH_HOSTCOMPLETE 63
# define SH_HUPONEXIT 64
# define SH_INTERACTIVE_COMM 65
# define SH_LITHIST 66
# define SH_MAILWARN 68
# define SH_NOEMPTYCMDCOMPL 69
# define SH_NOCASEGLOB 70
# define SH_NULLGLOB 71
# define SH_PHYSICAL 45
# define SH_PROGCOMP 72
# define SH_PROMPTVARS 73
# define SH_RESTRICTED2 74
# define SH_SHIFT_VERBOSE 75
# define SH_SOURCEPATH 76
# define SH_XPG_ECHO 77
#endif
#if SHOPT_HISTEXPAND
# define SH_HISTAPPEND 60
# define SH_HISTEXPAND 43
# define SH_HISTORY2 44
# define SH_HISTREEDIT 61
# define SH_HISTVERIFY 62
#endif
#ifndef PIPE_BUF
# define PIPE_BUF 512
#endif
#define MATCH_MAX 64
extern int sh_addlib(void*);
extern void *sh_argopen(Shell_t*);
extern char *sh_checkid(char*,char*);
extern int sh_echolist(Sfio_t*, int, char**);
extern char **sh_envgen(void);
#if SHOPT_ENV
#endif
extern void sh_envnolocal(Namval_t*,void*);
extern Sfdouble_t sh_arith(const char*);
extern void *sh_arithcomp(char*);
extern char *sh_mactrim(Shell_t*,char*,int);
extern void *sh_macopen(Shell_t*);
extern int sh_readline(Shell_t*,char**,int,int,long);
extern void sh_setmatch(const char*,int,int,int[]);
extern Dt_t *sh_subaliastree(int);
extern Dt_t *sh_subfuntree(int);
extern void sh_subjobcheck(pid_t);
extern int sh_subsavefd(int);
extern void sh_subtmpfile(int);
extern char *sh_substitute(const char*,const char*,char*);
extern const char *_sh_translate(const char*);
extern int sh_trace(char*[],int);
extern void sh_trim(char*);
extern int sh_type(const char*);
extern void sh_unscope(Shell_t*);
extern void sh_utol(const char*, char*);
extern int sh_whence(char**,int);
#ifndef ERROR_dictionary
# define ERROR_dictionary(s) (s)
#endif
#define WBITS (sizeof(long)*8)
#define WMASK (0xff)
#define sh_state(x) ( 1<<(x))
extern int32_t sh_mailchk;
extern const char e_dict[];
/* sh_printopts() mode flags -- set --[no]option by default */
#ifdef SHOPT_STATS
/* performance statistics */
# define STAT_ARGHITS 0
# define STAT_ARGEXPAND 1
# define STAT_COMSUB 2
# define STAT_FORKS 3
# define STAT_FUNCT 4
# define STAT_GLOBS 5
# define STAT_READS 6
# define STAT_NVHITS 7
# define STAT_NVOPEN 8
# define STAT_PATHS 9
# define STAT_SVFUNCT 10
# define STAT_SCMDS 11
# define STAT_SPAWN 12
# define STAT_SUBSHELL 13
extern const Shtable_t shtab_stats[];
#else
# define sh_stats(x)
#endif /* SHOPT_STATS */
#endif