xref: /original-bsd/lib/libc/stdio/local.h (revision 27393bdf)
1 /*-
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Chris Torek.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)local.h	8.3 (Berkeley) 07/03/94
11  */
12 
13 /*
14  * Information local to this implementation of stdio,
15  * in particular, macros and private variables.
16  */
17 
18 extern int	__sflush __P((FILE *));
19 extern FILE	*__sfp __P((void));
20 extern int	__srefill __P((FILE *));
21 extern int	__sread __P((void *, char *, int));
22 extern int	__swrite __P((void *, char const *, int));
23 extern fpos_t	__sseek __P((void *, fpos_t, int));
24 extern int	__sclose __P((void *));
25 extern void	__sinit __P((void));
26 extern void	_cleanup __P((void));
27 extern void	(*__cleanup) __P((void));
28 extern void	__smakebuf __P((FILE *));
29 extern int	__swhatbuf __P((FILE *, size_t *, int *));
30 extern int	_fwalk __P((int (*)(FILE *)));
31 extern int	__swsetup __P((FILE *));
32 extern int	__sflags __P((const char *, int *));
33 
34 extern int	__sdidinit;
35 
36 /*
37  * Return true iff the given FILE cannot be written now.
38  */
39 #define	cantwrite(fp) \
40 	((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
41 	 __swsetup(fp))
42 
43 /*
44  * Test whether the given stdio file has an active ungetc buffer;
45  * release such a buffer, without restoring ordinary unread data.
46  */
47 #define	HASUB(fp) ((fp)->_ub._base != NULL)
48 #define	FREEUB(fp) { \
49 	if ((fp)->_ub._base != (fp)->_ubuf) \
50 		free((char *)(fp)->_ub._base); \
51 	(fp)->_ub._base = NULL; \
52 }
53 
54 /*
55  * test for an fgetln() buffer.
56  */
57 #define	HASLB(fp) ((fp)->_lb._base != NULL)
58 #define	FREELB(fp) { \
59 	free((char *)(fp)->_lb._base); \
60 	(fp)->_lb._base = NULL; \
61 }
62