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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
41 * User-visible pieces of the ANSI C standard I/O package.
47 #include <sys/feature_tests.h>
48 #include <sys/va_list.h>
49 #include <stdio_tag.h>
50 #include <stdio_impl.h>
63 #if !defined(_LP64) && defined(__cplusplus)
64 typedef unsigned int size_t;
66 typedef unsigned long size_t;
72 #if !defined(_LP64) && defined(__cplusplus)
84 #define _NFILE 60 /* initial number of streams: Intel x86 ABI */
86 #define _NFILE 20 /* initial number of streams: SPARC ABI and default */
89 #define _SBFSIZ 8 /* compatibility with shared libs */
91 #define _IOFBF 0000 /* full buffered */
92 #define _IOLBF 0100 /* line buffered */
93 #define _IONBF 0004 /* not buffered */
94 #define _IOEOF 0020 /* EOF reached on read */
95 #define _IOERR 0040 /* I/O error from system */
97 #define _IOREAD 0001 /* currently reading */
98 #define _IOWRT 0002 /* currently writing */
99 #define _IORW 0200 /* opened for reading and writing */
100 #define _IOMYBUF 0010 /* stdio malloc()'d buffer */
106 #define FOPEN_MAX _NFILE
107 #define FILENAME_MAX 1024 /* max # of characters in a path name */
112 #define TMP_MAX 17576 /* 26 * 26 * 26 */
114 #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
117 #define P_tmpdir "/var/tmp/"
120 #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */
122 #define stdin (&__iob[0])
123 #define stdout (&__iob[1])
124 #define stderr (&__iob[2])
131 extern FILE __iob
[_NFILE
];
132 extern FILE *_lastbuf
;
133 extern unsigned char *_bufendtab
[];
134 extern unsigned char _sibuf
[], _sobuf
[];
136 /* Large file interfaces */
137 /* transition back from explicit 64-bit offset to implicit (64-bit) offset */
138 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
139 #ifdef __PRAGMA_REDEFINE_EXTNAME
140 #pragma redefine_extname fopen64 fopen
141 #pragma redefine_extname freopen64 freopen
143 #define fopen64 fopen
144 #define freopen64 freopen
148 /* transition from 32-bit offset to explicit 64-bit offset */
149 #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64)
150 #ifdef __PRAGMA_REDEFINE_EXTNAME
151 #pragma redefine_extname fopen fopen64
152 #pragma redefine_extname freopen freopen64
154 #define fopen fopen64
155 #define freopen freopen64
160 extern int remove(const char *);
161 extern int rename(const char *, const char *);
162 extern int fclose(FILE *);
163 extern int fflush(FILE *);
164 extern FILE *fopen(const char *, const char *);
165 extern FILE *freopen(const char *, const char *, FILE *);
166 extern void setbuf(FILE *, char *);
167 extern void setbuffer(FILE *, char *, int);
168 extern int setlinebuf(FILE *);
169 extern int setvbuf(FILE *, char *, int, size_t);
171 extern int fprintf(FILE *, const char *, ...);
173 extern int fscanf(FILE *, const char *, ...);
175 extern int printf(const char *, ...);
177 extern int scanf(const char *, ...);
179 extern char *sprintf(const char *, const char *, ...);
181 extern int sscanf(const char *, const char *, ...);
182 extern int vfprintf(FILE *, const char *, __va_list
);
183 extern int vprintf(const char *, __va_list
);
184 extern char *vsprintf(char *, char *, __va_list
);
185 extern int fgetc(FILE *);
186 extern char *fgets(char *, int, FILE *);
187 extern int fputc(int, FILE *);
188 extern int fputs(const char *, FILE *);
189 extern int getc(FILE *);
190 extern int getchar(void);
191 extern char *gets(char *);
192 extern int putc(int, FILE *);
193 extern int putchar(int);
194 extern int puts(const char *);
195 extern int ungetc(int, FILE *);
196 extern size_t fread(void *, size_t, size_t, FILE *);
197 extern size_t fwrite(const void *, size_t, size_t, FILE *);
198 extern int fgetpos(FILE *, fpos_t *);
199 extern int fseek(FILE *, long, int);
200 extern int fsetpos(FILE *, const fpos_t *);
201 extern long ftell(FILE *);
202 extern void rewind(FILE *);
203 extern void clearerr(FILE *);
204 extern int feof(FILE *);
205 extern int ferror(FILE *);
206 extern void perror(const char *);
208 extern int __filbuf(FILE *);
209 extern int __flsbuf(int, FILE *);
211 #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
212 /* non-ANSI standard compilation */
214 extern FILE *fdopen(int, const char *);
215 extern FILE *popen(const char *, const char *);
216 extern char *ctermid(char *);
217 extern char *cuserid(char *);
218 extern char *tempnam(const char *, const char *);
219 extern int getw(FILE *);
220 extern int putw(int, FILE *);
221 extern int pclose(FILE *);
222 extern int system(const char *);
223 extern int fileno(FILE *);
225 #endif /* !defined(_STRICT_STDC) */
233 #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
234 #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
235 : (int)(*(p)->_ptr++ = (x)))
238 #define clearerr(p) ((void) ((p)->_flag &= ~(_IOERR | _IOEOF)))
239 #define feof(p) ((p)->_flag & _IOEOF)
240 #define ferror(p) ((p)->_flag & _IOERR)
244 #define getchar() getc(stdin)
245 #define putchar(x) putc((x), stdout)
249 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
250 !defined(__PRAGMA_REDEFINE_EXTNAME))
251 extern FILE *fopen64(const char *, const char *);
252 extern FILE *freopen64(const char *, const char *, FILE *);
253 #endif /* _LARGEFILE64_SOURCE... */
259 #endif /* _STDIO_H */