xref: /csrg-svn/lib/libc/stdio/local.h (revision 59776)
146111Sbostic /*-
246111Sbostic  * Copyright (c) 1990 The Regents of the University of California.
346111Sbostic  * 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*59776Storek  *	@(#)local.h	5.3 (Berkeley) 05/06/93
1146111Sbostic  */
1246111Sbostic 
1346111Sbostic /*
1446111Sbostic  * Information local to this implementation of stdio,
1546111Sbostic  * in particular, macros and private variables.
1646111Sbostic  */
1746111Sbostic 
1846269Storek int	__sflush __P((FILE *));
1946269Storek FILE	*__sfp __P((void));
2046269Storek int	__srefill __P((FILE *));
2146269Storek int	__sread __P((void *, char *, int));
2246269Storek int	__swrite __P((void *, char const *, int));
2346269Storek fpos_t	__sseek __P((void *, fpos_t, int));
2446269Storek int	__sclose __P((void *));
2546269Storek void	__sinit __P((void));
2646269Storek void	_cleanup __P((void));
2746269Storek void	(*__cleanup) __P((void));
2846269Storek void	__smakebuf __P((FILE *));
29*59776Storek int	__swhatbuf __P((FILE *, size_t *, int *));
3046269Storek int	_fwalk __P((int (*)(FILE *)));
3146269Storek int	__swsetup __P((FILE *));
3246269Storek int	__sflags __P((const char *, int *));
3346111Sbostic 
3446111Sbostic 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 /*
5546111Sbostic  * test for an fgetline() 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