Home | History | Annotate | Download | only in current
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
     22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #pragma once
     30 
     31 /**
     32  * @file stdio_ext.h
     33  * @brief Extra standard I/O functionality. See also `<stdio.h>`.
     34  */
     35 
     36 #include <sys/cdefs.h>
     37 #include <stdio.h>
     38 
     39 __BEGIN_DECLS
     40 
     41 /**
     42  * [__fbufsize(3)](http://man7.org/linux/man-pages/man3/__fbufsize.3.html) returns the size of
     43  * the stream's buffer.
     44  *
     45  * Available since API level 23.
     46  */
     47 size_t __fbufsize(FILE* __fp) __INTRODUCED_IN(23);
     48 
     49 /**
     50  * [__freadable(3)](http://man7.org/linux/man-pages/man3/__freadable.3.html) returns non-zero if
     51  * the stream allows reading, 0 otherwise.
     52  *
     53  * Available since API level 23.
     54  */
     55 int __freadable(FILE* __fp) __INTRODUCED_IN(23);
     56 
     57 /**
     58  * [__freading(3)](http://man7.org/linux/man-pages/man3/__freading.3.html) returns non-zero if
     59  * the stream's last operation was a read, 0 otherwise.
     60  *
     61  * Available since API level 28.
     62  */
     63 int __freading(FILE* __fp) __INTRODUCED_IN(28);
     64 
     65 /**
     66  * [__fwritable(3)](http://man7.org/linux/man-pages/man3/__fwritable.3.html) returns non-zero if
     67  * the stream allows writing, 0 otherwise.
     68  *
     69  * Available since API level 23.
     70  */
     71 int __fwritable(FILE* __fp) __INTRODUCED_IN(23);
     72 
     73 /**
     74  * [__fwriting(3)](http://man7.org/linux/man-pages/man3/__fwriting.3.html) returns non-zero if
     75  * the stream's last operation was a write, 0 otherwise.
     76  *
     77  * Available since API level 28.
     78  */
     79 int __fwriting(FILE* __fp) __INTRODUCED_IN(28);
     80 
     81 /**
     82  * [__flbf(3)](http://man7.org/linux/man-pages/man3/__flbf.3.html) returns non-zero if
     83  * the stream is line-buffered, 0 otherwise.
     84  *
     85  * Available since API level 23.
     86  */
     87 int __flbf(FILE* __fp) __INTRODUCED_IN(23);
     88 
     89 /**
     90  * [__fpurge(3)](http://man7.org/linux/man-pages/man3/__fpurge.3.html) discards the contents of
     91  * the stream's buffer.
     92  *
     93  * Available since API level 23.
     94  */
     95 void __fpurge(FILE* __fp) __INTRODUCED_IN(23);
     96 
     97 /**
     98  * [__fpending(3)](http://man7.org/linux/man-pages/man3/__fpending.3.html) returns the number of
     99  * bytes in the output buffer.
    100  *
    101  * Available since API level 23.
    102  */
    103 size_t __fpending(FILE* __fp) __INTRODUCED_IN(23);
    104 
    105 /**
    106  * [_flushlbf(3)](http://man7.org/linux/man-pages/man3/_flushlbf.3.html) flushes all
    107  * line-buffered streams.
    108  *
    109  * Available since API level 23.
    110  */
    111 void _flushlbf(void) __INTRODUCED_IN(23);
    112 
    113 /**
    114  * `__fseterr` sets the
    115  * stream's error flag (as tested by ferror() and cleared by fclearerr()).
    116  *
    117  * Available since API level 28.
    118  */
    119 void __fseterr(FILE* __fp) __INTRODUCED_IN(28);
    120 
    121 /** __fsetlocking() constant to query locking type. */
    122 #define FSETLOCKING_QUERY 0
    123 /** __fsetlocking() constant to set locking to be maintained by stdio. */
    124 #define FSETLOCKING_INTERNAL 1
    125 /** __fsetlocking() constant to set locking to be maintained by the caller. */
    126 #define FSETLOCKING_BYCALLER 2
    127 
    128 /**
    129  * [__fsetlocking(3)](http://man7.org/linux/man-pages/man3/__fsetlocking.3.html) sets the
    130  * stream's locking mode to one of the `FSETLOCKING_` types.
    131  *
    132  * Returns the current locking style, `FSETLOCKING_INTERNAL` or `FSETLOCKING_BYCALLER`.
    133  *
    134  * Available since API level 23.
    135  */
    136 int __fsetlocking(FILE* __fp, int __type) __INTRODUCED_IN(23);
    137 
    138 __END_DECLS
    139