xref: /titanic_44/usr/src/stand/lib/sa/stdio.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SA_STDIO_H
28 #define	_SA_STDIO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <stdarg.h>
34 
35 /*
36  * Exported interfaces for standalone's subset of libc's <stdio.h>.
37  * All standalone code *must* use this header rather than libc's.
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #ifndef NULL
45 #define	NULL	0
46 #endif
47 
48 #ifndef	EOF
49 #define	EOF	(-1)
50 #endif
51 
52 /*
53  * Flags to setvbuf() which we pretend to support.  We're always really _IONBF.
54  */
55 #define	_IOFBF	0000	/* full buffered */
56 #define	_IOLBF	0100	/* line buffered */
57 #define	_IONBF	0004	/* not buffered */
58 
59 typedef struct {
60 	unsigned char	_flag; 		/* state of the stream */
61 	int		_file;		/* file descriptor */
62 	ssize_t		_len;		/* total len of file */
63 	ssize_t		_offset;	/* offset within the file */
64 	char		_name[256];	/* name of the file (for debugging) */
65 } FILE;
66 
67 #define	stdin	(&__iob[0])
68 #define	stdout	(&__iob[1])
69 #define	stderr	(&__iob[2])
70 
71 #define	_NFILE	10
72 extern	FILE	__iob[_NFILE];
73 
74 extern int	fclose(FILE *);
75 extern int	feof(FILE *);
76 extern int	fflush(FILE *);
77 extern int	ferror(FILE *);
78 extern void	clearerr(FILE *);
79 
80 extern char	*fgets(char *, int, FILE *);
81 extern FILE	*fopen(const char *, const char *);
82 extern size_t	fread(void *, size_t, size_t, FILE *);
83 extern int	fseek(FILE *, long, int);
84 extern long	ftell(FILE *);
85 extern size_t	fwrite(const void *, size_t, size_t, FILE *);
86 extern int	setvbuf(FILE *, char *, int, size_t);
87 
88 /* PRINTFLIKE1 */
89 extern void	printf(const char *, ...);
90 /* PRINTFLIKE2 */
91 extern int	fprintf(FILE *, const char *, ...);
92 /* PRINTFLIKE2 */
93 extern int	sprintf(char *, const char *, ...);
94 /* PRINTFLIKE3 */
95 extern size_t	snprintf(char *, size_t, const char *, ...);
96 extern int	vsprintf(char *, const char *, va_list);
97 extern size_t	vsnprintf(char *, size_t, const char *, va_list);
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* _SA_STDIO_H */
104