xref: /titanic_51/usr/src/lib/libbc/inc/5include/stdio.h (revision 24fe0b3bf671e123467ce1df0b67cadd3614c8e4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1988 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*      Copyright (c) 1984 AT&T */
28 /*        All Rights Reserved   */
29 
30 
31 #ifndef	__5include_stdio_h
32 #define	__5include_stdio_h
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/stdtypes.h>	/* for size_t */
37 
38 #if	pdp11
39 #define	BUFSIZ	512
40 #elif	u370
41 #define	BUFSIZ	4096
42 #else	/* just about every other UNIX system in existence */
43 #define	BUFSIZ	1024
44 #endif
45 #ifndef	EOF
46 #define	EOF		(-1)
47 #endif
48 #define	L_ctermid	9
49 #define	L_cuserid	9
50 #define	L_tmpnam	25		/* (sizeof (_tmpdir) + 15) */
51 #define	_tmpdir		"/usr/tmp/"
52 #define	FILENAME_MAX	1025
53 #define	TMP_MAX		17576
54 
55 /*
56  * ANSI C requires definitions of SEEK_CUR, SEEK_END, and SEEK_SET here.
57  * They must be kept in sync with SEEK_* in <sys/unistd.h> (as required
58  * by POSIX.1) and L_* in <sys/file.h>.
59  * FOPEN_MAX should follow definition of _POSIX_OPEN_MAX in <sys/unistd.h>.
60  */
61 
62 #ifndef SEEK_SET
63 #define	SEEK_SET	0
64 #define	SEEK_CUR	1
65 #define	SEEK_END	2
66 #endif
67 
68 #define	FOPEN_MAX	16
69 
70 #ifndef	_POSIX_SOURCE
71 #define	P_tmpdir	_tmpdir
72 #endif
73 #ifndef	NULL
74 #define	NULL		0
75 #endif
76 #define	stdin		(&_iob[0])
77 #define	stdout		(&_iob[1])
78 #define	stderr		(&_iob[2])
79 /*
80  * _IOLBF means that a file's output will be buffered line by line
81  * In addition to being flags, _IONBF, _IOLBF and _IOFBF are possible
82  * values for "type" in setvbuf.
83  */
84 #define	_IOFBF		0000
85 #define	_IOREAD		0001
86 #define	_IOWRT		0002
87 #define	_IONBF		0004
88 #define	_IOMYBUF	0010
89 #define	_IOEOF		0020
90 #define	_IOERR		0040
91 #define	_IOSTRG		0100
92 #define	_IOLBF		0200
93 #define	_IORW		0400
94 /*
95  * buffer size for multi-character output to unbuffered files
96  */
97 #define	_SBFSIZ 8
98 
99 typedef	struct {
100 #if	pdp11 || u370
101 	unsigned char	*_ptr;
102 	int	_cnt;
103 #else	/* just about every other UNIX system in existence */
104 	int	_cnt;
105 	unsigned char	*_ptr;
106 #endif
107 	unsigned char	*_base;
108 	int	_bufsiz;
109 	short	_flag;
110 	unsigned char	_file;	/* should be short */
111 } FILE;
112 
113 #ifndef	_POSIX_SOURCE
114 extern char	*ctermid(char *);	/* unistd.h */
115 extern char	*cuserid(char *);	/* unistd.h */
116 extern FILE	*popen(char *, char *);
117 extern char	*tempnam(char *, char *);
118 #endif
119 
120 extern void	clearerr(FILE *);
121 extern int	fclose(FILE *);
122 extern FILE	*fdopen(int, char *);
123 extern int	feof(FILE *);
124 extern int	ferror(FILE *);
125 extern int	fflush(FILE *);
126 extern int	fgetc(FILE *);
127 extern int	fileno(FILE *);
128 extern FILE	*fopen(char *, char *);
129 extern char	*fgets(char *, int, FILE *);
130 extern int	fprintf(FILE *, char *, ...);
131 extern int	fputc(int, FILE *);
132 extern int	fputs(char *, FILE *);
133 extern size_t	fread(char *, int, int, FILE *);
134 extern FILE	*freopen(char *, char *, FILE *);
135 extern int	fscanf(FILE *, char *, ...);
136 extern int	fseek(FILE *, long int, int);
137 extern long	ftell(FILE *);
138 extern size_t	fwrite(char *, int, int, FILE *);
139 extern int	getc(FILE *);
140 extern int	getchar(void);
141 extern char	*gets(char *);
142 extern void	perror(char *);
143 extern int	printf(char *, ...);
144 extern int	putc(int, FILE *);
145 extern int	putchar(int);
146 extern int	puts(char *);
147 extern int	remove(char *);
148 extern int	rename(char *, char *);
149 extern void	rewind(FILE *);
150 extern int	scanf(char *, ...);
151 extern void	setbuf(FILE *, char *);
152 extern int	sprintf(char *, char *, ...);
153 extern int	sscanf(char *, char *, ...);
154 extern FILE	*tmpfile(void);
155 extern char	*tmpnam(char *);
156 extern int	ungetc(int, FILE *);
157 
158 #ifndef	lint
159 #define	getc(p)		(--(p)->_cnt >= 0 ? ((int) *(p)->_ptr++) : _filbuf(p))
160 #define	putc(x, p)	(--(p)->_cnt >= 0 ?\
161 	(int)(*(p)->_ptr++ = (unsigned char)(x)) :\
162 	(((p)->_flag & _IOLBF) && -(p)->_cnt < (p)->_bufsiz ?\
163 		((*(p)->_ptr = (unsigned char)(x)) != '\n' ?\
164 			(int)(*(p)->_ptr++) :\
165 			_flsbuf(*(unsigned char *)(p)->_ptr, p)) :\
166 		_flsbuf((unsigned char)(x), p)))
167 #define	getchar()	getc(stdin)
168 #define	putchar(x)	putc((x), stdout)
169 #define	clearerr(p)	((void) ((p)->_flag &= ~(_IOERR | _IOEOF)))
170 #define	feof(p)		(((p)->_flag & _IOEOF) != 0)
171 #define	ferror(p)	(((p)->_flag & _IOERR) != 0)
172 #endif
173 
174 extern FILE	_iob[];
175 
176 #endif	/* !__5include_stdio_h */
177