1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*0Sstevel@tonic-gate * The Regents of the University of California 33*0Sstevel@tonic-gate * All Rights Reserved 34*0Sstevel@tonic-gate * 35*0Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*0Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*0Sstevel@tonic-gate * contributors. 38*0Sstevel@tonic-gate */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * User-visible pieces of the ANSI C standard I/O package. 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #ifndef _STDIO_H 45*0Sstevel@tonic-gate #define _STDIO_H 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #include <sys/feature_tests.h> 50*0Sstevel@tonic-gate #include <sys/va_list.h> 51*0Sstevel@tonic-gate #include <stdio_tag.h> 52*0Sstevel@tonic-gate #include <stdio_impl.h> 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate #ifdef __cplusplus 55*0Sstevel@tonic-gate extern "C" { 56*0Sstevel@tonic-gate #endif 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate #ifndef BSD 59*0Sstevel@tonic-gate #define BSD 60*0Sstevel@tonic-gate #endif 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate #ifndef _SIZE_T 63*0Sstevel@tonic-gate #define _SIZE_T 64*0Sstevel@tonic-gate #if !defined(_LP64) && defined(__cplusplus) 65*0Sstevel@tonic-gate typedef unsigned int size_t; 66*0Sstevel@tonic-gate #else 67*0Sstevel@tonic-gate typedef unsigned long size_t; 68*0Sstevel@tonic-gate #endif 69*0Sstevel@tonic-gate #endif 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #ifndef _SSIZE_T 72*0Sstevel@tonic-gate #define _SSIZE_T 73*0Sstevel@tonic-gate #if !defined(_LP64) && defined(__cplusplus) 74*0Sstevel@tonic-gate typedef int ssize_t; 75*0Sstevel@tonic-gate #else 76*0Sstevel@tonic-gate typedef long ssize_t; 77*0Sstevel@tonic-gate #endif 78*0Sstevel@tonic-gate #endif 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate typedef long fpos_t; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate #ifndef NULL 83*0Sstevel@tonic-gate #define NULL 0 84*0Sstevel@tonic-gate #endif 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate #if defined(__STDC__) 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate #if #machine(pdp11) 89*0Sstevel@tonic-gate #define BUFSIZ 512 90*0Sstevel@tonic-gate #define _STDIO_REVERSE 91*0Sstevel@tonic-gate #elif #machine(u370) 92*0Sstevel@tonic-gate #define BUFSIZ 4096 93*0Sstevel@tonic-gate #define _STDIO_REVERSE 94*0Sstevel@tonic-gate #define _STDIO_ALLOCATE 95*0Sstevel@tonic-gate #else 96*0Sstevel@tonic-gate #define BUFSIZ 1024 97*0Sstevel@tonic-gate #endif 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate #else /* !defined(__STDC__) */ 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate #if pdp11 || u370 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #if pdp11 104*0Sstevel@tonic-gate #define BUFSIZ 512 105*0Sstevel@tonic-gate #define _STDIO_REVERSE 106*0Sstevel@tonic-gate #else /* u370 */ 107*0Sstevel@tonic-gate #define BUFSIZ 4096 108*0Sstevel@tonic-gate #define _STDIO_REVERSE 109*0Sstevel@tonic-gate #define _STDIO_ALLOCATE 110*0Sstevel@tonic-gate #endif 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate #else 113*0Sstevel@tonic-gate #define BUFSIZ 1024 114*0Sstevel@tonic-gate #endif 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate #endif /* __STDC__ */ 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate #if defined(__i386) 119*0Sstevel@tonic-gate #define _NFILE 60 /* initial number of streams: Intel x86 ABI */ 120*0Sstevel@tonic-gate #else 121*0Sstevel@tonic-gate #define _NFILE 20 /* initial number of streams: SPARC ABI and default */ 122*0Sstevel@tonic-gate #endif 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate #define _SBFSIZ 8 /* compatibility with shared libs */ 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #define _IOFBF 0000 /* full buffered */ 127*0Sstevel@tonic-gate #define _IOLBF 0100 /* line buffered */ 128*0Sstevel@tonic-gate #define _IONBF 0004 /* not buffered */ 129*0Sstevel@tonic-gate #define _IOEOF 0020 /* EOF reached on read */ 130*0Sstevel@tonic-gate #define _IOERR 0040 /* I/O error from system */ 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate #define _IOREAD 0001 /* currently reading */ 133*0Sstevel@tonic-gate #define _IOWRT 0002 /* currently writing */ 134*0Sstevel@tonic-gate #define _IORW 0200 /* opened for reading and writing */ 135*0Sstevel@tonic-gate #define _IOMYBUF 0010 /* stdio malloc()'d buffer */ 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate #ifndef EOF 138*0Sstevel@tonic-gate #define EOF (-1) 139*0Sstevel@tonic-gate #endif 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate #define FOPEN_MAX _NFILE 142*0Sstevel@tonic-gate #define FILENAME_MAX 1024 /* max # of characters in a path name */ 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate #define SEEK_SET 0 145*0Sstevel@tonic-gate #define SEEK_CUR 1 146*0Sstevel@tonic-gate #define SEEK_END 2 147*0Sstevel@tonic-gate #define TMP_MAX 17576 /* 26 * 26 * 26 */ 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) 150*0Sstevel@tonic-gate #define L_ctermid 9 151*0Sstevel@tonic-gate #define L_cuserid 9 152*0Sstevel@tonic-gate #define P_tmpdir "/var/tmp/" 153*0Sstevel@tonic-gate #endif 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */ 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate #if defined(__STDC__) 158*0Sstevel@tonic-gate #define stdin (&__iob[0]) 159*0Sstevel@tonic-gate #define stdout (&__iob[1]) 160*0Sstevel@tonic-gate #define stderr (&__iob[2]) 161*0Sstevel@tonic-gate #else 162*0Sstevel@tonic-gate #define stdin (&_iob[0]) 163*0Sstevel@tonic-gate #define stdout (&_iob[1]) 164*0Sstevel@tonic-gate #define stderr (&_iob[2]) 165*0Sstevel@tonic-gate #endif 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate #ifndef _FILEDEFED 168*0Sstevel@tonic-gate #define _FILEDEFED 169*0Sstevel@tonic-gate typedef __FILE FILE; 170*0Sstevel@tonic-gate #endif 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gate #if defined(__STDC__) 173*0Sstevel@tonic-gate extern FILE __iob[_NFILE]; 174*0Sstevel@tonic-gate #else 175*0Sstevel@tonic-gate extern FILE _iob[_NFILE]; 176*0Sstevel@tonic-gate #endif 177*0Sstevel@tonic-gate extern FILE *_lastbuf; 178*0Sstevel@tonic-gate extern unsigned char *_bufendtab[]; 179*0Sstevel@tonic-gate #ifndef _STDIO_ALLOCATE 180*0Sstevel@tonic-gate extern unsigned char _sibuf[], _sobuf[]; 181*0Sstevel@tonic-gate #endif 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate /* Large file interfaces */ 184*0Sstevel@tonic-gate /* transition back from explicit 64-bit offset to implicit (64-bit) offset */ 185*0Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 186*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 187*0Sstevel@tonic-gate #pragma redefine_extname fopen64 fopen 188*0Sstevel@tonic-gate #pragma redefine_extname freopen64 freopen 189*0Sstevel@tonic-gate #else 190*0Sstevel@tonic-gate #define fopen64 fopen 191*0Sstevel@tonic-gate #define freopen64 freopen 192*0Sstevel@tonic-gate #endif 193*0Sstevel@tonic-gate #endif 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate /* transition from 32-bit offset to explicit 64-bit offset */ 196*0Sstevel@tonic-gate #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64) 197*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 198*0Sstevel@tonic-gate #pragma redefine_extname fopen fopen64 199*0Sstevel@tonic-gate #pragma redefine_extname freopen freopen64 200*0Sstevel@tonic-gate #else 201*0Sstevel@tonic-gate #define fopen fopen64 202*0Sstevel@tonic-gate #define freopen freopen64 203*0Sstevel@tonic-gate #endif 204*0Sstevel@tonic-gate #endif 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate #if defined(__STDC__) 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate extern int remove(const char *); 209*0Sstevel@tonic-gate extern int rename(const char *, const char *); 210*0Sstevel@tonic-gate extern int fclose(FILE *); 211*0Sstevel@tonic-gate extern int fflush(FILE *); 212*0Sstevel@tonic-gate extern FILE *fopen(const char *, const char *); 213*0Sstevel@tonic-gate extern FILE *freopen(const char *, const char *, FILE *); 214*0Sstevel@tonic-gate extern void setbuf(FILE *, char *); 215*0Sstevel@tonic-gate extern void setbuffer(FILE *, char *, int); 216*0Sstevel@tonic-gate extern int setlinebuf(FILE *); 217*0Sstevel@tonic-gate extern int setvbuf(FILE *, char *, int, size_t); 218*0Sstevel@tonic-gate /* PRINTFLIKE2 */ 219*0Sstevel@tonic-gate extern int fprintf(FILE *, const char *, ...); 220*0Sstevel@tonic-gate /* SCANFLIKE2 */ 221*0Sstevel@tonic-gate extern int fscanf(FILE *, const char *, ...); 222*0Sstevel@tonic-gate /* PRINTFLIKE1 */ 223*0Sstevel@tonic-gate extern int printf(const char *, ...); 224*0Sstevel@tonic-gate /* SCANFLIKE1 */ 225*0Sstevel@tonic-gate extern int scanf(const char *, ...); 226*0Sstevel@tonic-gate /* PRINTFLIKE2 */ 227*0Sstevel@tonic-gate extern char *sprintf(const char *, const char *, ...); 228*0Sstevel@tonic-gate /* SCANFLIKE2 */ 229*0Sstevel@tonic-gate extern int sscanf(const char *, const char *, ...); 230*0Sstevel@tonic-gate extern int vfprintf(FILE *, const char *, __va_list); 231*0Sstevel@tonic-gate extern int vprintf(const char *, __va_list); 232*0Sstevel@tonic-gate extern char *vsprintf(char *, char *, __va_list); 233*0Sstevel@tonic-gate extern int fgetc(FILE *); 234*0Sstevel@tonic-gate extern char *fgets(char *, int, FILE *); 235*0Sstevel@tonic-gate extern int fputc(int, FILE *); 236*0Sstevel@tonic-gate extern int fputs(const char *, FILE *); 237*0Sstevel@tonic-gate extern int getc(FILE *); 238*0Sstevel@tonic-gate extern int getchar(void); 239*0Sstevel@tonic-gate extern char *gets(char *); 240*0Sstevel@tonic-gate extern int putc(int, FILE *); 241*0Sstevel@tonic-gate extern int putchar(int); 242*0Sstevel@tonic-gate extern int puts(const char *); 243*0Sstevel@tonic-gate extern int ungetc(int, FILE *); 244*0Sstevel@tonic-gate extern size_t fread(void *, size_t, size_t, FILE *); 245*0Sstevel@tonic-gate extern size_t fwrite(const void *, size_t, size_t, FILE *); 246*0Sstevel@tonic-gate extern int fgetpos(FILE *, fpos_t *); 247*0Sstevel@tonic-gate extern int fseek(FILE *, long, int); 248*0Sstevel@tonic-gate extern int fsetpos(FILE *, const fpos_t *); 249*0Sstevel@tonic-gate extern long ftell(FILE *); 250*0Sstevel@tonic-gate extern void rewind(FILE *); 251*0Sstevel@tonic-gate extern void clearerr(FILE *); 252*0Sstevel@tonic-gate extern int feof(FILE *); 253*0Sstevel@tonic-gate extern int ferror(FILE *); 254*0Sstevel@tonic-gate extern void perror(const char *); 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate extern int __filbuf(FILE *); 257*0Sstevel@tonic-gate extern int __flsbuf(int, FILE *); 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) 260*0Sstevel@tonic-gate /* non-ANSI standard compilation */ 261*0Sstevel@tonic-gate 262*0Sstevel@tonic-gate extern FILE *fdopen(int, const char *); 263*0Sstevel@tonic-gate extern FILE *popen(const char *, const char *); 264*0Sstevel@tonic-gate extern char *ctermid(char *); 265*0Sstevel@tonic-gate extern char *cuserid(char *); 266*0Sstevel@tonic-gate extern char *tempnam(const char *, const char *); 267*0Sstevel@tonic-gate extern int getw(FILE *); 268*0Sstevel@tonic-gate extern int putw(int, FILE *); 269*0Sstevel@tonic-gate extern int pclose(FILE *); 270*0Sstevel@tonic-gate extern int system(const char *); 271*0Sstevel@tonic-gate extern int fileno(FILE *); 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate #endif /* !defined(_STRICT_STDC) */ 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate #else /* !defined __STDC__ */ 276*0Sstevel@tonic-gate #define _bufend(p) _bufendtab[fileno(p)] 277*0Sstevel@tonic-gate #define _bufsiz(p) (_bufend(p) - (p)->_base) 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate extern FILE *fopen(), *fdopen(), *freopen(), *popen(); 280*0Sstevel@tonic-gate extern long ftell(); 281*0Sstevel@tonic-gate extern void rewind(), setbuf(), setbuffer(); 282*0Sstevel@tonic-gate extern int setlinebuf(); 283*0Sstevel@tonic-gate extern char *ctermid(), *cuserid(), *fgets(), *gets(), *sprintf(), 284*0Sstevel@tonic-gate *vsprintf(); 285*0Sstevel@tonic-gate extern int fclose(), fflush(), fread(), fwrite(), fseek(), fgetc(), 286*0Sstevel@tonic-gate getw(), pclose(), printf(), fprintf(), 287*0Sstevel@tonic-gate vprintf(), vfprintf(), fputc(), putw(), 288*0Sstevel@tonic-gate puts(), fputs(), scanf(), fscanf(), sscanf(), 289*0Sstevel@tonic-gate setvbuf(), system(), ungetc(); 290*0Sstevel@tonic-gate extern int fileno(); 291*0Sstevel@tonic-gate extern int getc(), getchar(), putc(), putchar(), feof(), ferror(); 292*0Sstevel@tonic-gate extern void clearerr(); 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate #endif /* __STDC__ */ 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate #ifndef __lint 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate #ifndef _LP64 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate #ifdef __STDC__ 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++) 303*0Sstevel@tonic-gate #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \ 304*0Sstevel@tonic-gate : (int)(*(p)->_ptr++ = (x))) 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate #else /* __STDC__ */ 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate #define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int)*(p)->_ptr++) 309*0Sstevel@tonic-gate #define putc(x, p) (--(p)->_cnt < 0 ? \ 310*0Sstevel@tonic-gate _flsbuf((unsigned char) (x), (p)) : \ 311*0Sstevel@tonic-gate (int)(*(p)->_ptr++ = (unsigned char)(x))) 312*0Sstevel@tonic-gate #endif /* __STDC__ */ 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate #define clearerr(p) ((void) ((p)->_flag &= ~(_IOERR | _IOEOF))) 315*0Sstevel@tonic-gate #define feof(p) ((p)->_flag & _IOEOF) 316*0Sstevel@tonic-gate #define ferror(p) ((p)->_flag & _IOERR) 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate #endif /* _LP64 */ 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate #define getchar() getc(stdin) 321*0Sstevel@tonic-gate #define putchar(x) putc((x), stdout) 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate #endif /* __lint */ 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 326*0Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 327*0Sstevel@tonic-gate #if defined(__STDC__) 328*0Sstevel@tonic-gate extern FILE *fopen64(const char *, const char *); 329*0Sstevel@tonic-gate extern FILE *freopen64(const char *, const char *, FILE *); 330*0Sstevel@tonic-gate #else 331*0Sstevel@tonic-gate extern FILE *fopen64(), *freopen64(); 332*0Sstevel@tonic-gate #endif 333*0Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE... */ 334*0Sstevel@tonic-gate 335*0Sstevel@tonic-gate #ifdef __cplusplus 336*0Sstevel@tonic-gate } 337*0Sstevel@tonic-gate #endif 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate #endif /* _STDIO_H */ 340