1*4887Schin /***********************************************************************
2*4887Schin *                                                                      *
3*4887Schin *               This software is part of the ast package               *
4*4887Schin *           Copyright (c) 1982-2007 AT&T Knowledge Ventures            *
5*4887Schin *                      and is licensed under the                       *
6*4887Schin *                  Common Public License, Version 1.0                  *
7*4887Schin *                      by AT&T Knowledge Ventures                      *
8*4887Schin *                                                                      *
9*4887Schin *                A copy of the License is available at                 *
10*4887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
11*4887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12*4887Schin *                                                                      *
13*4887Schin *              Information and Software Systems Research               *
14*4887Schin *                            AT&T Research                             *
15*4887Schin *                           Florham Park NJ                            *
16*4887Schin *                                                                      *
17*4887Schin *                  David Korn <dgk@research.att.com>                   *
18*4887Schin *                                                                      *
19*4887Schin ***********************************************************************/
20*4887Schin #pragma prototyped
21*4887Schin /*
22*4887Schin  *	UNIX shell
23*4887Schin  *	David Korn
24*4887Schin  *
25*4887Schin  */
26*4887Schin 
27*4887Schin #include	<ast.h>
28*4887Schin #include	<sfio.h>
29*4887Schin 
30*4887Schin #ifndef IOBSIZE
31*4887Schin #   define  IOBSIZE	SF_BUFSIZE
32*4887Schin #endif /* IOBSIZE */
33*4887Schin #define IOMAXTRY	20
34*4887Schin 
35*4887Schin #ifndef SF_CLOSING
36*4887Schin #define SF_CLOSING	SF_CLOSE
37*4887Schin #endif
38*4887Schin #ifndef SF_APPENDWR
39*4887Schin #define SF_APPENDWR	SF_APPEND
40*4887Schin #endif
41*4887Schin 
42*4887Schin /* used for output of shell errors */
43*4887Schin #define ERRIO		2
44*4887Schin 
45*4887Schin #define IOREAD		001
46*4887Schin #define IOWRITE		002
47*4887Schin #define IODUP 		004
48*4887Schin #define IOSEEK		010
49*4887Schin #define IONOSEEK	020
50*4887Schin #define IOTTY 		040
51*4887Schin #define IOCLEX 		0100
52*4887Schin #define IOCLOSE		(IOSEEK|IONOSEEK)
53*4887Schin 
54*4887Schin #define IOSUBSHELL	0x8000	/* must be larger than any file descriptor */
55*4887Schin 
56*4887Schin /*
57*4887Schin  * The remainder of this file is only used when compiled with shell
58*4887Schin  */
59*4887Schin 
60*4887Schin #if KSHELL
61*4887Schin 
62*4887Schin #ifndef ARG_RAW
63*4887Schin     struct ionod;
64*4887Schin #endif /* !ARG_RAW */
65*4887Schin 
66*4887Schin #define sh_inuse(f2)	(sh.fdptrs[f2])
67*4887Schin 
68*4887Schin extern int	sh_iocheckfd(int);
69*4887Schin extern void 	sh_ioinit(void);
70*4887Schin extern int 	sh_iomovefd(int);
71*4887Schin extern int	sh_iorenumber(int,int);
72*4887Schin extern void 	sh_pclose(int[]);
73*4887Schin extern void 	sh_iorestore(int,int);
74*4887Schin #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
75*4887Schin    __EXPORT__
76*4887Schin #endif
77*4887Schin extern Sfio_t 	*sh_iostream(int);
78*4887Schin extern int	sh_redirect(struct ionod*,int);
79*4887Schin extern void 	sh_iosave(int,int);
80*4887Schin extern void 	sh_iounsave(void);
81*4887Schin extern int	sh_chkopen(const char*);
82*4887Schin extern int	sh_ioaccess(int,int);
83*4887Schin extern int	sh_devtofd(const char*);
84*4887Schin extern int	sh_source(Shell_t*, Sfio_t*, const char*);
85*4887Schin 
86*4887Schin /* the following are readonly */
87*4887Schin extern const char	e_pexists[];
88*4887Schin extern const char	e_query[];
89*4887Schin extern const char	e_history[];
90*4887Schin extern const char	e_argtype[];
91*4887Schin extern const char	e_create[];
92*4887Schin extern const char	e_tmpcreate[];
93*4887Schin extern const char	e_exists[];
94*4887Schin extern const char	e_file[];
95*4887Schin extern const char	e_formspec[];
96*4887Schin extern const char	e_badregexp[];
97*4887Schin extern const char	e_open[];
98*4887Schin extern const char	e_notseek[];
99*4887Schin extern const char	e_noread[];
100*4887Schin extern const char	e_badseek[];
101*4887Schin extern const char	e_badpattern[];
102*4887Schin extern const char	e_toomany[];
103*4887Schin extern const char	e_pipe[];
104*4887Schin extern const char	e_unknown[];
105*4887Schin extern const char	e_devnull[];
106*4887Schin extern const char	e_profile[];
107*4887Schin extern const char	e_sysprofile[];
108*4887Schin #if SHOPT_SYSRC
109*4887Schin extern const char	e_sysrc[];
110*4887Schin #endif
111*4887Schin #if SHOPT_BASH
112*4887Schin #if SHOPT_SYSRC
113*4887Schin extern const char	e_bash_sysrc[];
114*4887Schin #endif
115*4887Schin extern const char	e_bash_rc[];
116*4887Schin extern const char	e_bash_login[];
117*4887Schin extern const char	e_bash_logout[];
118*4887Schin extern const char	e_bash_profile[];
119*4887Schin #endif
120*4887Schin extern const char	e_stdprompt[];
121*4887Schin extern const char	e_supprompt[];
122*4887Schin extern const char	e_ambiguous[];
123*4887Schin #endif /* KSHELL */
124