The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* $OpenBSD: stdio.h,v 1.35 2006/01/13 18:10:09 miod Exp $ */ |
| 2 | /* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1990 The Regents of the University of California. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * This code is derived from software contributed to Berkeley by |
| 9 | * Chris Torek. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. Neither the name of the University nor the names of its contributors |
| 20 | * may be used to endorse or promote products derived from this software |
| 21 | * without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 33 | * SUCH DAMAGE. |
| 34 | * |
| 35 | * @(#)stdio.h 5.17 (Berkeley) 6/3/91 |
| 36 | */ |
| 37 | |
| 38 | #ifndef _STDIO_H_ |
| 39 | #define _STDIO_H_ |
| 40 | |
| 41 | #include <sys/cdefs.h> |
Elliott Hughes | 3975cec | 2012-11-29 17:25:23 -0800 | [diff] [blame] | 42 | #include <sys/types.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 43 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 44 | #include <stdarg.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 45 | #include <stddef.h> |
| 46 | |
Elliott Hughes | fd936ae | 2016-08-12 10:16:34 -0700 | [diff] [blame] | 47 | #include <bits/seek_constants.h> |
| 48 | |
Elliott Hughes | 95c6cd7 | 2019-12-20 13:26:14 -0800 | [diff] [blame] | 49 | #if __ANDROID_API__ < 24 |
Dan Albert | 3037ea4 | 2016-10-06 15:46:45 -0700 | [diff] [blame] | 50 | #include <bits/struct_file.h> |
| 51 | #endif |
| 52 | |
Dan Albert | 658727e | 2014-10-07 11:10:36 -0700 | [diff] [blame] | 53 | __BEGIN_DECLS |
| 54 | |
Elliott Hughes | 9677fab | 2016-01-25 15:50:59 -0800 | [diff] [blame] | 55 | typedef off_t fpos_t; |
| 56 | typedef off64_t fpos64_t; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 57 | |
Elliott Hughes | f0141df | 2015-10-12 12:44:23 -0700 | [diff] [blame] | 58 | struct __sFILE; |
| 59 | typedef struct __sFILE FILE; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 60 | |
Elliott Hughes | 95c6cd7 | 2019-12-20 13:26:14 -0800 | [diff] [blame] | 61 | #if __ANDROID_API__ >= 23 |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 62 | extern FILE* _Nonnull stdin __INTRODUCED_IN(23); |
| 63 | extern FILE* _Nonnull stdout __INTRODUCED_IN(23); |
| 64 | extern FILE* _Nonnull stderr __INTRODUCED_IN(23); |
Dan Albert | 32c79c2 | 2016-07-15 11:32:23 -0700 | [diff] [blame] | 65 | |
Elliott Hughes | 168667c | 2014-11-14 14:42:59 -0800 | [diff] [blame] | 66 | /* C99 and earlier plus current C++ standards say these must be macros. */ |
| 67 | #define stdin stdin |
| 68 | #define stdout stdout |
| 69 | #define stderr stderr |
Dan Albert | 32c79c2 | 2016-07-15 11:32:23 -0700 | [diff] [blame] | 70 | #else |
| 71 | /* Before M the actual symbols for stdin and friends had different names. */ |
Dan Albert | cc86c74 | 2024-05-02 18:53:45 +0000 | [diff] [blame^] | 72 | extern FILE __sF[] __REMOVED_IN(23, "Use stdin/stdout/stderr"); |
Dan Albert | 32c79c2 | 2016-07-15 11:32:23 -0700 | [diff] [blame] | 73 | |
Dan Albert | 3037ea4 | 2016-10-06 15:46:45 -0700 | [diff] [blame] | 74 | #define stdin (&__sF[0]) |
| 75 | #define stdout (&__sF[1]) |
| 76 | #define stderr (&__sF[2]) |
Dan Albert | 32c79c2 | 2016-07-15 11:32:23 -0700 | [diff] [blame] | 77 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 78 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 79 | /* |
| 80 | * The following three definitions are for ANSI C, which took them |
| 81 | * from System V, which brilliantly took internal interface macros and |
| 82 | * made them official arguments to setvbuf(), without renaming them. |
| 83 | * Hence, these ugly _IOxxx names are *supposed* to appear in user code. |
| 84 | * |
| 85 | * Although numbered as their counterparts above, the implementation |
| 86 | * does not rely on this. |
| 87 | */ |
| 88 | #define _IOFBF 0 /* setvbuf should set fully buffered */ |
| 89 | #define _IOLBF 1 /* setvbuf should set line buffered */ |
| 90 | #define _IONBF 2 /* setvbuf should set unbuffered */ |
| 91 | |
| 92 | #define BUFSIZ 1024 /* size of buffer used by setbuf */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 93 | #define EOF (-1) |
| 94 | |
| 95 | /* |
Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 96 | * FOPEN_MAX is a minimum maximum, and is the number of streams that |
| 97 | * stdio can provide without attempting to allocate further resources |
| 98 | * (which could fail). Do not use this for anything. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 99 | */ |
Elliott Hughes | b15feb7 | 2017-07-31 17:20:18 -0700 | [diff] [blame] | 100 | #define FOPEN_MAX 20 |
| 101 | #define FILENAME_MAX 4096 |
Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 102 | |
Elliott Hughes | b15feb7 | 2017-07-31 17:20:18 -0700 | [diff] [blame] | 103 | #define L_tmpnam 4096 |
| 104 | #define TMP_MAX 308915776 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 105 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 106 | void clearerr(FILE* _Nonnull __fp); |
| 107 | int fclose(FILE* _Nonnull __fp); |
| 108 | int feof(FILE* _Nonnull __fp); |
| 109 | int ferror(FILE* _Nonnull __fp); |
| 110 | int fflush(FILE* _Nullable __fp); |
| 111 | int fgetc(FILE* _Nonnull __fp); |
| 112 | char* _Nullable fgets(char* _Nonnull __buf, int __size, FILE* _Nonnull __fp); |
| 113 | int fprintf(FILE* _Nonnull __fp , const char* _Nonnull __fmt, ...) __printflike(2, 3); |
| 114 | int fputc(int __ch, FILE* _Nonnull __fp); |
| 115 | int fputs(const char* _Nonnull __s, FILE* _Nonnull __fp); |
| 116 | size_t fread(void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp); |
| 117 | int fscanf(FILE* _Nonnull __fp, const char* _Nonnull __fmt, ...) __scanflike(2, 3); |
| 118 | size_t fwrite(const void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp); |
| 119 | int getc(FILE* _Nonnull __fp); |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 120 | int getchar(void); |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 121 | ssize_t getdelim(char* _Nullable * _Nonnull __line_ptr, size_t* _Nonnull __line_length_ptr, int __delimiter, FILE* _Nonnull __fp); |
| 122 | ssize_t getline(char* _Nullable * _Nonnull __line_ptr, size_t* _Nonnull __line_length_ptr, FILE* _Nonnull __fp); |
Elliott Hughes | c13fb75 | 2013-12-17 20:43:30 -0800 | [diff] [blame] | 123 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 124 | void perror(const char* _Nullable __msg); |
| 125 | int printf(const char* _Nonnull __fmt, ...) __printflike(1, 2); |
| 126 | int putc(int __ch, FILE* _Nonnull __fp); |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 127 | int putchar(int __ch); |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 128 | int puts(const char* _Nonnull __s); |
| 129 | int remove(const char* _Nonnull __path); |
| 130 | void rewind(FILE* _Nonnull __fp); |
| 131 | int scanf(const char* _Nonnull __fmt, ...) __scanflike(1, 2); |
| 132 | void setbuf(FILE* _Nonnull __fp, char* _Nullable __buf); |
| 133 | int setvbuf(FILE* _Nonnull __fp, char* _Nullable __buf, int __mode, size_t __size); |
| 134 | int sscanf(const char* _Nonnull __s, const char* _Nonnull __fmt, ...) __scanflike(2, 3); |
| 135 | int ungetc(int __ch, FILE* _Nonnull __fp); |
| 136 | int vfprintf(FILE* _Nonnull __fp, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0); |
| 137 | int vprintf(const char* _Nonnull __fp, va_list __args) __printflike(1, 0); |
Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 138 | |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 139 | int dprintf(int __fd, const char* _Nonnull __fmt, ...) __printflike(2, 3); |
| 140 | int vdprintf(int __fd, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0); |
Elliott Hughes | fcac8ff | 2014-05-22 01:24:30 -0700 | [diff] [blame] | 141 | |
Elliott Hughes | f6495c7 | 2016-07-25 09:20:57 -0700 | [diff] [blame] | 142 | #if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L) || \ |
| 143 | (defined(__cplusplus) && __cplusplus <= 201103L) |
Elliott Hughes | a1b5ca2 | 2024-04-22 20:10:53 +0000 | [diff] [blame] | 144 | char* _Nullable gets(char* _Nonnull __buf) __attribute__((__deprecated__("gets is unsafe, use fgets instead"))); |
Dan Albert | 9635046 | 2014-06-17 23:31:21 +0000 | [diff] [blame] | 145 | #endif |
zijunzhao | e1833e5 | 2023-04-26 21:43:30 +0000 | [diff] [blame] | 146 | int sprintf(char* __BIONIC_COMPLICATED_NULLNESS __s, const char* _Nonnull __fmt, ...) |
George Burgess IV | 9024235 | 2018-02-06 12:51:31 -0800 | [diff] [blame] | 147 | __printflike(2, 3) __warnattr_strict("sprintf is often misused; please use snprintf"); |
zijunzhao | e1833e5 | 2023-04-26 21:43:30 +0000 | [diff] [blame] | 148 | int vsprintf(char* __BIONIC_COMPLICATED_NULLNESS __s, const char* _Nonnull __fmt, va_list __args) |
George Burgess IV | 9024235 | 2018-02-06 12:51:31 -0800 | [diff] [blame] | 149 | __printflike(2, 0) __warnattr_strict("vsprintf is often misused; please use vsnprintf"); |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 150 | char* _Nullable tmpnam(char* _Nullable __s) |
Elliott Hughes | 439ebbd | 2020-12-04 18:51:42 -0800 | [diff] [blame] | 151 | __warnattr("tmpnam is unsafe, use mkstemp or tmpfile instead"); |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 152 | #define P_tmpdir "/tmp/" /* deprecated */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 153 | char* _Nullable tempnam(const char* _Nullable __dir, const char* _Nullable __prefix) |
George Burgess IV | 7cc779f | 2017-02-09 00:00:31 -0800 | [diff] [blame] | 154 | __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead"); |
Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 155 | |
Elliott Hughes | 05b675e | 2019-04-17 13:01:06 -0700 | [diff] [blame] | 156 | /** |
| 157 | * [rename(2)](http://man7.org/linux/man-pages/man2/rename.2.html) changes |
| 158 | * the name or location of a file. |
| 159 | * |
| 160 | * Returns 0 on success, and returns -1 and sets `errno` on failure. |
| 161 | */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 162 | int rename(const char* _Nonnull __old_path, const char* _Nonnull __new_path); |
Elliott Hughes | 05b675e | 2019-04-17 13:01:06 -0700 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * [renameat(2)](http://man7.org/linux/man-pages/man2/renameat.2.html) changes |
| 166 | * the name or location of a file, interpreting relative paths using an fd. |
| 167 | * |
| 168 | * Returns 0 on success, and returns -1 and sets `errno` on failure. |
| 169 | */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 170 | int renameat(int __old_dir_fd, const char* _Nonnull __old_path, int __new_dir_fd, const char* _Nonnull __new_path); |
Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 171 | |
Elliott Hughes | 05b675e | 2019-04-17 13:01:06 -0700 | [diff] [blame] | 172 | #if defined(__USE_GNU) |
| 173 | |
| 174 | /** |
| 175 | * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html) |
| 176 | * to fail if the new path already exists. |
| 177 | */ |
| 178 | #define RENAME_NOREPLACE (1<<0) |
| 179 | |
| 180 | /** |
| 181 | * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html) |
| 182 | * to atomically exchange the two paths. |
| 183 | */ |
| 184 | #define RENAME_EXCHANGE (1<<1) |
| 185 | |
| 186 | /** |
| 187 | * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html) |
| 188 | * to create a union/overlay filesystem object. |
| 189 | */ |
| 190 | #define RENAME_WHITEOUT (1<<2) |
| 191 | |
| 192 | /** |
| 193 | * [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html) changes |
| 194 | * the name or location of a file, interpreting relative paths using an fd, |
| 195 | * with optional `RENAME_` flags. |
| 196 | * |
| 197 | * Returns 0 on success, and returns -1 and sets `errno` on failure. |
| 198 | */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 199 | int renameat2(int __old_dir_fd, const char* _Nonnull __old_path, int __new_dir_fd, const char* _Nonnull __new_path, unsigned __flags) __INTRODUCED_IN(30); |
Elliott Hughes | 05b675e | 2019-04-17 13:01:06 -0700 | [diff] [blame] | 200 | |
| 201 | #endif |
| 202 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 203 | int fseek(FILE* _Nonnull __fp, long __offset, int __whence); |
| 204 | long ftell(FILE* _Nonnull __fp); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 205 | |
Elliott Hughes | 9c06d16 | 2023-10-04 23:36:14 +0000 | [diff] [blame] | 206 | /* See https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md */ |
Elliott Hughes | 00fedf5 | 2017-07-05 15:23:50 -0700 | [diff] [blame] | 207 | #if defined(__USE_FILE_OFFSET64) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 208 | int fgetpos(FILE* _Nonnull __fp, fpos_t* _Nonnull __pos) __RENAME(fgetpos64) __INTRODUCED_IN(24); |
| 209 | int fsetpos(FILE* _Nonnull __fp, const fpos_t* _Nonnull __pos) __RENAME(fsetpos64) __INTRODUCED_IN(24); |
| 210 | int fseeko(FILE* _Nonnull __fp, off_t __offset, int __whence) __RENAME(fseeko64) __INTRODUCED_IN(24); |
| 211 | off_t ftello(FILE* _Nonnull __fp) __RENAME(ftello64) __INTRODUCED_IN(24); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 212 | # if defined(__USE_BSD) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 213 | /* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */ |
| 214 | FILE* _Nullable funopen(const void* _Nullable __cookie, |
| 215 | int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int), |
| 216 | int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int), |
| 217 | fpos_t (* _Nullable __seek_fn)(void* _Nonnull, fpos_t, int), |
| 218 | int (* _Nullable __close_fn)(void* _Nonnull)) __RENAME(funopen64) __INTRODUCED_IN(24); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 219 | # endif |
Elliott Hughes | 68dc20d | 2015-02-06 22:28:49 -0800 | [diff] [blame] | 220 | #else |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 221 | int fgetpos(FILE* _Nonnull __fp, fpos_t* _Nonnull __pos); |
| 222 | int fsetpos(FILE* _Nonnull __fp, const fpos_t* _Nonnull __pos); |
| 223 | int fseeko(FILE* _Nonnull __fp, off_t __offset, int __whence); |
| 224 | off_t ftello(FILE* _Nonnull __fp); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 225 | # if defined(__USE_BSD) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 226 | /* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */ |
| 227 | FILE* _Nullable funopen(const void* _Nullable __cookie, |
| 228 | int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int), |
| 229 | int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int), |
| 230 | fpos_t (* _Nullable __seek_fn)(void* _Nonnull, fpos_t, int), |
| 231 | int (* _Nullable __close_fn)(void* _Nonnull)); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 232 | # endif |
Elliott Hughes | 68dc20d | 2015-02-06 22:28:49 -0800 | [diff] [blame] | 233 | #endif |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 234 | int fgetpos64(FILE* _Nonnull __fp, fpos64_t* _Nonnull __pos) __INTRODUCED_IN(24); |
| 235 | int fsetpos64(FILE* _Nonnull __fp, const fpos64_t* _Nonnull __pos) __INTRODUCED_IN(24); |
| 236 | int fseeko64(FILE* _Nonnull __fp, off64_t __offset, int __whence) __INTRODUCED_IN(24); |
| 237 | off64_t ftello64(FILE* _Nonnull __fp) __INTRODUCED_IN(24); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 238 | #if defined(__USE_BSD) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 239 | /* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */ |
| 240 | FILE* _Nullable funopen64(const void* _Nullable __cookie, |
| 241 | int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int), |
| 242 | int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int), |
| 243 | fpos64_t (* _Nullable __seek_fn)(void* _Nonnull, fpos64_t, int), |
| 244 | int (* _Nullable __close_fn)(void* _Nonnull)) __INTRODUCED_IN(24); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 245 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 246 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 247 | FILE* _Nullable fopen(const char* _Nonnull __path, const char* _Nonnull __mode); |
| 248 | FILE* _Nullable fopen64(const char* _Nonnull __path, const char* _Nonnull __mode) __INTRODUCED_IN(24); |
| 249 | FILE* _Nullable freopen(const char* _Nullable __path, const char* _Nonnull __mode, FILE* _Nonnull __fp); |
| 250 | FILE* _Nullable freopen64(const char* _Nullable __path, const char* _Nonnull __mode, FILE* _Nonnull __fp) __INTRODUCED_IN(24); |
| 251 | FILE* _Nullable tmpfile(void); |
| 252 | FILE* _Nullable tmpfile64(void) __INTRODUCED_IN(24); |
Elliott Hughes | f226ee5 | 2016-02-03 11:24:28 -0800 | [diff] [blame] | 253 | |
zijunzhao | e1833e5 | 2023-04-26 21:43:30 +0000 | [diff] [blame] | 254 | int snprintf(char* __BIONIC_COMPLICATED_NULLNESS __buf, size_t __size, const char* _Nonnull __fmt, ...) __printflike(3, 4); |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 255 | int vfscanf(FILE* _Nonnull __fp, const char* _Nonnull __fmt, va_list __args) __scanflike(2, 0); |
| 256 | int vscanf(const char* _Nonnull __fmt , va_list __args) __scanflike(1, 0); |
zijunzhao | e1833e5 | 2023-04-26 21:43:30 +0000 | [diff] [blame] | 257 | int vsnprintf(char* __BIONIC_COMPLICATED_NULLNESS __buf, size_t __size, const char* _Nonnull __fmt, va_list __args) __printflike(3, 0); |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 258 | int vsscanf(const char* _Nonnull __s, const char* _Nonnull __fmt, va_list __args) __scanflike(2, 0); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 259 | |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 260 | #define L_ctermid 1024 /* size for ctermid() */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 261 | char* _Nonnull ctermid(char* _Nullable __buf) __INTRODUCED_IN(26); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 262 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 263 | FILE* _Nullable fdopen(int __fd, const char* _Nonnull __mode); |
| 264 | int fileno(FILE* _Nonnull __fp); |
| 265 | int pclose(FILE* _Nonnull __fp); |
| 266 | FILE* _Nullable popen(const char* _Nonnull __command, const char* _Nonnull __mode); |
| 267 | void flockfile(FILE* _Nonnull __fp); |
| 268 | int ftrylockfile(FILE* _Nonnull __fp); |
| 269 | void funlockfile(FILE* _Nonnull __fp); |
| 270 | int getc_unlocked(FILE* _Nonnull __fp); |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 271 | int getchar_unlocked(void); |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 272 | int putc_unlocked(int __ch, FILE* _Nonnull __fp); |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 273 | int putchar_unlocked(int __ch); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 274 | |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 275 | FILE* _Nullable fmemopen(void* _Nullable __buf, size_t __size, const char* _Nonnull __mode) __INTRODUCED_IN(23); |
| 276 | FILE* _Nullable open_memstream(char* _Nonnull * _Nonnull __ptr, size_t* _Nonnull __size_ptr) __INTRODUCED_IN(23); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 277 | |
Elliott Hughes | 9c8d711 | 2016-06-13 13:23:42 -0700 | [diff] [blame] | 278 | #if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */ |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 279 | int asprintf(char* _Nullable * _Nonnull __s_ptr, const char* _Nonnull __fmt, ...) __printflike(2, 3); |
| 280 | char* _Nullable fgetln(FILE* _Nonnull __fp, size_t* _Nonnull __length_ptr); |
| 281 | int fpurge(FILE* _Nonnull __fp); |
| 282 | void setbuffer(FILE* _Nonnull __fp, char* _Nullable __buf, int __size); |
| 283 | int setlinebuf(FILE* _Nonnull __fp); |
| 284 | int vasprintf(char* _Nullable * _Nonnull __s_ptr, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0); |
| 285 | void clearerr_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23); |
| 286 | int feof_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23); |
| 287 | int ferror_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23); |
| 288 | int fileno_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(24); |
Elliott Hughes | 03e65eb | 2016-01-26 14:13:04 -0800 | [diff] [blame] | 289 | #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) |
| 290 | #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) |
Elliott Hughes | 37ad959 | 2017-10-30 17:47:12 -0700 | [diff] [blame] | 291 | #endif |
| 292 | |
| 293 | #if defined(__USE_BSD) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 294 | int fflush_unlocked(FILE* _Nullable __fp) __INTRODUCED_IN(28); |
| 295 | int fgetc_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
| 296 | int fputc_unlocked(int __ch, FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
| 297 | size_t fread_unlocked(void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
| 298 | size_t fwrite_unlocked(const void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
Elliott Hughes | 37ad959 | 2017-10-30 17:47:12 -0700 | [diff] [blame] | 299 | #endif |
| 300 | |
| 301 | #if defined(__USE_GNU) |
zijunzhao | 00a3dba | 2023-03-01 00:07:40 +0000 | [diff] [blame] | 302 | int fputs_unlocked(const char* _Nonnull __s, FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
| 303 | char* _Nullable fgets_unlocked(char* _Nonnull __buf, int __size, FILE* _Nonnull __fp) __INTRODUCED_IN(28); |
Elliott Hughes | 37ad959 | 2017-10-30 17:47:12 -0700 | [diff] [blame] | 304 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 305 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 306 | #if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS) |
| 307 | #include <bits/fortify/stdio.h> |
| 308 | #endif |
Nick Kralevich | cffdf66 | 2012-06-11 15:50:57 -0700 | [diff] [blame] | 309 | |
Dan Albert | 658727e | 2014-10-07 11:10:36 -0700 | [diff] [blame] | 310 | __END_DECLS |
| 311 | |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 312 | #endif |