xref: /titanic_41/usr/src/head/stdio_ext.h (revision 35a5a3587fd94b666239c157d3722745250ccbd7)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <stdio.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Even though the contents of the stdio FILE structure have always been
44  * private to the stdio implementation, over the years some programs have
45  * needed to get information about a stdio stream that was not accessible
46  * through a supported interface. These programs have resorted to accessing
47  * fields of the FILE structure directly, rendering them possibly non-portable
48  * to new implementations of stdio, or more likely, preventing enhancements
49  * to stdio because those programs will break.
50  *
51  * In the 64-bit world, the FILE structure is opaque. The routines here
52  * are provided as a way to get the information that used to be retrieved
53  * directly from the FILE structure. They are based on the needs of
54  * existing programs (such as 'mh' and 'emacs'), so they may be extended
55  * as other programs are ported. Though they may still be non-portable to
56  * other operating systems, they will work from each Solaris release to
57  * the next. More portable interfaces are being developed.
58  */
59 
60 #define	FSETLOCKING_QUERY	0
61 #define	FSETLOCKING_INTERNAL	1
62 #define	FSETLOCKING_BYCALLER	2
63 
64 extern size_t __fbufsize(FILE *stream);
65 extern int __freading(FILE *stream);
66 extern int __fwriting(FILE *stream);
67 extern int __freadable(FILE *stream);
68 extern int __fwritable(FILE *stream);
69 extern int __flbf(FILE *stream);
70 extern void __fpurge(FILE *stream);
71 extern size_t __fpending(FILE *stream);
72 extern void _flushlbf(void);
73 extern int __fsetlocking(FILE *stream, int type);
74 
75 /*
76  * Extended FILE enabling function.
77  */
78 #if defined(_LP64) && !defined(__lint)
79 #define	enable_extended_FILE_stdio(fd, act)		(0)
80 #else
81 extern int enable_extended_FILE_stdio(int, int);
82 #endif
83 
84 #ifdef	__cplusplus
85 }
86 #endif
87 
88 #endif	/* _STDIO_EXT_H */
89