24 RCSID(
"$Id: 348c07f011aa98ac101bfca7ec5a73628297a13d $")
26 #ifndef HAVE_FOPENCOOKIE
27 #include <freeradius-devel/util/talloc.h>
31 #define NEED_READ 0x01
32 #define NEED_WRITE 0x02
33 #define NEED_SEEK 0x04
47 static int _read(
void *c,
char *buf,
int n)
57 static int _write(
void *c,
const char *buf,
int n)
67 static fpos_t
_seek(
void *c, fpos_t offset,
int whence)
81 if (ret != 0)
return -1;
109 for (p = mode; *p !=
'\0'; p++) {
114 if (p[1] ==
'b') p++;
125 if (p[1] ==
'b') p++;
136 if (p[1] ==
'b') p++;
184 if (fseek(f, 0
L, SEEK_END) < 0) {
#define L(_str)
Helper for initialising arrays of string literals.
static int _write(void *c, const char *buf, int n)
Wrap fopencookie write function.
static int _close(void *c)
Wrap fopencookie close function and free our fr_funopen_cookie_t.
static fpos_t _seek(void *c, fpos_t offset, int whence)
Wrap fopencookie seek function.
void * cookie
Original cookie passed to fopencookie.
static int _read(void *c, char *buf, int n)
Wrap fopencookie read function.
cookie_io_functions_t io_funcs
Fopencookie callbacks (which we wrap)
FILE * fopencookie(void *cookie, const char *mode, cookie_io_functions_t io_funcs)
Holds the fopencookie function pointers plus the funopen cookie.
Provide missing types for fopencookie on systems that don't support it.
cookie_close_function_t close
cookie_seek_function_t seek
cookie_read_function_t read
cookie_write_function_t write