xref: /titanic_50/usr/src/lib/libshell/common/include/io.h (revision 174bc6499d233e329ecd3d98a880a7b07df16bfa)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
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(Shell_t*,int);
69 extern void 	sh_ioinit(Shell_t*);
70 extern int 	sh_iomovefd(int);
71 extern int	sh_iorenumber(Shell_t*,int,int);
72 extern void 	sh_pclose(int[]);
73 extern void 	sh_iorestore(Shell_t*,int,int);
74 #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
75    __EXPORT__
76 #endif
77 extern Sfio_t 	*sh_iostream(Shell_t*,int);
78 extern int	sh_redirect(Shell_t*,struct ionod*,int);
79 extern void 	sh_iosave(Shell_t *, int,int,char*);
80 extern void 	sh_iounsave(Shell_t*);
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_redirect[];
96 extern const char	e_formspec[];
97 extern const char	e_badregexp[];
98 extern const char	e_open[];
99 extern const char	e_notseek[];
100 extern const char	e_noread[];
101 extern const char	e_badseek[];
102 extern const char	e_badwrite[];
103 extern const char	e_badpattern[];
104 extern const char	e_toomany[];
105 extern const char	e_pipe[];
106 extern const char	e_unknown[];
107 extern const char	e_devnull[];
108 extern const char	e_profile[];
109 extern const char	e_sysprofile[];
110 #if SHOPT_SYSRC
111 extern const char	e_sysrc[];
112 #endif
113 #if SHOPT_BASH
114 #if SHOPT_SYSRC
115 extern const char	e_bash_sysrc[];
116 #endif
117 extern const char	e_bash_rc[];
118 extern const char	e_bash_login[];
119 extern const char	e_bash_logout[];
120 extern const char	e_bash_profile[];
121 #endif
122 extern const char	e_stdprompt[];
123 extern const char	e_supprompt[];
124 extern const char	e_ambiguous[];
125 #endif /* KSHELL */
126