diff options
author | Werner Koch <[email protected]> | 2003-12-11 13:10:45 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2003-12-11 13:10:45 +0000 |
commit | 16d5599ef42126a9f908fa31221a1bb8d4dbb2da (patch) | |
tree | a4653667cbc45f88f6480d1637c608ac52e9f65f | |
parent | * Makefile.am: Add README.CVS and autogen.sh. Removed m4/Makefile. (diff) | |
download | libassuan-16d5599ef42126a9f908fa31221a1bb8d4dbb2da.tar.gz libassuan-16d5599ef42126a9f908fa31221a1bb8d4dbb2da.zip |
* funopen.c (_assuan_funopen): Renamed from funopen, to keep the
name space clean and avoid duplicate definitions if another
library uses the same replacement.
* assuan-defs.h (funopen): Renamed prototype and add a macro.
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/assuan-defs.h | 10 | ||||
-rw-r--r-- | src/funopen.c | 35 |
3 files changed, 40 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5c456b8..542e6be 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-12-11 Werner Koch <[email protected]> + + * funopen.c (_assuan_funopen): Renamed from funopen, to keep the + name space clean and avoid duplicate definitions if another + library uses the same replacement. + * assuan-defs.h (funopen): Renamed prototype and add a macro. + 2003-12-08 Werner Koch <[email protected]> * TODO: Removed. diff --git a/src/assuan-defs.h b/src/assuan-defs.h index 1f7f1f0..e25fc6a 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -184,10 +184,12 @@ ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, #ifdef HAVE_FOPENCOOKIE /* We have to implement funopen in terms of glibc's 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); +FILE *_assuan_funopen(void *cookie, + cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn); +#define funopen(a,r,w,s,c) _assuan_funopen ((a), (r), (w), (s), (c)) #endif /*HAVE_FOPENCOOKIE*/ #endif /*ASSUAN_DEFS_H*/ 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); } |