diff options
Diffstat (limited to 'src/funopen.c')
-rw-r--r-- | src/funopen.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/funopen.c b/src/funopen.c index e768b05..47f3370 100644 --- a/src/funopen.c +++ b/src/funopen.c @@ -24,18 +24,37 @@ #include <stdio.h> + +/* Replacement for the *BSD function: + + FILE *funopen (void *cookie, + int (*readfn)(void *, char *, int), + int (*writefn)(void *, const char *, int), + fpos_t (*seekfn)(void *, fpos_t, int), + int (*closefn)(void *)); + + The functions to provide my either be NULL if not required or + similar to the unistd function with the exception of using the + cookie instead of the fiel descripor. +*/ + + #ifdef HAVE_FOPENCOOKIE FILE * -funopen(const void *cookie, cookie_read_function_t *readfn, - cookie_write_function_t *writefn, - cookie_seek_function_t *seekfn, - cookie_close_function_t *closefn) +_assuan_funopen(void *cookie, + cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn) { - cookie_io_functions_t io = { read: readfn, write: writefn, - seek: seekfn, - close: closefn }; + cookie_io_functions_t io = { NULL }; + + io.read = readfn; + io.write = writefn; + io.seek = seekfn; + io.close = closefn; - return fopencookie ((void *) cookie, + return fopencookie (cookie, readfn ? ( writefn ? "rw" : "r" ) : ( writefn ? "w" : ""), io); } |