diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-07-06 16:53:48 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-07-06 17:52:54 +0200 |
commit | 3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10 (patch) | |
tree | 2eb99509fbdfb5f61ee40bdf634c63f092b85ae2 /include/stdio.h | |
parent | 397c54c1afa531242602fe3ac7bb47eff0e909f9 (diff) | |
download | glibc-3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10.tar.gz glibc-3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10.tar.xz glibc-3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10.zip |
libio: Implement internal function __libc_readline_unlocked
This is a variant of fgets which fails with ERANGE if the buffer is too small, and the buffer length is given as an argument of type size_t. This function will be useful for implementing NSS file reading operations. Compared to a direct implementation using the public API, it avoids an lseek system call in case the line terminator can be found in the internal read buffer.
Diffstat (limited to 'include/stdio.h')
-rw-r--r-- | include/stdio.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h index 3ba0edc924..9162d4e247 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -127,6 +127,19 @@ extern int __fxprintf (FILE *__fp, const char *__fmt, ...) extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden; +/* Read the next line from FP into BUFFER, of LENGTH bytes. LINE will + include the line terminator and a NUL terminator. On success, + return the length of the line, including the line terminator, but + excluding the NUL termintor. On EOF, return zero and write a NUL + terminator. On error, return -1 and set errno. If the total byte + count (line and both terminators) exceeds LENGTH, return -1 and set + errno to ERANGE (but do not mark the stream as failed). + + The behavior is undefined if FP is not seekable, or if the stream + is already in an error state. */ +ssize_t __libc_readline_unlocked (FILE *fp, char *buffer, size_t length); +libc_hidden_proto (__libc_readline_unlocked); + extern const char *const _sys_errlist_internal[] attribute_hidden; extern int _sys_nerr_internal attribute_hidden; @@ -170,6 +183,10 @@ libc_hidden_proto (fwrite) libc_hidden_proto (fseek) extern __typeof (ftello) __ftello; libc_hidden_proto (__ftello) +extern __typeof (fseeko64) __fseeko64; +libc_hidden_proto (__fseeko64) +extern __typeof (ftello64) __ftello64; +libc_hidden_proto (__ftello64) libc_hidden_proto (fflush) libc_hidden_proto (fflush_unlocked) extern __typeof (fflush_unlocked) __fflush_unlocked; |