[BACK]Return to local.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / stdio

Annotation of src/lib/libc/stdio/local.h, Revision 1.30.2.2

1.30.2.2! yamt        1: /*     $NetBSD: local.h,v 1.30.2.1 2012/04/17 00:05:24 yamt Exp $      */
1.5       jtc         2:
1.1       cgd         3: /*-
1.5       jtc         4:  * Copyright (c) 1990, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
1.1       cgd         6:  *
                      7:  * This code is derived from software contributed to Berkeley by
                      8:  * Chris Torek.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
1.17      agc        18:  * 3. Neither the name of the University nor the names of its contributors
1.1       cgd        19:  *    may be used to endorse or promote products derived from this software
                     20:  *    without specific prior written permission.
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     23:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     24:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     25:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     26:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     27:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     28:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     29:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     30:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     31:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     32:  * SUCH DAMAGE.
                     33:  *
1.7       perry      34:  *     @(#)local.h     8.3 (Berkeley) 7/3/94
1.1       cgd        35:  */
                     36:
1.10      yamt       37: #include "wcio.h"
                     38: #include "fileext.h"
                     39:
1.29      tron       40: #include <limits.h>
1.30      joerg      41: #include <stdarg.h>
1.29      tron       42: #include <stdbool.h>
                     43:
1.1       cgd        44: /*
                     45:  * Information local to this implementation of stdio,
                     46:  * in particular, macros and private variables.
                     47:  */
                     48:
1.30.2.1  yamt       49: extern int     __sflush(FILE *);
                     50: extern FILE    *__sfp(void);
                     51: extern void    __sfpinit(FILE *);
                     52: extern int     __srefill(FILE *);
                     53: extern ssize_t __sread(void *, void *, size_t);
                     54: extern ssize_t __swrite(void *, const void *, size_t);
                     55: extern off_t   __sseek(void *, off_t, int);
                     56: extern int     __sclose(void *);
                     57: extern void    __sinit(void);
                     58: extern void    _cleanup(void);
                     59: extern void    (*__cleanup)(void);
                     60: extern void    __smakebuf(FILE *);
                     61: extern int     __swhatbuf(FILE *, size_t *, int *);
                     62: extern int     _fwalk(int (*)(FILE *));
                     63: extern char    *_mktemp(char *);
                     64: extern int     __swsetup(FILE *);
                     65: extern int     __sflags(const char *, int *);
                     66: extern int     __svfscanf(FILE * __restrict, const char * __restrict,
                     67:     va_list) __scanflike(2, 0);
1.30.2.2! yamt       68: extern int     __svfscanf_l(FILE * __restrict, locale_t,
        !            69:     const char * __restrict, va_list) __scanflike(3, 0);
        !            70: extern int     __svfscanf_unlocked_l(FILE * __restrict, locale_t,
        !            71:     const char * __restrict, va_list) __scanflike(3, 0);
        !            72: extern int     __vfprintf_unlocked_l(FILE * __restrict, locale_t,
        !            73:     const char * __restrict, va_list) __printflike(3, 0);
1.19      kleink     74:
1.1       cgd        75:
1.7       perry      76: extern int     __sdidinit;
1.8       mycroft    77:
1.30.2.1  yamt       78: extern int     __gettemp(char *, int *, int);
1.1       cgd        79:
1.30.2.1  yamt       80: extern wint_t  __fgetwc_unlock(FILE *);
                     81: extern wint_t  __fputwc_unlock(wchar_t, FILE *);
1.18      drochner   82:
1.23      roy        83: extern ssize_t __getdelim(char **__restrict, size_t *__restrict, int,
                     84:     FILE *__restrict);
1.30.2.1  yamt       85: extern char    *__fgetstr(FILE * __restrict, size_t * __restrict, int);
1.30.2.2! yamt       86: extern int      __vfwprintf_unlocked_l(FILE *, locale_t, const wchar_t *, va_list);
        !            87: extern int      __vfwscanf_unlocked_l(FILE * __restrict, locale_t,
1.30.2.1  yamt       88:     const wchar_t * __restrict, va_list);
1.18      drochner   89:
1.1       cgd        90: /*
                     91:  * Return true iff the given FILE cannot be written now.
                     92:  */
                     93: #define        cantwrite(fp) \
                     94:        ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
                     95:         __swsetup(fp))
                     96:
                     97: /*
                     98:  * Test whether the given stdio file has an active ungetc buffer;
                     99:  * release such a buffer, without restoring ordinary unread data.
                    100:  */
1.10      yamt      101: #define        HASUB(fp) (_UB(fp)._base != NULL)
1.1       cgd       102: #define        FREEUB(fp) { \
1.10      yamt      103:        if (_UB(fp)._base != (fp)->_ubuf) \
                    104:                free((char *)_UB(fp)._base); \
                    105:        _UB(fp)._base = NULL; \
1.1       cgd       106: }
                    107:
                    108: /*
1.4       cgd       109:  * test for an fgetln() buffer.
1.1       cgd       110:  */
                    111: #define        FREELB(fp) { \
1.24      joerg     112:        free(_EXT(fp)->_fgetstr_buf); \
                    113:        _EXT(fp)->_fgetstr_buf = NULL; \
                    114:        _EXT(fp)->_fgetstr_len = 0; \
1.1       cgd       115: }
1.10      yamt      116:
1.30.2.1  yamt      117: extern void __flockfile_internal(FILE *, int);
                    118: extern void __funlockfile_internal(FILE *, int);
1.26      christos  119:
1.30.2.2! yamt      120: extern char *__gets(char *);
        !           121:
1.26      christos  122: /*
                    123:  * Detect if the current file position fits in a long int.
                    124:  */
1.29      tron      125:
                    126: static __inline bool
1.30.2.1  yamt      127: __long_overflow(off_t pos)
1.29      tron      128: {
1.30.2.1  yamt      129:        return (pos < LONG_MIN) || (pos > LONG_MAX);
1.29      tron      130: }

CVSweb <webmaster@jp.NetBSD.org>