gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/stdio/local.hbare sourcepermlink (0.02 seconds)

Search this content:

    1: /* Add __sungetc() and __sfread() */
    2: 
    3: /*      $OpenBSD: local.h,v 1.20 2011/11/08 18:30:42 guenther Exp $  */
    4: 
    5: /*-
    6:  * Copyright (c) 1990, 1993
    7:  *      The Regents of the University of California.  All rights reserved.
    8:  *
    9:  * This code is derived from software contributed to Berkeley by
   10:  * Chris Torek.
   11:  *
   12:  * Redistribution and use in source and binary forms, with or without
   13:  * modification, are permitted provided that the following conditions
   14:  * are met:
   15:  * 1. Redistributions of source code must retain the above copyright
   16:  *    notice, this list of conditions and the following disclaimer.
   17:  * 2. Redistributions in binary form must reproduce the above copyright
   18:  *    notice, this list of conditions and the following disclaimer in the
   19:  *    documentation and/or other materials provided with the distribution.
   20:  * 3. Neither the name of the University nor the names of its contributors
   21:  *    may be used to endorse or promote products derived from this software
   22:  *    without specific prior written permission.
   23:  *
   24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34:  * SUCH DAMAGE.
   35:  */
   36: 
   37: /*
   38:  * Information local to this implementation of stdio,
   39:  * in particular, macros and private variables.
   40:  */
   41: 
   42: #include <wchar.h> 
   43: #include "wcio.h"
   44: #include "fileext.h"
   45: 
   46: int     __sflush(FILE *);
   47: int     __sflush_locked(FILE *);
   48: FILE    *__sfp(void);
   49: int     __srefill(FILE *);
   50: int     __sread(void *, char *, int);
   51: int     __swrite(void *, const char *, int);
   52: fpos_t  __sseek(void *, fpos_t, int);
   53: int     __sclose(void *);
   54: void    __sinit(void);
   55: void    _cleanup(void);
   56: void    __smakebuf(FILE *);
   57: int     __swhatbuf(FILE *, size_t *, int *);
   58: int     _fwalk(int (*)(FILE *));
   59: int     __swsetup(FILE *);
   60: int     __sflags(const char *, int *);
   61: wint_t __fgetwc_unlock(FILE *);
   62: wint_t  __ungetwc(wint_t, FILE *);
   63: int     __vfprintf(FILE *, const char *, __va_list);
   64: int     __svfscanf(FILE * __restrict, const char * __restrict, __va_list);
   65: int     __vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list);
   66: int     __vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list);
   67: 
   68: int     __sungetc(int c, FILE *fp);
   69: size_t  __sfread(void *buf, size_t size, size_t count, FILE *fp);
   70: 
   71: extern void __atexit_register_cleanup(void (*)(void));
   72: extern int __sdidinit;
   73: 
   74: /*
   75:  * Return true if the given FILE cannot be written now.
   76:  */
   77: #define cantwrite(fp) \
   78:         ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
   79:          __swsetup(fp))
   80: 
   81: /*
   82:  * Test whether the given stdio file has an active ungetc buffer;
   83:  * release such a buffer, without restoring ordinary unread data.
   84:  */
   85: #define HASUB(fp) (_UB(fp)._base != NULL)
   86: #define FREEUB(fp) { \
   87:         if (_UB(fp)._base != (fp)->_ubuf) \
   88:                 free(_UB(fp)._base); \
   89:         _UB(fp)._base = NULL; \
   90: }
   91: 
   92: /*
   93:  * test for an fgetln() buffer.
   94:  */
   95: #define HASLB(fp) ((fp)->_lb._base != NULL)
   96: #define FREELB(fp) { \
   97:         free((char *)(fp)->_lb._base); \
   98:         (fp)->_lb._base = NULL; \
   99: }
  100: 
  101: #define FLOCKFILE(fp)   do { if (__isthreaded) flockfile(fp); } while (0)
  102: #define FUNLOCKFILE(fp) do { if (__isthreaded) funlockfile(fp); } while (0)