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