xref: /csrg-svn/lib/libc/stdio/local.h (revision 67485)
146111Sbostic /*-
261180Sbostic  * Copyright (c) 1990, 1993
361180Sbostic  *	The Regents of the University of California.  All rights reserved.
446111Sbostic  *
546111Sbostic  * This code is derived from software contributed to Berkeley by
646111Sbostic  * Chris Torek.
746111Sbostic  *
846111Sbostic  * %sccs.include.redist.c%
946111Sbostic  *
10*67485Smckusick  *	@(#)local.h	8.3 (Berkeley) 07/03/94
1146111Sbostic  */
1246111Sbostic 
1346111Sbostic /*
1446111Sbostic  * Information local to this implementation of stdio,
1546111Sbostic  * in particular, macros and private variables.
1646111Sbostic  */
1746111Sbostic 
18*67485Smckusick extern int	__sflush __P((FILE *));
19*67485Smckusick extern FILE	*__sfp __P((void));
20*67485Smckusick extern int	__srefill __P((FILE *));
21*67485Smckusick extern int	__sread __P((void *, char *, int));
22*67485Smckusick extern int	__swrite __P((void *, char const *, int));
23*67485Smckusick extern fpos_t	__sseek __P((void *, fpos_t, int));
24*67485Smckusick extern int	__sclose __P((void *));
25*67485Smckusick extern void	__sinit __P((void));
26*67485Smckusick extern void	_cleanup __P((void));
27*67485Smckusick extern void	(*__cleanup) __P((void));
28*67485Smckusick extern void	__smakebuf __P((FILE *));
29*67485Smckusick extern int	__swhatbuf __P((FILE *, size_t *, int *));
30*67485Smckusick extern int	_fwalk __P((int (*)(FILE *)));
31*67485Smckusick extern int	__swsetup __P((FILE *));
32*67485Smckusick extern int	__sflags __P((const char *, int *));
3346111Sbostic 
34*67485Smckusick extern int	__sdidinit;
3546111Sbostic 
3646111Sbostic /*
3746111Sbostic  * Return true iff the given FILE cannot be written now.
3846111Sbostic  */
3946111Sbostic #define	cantwrite(fp) \
4046111Sbostic 	((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
4146111Sbostic 	 __swsetup(fp))
4246111Sbostic 
4346111Sbostic /*
4446111Sbostic  * Test whether the given stdio file has an active ungetc buffer;
4546111Sbostic  * release such a buffer, without restoring ordinary unread data.
4646111Sbostic  */
4746111Sbostic #define	HASUB(fp) ((fp)->_ub._base != NULL)
4846111Sbostic #define	FREEUB(fp) { \
4946111Sbostic 	if ((fp)->_ub._base != (fp)->_ubuf) \
5046111Sbostic 		free((char *)(fp)->_ub._base); \
5146111Sbostic 	(fp)->_ub._base = NULL; \
5246111Sbostic }
5346111Sbostic 
5446111Sbostic /*
5565334Sbostic  * test for an fgetln() buffer.
5646111Sbostic  */
5746111Sbostic #define	HASLB(fp) ((fp)->_lb._base != NULL)
5846111Sbostic #define	FREELB(fp) { \
5946111Sbostic 	free((char *)(fp)->_lb._base); \
6046111Sbostic 	(fp)->_lb._base = NULL; \
6146111Sbostic }
62