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 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1988 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * An application should not include this header directly. Instead it 32 * should be included only through the inclusion of other Sun headers. 33 * 34 * The contents of this header is limited to identifiers specified in the 35 * C Standard. Any new identifiers specified in future amendments to the 36 * C Standard must be placed in this header. If these new identifiers 37 * are required to also be in the C++ Standard "std" namespace, then for 38 * anything other than macro definitions, corresponding "using" directives 39 * must also be added to <stdio.h>. 40 */ 41 42 /* 43 * User-visible pieces of the ANSI C standard I/O package. 44 */ 45 46 #ifndef _ISO_STDIO_ISO_H 47 #define _ISO_STDIO_ISO_H 48 49 #pragma ident "%Z%%M% %I% %E% SMI" 50 51 #include <sys/feature_tests.h> 52 #include <sys/va_list.h> 53 #include <stdio_tag.h> 54 #include <stdio_impl.h> 55 56 /* 57 * If feature test macros are set that enable interfaces that use types 58 * defined in <sys/types.h>, get those types by doing the include. 59 * 60 * Note that in asking for the interfaces associated with this feature test 61 * macro one also asks for definitions of the POSIX types. 62 */ 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE)) 69 /* 70 * The following typedefs are adopted from ones in <sys/types.h> (with leading 71 * underscores added to avoid polluting the ANSI C name space). See the 72 * commentary there for further explanation. 73 */ 74 #if defined(_LONGLONG_TYPE) 75 typedef long long __longlong_t; 76 #else 77 /* used to reserve space and generate alignment */ 78 typedef union { 79 double _d; 80 int _l[2]; 81 } __longlong_t; 82 #endif 83 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */ 84 85 #if __cplusplus >= 199711L 86 namespace std { 87 #endif 88 89 #if !defined(_FILEDEFED) || __cplusplus >= 199711L 90 #define _FILEDEFED 91 typedef __FILE FILE; 92 #endif 93 94 #if !defined(_SIZE_T) || __cplusplus >= 199711L 95 #define _SIZE_T 96 #if defined(_LP64) || defined(_I32LPx) 97 typedef unsigned long size_t; /* size of something in bytes */ 98 #else 99 typedef unsigned int size_t; /* (historical version) */ 100 #endif 101 #endif /* !_SIZE_T */ 102 103 #if defined(_LP64) || _FILE_OFFSET_BITS == 32 104 typedef long fpos_t; 105 #else 106 typedef __longlong_t fpos_t; 107 #endif 108 109 #if __cplusplus >= 199711L 110 } 111 #endif /* end of namespace std */ 112 113 #ifndef NULL 114 #if defined(_LP64) 115 #define NULL 0L 116 #else 117 #define NULL 0 118 #endif 119 #endif 120 121 #define BUFSIZ 1024 122 123 /* 124 * The value of _NFILE is defined in the Processor Specific ABI. The value 125 * is chosen for historical reasons rather than for truly processor related 126 * attribute. Note that the SPARC Processor Specific ABI uses the common 127 * UNIX historical value of 20 so it is allowed to fall through. 128 */ 129 #if defined(__i386) 130 #define _NFILE 60 /* initial number of streams: Intel x86 ABI */ 131 #else 132 #define _NFILE 20 /* initial number of streams: SPARC ABI and default */ 133 #endif 134 135 #define _SBFSIZ 8 /* compatibility with shared libs */ 136 137 #define _IOFBF 0000 /* full buffered */ 138 #define _IOLBF 0100 /* line buffered */ 139 #define _IONBF 0004 /* not buffered */ 140 #define _IOEOF 0020 /* EOF reached on read */ 141 #define _IOERR 0040 /* I/O error from system */ 142 143 #define _IOREAD 0001 /* currently reading */ 144 #define _IOWRT 0002 /* currently writing */ 145 #define _IORW 0200 /* opened for reading and writing */ 146 #define _IOMYBUF 0010 /* stdio malloc()'d buffer */ 147 148 #ifndef EOF 149 #define EOF (-1) 150 #endif 151 152 #define FOPEN_MAX _NFILE 153 #define FILENAME_MAX 1024 /* max # of characters in a path name */ 154 155 #define SEEK_SET 0 156 #define SEEK_CUR 1 157 #define SEEK_END 2 158 #define TMP_MAX 17576 /* 26 * 26 * 26 */ 159 160 #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */ 161 162 #if defined(__STDC__) 163 extern __FILE __iob[_NFILE]; 164 #define stdin (&__iob[0]) 165 #define stdout (&__iob[1]) 166 #define stderr (&__iob[2]) 167 #else 168 extern __FILE _iob[_NFILE]; 169 #define stdin (&_iob[0]) 170 #define stdout (&_iob[1]) 171 #define stderr (&_iob[2]) 172 #endif /* __STDC__ */ 173 174 #if __cplusplus >= 199711L 175 namespace std { 176 #endif 177 178 #if !defined(_LP64) && !defined(_LONGLONG_TYPE) 179 180 #ifdef __PRAGMA_REDEFINE_EXTNAME 181 #pragma redefine_extname fprintf _fprintf_c89 182 #pragma redefine_extname printf _printf_c89 183 #pragma redefine_extname sprintf _sprintf_c89 184 #pragma redefine_extname vfprintf _vfprintf_c89 185 #pragma redefine_extname vprintf _vprintf_c89 186 #pragma redefine_extname vsprintf _vsprintf_c89 187 #pragma redefine_extname fscanf _fscanf_c89 188 #pragma redefine_extname scanf _scanf_c89 189 #pragma redefine_extname sscanf _sscanf_c89 190 #else 191 #define fprintf _fprintf_c89 192 #define printf _printf_c89 193 #define sprintf _sprintf_c89 194 #define vfprintf _vfprintf_c89 195 #define vprintf _vprintf_c89 196 #define vsprintf _vsprintf_c89 197 #define fscanf _fscanf_c89 198 #define scanf _scanf_c89 199 #define sscanf _sscanf_c89 200 #endif 201 202 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ 203 204 #if defined(__STDC__) 205 206 extern int remove(const char *); 207 extern int rename(const char *, const char *); 208 extern FILE *tmpfile(void); 209 extern char *tmpnam(char *); 210 extern int fclose(FILE *); 211 extern int fflush(FILE *); 212 extern FILE *fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); 213 extern FILE *freopen(const char *_RESTRICT_KYWD, 214 const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); 215 extern void setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD); 216 extern int setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int, 217 size_t); 218 /* PRINTFLIKE2 */ 219 extern int fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 220 /* SCANFLIKE2 */ 221 extern int fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 222 /* PRINTFLIKE1 */ 223 extern int printf(const char *_RESTRICT_KYWD, ...); 224 /* SCANFLIKE1 */ 225 extern int scanf(const char *_RESTRICT_KYWD, ...); 226 /* PRINTFLIKE2 */ 227 extern int sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 228 /* SCANFLIKE2 */ 229 extern int sscanf(const char *_RESTRICT_KYWD, 230 const char *_RESTRICT_KYWD, ...); 231 extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 232 __va_list); 233 extern int vprintf(const char *_RESTRICT_KYWD, __va_list); 234 extern int vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 235 __va_list); 236 extern int fgetc(FILE *); 237 extern char *fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD); 238 extern int fputc(int, FILE *); 239 extern int fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); 240 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ 241 __cplusplus < 199711L 242 extern int getc(FILE *); 243 extern int putc(int, FILE *); 244 #endif 245 #if (__cplusplus >= 199711L && defined(_REENTRANT)) || \ 246 __cplusplus < 199711L 247 extern int getchar(void); 248 extern int putchar(int); 249 #endif 250 extern char *gets(char *); 251 extern int puts(const char *); 252 extern int ungetc(int, FILE *); 253 extern size_t fread(void *_RESTRICT_KYWD, size_t, size_t, 254 FILE *_RESTRICT_KYWD); 255 extern size_t fwrite(const void *_RESTRICT_KYWD, size_t, size_t, 256 FILE *_RESTRICT_KYWD); 257 #if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32 258 extern int fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD); 259 extern int fsetpos(FILE *, const fpos_t *); 260 #endif 261 extern int fseek(FILE *, long, int); 262 extern long ftell(FILE *); 263 extern void rewind(FILE *); 264 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ 265 __cplusplus < 199711L 266 extern void clearerr(FILE *); 267 extern int feof(FILE *); 268 extern int ferror(FILE *); 269 #endif 270 extern void perror(const char *); 271 272 #ifndef _LP64 273 extern int __filbuf(FILE *); 274 extern int __flsbuf(int, FILE *); 275 #endif /* _LP64 */ 276 277 #else /* !defined __STDC__ */ 278 279 extern int remove(); 280 extern int rename(); 281 extern FILE *tmpfile(); 282 extern char *tmpnam(); 283 extern int fclose(); 284 extern int fflush(); 285 extern FILE *fopen(); 286 extern FILE *freopen(); 287 extern void setbuf(); 288 extern int setvbuf(); 289 extern int fprintf(); 290 extern int fscanf(); 291 extern int printf(); 292 extern int scanf(); 293 extern int sprintf(); 294 extern int sscanf(); 295 extern int vfprintf(); 296 extern int vprintf(); 297 extern int vsprintf(); 298 extern int fgetc(); 299 extern char *fgets(); 300 extern int fputc(); 301 extern int fputs(); 302 extern int getc(); 303 extern int getchar(); 304 extern char *gets(); 305 extern int putc(); 306 extern int putchar(); 307 extern int puts(); 308 extern int ungetc(); 309 extern size_t fread(); 310 extern size_t fwrite(); 311 extern int fgetpos(); 312 extern int fseek(); 313 extern int fsetpos(); 314 extern long ftell(); 315 extern void rewind(); 316 extern void clearerr(); 317 extern int feof(); 318 extern int ferror(); 319 extern void perror(); 320 321 #ifndef _LP64 322 extern int _filbuf(); 323 extern int _flsbuf(); 324 #endif /* _LP64 */ 325 326 #endif /* __STDC__ */ 327 328 #if __cplusplus >= 199711L 329 } 330 #endif /* end of namespace std */ 331 332 #if !defined(__lint) 333 334 #if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC) 335 336 #ifdef __STDC__ 337 #if __cplusplus >= 199711L 338 namespace std { 339 inline int getc(FILE *_p) { 340 return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); } 341 inline int putc(int _x, FILE *_p) { 342 return (--_p->_cnt < 0 ? __flsbuf(_x, _p) 343 : (int)(*_p->_ptr++ = (unsigned char) _x)); } 344 } 345 #else /* __cplusplus >= 199711L */ 346 #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++) 347 #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \ 348 : (int)(*(p)->_ptr++ = (unsigned char) (x))) 349 #endif /* __cplusplus >= 199711L */ 350 #else /* __STDC__ */ 351 #define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int)*(p)->_ptr++) 352 #define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((x), (p)) : \ 353 (int)(*(p)->_ptr++ = (unsigned char) (x))) 354 #endif /* __STDC__ */ 355 356 #endif /* !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC) */ 357 358 #ifndef _REENTRANT 359 360 #if __cplusplus >= 199711L 361 namespace std { 362 inline int getchar() { return getc(stdin); } 363 inline int putchar(int _x) { return putc(_x, stdout); } 364 } 365 #else 366 #define getchar() getc(stdin) 367 #define putchar(x) putc((x), stdout) 368 #endif /* __cplusplus >= 199711L */ 369 370 #ifndef _LP64 371 #if __cplusplus >= 199711L 372 namespace std { 373 inline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); } 374 inline int feof(FILE *_p) { return _p->_flag & _IOEOF; } 375 inline int ferror(FILE *_p) { return _p->_flag & _IOERR; } 376 } 377 #else /* __cplusplus >= 199711L */ 378 #define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF))) 379 #define feof(p) ((p)->_flag & _IOEOF) 380 #define ferror(p) ((p)->_flag & _IOERR) 381 #endif /* __cplusplus >= 199711L */ 382 #endif /* _LP64 */ 383 384 #endif /* _REENTRANT */ 385 386 #endif /* !defined(__lint) */ 387 388 #ifdef __cplusplus 389 } 390 #endif 391 392 #endif /* _ISO_STDIO_ISO_H */ 393