/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* 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"
#include <ctype.h>
#ifndef pointerof
#define pointerof(x) ((void*)((char*)0+(x)))
#endif
#if SHOPT_ENV
# include <env.h>
#else
# define Env_t void
#endif
extern char* sh_getenv(const char*);
extern char* sh_setenviron(const char*);
/*
* 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 **otrap;
char **trapcom;
char **otrapcom;
void *timetrap;
};
struct limits
{
};
#ifndef SH_wait_f_defined
typedef int (*Shwait_f)(int, long, int);
# define SH_wait_f_defined
#endif
struct shared
{
char *shpath;
char *user;
char **sigmsg;
char *rcfile;
char **login_files;
void *ed_context;
void *init_context;
void *job_context;
int *stats;
int sigmax;
int nforks;
};
#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 */ \
short nextprompt; /* next prompt is PS<nextprompt> */ \
short poolfiles; \
char *outbuff; /* pointer to output buffer */ \
char *errbuff; /* pointer to stderr buffer */ \
char *prompt; /* pointer to prompt string */ \
char *shname; /* shell name */ \
char *comdiv; /* points to sh -c argument */ \
char *prefix; /* prefix for compound assignment */ \
char *fifo; /* fifo name for process sub */ \
int oldexit; \
pid_t outpipepid; \
int topfd; \
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 inarith; /* set when in ((...)) */ \
char indebug; /* set when in debug trap */ \
unsigned char ignsig; /* ignored signal in subshell */ \
unsigned char lastsig; /* last signal received */ \
char pathinit; /* pathinit called from subshell */ \
char comsub; /* set when in $() comsub */ \
char subshare; /* set when in ${..} comsub */ \
char toomany; /* set when out of fd's */ \
char instance; /* in set_instance */ \
char decomma; /* decimal_point=',' */ \
char redir0; /* redirect of 0 */ \
char *readscript; /* set before reading a script */ \
int subdup; /* bitmask for dups of 1 */ \
int *inpipe; /* input pipe pointer */ \
int *outpipe; /* output pipe pointer */ \
int cpipe[3]; \
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; \
void *init_context; \
void *mac_context; \
void *lex_context; \
void *arg_context; \
void *job_context; \
void *pathlist; \
void *defpathlist; \
void *cdpathlist; \
char **argaddr; \
void *optlist; \
char *cur_line; \
int offsets[10]; \
unsigned char *fdstatus; \
const char *pwd; \
void *jmpbuffer; \
void *mktype; \
Dt_t *first_root; \
Dt_t *prefix_root; \
char ifstable[256]; \
unsigned long test; \
char *mathnodes; \
void *coshell; \
char *bltin_dir; \
#include <shell.h>
#include "shtable.h"
#include "regress.h"
/* error exits from various parts of shell */
#ifndef SH_DICT
#endif
#ifndef SH_CMDLIB_DIR
#endif
/* states */
/* low numbered states are same as options */
/* defines for sh_type() */
#if SHOPT_BASH
# ifndef SHOPT_HISTEXPAND
# endif
/*
* define for all the bash options
*/
#endif
#if SHOPT_HISTEXPAND
#endif
#ifndef PIPE_BUF
#endif
#endif
extern void *sh_argopen(Shell_t*);
extern char *sh_checkid(char*,char*);
extern void sh_chktrap(Shell_t*);
extern char **sh_envgen(void);
#if SHOPT_ENV
#endif
extern void sh_envnolocal(Namval_t*,void*);
extern void *sh_arithcomp(Shell_t *,char*);
extern char *sh_mactrim(Shell_t*,char*,int);
extern void *sh_macopen(Shell_t*);
extern int sh_mathstd(const char*);
extern void sh_setmatch(Shell_t*,const char*,int,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(Shell_t*);
extern char *sh_substitute(const char*,const char*,char*);
extern void sh_timetraps(Shell_t*);
extern const char *_sh_translate(const char*);
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);
#if SHOPT_COSHELL
extern int sh_coaddfile(Shell_t*,char*);
extern int sh_coaccept(Shell_t*,int[],int);
#endif /* SHOPT_COSHELL */
#if SHOPT_NAMESPACE
#endif /* SHOPT_NAMESPACE */
#ifndef ERROR_dictionary
# define ERROR_dictionary(s) (s)
#endif
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
extern const Shtable_t shtab_stats[];
#else
# define sh_stats(x)
#endif /* SHOPT_STATS */
#endif