xref: /onnv-gate/usr/src/lib/libshell/common/include/io.h (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                  David Korn <dgk@research.att.com>                   *
184887Schin *                                                                      *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin /*
224887Schin  *	UNIX shell
234887Schin  *	David Korn
244887Schin  *
254887Schin  */
264887Schin 
274887Schin #include	<ast.h>
284887Schin #include	<sfio.h>
294887Schin 
304887Schin #ifndef IOBSIZE
314887Schin #   define  IOBSIZE	SF_BUFSIZE
324887Schin #endif /* IOBSIZE */
334887Schin #define IOMAXTRY	20
344887Schin 
354887Schin #ifndef SF_CLOSING
364887Schin #define SF_CLOSING	SF_CLOSE
374887Schin #endif
384887Schin #ifndef SF_APPENDWR
394887Schin #define SF_APPENDWR	SF_APPEND
404887Schin #endif
414887Schin 
424887Schin /* used for output of shell errors */
434887Schin #define ERRIO		2
444887Schin 
454887Schin #define IOREAD		001
464887Schin #define IOWRITE		002
474887Schin #define IODUP 		004
484887Schin #define IOSEEK		010
494887Schin #define IONOSEEK	020
504887Schin #define IOTTY 		040
514887Schin #define IOCLEX 		0100
524887Schin #define IOCLOSE		(IOSEEK|IONOSEEK)
534887Schin 
544887Schin #define IOSUBSHELL	0x8000	/* must be larger than any file descriptor */
554887Schin 
564887Schin /*
574887Schin  * The remainder of this file is only used when compiled with shell
584887Schin  */
594887Schin 
604887Schin #if KSHELL
614887Schin 
624887Schin #ifndef ARG_RAW
634887Schin     struct ionod;
644887Schin #endif /* !ARG_RAW */
654887Schin 
664887Schin #define sh_inuse(f2)	(sh.fdptrs[f2])
674887Schin 
688462SApril.Chin@Sun.COM extern int	sh_iocheckfd(Shell_t*,int);
698462SApril.Chin@Sun.COM extern void 	sh_ioinit(Shell_t*);
704887Schin extern int 	sh_iomovefd(int);
718462SApril.Chin@Sun.COM extern int	sh_iorenumber(Shell_t*,int,int);
724887Schin extern void 	sh_pclose(int[]);
738462SApril.Chin@Sun.COM extern void 	sh_iorestore(Shell_t*,int,int);
744887Schin #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
754887Schin    __EXPORT__
764887Schin #endif
778462SApril.Chin@Sun.COM extern Sfio_t 	*sh_iostream(Shell_t*,int);
788462SApril.Chin@Sun.COM extern int	sh_redirect(Shell_t*,struct ionod*,int);
798462SApril.Chin@Sun.COM extern void 	sh_iosave(Shell_t *, int,int,char*);
808462SApril.Chin@Sun.COM extern void 	sh_iounsave(Shell_t*);
814887Schin extern int	sh_chkopen(const char*);
824887Schin extern int	sh_ioaccess(int,int);
834887Schin extern int	sh_devtofd(const char*);
844887Schin extern int	sh_source(Shell_t*, Sfio_t*, const char*);
854887Schin 
864887Schin /* the following are readonly */
874887Schin extern const char	e_pexists[];
884887Schin extern const char	e_query[];
894887Schin extern const char	e_history[];
904887Schin extern const char	e_argtype[];
914887Schin extern const char	e_create[];
924887Schin extern const char	e_tmpcreate[];
934887Schin extern const char	e_exists[];
944887Schin extern const char	e_file[];
9510898Sroland.mainz@nrubsig.org extern const char	e_redirect[];
964887Schin extern const char	e_formspec[];
974887Schin extern const char	e_badregexp[];
984887Schin extern const char	e_open[];
994887Schin extern const char	e_notseek[];
1004887Schin extern const char	e_noread[];
1014887Schin extern const char	e_badseek[];
1028462SApril.Chin@Sun.COM extern const char	e_badwrite[];
1034887Schin extern const char	e_badpattern[];
1044887Schin extern const char	e_toomany[];
1054887Schin extern const char	e_pipe[];
1064887Schin extern const char	e_unknown[];
1074887Schin extern const char	e_devnull[];
1084887Schin extern const char	e_profile[];
1094887Schin extern const char	e_sysprofile[];
1104887Schin #if SHOPT_SYSRC
1114887Schin extern const char	e_sysrc[];
1124887Schin #endif
1134887Schin #if SHOPT_BASH
1144887Schin #if SHOPT_SYSRC
1154887Schin extern const char	e_bash_sysrc[];
1164887Schin #endif
1174887Schin extern const char	e_bash_rc[];
1184887Schin extern const char	e_bash_login[];
1194887Schin extern const char	e_bash_logout[];
1204887Schin extern const char	e_bash_profile[];
1214887Schin #endif
1224887Schin extern const char	e_stdprompt[];
1234887Schin extern const char	e_supprompt[];
1244887Schin extern const char	e_ambiguous[];
1254887Schin #endif /* KSHELL */
126