xref: /csrg-svn/lib/libc/stdio/local.h (revision 46111)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * 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	5.1 (Berkeley) 01/20/91
11  */
12 
13 /*
14  * Information local to this implementation of stdio,
15  * in particular, macros and private variables.
16  */
17 
18 #if __STDC__ || c_plusplus
19 extern int	__sflush(FILE *);
20 extern FILE	*__sfp(void);
21 extern int	__srefill(FILE *);
22 extern int	__sread(void *, char *, int);
23 extern int	__swrite(void *, char const *, int);
24 extern fpos_t	__sseek(void *, fpos_t, int);
25 extern int	__sclose(void *);
26 extern void	__sinit(void);
27 extern void	_cleanup(void);
28 extern void	(*__cleanup)(void);
29 extern void	__smakebuf(FILE *);
30 extern int	_fwalk(int (*)(FILE *));
31 #else /* __STDC__ || c_plusplus */
32 extern int	__sflush();
33 extern FILE	*__sfp();
34 extern int	__srefill();
35 extern int	__sread();
36 extern int	__swrite();
37 extern fpos_t	__sseek();
38 extern int	__sclose();
39 extern void	__sinit();
40 extern void	_cleanup();
41 extern void	(*__cleanup)();
42 extern void	__smakebuf();
43 extern int	__sfwalk();
44 #endif /* __STDC__ || c_plusplus */
45 
46 extern int __sdidinit;
47 
48 /*
49  * Return true iff the given FILE cannot be written now.
50  */
51 #define	cantwrite(fp) \
52 	((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
53 	 __swsetup(fp))
54 
55 /*
56  * Test whether the given stdio file has an active ungetc buffer;
57  * release such a buffer, without restoring ordinary unread data.
58  */
59 #define	HASUB(fp) ((fp)->_ub._base != NULL)
60 #define	FREEUB(fp) { \
61 	if ((fp)->_ub._base != (fp)->_ubuf) \
62 		free((char *)(fp)->_ub._base); \
63 	(fp)->_ub._base = NULL; \
64 }
65 
66 /*
67  * test for an fgetline() buffer.
68  */
69 #define	HASLB(fp) ((fp)->_lb._base != NULL)
70 #define	FREELB(fp) { \
71 	free((char *)(fp)->_lb._base); \
72 	(fp)->_lb._base = NULL; \
73 }
74