/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1984-2011 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> *
* Pat Sullivan *
* *
***********************************************************************/
/*
* UNIX shell
* S. R. Bourne
* rewritten by David Korn
*
*/
#include <ast.h>
#include <error.h>
#include "sh_config.h"
#ifdef _hdr_unistd
# include <unistd.h>
#endif /* _hdr_unistd */
#ifdef _hdr_fcntl
# include <fcntl.h>
#endif /* _hdr_fcntl */
#ifndef O_CREAT
# ifdef _sys_file
# endif /* _sys_file */
#endif /* O_CREAT */
#ifndef S_ISDIR
#endif /* S_ISDIR */
#ifndef S_ISREG
#endif /* S_ISREG */
#ifndef S_ISCHR
#endif /* S_ISCHR */
#ifndef S_ISBLK
#endif /* S_ISBLK */
#ifdef S_IFIFO
# ifndef S_ISFIFO
# endif /* S_ISFIFO */
#endif /* S_IFIFO */
#ifndef S_IRUSR
#endif /* S_IRUSR */
#ifndef S_IWUSR
#endif /* S_IWUSR */
#ifndef S_IXUSR
#endif /* S_IXUSR */
#ifndef S_IRGRP
#endif /* S_IRGRP */
#ifndef S_IWGRP
#endif /* S_IWGRP */
#ifndef S_IXGRP
#endif /* S_IXGRP */
#ifndef S_IROTH
#endif /* S_IROTH */
#ifndef S_IWOTH
#endif /* S_IWOTH */
#ifndef S_IXOTH
#endif /* S_IXOTH */
#ifndef NFILE
#endif /* NFILE */
#ifndef IOBSIZE
#endif /* IOBSIZE */
#ifdef SEVENBIT
#else
#endif /* SEVENBIT */
/* used for input and output of shell */
#ifdef KSHELL
#endif /* KSHELL */
/* SHELL file I/O structure */
struct fileblk
{
char *ptr;
char *base;
char *last;
int flag;
unsigned char fdes;
#ifdef KSHELL
char ftype;
int flast;
char **feval;
unsigned flin;
#endif /* KSHELL */
};
#ifdef FNDELAY
# ifdef EAGAIN
# if EAGAIN!=EWOULDBLOCK
# endif
# else
# endif /* EAGAIN */
# ifndef O_NONBLOCK
# endif /* !O_NONBLOCK */
#endif /* FNDELAY */
#ifndef O_CREAT
#endif /* O_CREAT */
#ifndef O_RDWR
# define O_RDONLY 0
#endif /* O_RDWR */
#ifdef NOFCNTL
# define F_DUPFD 0
#endif /* F_DUPFD */
#ifndef R_OK
#endif /* R_OK */
#ifndef SEEK_SET
#endif /* SEEK_SET */
/*io nodes*/
#define INPIPE 0
/*
* The remainder of this file is only used when compiled with shell
*/
#ifdef KSHELL
/* possible values for ftype */
/* The following union is used for argument to sh_eval */
union io_eval
{
int fd;
char **com;
};
#ifndef clearerr
#endif
struct filesave
{
short org_fd;
short dup_fd;
};
#ifdef PROTO
extern void io_fclose(int);
extern int io_getc(int);
extern int io_pop(int);
extern int io_mktmp(char*);
extern int io_readbuff(struct fileblk*);
extern int io_readc(void);
extern int io_renumber(int,int);
extern void io_sync(void);
extern int io_movefd(int);
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 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 int io_readbuff();
extern int io_readc();
extern int io_renumber();
extern void io_sync();
extern int io_movefd();
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 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 */