shell.h revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Knowledge Ventures *
* *
* 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
#ifndef SH_INTERACTIVE
/*
* David Korn
* AT&T Labs
*
* Interface definitions for shell command language
*
*/
#include <cmd.h>
#include <cdt.h>
#ifdef _SH_PRIVATE
# include "name.h"
#else
# include <nval.h>
#endif /* _SH_PRIVATE */
#define SH_VERSION 20060510
#define NOT_USED(x) (&x,1)
/* options */
typedef struct
{
unsigned long v[4];
}
typedef void (*Shinit_f)(int);
typedef int (*Shbltin_f)(int, char*[], void*);
typedef int (*Shwait_f)(int, long, int);
union Shnode_u;
#define SH_CFLAG 0
#define SH_RESTRICTED 6
#define SH_XTRACE 7
#define SH_KEYWORD 8
#define SH_NOUNSET 9
#define SH_NOGLOB 10
#define SH_ALLEXPORT 11
#define SH_PFSH 12
#define SH_IGNOREEOF 13
#define SH_NOCLOBBER 14
#define SH_MARKDIRS 15
#define SH_BGNICE 16
#define SH_VI 17
#define SH_VIRAW 18
#define SH_TFLAG 19
#define SH_TRACKALL 20
#define SH_SFLAG 21
#define SH_NOEXEC 22
#define SH_GMACS 24
#define SH_EMACS 25
#define SH_PRIVILEGED 26
#define SH_NOLOG 28
#define SH_NOTIFY 29
#define SH_DICTIONARY 30
#define SH_PIPEFAIL 32
#define SH_GLOBSTARS 33
#define SH_XARGS 34
#define SH_RC 35
#define SH_SHOWME 36
/*
* passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
*/
#define SH_BEGIN_OPTIM 0x1
#define SH_END_OPTIM 0x2
/* The following type is used for error messages */
/* error messages */
extern const char e_defpath[];
extern const char e_found[];
extern const char e_nospace[];
extern const char e_format[];
extern const char e_number[];
extern const char e_restricted[];
extern const char e_recursive[];
extern char e_version[];
typedef struct sh_scope
{
int argc;
char **argv;
char *cmdname;
char *filename;
int lineno;
} Shscope_t;
/*
* Saves the state of the shell
*/
typedef struct sh_static
{
int inlineno; /* line number of current input file */
int exitval; /* most recent exit value */
char subshell; /* set for virtual subshell */
#ifdef _SH_PRIVATE
#endif /* _SH_PRIVATE */
} Shell_t;
/* flags for sh_parse */
/* symbolic values for sh_iogetiop */
#define SH_IOCOPROCESS (-2)
#define SH_IOHISTFILE (-3)
/* symbolic value for sh_fdnotify */
#define SH_FDCLOSE (-1)
#if defined(__EXPORT__) && defined(_DLL)
# ifdef _BLD_shell
# define extern __EXPORT__
# endif /* _BLD_shell */
#endif /* _DLL */
extern Dt_t *sh_bltin_tree(void);
extern void sh_subfork(void);
extern int sh_reinit(char*[]);
extern void sh_delay(double);
extern int sh_trap(const char*,int);
extern int sh_funscope(int,char*[],int(*)(void*),void*,int);
extern Sfio_t *sh_iogetiop(int,int);
extern int sh_main(int, char*[], void(*)(int));
extern Namval_t *sh_addbuiltin(const char*, int(*)(int, char*[],void*), void*);
extern char *sh_fmtq(const char*);
extern char *sh_fmtqf(const char*, int, int);
extern Sfdouble_t sh_strnum(const char*, char**, int);
extern int sh_access(const char*,int);
extern int sh_close(int);
extern int sh_dup(int);
extern void sh_exit(int);
extern int sh_fcntl(int, int, ...);
extern Sfio_t *sh_fd2sfio(int);
extern int (*sh_fdnotify(int(*)(int,int)))(int,int);
extern Shell_t *sh_getinterp(void);
extern int sh_open(const char*, int, ...);
extern int sh_openmax(void);
extern Sfio_t *sh_pathopen(const char*);
extern int sh_pipe(int[]);
extern void *sh_waitnotify(Shwait_f);
extern Shscope_t *sh_getscope(int,int);
extern void sh_sigcheck(void);
extern unsigned long sh_isoption(int);
extern unsigned long sh_onoption(int);
extern unsigned long sh_offoption(int);
extern int sh_waitsafe(void);
#if SHOPT_DYNAMIC
extern void **sh_getliblist(void);
#endif /* SHOPT_DYNAMIC */
/*
* direct access to sh is obsolete, use sh_getinterp() instead
*/
#else
#endif
#ifdef _DLL
# undef extern
#endif /* _DLL */
#ifndef _SH_PRIVATE
# if _lib_lseek64
# else
# endif
#endif /* !_SH_PRIVATE */
#define SH_SIGSET 4
#endif /* SH_INTERACTIVE */