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