xref: /original-bsd/local/toolchest/ksh/sh/io.h (revision 7e5f7ee2)
1*7e5f7ee2Smarc /*
2*7e5f7ee2Smarc 
3*7e5f7ee2Smarc  *      Copyright (c) 1984, 1985, 1986 AT&T
4*7e5f7ee2Smarc  *      All Rights Reserved
5*7e5f7ee2Smarc 
6*7e5f7ee2Smarc  *      THIS IS UNPUBLISHED PROPRIETARY SOURCE
7*7e5f7ee2Smarc  *      CODE OF AT&T.
8*7e5f7ee2Smarc  *      The copyright notice above does not
9*7e5f7ee2Smarc  *      evidence any actual or intended
10*7e5f7ee2Smarc  *      publication of such source code.
11*7e5f7ee2Smarc 
12*7e5f7ee2Smarc  */
13*7e5f7ee2Smarc /* @(#)io.h	1.1 */
14*7e5f7ee2Smarc 
15*7e5f7ee2Smarc /*
16*7e5f7ee2Smarc  *	UNIX shell
17*7e5f7ee2Smarc  *	S. R. Bourne
18*7e5f7ee2Smarc  *	rewritten by David Korn
19*7e5f7ee2Smarc  *
20*7e5f7ee2Smarc  */
21*7e5f7ee2Smarc 
22*7e5f7ee2Smarc #ifndef _NFILE		/* This is true for BSD 4.3 */
23*7e5f7ee2Smarc #define _NFILE	20
24*7e5f7ee2Smarc #define _N_STATIC_IOBS	3
25*7e5f7ee2Smarc #endif	/* _NFILE */
26*7e5f7ee2Smarc 
27*7e5f7ee2Smarc /* used for input and output of shell */
28*7e5f7ee2Smarc #define FCIO	19	/* history file */
29*7e5f7ee2Smarc #define INIO	18	/* saved standard ioput */
30*7e5f7ee2Smarc #define TMPIO	17	/* used for command substitution */
31*7e5f7ee2Smarc #define CINPIPE 16	/* inpipe for cooperating process */
32*7e5f7ee2Smarc #define COTPIPE 15	/* outpipe for cooperating process */
33*7e5f7ee2Smarc #define MAXFILES 10	/* maximum number of saved open files */
34*7e5f7ee2Smarc 
35*7e5f7ee2Smarc /*io nodes*/
36*7e5f7ee2Smarc #define USERIO	10
37*7e5f7ee2Smarc #define IOUFD	15
38*7e5f7ee2Smarc #define IODOC	16
39*7e5f7ee2Smarc #define IOPUT	32
40*7e5f7ee2Smarc #define IOAPP	64
41*7e5f7ee2Smarc #define IOMOV	128
42*7e5f7ee2Smarc #define IORDW	256
43*7e5f7ee2Smarc #define IOSTRIP 512
44*7e5f7ee2Smarc #define INPIPE	0
45*7e5f7ee2Smarc #define OTPIPE	1
46*7e5f7ee2Smarc #define DUPFLG	0100
47*7e5f7ee2Smarc 
48*7e5f7ee2Smarc #define TMPSIZ		20
49*7e5f7ee2Smarc #define F_STRING	((unsigned char)_NFILE)	/* file number for incore files */
50*7e5f7ee2Smarc #define F_INFINITE	0x7fff			/* effectively infinite */
51*7e5f7ee2Smarc 
52*7e5f7ee2Smarc /* temp files and io */
53*7e5f7ee2Smarc /* SHELL file structure */
54*7e5f7ee2Smarc struct fileblk
55*7e5f7ee2Smarc {
56*7e5f7ee2Smarc 	FILE		*fdes;
57*7e5f7ee2Smarc 	unsigned	flin;
58*7e5f7ee2Smarc 	char		**feval;
59*7e5f7ee2Smarc 	SHFILE		fstak;
60*7e5f7ee2Smarc };
61*7e5f7ee2Smarc 
62*7e5f7ee2Smarc #ifdef _N_STATIC_IOBS
63*7e5f7ee2Smarc extern FILE	*file_fd();
64*7e5f7ee2Smarc extern FILE	_myiob[];
65*7e5f7ee2Smarc #else
66*7e5f7ee2Smarc #define	file_fd(n)	(&_iob[n])
67*7e5f7ee2Smarc #endif /* _N_STATIC_IOBS */
68*7e5f7ee2Smarc #define input	(standin->fdes)
69*7e5f7ee2Smarc #define fisopen(fd)	((fd)->_flag)
70*7e5f7ee2Smarc #define fiswrite(fd)	((fd)->_flag&(_IOWRT|_IORW))
71*7e5f7ee2Smarc #define fisread(fd)	((fd)->_flag&(_IOREAD|_IORW))
72*7e5f7ee2Smarc #define fnobuff(fd)	(((fd)->_flag&_IONBF)||(fd)->_base==NULL)
73*7e5f7ee2Smarc #define nextchar(fd)	(*((fd)->_ptr))
74*7e5f7ee2Smarc #ifndef clearerr
75*7e5f7ee2Smarc #define clearerr(fd)	((fd)->_flag &= ~(_IOERR|_IOEOF))
76*7e5f7ee2Smarc #endif
77*7e5f7ee2Smarc 
78*7e5f7ee2Smarc struct ionod
79*7e5f7ee2Smarc {
80*7e5f7ee2Smarc 	int	iofile;
81*7e5f7ee2Smarc 	char	*ioname;
82*7e5f7ee2Smarc 	char	*iolink;
83*7e5f7ee2Smarc 	IOPTR	ionxt;
84*7e5f7ee2Smarc 	IOPTR	iolst;
85*7e5f7ee2Smarc };
86*7e5f7ee2Smarc 
87*7e5f7ee2Smarc #define	IOTYPE	(sizeof(struct ionod))
88*7e5f7ee2Smarc 
89*7e5f7ee2Smarc struct filesave
90*7e5f7ee2Smarc {
91*7e5f7ee2Smarc 	short	org_fd;
92*7e5f7ee2Smarc 	short	dup_fd;
93*7e5f7ee2Smarc };
94*7e5f7ee2Smarc 
95*7e5f7ee2Smarc 
96*7e5f7ee2Smarc extern void	rmtemp();
97*7e5f7ee2Smarc extern FILE	*frenumber();
98*7e5f7ee2Smarc extern unsigned char _sibuf[];
99*7e5f7ee2Smarc extern unsigned char _sobuf[];
100*7e5f7ee2Smarc extern FILEBLK	stdfile;
101*7e5f7ee2Smarc extern char	tmpout[];
102*7e5f7ee2Smarc 
103*7e5f7ee2Smarc /* the following are readonly */
104*7e5f7ee2Smarc extern MSG	badcreate;
105*7e5f7ee2Smarc extern MSG	badfile;
106*7e5f7ee2Smarc extern MSG	badopen;
107*7e5f7ee2Smarc extern MSG	devnull;
108*7e5f7ee2Smarc extern MSG	endoffile;
109*7e5f7ee2Smarc extern MSG	nomorefiles;
110*7e5f7ee2Smarc extern MSG	piperr;
111*7e5f7ee2Smarc extern MSG	profile;
112*7e5f7ee2Smarc #ifdef BSD_4_2
113*7e5f7ee2Smarc extern MSG	prohibited;
114*7e5f7ee2Smarc #endif /* BSD_4_2 */
115*7e5f7ee2Smarc extern MSG	sysprofile;
116*7e5f7ee2Smarc extern MSG	unknown;
117*7e5f7ee2Smarc #ifdef SUID_EXEC
118*7e5f7ee2Smarc extern MSG	devfdNN;
119*7e5f7ee2Smarc extern MSG	suid_exec;
120*7e5f7ee2Smarc #endif /* SUID_EXEC */
121*7e5f7ee2Smarc 
122*7e5f7ee2Smarc #ifdef apollo
123*7e5f7ee2Smarc /* only a fool would have changed these names */
124*7e5f7ee2Smarc #define	_IOREAD		_SIRD
125*7e5f7ee2Smarc #define _IOWRT		_SIWR
126*7e5f7ee2Smarc #define	_IOLBF		_SINLB
127*7e5f7ee2Smarc #define	_IONBF		_SIUNB
128*7e5f7ee2Smarc #define	_IOMYBUF	_SIBIG
129*7e5f7ee2Smarc #define _IORW		_SIUP
130*7e5f7ee2Smarc #define _IOEOF		_SIEOF
131*7e5f7ee2Smarc #define	_IOERR		_SIERR
132*7e5f7ee2Smarc #define	_flsbuf		_flshbuf
133*7e5f7ee2Smarc #define	_file		_fd
134*7e5f7ee2Smarc #endif	/* apollo */
135