qlibs:
Section: Misc. Reference Manual Pages (readclose)
Updated: 3
Index
Return to Main Contents
NAME
readclose - open a file, copy it's content into a buffer, and close the file
SYNTAX
#include "readclose.h"
int readclose(int fd,stralloc *sa,unsigned int bufsize);
int readclose_append(int fd,stralloc *sa,unsigned int bufsize);
int openreadclose(const char *fd,stralloc *sa,unsigned int bufsize);
DESCRIPTION
readclose_append
opens a file with file descriptor
fd
and appends the result into a pre-allocated buffer stralloc
*sa
while reading
bufsize
bytes of data-chunks consecutive until reaching EOF.
The file descriptor is closed then and the number of bytes
read/stored is returned.
readclose
opens a file with file descriptor
fd
and stores the result into a pre-allocated buffer stralloc
*sa
while reading
bufsize
bytes of data-chunks until EOF and closing the file.
On return, the number of bytes read/stored is given.
openreadclose
performs the same action like
readclose
but now instead of the file desriptor
fd
the file name
fn
is given.
NOTE
The
readclose
routines substitude the former
slurp
called functions. In addition, the macros
slurp
and
slurpclose
are provided, allowing to keep the code
unaltered while simply including the header
readclose.h.
SEE ALSO
stralloc(3)
Index
- NAME
-
- SYNTAX
-
- DESCRIPTION
-
- NOTE
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 11:50:49 GMT, June 03, 2025