17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
23ba3594bGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
244870e0aRichard PALO * Copyright 2014 PALO, Richard.
25ba3594bGarrett D'Amore *
2650b3752muffin * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
277c478bdstevel@tonic-gate * Use is subject to license terms.
287c478bdstevel@tonic-gate */
297c478bdstevel@tonic-gate
3050b3752muffin/*	Copyright (c) 1988 AT&T	*/
31b4203d7Marcel Telka/*	  All Rights Reserved	*/
3250b3752muffin
337c478bdstevel@tonic-gate/*
347c478bdstevel@tonic-gate * An application should not include this header directly.  Instead it
357c478bdstevel@tonic-gate * should be included only through the inclusion of other Sun headers.
367c478bdstevel@tonic-gate *
377c478bdstevel@tonic-gate * The contents of this header is limited to identifiers specified in the
387c478bdstevel@tonic-gate * C Standard.  Any new identifiers specified in future amendments to the
397c478bdstevel@tonic-gate * C Standard must be placed in this header.  If these new identifiers
407c478bdstevel@tonic-gate * are required to also be in the C++ Standard "std" namespace, then for
417c478bdstevel@tonic-gate * anything other than macro definitions, corresponding "using" directives
427c478bdstevel@tonic-gate * must also be added to <stdio.h>.
437c478bdstevel@tonic-gate */
447c478bdstevel@tonic-gate
457c478bdstevel@tonic-gate/*
467c478bdstevel@tonic-gate * User-visible pieces of the ANSI C standard I/O package.
477c478bdstevel@tonic-gate */
487c478bdstevel@tonic-gate
497c478bdstevel@tonic-gate#ifndef _ISO_STDIO_ISO_H
507c478bdstevel@tonic-gate#define	_ISO_STDIO_ISO_H
517c478bdstevel@tonic-gate
527c478bdstevel@tonic-gate#include <sys/feature_tests.h>
534870e0aRichard PALO#include <sys/null.h>
547c478bdstevel@tonic-gate#include <sys/va_list.h>
557c478bdstevel@tonic-gate#include <stdio_tag.h>
567c478bdstevel@tonic-gate#include <stdio_impl.h>
577c478bdstevel@tonic-gate
587c478bdstevel@tonic-gate/*
597c478bdstevel@tonic-gate * If feature test macros are set that enable interfaces that use types
607c478bdstevel@tonic-gate * defined in <sys/types.h>, get those types by doing the include.
617c478bdstevel@tonic-gate *
627c478bdstevel@tonic-gate * Note that in asking for the interfaces associated with this feature test
637c478bdstevel@tonic-gate * macro one also asks for definitions of the POSIX types.
647c478bdstevel@tonic-gate */
657c478bdstevel@tonic-gate
667c478bdstevel@tonic-gate#ifdef	__cplusplus
677c478bdstevel@tonic-gateextern "C" {
687c478bdstevel@tonic-gate#endif
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate#if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE))
717c478bdstevel@tonic-gate/*
727c478bdstevel@tonic-gate * The following typedefs are adopted from ones in <sys/types.h> (with leading
737c478bdstevel@tonic-gate * underscores added to avoid polluting the ANSI C name space).  See the
747c478bdstevel@tonic-gate * commentary there for further explanation.
757c478bdstevel@tonic-gate */
767c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
777c478bdstevel@tonic-gatetypedef	long long	__longlong_t;
787c478bdstevel@tonic-gate#else
797c478bdstevel@tonic-gate/* used to reserve space and generate alignment */
807c478bdstevel@tonic-gatetypedef union {
817c478bdstevel@tonic-gate	double	_d;
827c478bdstevel@tonic-gate	int	_l[2];
837c478bdstevel@tonic-gate} __longlong_t;
847c478bdstevel@tonic-gate#endif
857c478bdstevel@tonic-gate#endif  /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */
867c478bdstevel@tonic-gate
877c478bdstevel@tonic-gate#if __cplusplus >= 199711L
887c478bdstevel@tonic-gatenamespace std {
897c478bdstevel@tonic-gate#endif
907c478bdstevel@tonic-gate
917c478bdstevel@tonic-gate#if !defined(_FILEDEFED) || __cplusplus >= 199711L
927c478bdstevel@tonic-gate#define	_FILEDEFED
937c478bdstevel@tonic-gatetypedef	__FILE FILE;
947c478bdstevel@tonic-gate#endif
957c478bdstevel@tonic-gate
967c478bdstevel@tonic-gate#if !defined(_SIZE_T) || __cplusplus >= 199711L
977c478bdstevel@tonic-gate#define	_SIZE_T
987c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
997c478bdstevel@tonic-gatetypedef unsigned long	size_t;		/* size of something in bytes */
1007c478bdstevel@tonic-gate#else
1017c478bdstevel@tonic-gatetypedef unsigned int	size_t;		/* (historical version) */
1027c478bdstevel@tonic-gate#endif
1037c478bdstevel@tonic-gate#endif	/* !_SIZE_T */
1047c478bdstevel@tonic-gate
1057c478bdstevel@tonic-gate#if defined(_LP64) || _FILE_OFFSET_BITS == 32
1067c478bdstevel@tonic-gatetypedef long		fpos_t;
1077c478bdstevel@tonic-gate#else
1087c478bdstevel@tonic-gatetypedef	__longlong_t	fpos_t;
1097c478bdstevel@tonic-gate#endif
1107c478bdstevel@tonic-gate
1117c478bdstevel@tonic-gate#if __cplusplus >= 199711L
1127c478bdstevel@tonic-gate}
1137c478bdstevel@tonic-gate#endif /* end of namespace std */
1147c478bdstevel@tonic-gate
1157c478bdstevel@tonic-gate#define	BUFSIZ	1024
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate/*
1187c478bdstevel@tonic-gate * The value of _NFILE is defined in the Processor Specific ABI.  The value
1197c478bdstevel@tonic-gate * is chosen for historical reasons rather than for truly processor related
1207c478bdstevel@tonic-gate * attribute.  Note that the SPARC Processor Specific ABI uses the common
1217c478bdstevel@tonic-gate * UNIX historical value of 20 so it is allowed to fall through.
1227c478bdstevel@tonic-gate */
1237c478bdstevel@tonic-gate#if defined(__i386)
1247c478bdstevel@tonic-gate#define	_NFILE	60	/* initial number of streams: Intel x86 ABI */
1257c478bdstevel@tonic-gate#else
1267c478bdstevel@tonic-gate#define	_NFILE	20	/* initial number of streams: SPARC ABI and default */
1277c478bdstevel@tonic-gate#endif
1287c478bdstevel@tonic-gate
1297c478bdstevel@tonic-gate#define	_SBFSIZ	8	/* compatibility with shared libs */
1307c478bdstevel@tonic-gate
1317c478bdstevel@tonic-gate#define	_IOFBF		0000	/* full buffered */
1327c478bdstevel@tonic-gate#define	_IOLBF		0100	/* line buffered */
1337c478bdstevel@tonic-gate#define	_IONBF		0004	/* not buffered */
1347c478bdstevel@tonic-gate#define	_IOEOF		0020	/* EOF reached on read */
1357c478bdstevel@tonic-gate#define	_IOERR		0040	/* I/O error from system */
1367c478bdstevel@tonic-gate
1377c478bdstevel@tonic-gate#define	_IOREAD		0001	/* currently reading */
1387c478bdstevel@tonic-gate#define	_IOWRT		0002	/* currently writing */
1397c478bdstevel@tonic-gate#define	_IORW		0200	/* opened for reading and writing */
1407c478bdstevel@tonic-gate#define	_IOMYBUF	0010	/* stdio malloc()'d buffer */
1417c478bdstevel@tonic-gate
1427c478bdstevel@tonic-gate#ifndef EOF
1437c478bdstevel@tonic-gate#define	EOF	(-1)
1447c478bdstevel@tonic-gate#endif
1457c478bdstevel@tonic-gate
1467c478bdstevel@tonic-gate#define	FOPEN_MAX	_NFILE
1477c478bdstevel@tonic-gate#define	FILENAME_MAX    1024	/* max # of characters in a path name */
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate#define	SEEK_SET	0
1507c478bdstevel@tonic-gate#define	SEEK_CUR	1
1517c478bdstevel@tonic-gate#define	SEEK_END	2
1527c478bdstevel@tonic-gate#define	TMP_MAX		17576	/* 26 * 26 * 26 */
1537c478bdstevel@tonic-gate
1547c478bdstevel@tonic-gate#define	L_tmpnam	25	/* (sizeof(P_tmpdir) + 15) */
1557c478bdstevel@tonic-gate
1567c478bdstevel@tonic-gateextern __FILE	__iob[_NFILE];
1577c478bdstevel@tonic-gate#define	stdin	(&__iob[0])
1587c478bdstevel@tonic-gate#define	stdout	(&__iob[1])
1597c478bdstevel@tonic-gate#define	stderr	(&__iob[2])
1607c478bdstevel@tonic-gate
1617c478bdstevel@tonic-gate#if __cplusplus >= 199711L
1627c478bdstevel@tonic-gatenamespace std {
1637c478bdstevel@tonic-gate#endif
1647c478bdstevel@tonic-gate
1657c478bdstevel@tonic-gate#if !defined(_LP64) && !defined(_LONGLONG_TYPE)
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate#ifdef __PRAGMA_REDEFINE_EXTNAME
1687c478bdstevel@tonic-gate#pragma redefine_extname fprintf	_fprintf_c89
1697c478bdstevel@tonic-gate#pragma redefine_extname printf		_printf_c89
1707c478bdstevel@tonic-gate#pragma redefine_extname sprintf	_sprintf_c89
1717c478bdstevel@tonic-gate#pragma redefine_extname vfprintf	_vfprintf_c89
1727c478bdstevel@tonic-gate#pragma redefine_extname vprintf	_vprintf_c89
1737c478bdstevel@tonic-gate#pragma redefine_extname vsprintf	_vsprintf_c89
1747c478bdstevel@tonic-gate#pragma redefine_extname fscanf		_fscanf_c89
1757c478bdstevel@tonic-gate#pragma redefine_extname scanf		_scanf_c89
1767c478bdstevel@tonic-gate#pragma redefine_extname sscanf		_sscanf_c89
1777c478bdstevel@tonic-gate#else
1787c478bdstevel@tonic-gate#define	fprintf		_fprintf_c89
1797c478bdstevel@tonic-gate#define	printf		_printf_c89
1807c478bdstevel@tonic-gate#define	sprintf		_sprintf_c89
1817c478bdstevel@tonic-gate#define	vfprintf	_vfprintf_c89
1827c478bdstevel@tonic-gate#define	vprintf		_vprintf_c89
1837c478bdstevel@tonic-gate#define	vsprintf	_vsprintf_c89
1847c478bdstevel@tonic-gate#define	fscanf		_fscanf_c89
1857c478bdstevel@tonic-gate#define	scanf		_scanf_c89
1867c478bdstevel@tonic-gate#define	sscanf		_sscanf_c89
1877c478bdstevel@tonic-gate#endif
1887c478bdstevel@tonic-gate
1897c478bdstevel@tonic-gate#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
1907c478bdstevel@tonic-gate
1917c478bdstevel@tonic-gateextern int	remove(const char *);
1927c478bdstevel@tonic-gateextern int	rename(const char *, const char *);
1937c478bdstevel@tonic-gateextern FILE	*tmpfile(void);
1947c478bdstevel@tonic-gateextern char	*tmpnam(char *);
1957c478bdstevel@tonic-gateextern int	fclose(FILE *);
1967c478bdstevel@tonic-gateextern int	fflush(FILE *);
1977c478bdstevel@tonic-gateextern FILE	*fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1987c478bdstevel@tonic-gateextern FILE	*freopen(const char *_RESTRICT_KYWD,
1997c478bdstevel@tonic-gate			const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
2007c478bdstevel@tonic-gateextern void	setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
2017c478bdstevel@tonic-gateextern int	setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int,
2027c478bdstevel@tonic-gate			size_t);
2037c478bdstevel@tonic-gate/* PRINTFLIKE2 */
2047c478bdstevel@tonic-gateextern int	fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
2057c478bdstevel@tonic-gate/* SCANFLIKE2 */
2067c478bdstevel@tonic-gateextern int	fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
2077c478bdstevel@tonic-gate/* PRINTFLIKE1 */
2087c478bdstevel@tonic-gateextern int	printf(const char *_RESTRICT_KYWD, ...);
2097c478bdstevel@tonic-gate/* SCANFLIKE1 */
2107c478bdstevel@tonic-gateextern int	scanf(const char *_RESTRICT_KYWD, ...);
2117c478bdstevel@tonic-gate/* PRINTFLIKE2 */
2127c478bdstevel@tonic-gateextern int	sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
2137c478bdstevel@tonic-gate/* SCANFLIKE2 */
2147c478bdstevel@tonic-gateextern int	sscanf(const char *_RESTRICT_KYWD,
2157c478bdstevel@tonic-gate			const char *_RESTRICT_KYWD, ...);
2167c478bdstevel@tonic-gateextern int	vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
2177c478bdstevel@tonic-gate			__va_list);
2187c478bdstevel@tonic-gateextern int	vprintf(const char *_RESTRICT_KYWD, __va_list);
2197c478bdstevel@tonic-gateextern int	vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
2207c478bdstevel@tonic-gate			__va_list);
2217c478bdstevel@tonic-gateextern int	fgetc(FILE *);
2227c478bdstevel@tonic-gateextern char	*fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD);
2237c478bdstevel@tonic-gateextern int	fputc(int, FILE *);
2247c478bdstevel@tonic-gateextern int	fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
2257c478bdstevel@tonic-gate#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
2267c478bdstevel@tonic-gate	__cplusplus < 199711L
2277c478bdstevel@tonic-gateextern int	getc(FILE *);
2287c478bdstevel@tonic-gateextern int	putc(int, FILE *);
2297c478bdstevel@tonic-gate#endif
2307c478bdstevel@tonic-gate#if (__cplusplus >= 199711L && defined(_REENTRANT)) || \
2317c478bdstevel@tonic-gate	__cplusplus < 199711L
2327c478bdstevel@tonic-gateextern int	getchar(void);
2337c478bdstevel@tonic-gateextern int	putchar(int);
2347c478bdstevel@tonic-gate#endif
235fc2512cRobert Mustacchi
236fc2512cRobert Mustacchi/*
237fc2512cRobert Mustacchi * ISO/IEC C11 removed gets from the standard library. Therefore if a strict C11
238fc2512cRobert Mustacchi * environment has been requested, we remove it.
239fc2512cRobert Mustacchi */
240fc2512cRobert Mustacchi#if !defined(_STDC_C11) || defined(__EXTENSIONS__)
2417c478bdstevel@tonic-gateextern char	*gets(char *);
242fc2512cRobert Mustacchi#endif
2437c478bdstevel@tonic-gateextern int	puts(const char *);
2447c478bdstevel@tonic-gateextern int	ungetc(int, FILE *);
2457c478bdstevel@tonic-gateextern size_t	fread(void *_RESTRICT_KYWD, size_t, size_t,
2467c478bdstevel@tonic-gate	FILE *_RESTRICT_KYWD);
2477c478bdstevel@tonic-gateextern size_t	fwrite(const void *_RESTRICT_KYWD, size_t, size_t,
2487c478bdstevel@tonic-gate	FILE *_RESTRICT_KYWD);
2497c478bdstevel@tonic-gate#if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32
2507c478bdstevel@tonic-gateextern int	fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD);
2517c478bdstevel@tonic-gateextern int	fsetpos(FILE *, const fpos_t *);
2527c478bdstevel@tonic-gate#endif
2537c478bdstevel@tonic-gateextern int	fseek(FILE *, long, int);
2547c478bdstevel@tonic-gateextern long	ftell(FILE *);
2557c478bdstevel@tonic-gateextern void	rewind(FILE *);
2567c478bdstevel@tonic-gate#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
2577c478bdstevel@tonic-gate	__cplusplus < 199711L
2587c478bdstevel@tonic-gateextern void	clearerr(FILE *);
2597c478bdstevel@tonic-gateextern int	feof(FILE *);
2607c478bdstevel@tonic-gateextern int	ferror(FILE *);
2617c478bdstevel@tonic-gate#endif
2627c478bdstevel@tonic-gateextern void	perror(const char *);
2637c478bdstevel@tonic-gate
2647c478bdstevel@tonic-gate#ifndef	_LP64
2657c478bdstevel@tonic-gateextern int	__filbuf(FILE *);
2667c478bdstevel@tonic-gateextern int	__flsbuf(int, FILE *);
2677c478bdstevel@tonic-gate#endif	/*	_LP64	*/
2687c478bdstevel@tonic-gate
2697c478bdstevel@tonic-gate#if __cplusplus >= 199711L
2707c478bdstevel@tonic-gate}
2717c478bdstevel@tonic-gate#endif /* end of namespace std */
2727c478bdstevel@tonic-gate
2737c478bdstevel@tonic-gate#if !defined(__lint)
2747c478bdstevel@tonic-gate
275693e4d8Alexander Pyhalov#if	!defined(_REENTRANT) && !defined(_LP64)
2767c478bdstevel@tonic-gate
2777c478bdstevel@tonic-gate#if __cplusplus >= 199711L
2787c478bdstevel@tonic-gatenamespace std {
2797c478bdstevel@tonic-gateinline int getc(FILE *_p) {
2807c478bdstevel@tonic-gate	return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); }
2817c478bdstevel@tonic-gateinline int putc(int _x, FILE *_p) {
2827c478bdstevel@tonic-gate	return (--_p->_cnt < 0 ? __flsbuf(_x, _p)
2837c478bdstevel@tonic-gate		: (int)(*_p->_ptr++ = (unsigned char) _x)); }
2847c478bdstevel@tonic-gate}
2857c478bdstevel@tonic-gate#else /* __cplusplus >= 199711L */
2867c478bdstevel@tonic-gate#define	getc(p)		(--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
2877c478bdstevel@tonic-gate#define	putc(x, p)	(--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
2887c478bdstevel@tonic-gate				: (int)(*(p)->_ptr++ = (unsigned char) (x)))
2897c478bdstevel@tonic-gate#endif /* __cplusplus >= 199711L */
29050b3752muffin
291693e4d8Alexander Pyhalov#endif /* !defined(_REENTRANT) && !defined(_LP64) */
29250b3752muffin
29350b3752muffin#ifndef	_REENTRANT
2947c478bdstevel@tonic-gate
2957c478bdstevel@tonic-gate#if __cplusplus >= 199711L
2967c478bdstevel@tonic-gatenamespace std {
2977c478bdstevel@tonic-gateinline int getchar() { return getc(stdin); }
2987c478bdstevel@tonic-gateinline int putchar(int _x) { return putc(_x, stdout); }
2997c478bdstevel@tonic-gate}
3007c478bdstevel@tonic-gate#else
3017c478bdstevel@tonic-gate#define	getchar()	getc(stdin)
3027c478bdstevel@tonic-gate#define	putchar(x)	putc((x), stdout)
3037c478bdstevel@tonic-gate#endif /* __cplusplus >= 199711L */
3047c478bdstevel@tonic-gate
3057c478bdstevel@tonic-gate#ifndef	_LP64
3067c478bdstevel@tonic-gate#if __cplusplus >= 199711L
3077c478bdstevel@tonic-gatenamespace std {
3087c478bdstevel@tonic-gateinline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); }
3097c478bdstevel@tonic-gateinline int feof(FILE *_p) { return _p->_flag & _IOEOF; }
3107c478bdstevel@tonic-gateinline int ferror(FILE *_p) { return _p->_flag & _IOERR; }
3117c478bdstevel@tonic-gate}
3127c478bdstevel@tonic-gate#else /* __cplusplus >= 199711L */
3137c478bdstevel@tonic-gate#define	clearerr(p)	((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
3147c478bdstevel@tonic-gate#define	feof(p)		((p)->_flag & _IOEOF)
3157c478bdstevel@tonic-gate#define	ferror(p)	((p)->_flag & _IOERR)
3167c478bdstevel@tonic-gate#endif /* __cplusplus >= 199711L */
3177c478bdstevel@tonic-gate#endif	/* _LP64 */
3187c478bdstevel@tonic-gate
3197c478bdstevel@tonic-gate#endif	/* _REENTRANT */
3207c478bdstevel@tonic-gate
3217c478bdstevel@tonic-gate#endif	/* !defined(__lint) */
3227c478bdstevel@tonic-gate
3237c478bdstevel@tonic-gate#ifdef	__cplusplus
3247c478bdstevel@tonic-gate}
3257c478bdstevel@tonic-gate#endif
3267c478bdstevel@tonic-gate
3277c478bdstevel@tonic-gate#endif	/* _ISO_STDIO_ISO_H */
328