xref: /illumos-gate/usr/src/head/stdio_ext.h (revision 0250c53ad267726f2438e3c6556199a0bbf588a2)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Extensions to the stdio package
29  */
30 
31 #ifndef _STDIO_EXT_H
32 #define	_STDIO_EXT_H
33 
34 #include <stdio.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Even though the contents of the stdio FILE structure have always been
42  * private to the stdio implementation, over the years some programs have
43  * needed to get information about a stdio stream that was not accessible
44  * through a supported interface. These programs have resorted to accessing
45  * fields of the FILE structure directly, rendering them possibly non-portable
46  * to new implementations of stdio, or more likely, preventing enhancements
47  * to stdio because those programs will break.
48  *
49  * In the 64-bit world, the FILE structure is opaque. The routines here
50  * are provided as a way to get the information that used to be retrieved
51  * directly from the FILE structure. They are based on the needs of
52  * existing programs (such as 'mh' and 'emacs'), so they may be extended
53  * as other programs are ported. Though they may still be non-portable to
54  * other operating systems, they will work from each Solaris release to
55  * the next. More portable interfaces are being developed.
56  */
57 
58 #define	FSETLOCKING_QUERY	0
59 #define	FSETLOCKING_INTERNAL	1
60 #define	FSETLOCKING_BYCALLER	2
61 
62 extern size_t __fbufsize(FILE *stream);
63 extern int __freading(FILE *stream);
64 extern int __fwriting(FILE *stream);
65 extern int __freadable(FILE *stream);
66 extern int __fwritable(FILE *stream);
67 extern int __flbf(FILE *stream);
68 extern void __fpurge(FILE *stream);
69 extern size_t __fpending(FILE *stream);
70 extern void _flushlbf(void);
71 extern int __fsetlocking(FILE *stream, int type);
72 
73 /*
74  * Extended FILE enabling function.
75  */
76 #if defined(_LP64) && !defined(__lint)
77 #define	enable_extended_FILE_stdio(fd, act)		(0)
78 #else
79 extern int enable_extended_FILE_stdio(int, int);
80 #endif
81 
82 #ifdef	__cplusplus
83 }
84 #endif
85 
86 #endif	/* _STDIO_EXT_H */
87