diff options
author | Werner Koch <wk@gnupg.org> | 2014-08-22 15:12:57 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-08-25 16:37:46 +0200 |
commit | 6714d41af5b3f4d447eb0caea0ede38b753397f8 (patch) | |
tree | 33c3ca37cfb09e864289dc55d50c0c466e08579c | |
parent | 8d57ce619aa49862caeee30181fbbd9c76846554 (diff) | |
download | libgpg-error-6714d41af5b3f4d447eb0caea0ede38b753397f8.tar.gz |
First set of changes to include estream into the API.
* configure.ac (AH_BOTTOM): Define GPGRT_ENABLE_ES_MACROS.
* src/gpg-error.h.in: include stdio.h. Include most of the estream
functions and rename structures and types.
* src/estream.h: Rewrite. Include only gpg-error.h and local
prototypes.
* src/estream.c: Rename types and macros.
* src/estream-printf.c (_gpgrt_estream_snprintf): Prefix public
functions with _gpgrt_.
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/estream-printf.c | 42 | ||||
-rw-r--r-- | src/estream-printf.h | 18 | ||||
-rw-r--r-- | src/estream.c | 255 | ||||
-rw-r--r-- | src/estream.h | 431 | ||||
-rw-r--r-- | src/gpg-error.h.in | 373 |
6 files changed, 525 insertions, 597 deletions
diff --git a/configure.ac b/configure.ac index 30aa2cf..7390bc1 100644 --- a/configure.ac +++ b/configure.ac @@ -139,8 +139,7 @@ AH_BOTTOM([ /* For building we need to define these macro. */ #define GPG_ERR_ENABLE_GETTEXT_MACROS 1 #define GPG_ERR_ENABLE_ERRNO_MACROS 1 -/* The prefix for the internal estream functions. */ -#define _ESTREAM_EXT_SYM_PREFIX _gpgrt_ +#define GPGRT_ENABLE_ES_MACROS 1 ]) diff --git a/src/estream-printf.c b/src/estream-printf.c index 83336c8..d2d13fc 100644 --- a/src/estream-printf.c +++ b/src/estream-printf.c @@ -1,5 +1,5 @@ /* estream-printf.c - Versatile mostly C-99 compliant printf formatting - * Copyright (C) 2007, 2008, 2009, 2010, 2012 g10 Code GmbH + * Copyright (C) 2007, 2008, 2009, 2010, 2012, 2014 g10 Code GmbH * * This file is part of Libestream. * @@ -1476,9 +1476,9 @@ do_format (estream_printf_out_t outfnc, void *outfncarg, and VAARGS a variable argumemt list matching the arguments of FORMAT. */ int -estream_format (estream_printf_out_t outfnc, - void *outfncarg, - const char *format, va_list vaargs) +_gpgrt_estream_format (estream_printf_out_t outfnc, + void *outfncarg, + const char *format, va_list vaargs) { /* Buffer to hold the argspecs and a pointer to it.*/ struct argspec_s argspecs_buffer[DEFAULT_MAX_ARGSPECS]; @@ -1636,13 +1636,13 @@ plain_stdio_out (void *outfncarg, const char *buf, size_t buflen) /* A replacement for printf. */ int -estream_printf (const char *format, ...) +_gpgrt_estream_printf (const char *format, ...) { int rc; va_list arg_ptr; va_start (arg_ptr, format); - rc = estream_format (plain_stdio_out, stderr, format, arg_ptr); + rc = _gpgrt_estream_format (plain_stdio_out, stderr, format, arg_ptr); va_end (arg_ptr); return rc; @@ -1650,13 +1650,13 @@ estream_printf (const char *format, ...) /* A replacement for fprintf. */ int -estream_fprintf (FILE *fp, const char *format, ...) +_gpgrt_estream_fprintf (FILE *fp, const char *format, ...) { int rc; va_list arg_ptr; va_start (arg_ptr, format); - rc = estream_format (plain_stdio_out, fp, format, arg_ptr); + rc = _gpgrt_estream_format (plain_stdio_out, fp, format, arg_ptr); va_end (arg_ptr); return rc; @@ -1664,9 +1664,9 @@ estream_fprintf (FILE *fp, const char *format, ...) /* A replacement for vfprintf. */ int -estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) +_gpgrt_estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) { - return estream_format (plain_stdio_out, fp, format, arg_ptr); + return _gpgrt_estream_format (plain_stdio_out, fp, format, arg_ptr); } @@ -1711,7 +1711,7 @@ fixed_buffer_out (void *outfncarg, const char *buf, size_t buflen) /* A replacement for vsnprintf. */ int -estream_vsnprintf (char *buf, size_t bufsize, +_gpgrt_estream_vsnprintf (char *buf, size_t bufsize, const char *format, va_list arg_ptr) { struct fixed_buffer_parm_s parm; @@ -1721,7 +1721,7 @@ estream_vsnprintf (char *buf, size_t bufsize, parm.count = 0; parm.used = 0; parm.buffer = bufsize?buf:NULL; - rc = estream_format (fixed_buffer_out, &parm, format, arg_ptr); + rc = _gpgrt_estream_format (fixed_buffer_out, &parm, format, arg_ptr); if (!rc) rc = fixed_buffer_out (&parm, "", 1); /* Print terminating Nul. */ if (rc == -1) @@ -1736,13 +1736,13 @@ estream_vsnprintf (char *buf, size_t bufsize, /* A replacement for snprintf. */ int -estream_snprintf (char *buf, size_t bufsize, const char *format, ...) +_gpgrt_estream_snprintf (char *buf, size_t bufsize, const char *format, ...) { int rc; va_list arg_ptr; va_start (arg_ptr, format); - rc = estream_vsnprintf (buf, bufsize, format, arg_ptr); + rc = _gpgrt_estream_vsnprintf (buf, bufsize, format, arg_ptr); va_end (arg_ptr); return rc; @@ -1797,11 +1797,11 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen) } -/* A replacement for vasprintf. As with the BSD of vasprintf version -1 - will be returned on error and NULL stored at BUFP. On success the - number of bytes printed will be returned. */ +/* A replacement for vasprintf. As with the BSD version of vasprintf + -1 will be returned on error and NULL stored at BUFP. On success + the number of bytes printed will be returned. */ int -estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) +_gpgrt_estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) { struct dynamic_buffer_parm_s parm; int rc; @@ -1816,7 +1816,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) return -1; } - rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr); + rc = _gpgrt_estream_format (dynamic_buffer_out, &parm, format, arg_ptr); if (!rc) rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul. */ /* Fixme: Should we shrink the resulting buffer? */ @@ -1842,13 +1842,13 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) will be returned on error and NULL stored at BUFP. On success the number of bytes printed will be returned. */ int -estream_asprintf (char **bufp, const char *format, ...) +_gpgrt_estream_asprintf (char **bufp, const char *format, ...) { int rc; va_list arg_ptr; va_start (arg_ptr, format); - rc = estream_vasprintf (bufp, format, arg_ptr); + rc = _gpgrt_estream_vasprintf (bufp, format, arg_ptr); va_end (arg_ptr); return rc; diff --git a/src/estream-printf.h b/src/estream-printf.h index ca8ad8a..aabda9d 100644 --- a/src/estream-printf.h +++ b/src/estream-printf.h @@ -123,23 +123,23 @@ extern "C" typedef int (*estream_printf_out_t) (void *outfncarg, const char *buf, size_t buflen); -int estream_format (estream_printf_out_t outfnc, void *outfncarg, - const char *format, va_list vaargs) +int _gpgrt_estream_format (estream_printf_out_t outfnc, void *outfncarg, + const char *format, va_list vaargs) _ESTREAM_GCC_A_PRINTF(3,0); -int estream_printf (const char *format, ...) +int _gpgrt_estream_printf (const char *format, ...) _ESTREAM_GCC_A_PRINTF(1,2); -int estream_fprintf (FILE *fp, const char *format, ... ) +int _gpgrt_estream_fprintf (FILE *fp, const char *format, ... ) _ESTREAM_GCC_A_PRINTF(2,3); -int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) +int _gpgrt_estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) _ESTREAM_GCC_A_PRINTF(2,0); -int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) +int _gpgrt_estream_snprintf (char *buf, size_t bufsize, const char *format, ...) _ESTREAM_GCC_A_PRINTF(3,4); -int estream_vsnprintf (char *buf,size_t bufsize, +int _gpgrt_estream_vsnprintf (char *buf,size_t bufsize, const char *format, va_list arg_ptr) _ESTREAM_GCC_A_PRINTF(3,0); -int estream_asprintf (char **bufp, const char *format, ...) +int _gpgrt_estream_asprintf (char **bufp, const char *format, ...) _ESTREAM_GCC_A_PRINTF(2,3); -int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) +int _gpgrt_estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) _ESTREAM_GCC_A_PRINTF(2,0); diff --git a/src/estream.c b/src/estream.c index e7a81e8..2e31b51 100644 --- a/src/estream.c +++ b/src/estream.c @@ -85,9 +85,7 @@ # endif # include <windows.h> #endif -#ifdef HAVE_W32CE_SYSTEM -# include <gpg-error.h> /* ERRNO replacement. */ -#endif + #ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ # undef HAVE_NPTH @@ -105,7 +103,6 @@ #include "estream.h" #include "estream-printf.h" - #ifndef O_BINARY @@ -184,7 +181,7 @@ typedef int (*cookie_ioctl_function_t) (void *cookie, int cmd, /* The internal stream object. */ -struct estream_internal +struct _gpgrt_stream_internal { unsigned char buffer[BUFFER_BLOCK_SIZE]; unsigned char unread_buffer[BUFFER_UNREAD_SIZE]; @@ -198,11 +195,11 @@ struct estream_internal unsigned int modeflags; /* Flags for the backend. */ char *printable_fname; /* Malloced filename for es_fname_get. */ off_t offset; - es_cookie_read_function_t func_read; - es_cookie_write_function_t func_write; - es_cookie_seek_function_t func_seek; + gpgrt_cookie_read_function_t func_read; + gpgrt_cookie_write_function_t func_write; + gpgrt_cookie_seek_function_t func_seek; + gpgrt_cookie_close_function_t func_close; cookie_ioctl_function_t func_ioctl; - es_cookie_close_function_t func_close; int strategy; es_syshd_t syshd; /* A copy of the sytem handle. */ struct @@ -218,7 +215,7 @@ struct estream_internal size_t print_ntotal; /* Bytes written from in print_writer. */ notify_list_t onclose; /* On close notify function list. */ }; -typedef struct estream_internal *estream_internal_t; +typedef struct _gpgrt_stream_internal *estream_internal_t; /* A linked list to hold active stream objects. */ struct estream_list_s @@ -362,7 +359,7 @@ memrchr (const void *buffer, int c, size_t n) #endif static int -init_stream_lock (estream_t ES__RESTRICT stream) +init_stream_lock (estream_t _GPGRT__RESTRICT stream) { #ifdef USE_NPTH int rc; @@ -384,7 +381,7 @@ init_stream_lock (estream_t ES__RESTRICT stream) static void -lock_stream (estream_t ES__RESTRICT stream) +lock_stream (estream_t _GPGRT__RESTRICT stream) { #ifdef USE_NPTH if (!stream->intern->samethread) @@ -400,7 +397,7 @@ lock_stream (estream_t ES__RESTRICT stream) static int -trylock_stream (estream_t ES__RESTRICT stream) +trylock_stream (estream_t _GPGRT__RESTRICT stream) { #ifdef USE_NPTH int rc; @@ -422,7 +419,7 @@ trylock_stream (estream_t ES__RESTRICT stream) static void -unlock_stream (estream_t ES__RESTRICT stream) +unlock_stream (estream_t _GPGRT__RESTRICT stream) { #ifdef USE_NPTH if (!stream->intern->samethread) @@ -604,8 +601,8 @@ do_deinit (void) * Initialization. */ -static int -do_init (void) +int +_gpgrt_es_init (void) { static int initialized; @@ -653,8 +650,8 @@ typedef struct estream_cookie_mem by this function. If GROW is false FUNC_REALLOC is not required. */ static int -func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie, - unsigned char *ES__RESTRICT data, size_t data_n, +func_mem_create (void *_GPGRT__RESTRICT *_GPGRT__RESTRICT cookie, + unsigned char *_GPGRT__RESTRICT data, size_t data_n, size_t data_len, size_t block_size, unsigned int grow, func_realloc_t func_realloc, func_free_t func_free, @@ -924,7 +921,7 @@ es_func_mem_destroy (void *cookie) } -static es_cookie_io_functions_t estream_functions_mem = +static gpgrt_cookie_io_functions_t estream_functions_mem = { es_func_mem_read, es_func_mem_write, @@ -1066,7 +1063,7 @@ es_func_fd_destroy (void *cookie) } -static es_cookie_io_functions_t estream_functions_fd = +static gpgrt_cookie_io_functions_t estream_functions_fd = { es_func_fd_read, es_func_fd_write, @@ -1277,7 +1274,7 @@ es_func_w32_destroy (void *cookie) } -static es_cookie_io_functions_t estream_functions_w32 = +static gpgrt_cookie_io_functions_t estream_functions_w32 = { es_func_w32_read, es_func_w32_write, @@ -1439,7 +1436,7 @@ es_func_fp_destroy (void *cookie) } -static es_cookie_io_functions_t estream_functions_fp = +static gpgrt_cookie_io_functions_t estream_functions_fp = { es_func_fp_read, es_func_fp_write, @@ -1647,7 +1644,7 @@ es_fill (estream_t stream) } else { - es_cookie_read_function_t func_read = stream->intern->func_read; + gpgrt_cookie_read_function_t func_read = stream->intern->func_read; ssize_t ret; ret = (*func_read) (stream->intern->cookie, @@ -1679,7 +1676,7 @@ es_fill (estream_t stream) static int es_flush (estream_t stream) { - es_cookie_write_function_t func_write = stream->intern->func_write; + gpgrt_cookie_write_function_t func_write = stream->intern->func_write; int err; assert (stream->flags.writing); @@ -1759,7 +1756,7 @@ es_empty (estream_t stream) static void init_stream_obj (estream_t stream, void *cookie, es_syshd_t *syshd, - es_cookie_io_functions_t functions, + gpgrt_cookie_io_functions_t functions, unsigned int modeflags, int samethread) { stream->intern->cookie = cookie; @@ -1802,7 +1799,7 @@ init_stream_obj (estream_t stream, static int es_deinitialize (estream_t stream) { - es_cookie_close_function_t func_close; + gpgrt_cookie_close_function_t func_close; int err, tmp_err; func_close = stream->intern->func_close; @@ -1829,7 +1826,7 @@ es_deinitialize (estream_t stream) /* Create a new stream object, initialize it. */ static int es_create (estream_t *stream, void *cookie, es_syshd_t *syshd, - es_cookie_io_functions_t functions, unsigned int modeflags, + gpgrt_cookie_io_functions_t functions, unsigned int modeflags, int samethread, int with_locked_list) { estream_internal_t stream_internal_new; @@ -1943,11 +1940,11 @@ do_onclose (estream_t stream, int mode, unbuffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int -es_read_nbf (estream_t ES__RESTRICT stream, - unsigned char *ES__RESTRICT buffer, - size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) +es_read_nbf (estream_t _GPGRT__RESTRICT stream, + unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_read, size_t *_GPGRT__RESTRICT bytes_read) { - es_cookie_read_function_t func_read = stream->intern->func_read; + gpgrt_cookie_read_function_t func_read = stream->intern->func_read; size_t data_read; ssize_t ret; int err; @@ -1980,9 +1977,9 @@ es_read_nbf (estream_t ES__RESTRICT stream, fully-buffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int -es_read_fbf (estream_t ES__RESTRICT stream, - unsigned char *ES__RESTRICT buffer, - size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) +es_read_fbf (estream_t _GPGRT__RESTRICT stream, + unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_read, size_t *_GPGRT__RESTRICT bytes_read) { size_t data_available; size_t data_to_read; @@ -2030,9 +2027,9 @@ es_read_fbf (estream_t ES__RESTRICT stream, line-buffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int -es_read_lbf (estream_t ES__RESTRICT stream, - unsigned char *ES__RESTRICT buffer, - size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) +es_read_lbf (estream_t _GPGRT__RESTRICT stream, + unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_read, size_t *_GPGRT__RESTRICT bytes_read) { int err; @@ -2044,9 +2041,9 @@ es_read_lbf (estream_t ES__RESTRICT stream, /* Try to read BYTES_TO_READ bytes FROM STREAM into BUFFER, storing *the amount of bytes read in BYTES_READ. */ static int -es_readn (estream_t ES__RESTRICT stream, - void *ES__RESTRICT buffer_arg, - size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) +es_readn (estream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT buffer_arg, + size_t bytes_to_read, size_t *_GPGRT__RESTRICT bytes_read) { unsigned char *buffer = (unsigned char *)buffer_arg; size_t data_read_unread, data_read; @@ -2104,9 +2101,9 @@ es_readn (estream_t ES__RESTRICT stream, /* Try to unread DATA_N bytes from DATA into STREAM, storing the amount of bytes successfully unread in *BYTES_UNREAD. */ static void -es_unreadn (estream_t ES__RESTRICT stream, - const unsigned char *ES__RESTRICT data, size_t data_n, - size_t *ES__RESTRICT bytes_unread) +es_unreadn (estream_t _GPGRT__RESTRICT stream, + const unsigned char *_GPGRT__RESTRICT data, size_t data_n, + size_t *_GPGRT__RESTRICT bytes_unread) { size_t space_left; @@ -2130,10 +2127,10 @@ es_unreadn (estream_t ES__RESTRICT stream, /* Seek in STREAM. */ static int -es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence, - off_t *ES__RESTRICT offset_new) +es_seek (estream_t _GPGRT__RESTRICT stream, off_t offset, int whence, + off_t *_GPGRT__RESTRICT offset_new) { - es_cookie_seek_function_t func_seek = stream->intern->func_seek; + gpgrt_cookie_seek_function_t func_seek = stream->intern->func_seek; int err, ret; off_t off; @@ -2189,11 +2186,11 @@ es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence, unbuffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int -es_write_nbf (estream_t ES__RESTRICT stream, - const unsigned char *ES__RESTRICT buffer, - size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) +es_write_nbf (estream_t _GPGRT__RESTRICT stream, + const unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_write, size_t *_GPGRT__RESTRICT bytes_written) { - es_cookie_write_function_t func_write = stream->intern->func_write; + gpgrt_cookie_write_function_t func_write = stream->intern->func_write; size_t data_written; ssize_t ret; int err; @@ -2233,9 +2230,9 @@ es_write_nbf (estream_t ES__RESTRICT stream, fully-buffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int -es_write_fbf (estream_t ES__RESTRICT stream, - const unsigned char *ES__RESTRICT buffer, - size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) +es_write_fbf (estream_t _GPGRT__RESTRICT stream, + const unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_write, size_t *_GPGRT__RESTRICT bytes_written) { size_t space_available; size_t data_to_write; @@ -2277,9 +2274,9 @@ es_write_fbf (estream_t ES__RESTRICT stream, line-buffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int -es_write_lbf (estream_t ES__RESTRICT stream, - const unsigned char *ES__RESTRICT buffer, - size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) +es_write_lbf (estream_t _GPGRT__RESTRICT stream, + const unsigned char *_GPGRT__RESTRICT buffer, + size_t bytes_to_write, size_t *_GPGRT__RESTRICT bytes_written) { size_t data_flushed = 0; size_t data_buffered = 0; @@ -2311,9 +2308,9 @@ es_write_lbf (estream_t ES__RESTRICT stream, /* Write BYTES_TO_WRITE bytes from BUFFER into STREAM in, storing the amount of bytes written in BYTES_WRITTEN. */ static int -es_writen (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, - size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) +es_writen (estream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, + size_t bytes_to_write, size_t *_GPGRT__RESTRICT bytes_written) { size_t data_written; int err; @@ -2367,8 +2364,8 @@ es_writen (estream_t ES__RESTRICT stream, static int -es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data, - size_t *ES__RESTRICT data_len) +es_peek (estream_t _GPGRT__RESTRICT stream, unsigned char **_GPGRT__RESTRICT data, + size_t *_GPGRT__RESTRICT data_len) { int err; @@ -2423,9 +2420,9 @@ es_skip (estream_t stream, size_t size) static int -doreadline (estream_t ES__RESTRICT stream, size_t max_length, - char *ES__RESTRICT *ES__RESTRICT line, - size_t *ES__RESTRICT line_length) +doreadline (estream_t _GPGRT__RESTRICT stream, size_t max_length, + char *_GPGRT__RESTRICT *_GPGRT__RESTRICT line, + size_t *_GPGRT__RESTRICT line_length) { size_t space_left; size_t line_size; @@ -2569,13 +2566,13 @@ print_writer (void *outfncarg, const char *buf, size_t buflen) /* The core of our printf function. This is called in locked state. */ static int -es_print (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, va_list ap) +es_print (estream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) { int rc; stream->intern->print_ntotal = 0; - rc = estream_format (print_writer, stream, format, ap); + rc = _gpgrt_estream_format (print_writer, stream, format, ap); if (rc) return -1; return (int)stream->intern->print_ntotal; @@ -2607,8 +2604,8 @@ es_get_indicator (estream_t stream, int ind_err, int ind_eof) static int -es_set_buffering (estream_t ES__RESTRICT stream, - char *ES__RESTRICT buffer, int mode, size_t size) +es_set_buffering (estream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buffer, int mode, size_t size) { int err; @@ -2683,8 +2680,8 @@ es_offset_calculate (estream_t stream) static void -es_opaque_ctrl (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque_new, - void **ES__RESTRICT opaque_old) +es_opaque_ctrl (estream_t _GPGRT__RESTRICT stream, void *_GPGRT__RESTRICT opaque_new, + void **_GPGRT__RESTRICT opaque_old) { if (opaque_old) *opaque_old = stream->intern->opaque; @@ -2693,24 +2690,10 @@ es_opaque_ctrl (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque_new, } - - /* API. */ - -int -es_init (void) -{ - int err; - - err = do_init (); - - return err; -} - - estream_t -es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) +es_fopen (const char *_GPGRT__RESTRICT path, const char *_GPGRT__RESTRICT mode) { unsigned int modeflags, cmode; int samethread, create_called; @@ -2769,10 +2752,10 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) function but no free function. Providing only a free function is allowed as long as GROW is false. */ estream_t -es_mopen (void *ES__RESTRICT data, size_t data_n, size_t data_len, +es_mopen (void *_GPGRT__RESTRICT data, size_t data_n, size_t data_len, unsigned int grow, func_realloc_t func_realloc, func_free_t func_free, - const char *ES__RESTRICT mode) + const char *_GPGRT__RESTRICT mode) { int create_called = 0; estream_t stream = NULL; @@ -2808,7 +2791,7 @@ es_mopen (void *ES__RESTRICT data, size_t data_n, size_t data_len, estream_t -es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode) +es_fopenmem (size_t memlimit, const char *_GPGRT__RESTRICT mode) { unsigned int modeflags; int samethread; @@ -2845,7 +2828,7 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode) beginning. If MEMLIMIT is not 0 but shorter than DATALEN it DATALEN will be used as the value for MEMLIMIT. */ estream_t -es_fopenmem_init (size_t memlimit, const char *ES__RESTRICT mode, +es_fopenmem_init (size_t memlimit, const char *_GPGRT__RESTRICT mode, const void *data, size_t datalen) { estream_t stream; @@ -2875,9 +2858,9 @@ es_fopenmem_init (size_t memlimit, const char *ES__RESTRICT mode, estream_t -es_fopencookie (void *ES__RESTRICT cookie, - const char *ES__RESTRICT mode, - es_cookie_io_functions_t functions) +es_fopencookie (void *_GPGRT__RESTRICT cookie, + const char *_GPGRT__RESTRICT mode, + gpgrt_cookie_io_functions_t functions) { unsigned int modeflags; int samethread; @@ -3102,7 +3085,7 @@ es_sysopen_nc (es_syshd_t *syshd, const char *mode) stderr. This function needs to be called before any of the standard streams are accessed. */ void -_es_set_std_fd (int no, int fd) +_gpgrt_set_std_fd (int no, int fd) { /* fprintf (stderr, "es_set_std_fd(%d, %d)\n", no, fd); */ lock_list (); @@ -3117,7 +3100,7 @@ _es_set_std_fd (int no, int fd) /* Return the stream used for stdin, stdout or stderr. */ estream_t -_es_get_std_stream (int fd) +_gpgrt_get_std_stream (int fd) { estream_list_t list_obj; estream_t stream = NULL; @@ -3183,8 +3166,8 @@ _es_get_std_stream (int fd) /* Note: A "samethread" keyword given in "mode" is ignored and the value used by STREAM is used instead. */ estream_t -es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, - estream_t ES__RESTRICT stream) +es_freopen (const char *_GPGRT__RESTRICT path, const char *_GPGRT__RESTRICT mode, + estream_t _GPGRT__RESTRICT stream) { int err; @@ -3608,7 +3591,7 @@ es_rewind (estream_t stream) int -_es_getc_underflow (estream_t stream) +_gpgrt_getc_underflow (estream_t stream) { int err; unsigned char c; @@ -3621,7 +3604,7 @@ _es_getc_underflow (estream_t stream) int -_es_putc_overflow (int c, estream_t stream) +_gpgrt_putc_overflow (int c, estream_t stream) { unsigned char d = c; int err; @@ -3673,9 +3656,9 @@ es_ungetc (int c, estream_t stream) int -es_read (estream_t ES__RESTRICT stream, - void *ES__RESTRICT buffer, size_t bytes_to_read, - size_t *ES__RESTRICT bytes_read) +es_read (estream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT buffer, size_t bytes_to_read, + size_t *_GPGRT__RESTRICT bytes_read) { int err; @@ -3693,9 +3676,9 @@ es_read (estream_t ES__RESTRICT stream, int -es_write (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, size_t bytes_to_write, - size_t *ES__RESTRICT bytes_written) +es_write (estream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write, + size_t *_GPGRT__RESTRICT bytes_written) { int err; @@ -3713,8 +3696,8 @@ es_write (estream_t ES__RESTRICT stream, size_t -es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, - estream_t ES__RESTRICT stream) +es_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems, + estream_t _GPGRT__RESTRICT stream) { size_t ret, bytes; @@ -3734,8 +3717,8 @@ es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, size_t -es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t nitems, - estream_t ES__RESTRICT stream) +es_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems, + estream_t _GPGRT__RESTRICT stream) { size_t ret, bytes; @@ -3755,7 +3738,7 @@ es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t nitems, char * -es_fgets (char *ES__RESTRICT buffer, int length, estream_t ES__RESTRICT stream) +es_fgets (char *_GPGRT__RESTRICT buffer, int length, estream_t _GPGRT__RESTRICT stream) { unsigned char *s = (unsigned char*)buffer; int c; @@ -3784,7 +3767,7 @@ es_fgets (char *ES__RESTRICT buffer, int length, estream_t ES__RESTRICT stream) int -es_fputs_unlocked (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) +es_fputs_unlocked (const char *_GPGRT__RESTRICT s, estream_t _GPGRT__RESTRICT stream) { size_t length; int err; @@ -3795,7 +3778,7 @@ es_fputs_unlocked (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) } int -es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) +es_fputs (const char *_GPGRT__RESTRICT s, estream_t _GPGRT__RESTRICT stream) { size_t length; int err; @@ -3810,8 +3793,8 @@ es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) ssize_t -es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, - estream_t ES__RESTRICT stream) +es_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, size_t *_GPGRT__RESTRICT n, + estream_t _GPGRT__RESTRICT stream) { char *line = NULL; size_t line_n = 0; @@ -3989,8 +3972,8 @@ es_free (void *a) int -es_vfprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, +es_vfprintf_unlocked (estream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) { return es_print (stream, format, ap); @@ -3998,7 +3981,7 @@ es_vfprintf_unlocked (estream_t ES__RESTRICT stream, int -es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, +es_vfprintf (estream_t _GPGRT__RESTRICT stream, const char *_GPGRT__RESTRICT format, va_list ap) { int ret; @@ -4012,8 +3995,8 @@ es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, int -es_fprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) +es_fprintf_unlocked (estream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) { int ret; @@ -4027,8 +4010,8 @@ es_fprintf_unlocked (estream_t ES__RESTRICT stream, int -es_fprintf (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) +es_fprintf (estream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) { int ret; @@ -4044,7 +4027,7 @@ es_fprintf (estream_t ES__RESTRICT stream, int -es_printf_unlocked (const char *ES__RESTRICT format, ...) +es_printf_unlocked (const char *_GPGRT__RESTRICT format, ...) { int ret; @@ -4058,7 +4041,7 @@ es_printf_unlocked (const char *ES__RESTRICT format, ...) int -es_printf (const char *ES__RESTRICT format, ...) +es_printf (const char *_GPGRT__RESTRICT format, ...) { int ret; estream_t stream = es_stdout; @@ -4080,14 +4063,14 @@ es_printf (const char *ES__RESTRICT format, ...) belongs into estream-printf but we put it here as a convenience and because es_free is required anyway. */ char * -es_asprintf (const char *ES__RESTRICT format, ...) +es_asprintf (const char *_GPGRT__RESTRICT format, ...) { int rc; va_list ap; char *buf; va_start (ap, format); - rc = estream_vasprintf (&buf, format, ap); + rc = _gpgrt_estream_vasprintf (&buf, format, ap); va_end (ap); if (rc < 0) return NULL; @@ -4101,12 +4084,12 @@ es_asprintf (const char *ES__RESTRICT format, ...) belongs into estream-printf but we put it here as a convenience and because es_free is required anyway. */ char * -es_vasprintf (const char *ES__RESTRICT format, va_list ap) +es_vasprintf (const char *_GPGRT__RESTRICT format, va_list ap) { int rc; char *buf; - rc = estream_vasprintf (&buf, format, ap); + rc = _gpgrt_estream_vasprintf (&buf, format, ap); if (rc < 0) return NULL; return buf; @@ -4262,8 +4245,8 @@ es_tmpfile (void) int -es_setvbuf (estream_t ES__RESTRICT stream, - char *ES__RESTRICT buf, int type, size_t size) +es_setvbuf (estream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buf, int type, size_t size) { int err; @@ -4285,7 +4268,7 @@ es_setvbuf (estream_t ES__RESTRICT stream, void -es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf) +es_setbuf (estream_t _GPGRT__RESTRICT stream, char *_GPGRT__RESTRICT buf) { lock_stream (stream); es_set_buffering (stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); @@ -4414,10 +4397,10 @@ es_fname_get (estream_t stream) the number of bytes actually written are stored at this address. */ int -es_write_sanitized (estream_t ES__RESTRICT stream, - const void * ES__RESTRICT buffer, size_t length, +es_write_sanitized (estream_t _GPGRT__RESTRICT stream, + const void * _GPGRT__RESTRICT buffer, size_t length, const char * delimiters, - size_t * ES__RESTRICT bytes_written) + size_t * _GPGRT__RESTRICT bytes_written) { const unsigned char *p = buffer; size_t count = 0; @@ -4490,9 +4473,9 @@ es_write_sanitized (estream_t ES__RESTRICT stream, BYTES_WRITTEN is not NULL the number of bytes actually written are stored at this address. */ int -es_write_hexstring (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, size_t length, - int reserved, size_t *ES__RESTRICT bytes_written ) +es_write_hexstring (estream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t length, + int reserved, size_t *_GPGRT__RESTRICT bytes_written ) { int ret; const unsigned char *s; diff --git a/src/estream.h b/src/estream.h index 52c5083..dd17031 100644 --- a/src/estream.h +++ b/src/estream.h @@ -1,439 +1,30 @@ -/* estream.h - Extended stream I/O Library - * Copyright (C) 2004-2007, 2010-2011, 2014 g10 Code GmbH +/* estream.h - Interanl defiinitions for the Extended Stream I/O Library + * Copyright (C) 2014 g10 Code GmbH * - * This file is part of Libestream. + * This file is part of libgpg-error. * - * Libestream is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * Libestream is distributed in the hope that it will be useful, but + * libgpg-error is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libestream; if not, see <http://www.gnu.org/licenses/>. - * - * ALTERNATIVELY, Libestream may be distributed under the terms of the - * following license, in which case the provisions of this license are - * required INSTEAD OF the GNU General Public License. If you wish to - * allow use of your version of this file only under the terms of the - * GNU General Public License, and not to allow others to use your - * version of this file under the terms of the following license, - * indicate your decision by deleting this paragraph and the license - * below. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, and the entire permission notice in its entirety, - * including the disclaimer of warranties. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * License along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef ESTREAM_H #define ESTREAM_H -#include <sys/types.h> -#include <stdarg.h> -#include <stdio.h> - -/* To use this file with libraries the following macro is useful: - - #define _ESTREAM_EXT_SYM_PREFIX _foo_ - - This prefixes all external symbols with "_foo_". - - */ - - -#ifdef _ESTREAM_EXT_SYM_PREFIX -#ifndef _ESTREAM_PREFIX -#define _ESTREAM_PREFIX1(x,y) x ## y -#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y) -#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x) -#endif /*_ESTREAM_PREFIX*/ -#define es_init _ESTREAM_PREFIX(es_init) -#define es_fopen _ESTREAM_PREFIX(es_fopen) -#define es_mopen _ESTREAM_PREFIX(es_mopen) -#define es_fopenmem _ESTREAM_PREFIX(es_fopenmem) -#define es_fopenmem_init _ESTREAM_PREFIX(es_fopenmem_init) -#define es_fdopen _ESTREAM_PREFIX(es_fdopen) -#define es_fdopen_nc _ESTREAM_PREFIX(es_fdopen_nc) -#define es_sysopen _ESTREAM_PREFIX(es_sysopen) -#define es_sysopen_nc _ESTREAM_PREFIX(es_sysopen_nc) -#define es_fpopen _ESTREAM_PREFIX(es_fpopen) -#define es_fpopen_nc _ESTREAM_PREFIX(es_fpopen_nc) -#define _es_set_std_fd _ESTREAM_PREFIX(_es_set_std_fd) -#define _es_get_std_stream _ESTREAM_PREFIX(_es_get_std_stream) -#define es_freopen _ESTREAM_PREFIX(es_freopen) -#define es_fopencookie _ESTREAM_PREFIX(es_fopencookie) -#define es_fclose _ESTREAM_PREFIX(es_fclose) -#define es_fclose_snatch _ESTREAM_PREFIX(es_fclose_snatch) -#define es_onclose _ESTREAM_PREFIX(es_onclose) -#define es_fileno _ESTREAM_PREFIX(es_fileno) -#define es_fileno_unlocked _ESTREAM_PREFIX(es_fileno_unlocked) -#define es_syshd _ESTREAM_PREFIX(es_syshd) -#define es_syshd_unlocked _ESTREAM_PREFIX(es_syshd_unlocked) -#define es_flockfile _ESTREAM_PREFIX(es_flockfile) -#define es_ftrylockfile _ESTREAM_PREFIX(es_ftrylockfile) -#define es_funlockfile _ESTREAM_PREFIX(es_funlockfile) -#define es_feof _ESTREAM_PREFIX(es_feof) -#define es_feof_unlocked _ESTREAM_PREFIX(es_feof_unlocked) -#define es_ferror _ESTREAM_PREFIX(es_ferror) -#define es_ferror_unlocked _ESTREAM_PREFIX(es_ferror_unlocked) -#define es_clearerr _ESTREAM_PREFIX(es_clearerr) -#define es_clearerr_unlocked _ESTREAM_PREFIX(es_clearerr_unlocked) -#define es_fflush _ESTREAM_PREFIX(es_fflush) -#define es_fseek _ESTREAM_PREFIX(es_fseek) -#define es_fseeko _ESTREAM_PREFIX(es_fseeko) -#define es_ftell _ESTREAM_PREFIX(es_ftell) -#define es_ftello _ESTREAM_PREFIX(es_ftello) -#define es_rewind _ESTREAM_PREFIX(es_rewind) -#define es_fgetc _ESTREAM_PREFIX(es_fgetc) -#define es_fputc _ESTREAM_PREFIX(es_fputc) -#define _es_getc_underflow _ESTREAM_PREFIX(_es_getc_underflow) -#define _es_putc_overflow _ESTREAM_PREFIX(_es_putc_overflow) -#define es_ungetc _ESTREAM_PREFIX(es_ungetc) -#define es_read _ESTREAM_PREFIX(es_read) -#define es_write _ESTREAM_PREFIX(es_write) -#define es_write_sanitized _ESTREAM_PREFIX(es_write_sanitized) -#define es_write_hexstring _ESTREAM_PREFIX(es_write_hexstring) -#define es_fread _ESTREAM_PREFIX(es_fread) -#define es_fwrite _ESTREAM_PREFIX(es_fwrite) -#define es_fgets _ESTREAM_PREFIX(es_fgets) -#define es_fputs _ESTREAM_PREFIX(es_fputs) -#define es_fputs_unlocked _ESTREAM_PREFIX(es_fputs_unlocked) -#define es_getline _ESTREAM_PREFIX(es_getline) -#define es_read_line _ESTREAM_PREFIX(es_read_line) -#define es_free _ESTREAM_PREFIX(es_free) -#define es_fprintf _ESTREAM_PREFIX(es_fprintf) -#define es_fprintf_unlocked _ESTREAM_PREFIX(es_fprintf_unlocked) -#define es_printf _ESTREAM_PREFIX(es_printf) -#define es_printf_unlocked _ESTREAM_PREFIX(es_printf_unlocked) -#define es_vfprintf _ESTREAM_PREFIX(es_vfprint) -#define es_vfprintf_unlocked _ESTREAM_PREFIX(es_vfprint_unlocked) -#define es_asprintf _ESTREAM_PREFIX(es_asprintf) -#define es_vasprintf _ESTREAM_PREFIX(es_vasprintf) -#define es_setvbuf _ESTREAM_PREFIX(es_setvbuf) -#define es_setbuf _ESTREAM_PREFIX(es_setbuf) -#define es_set_binary _ESTREAM_PREFIX(es_set_binary) -#define es_tmpfile _ESTREAM_PREFIX(es_tmpfile) -#define es_opaque_set _ESTREAM_PREFIX(es_opaque_set) -#define es_opaque_get _ESTREAM_PREFIX(es_opaque_get) -#define es_fname_set _ESTREAM_PREFIX(es_fname_set) -#define es_fname_get _ESTREAM_PREFIX(es_fname_get) -#define es_write_sanitized_utf8_buffer \ - _ESTREAM_PREFIX(es_write_sanitized_utf8_buffer) -#endif /*_ESTREAM_EXT_SYM_PREFIX*/ - - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - - -/* Forward declaration for the (opaque) internal type. */ -struct estream_internal; - -/* The definition of this struct is entirely private. You must not - use it for anything. It is only here so some functions can be - implemented as macros. */ -struct es__stream -{ - /* The layout of this struct must never change. It may be grown, - but only if all functions which access the new members are - versioned. */ - - /* A pointer to the stream buffer. */ - unsigned char *buffer; - - /* The size of the buffer in bytes. */ - size_t buffer_size; - - /* The length of the usable data in the buffer, only valid when in - read mode (see flags). */ - size_t data_len; - - /* The current position of the offset pointer, valid in read and - write mode. */ - size_t data_offset; - - size_t data_flushed; - unsigned char *unread_buffer; - size_t unread_buffer_size; - - /* The number of unread bytes. */ - size_t unread_data_len; - - /* Various flags. */ - struct { - unsigned int writing: 1; - unsigned int reserved: 7; - } flags; - - /* A pointer to our internal data for this stream. */ - struct estream_internal *intern; -}; - -/* The opaque type for an estream. */ -typedef struct es__stream *estream_t; - - -typedef ssize_t (*es_cookie_read_function_t) (void *cookie, - void *buffer, size_t size); -typedef ssize_t (*es_cookie_write_function_t) (void *cookie, - const void *buffer, - size_t size); -typedef int (*es_cookie_seek_function_t) (void *cookie, - off_t *pos, int whence); -typedef int (*es_cookie_close_function_t) (void *cookie); - -typedef struct es_cookie_io_functions -{ - es_cookie_read_function_t func_read; - es_cookie_write_function_t func_write; - es_cookie_seek_function_t func_seek; - es_cookie_close_function_t func_close; -} es_cookie_io_functions_t; - - -enum es_syshd_types - { - ES_SYSHD_NONE, /* No system handle available. */ - ES_SYSHD_FD, /* A file descriptor as returned by open(). */ - ES_SYSHD_SOCK, /* A socket as returned by socket(). */ - ES_SYSHD_RVID, /* A rendevous id (see libassuan's gpgcedev.c). */ - ES_SYSHD_HANDLE /* A HANDLE object (Windows). */ - }; - -typedef struct -{ - enum es_syshd_types type; - union { - int fd; - int sock; - int rvid; - void *handle; - } u; -} es_syshd_t; - - - - -#ifndef _ESTREAM_GCC_A_PRINTF -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) -# define _ESTREAM_GCC_A_PRINTF( f, a ) \ - __attribute__ ((format (__gnu_printf__,f,a))) -# elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) -# define _ESTREAM_GCC_A_PRINTF( f, a ) \ - __attribute__ ((format (printf,f,a))) -# else -# define _ESTREAM_GCC_A_PRINTF( f, a ) -# endif -#endif /*_ESTREAM_GCC_A_PRINTF*/ - - -#ifndef ES__RESTRICT -# if defined __GNUC__ && defined __GNUC_MINOR__ -# if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 92)) -# define ES__RESTRICT __restrict__ -# endif -# endif -#endif -#ifndef ES__RESTRICT -# define ES__RESTRICT -#endif - -int es_init (void); - -estream_t es_fopen (const char *ES__RESTRICT path, - const char *ES__RESTRICT mode); -estream_t es_mopen (void *ES__RESTRICT data, - size_t data_n, size_t data_len, - unsigned int grow, - void *(*func_realloc) (void *mem, size_t size), - void (*func_free) (void *mem), - const char *ES__RESTRICT mode); -estream_t es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode); -estream_t es_fopenmem_init (size_t memlimit, const char *ES__RESTRICT mode, - const void *data, size_t datalen); -estream_t es_fdopen (int filedes, const char *mode); -estream_t es_fdopen_nc (int filedes, const char *mode); -estream_t es_sysopen (es_syshd_t *syshd, const char *mode); -estream_t es_sysopen_nc (es_syshd_t *syshd, const char *mode); -estream_t es_fpopen (FILE *fp, const char *mode); -estream_t es_fpopen_nc (FILE *fp, const char *mode); -estream_t es_freopen (const char *ES__RESTRICT path, - const char *ES__RESTRICT mode, - estream_t ES__RESTRICT stream); -estream_t es_fopencookie (void *ES__RESTRICT cookie, - const char *ES__RESTRICT mode, - es_cookie_io_functions_t functions); -int es_fclose (estream_t stream); -int es_fclose_snatch (estream_t stream, void **r_buffer, size_t *r_buflen); -int es_onclose (estream_t stream, int mode, - void (*fnc) (estream_t, void*), void *fnc_value); -int es_fileno (estream_t stream); -int es_fileno_unlocked (estream_t stream); -int es_syshd (estream_t stream, es_syshd_t *syshd); -int es_syshd_unlocked (estream_t stream, es_syshd_t *syshd); - -void _es_set_std_fd (int no, int fd); -estream_t _es_get_std_stream (int fd); - -#define es_stdin _es_get_std_stream (0) -#define es_stdout _es_get_std_stream (1) -#define es_stderr _es_get_std_stream (2) - - -void es_flockfile (estream_t stream); -int es_ftrylockfile (estream_t stream); -void es_funlockfile (estream_t stream); - -int es_feof (estream_t stream); -int es_feof_unlocked (estream_t stream); -int es_ferror (estream_t stream); -int es_ferror_unlocked (estream_t stream); -void es_clearerr (estream_t stream); -void es_clearerr_unlocked (estream_t stream); - -int es_fflush (estream_t stream); -int es_fseek (estream_t stream, long int offset, int whence); -int es_fseeko (estream_t stream, off_t offset, int whence); -long int es_ftell (estream_t stream); -off_t es_ftello (estream_t stream); -void es_rewind (estream_t stream); - -int es_fgetc (estream_t stream); -int es_fputc (int c, estream_t stream); - -int _es_getc_underflow (estream_t stream); -int _es_putc_overflow (int c, estream_t stream); - -#define es_getc_unlocked(stream) \ - (((!(stream)->flags.writing) \ - && ((stream)->data_offset < (stream)->data_len) \ - && (! (stream)->unread_data_len)) \ - ? ((int) (stream)->buffer[((stream)->data_offset)++]) \ - : _es_getc_underflow ((stream))) - -#define es_putc_unlocked(c, stream) \ - (((stream)->flags.writing \ - && ((stream)->data_offset < (stream)->buffer_size) \ - && (c != '\n')) \ - ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \ - : _es_putc_overflow ((c), (stream))) - -#define es_getc(stream) es_fgetc (stream) -#define es_putc(c, stream) es_fputc (c, stream) - -int es_ungetc (int c, estream_t stream); - -int es_read (estream_t ES__RESTRICT stream, - void *ES__RESTRICT buffer, size_t bytes_to_read, - size_t *ES__RESTRICT bytes_read); -int es_write (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, size_t bytes_to_write, - size_t *ES__RESTRICT bytes_written); -int es_write_sanitized (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, size_t length, - const char *delimiters, - size_t *ES__RESTRICT bytes_written); -int es_write_hexstring (estream_t ES__RESTRICT stream, - const void *ES__RESTRICT buffer, size_t length, - int reserved, size_t *ES__RESTRICT bytes_written); - -size_t es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, - estream_t ES__RESTRICT stream); -size_t es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t memb, - estream_t ES__RESTRICT stream); - -char *es_fgets (char *ES__RESTRICT s, int n, estream_t ES__RESTRICT stream); -int es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream); -int es_fputs_unlocked (const char *ES__RESTRICT s, - estream_t ES__RESTRICT stream); - -ssize_t es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, - size_t *ES__RESTRICT n, - estream_t stream); -ssize_t es_read_line (estream_t stream, - char **addr_of_buffer, size_t *length_of_buffer, - size_t *max_length); -void es_free (void *a); - -int es_fprintf (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) - _ESTREAM_GCC_A_PRINTF(2,3); -int es_fprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) - _ESTREAM_GCC_A_PRINTF(2,3); - -int es_printf (const char *ES__RESTRICT format, ...) - _ESTREAM_GCC_A_PRINTF(1,2); -int es_printf_unlocked (const char *ES__RESTRICT format, ...) - _ESTREAM_GCC_A_PRINTF(1,2); - -int es_vfprintf (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, va_list ap) - _ESTREAM_GCC_A_PRINTF(2,0); -int es_vfprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, va_list ap) - _ESTREAM_GCC_A_PRINTF(2,0); - -char *es_asprintf (const char *ES__RESTRICT format, ...) - _ESTREAM_GCC_A_PRINTF(1,2); -char *es_vasprintf (const char *ES__RESTRICT format, va_list ap) - _ESTREAM_GCC_A_PRINTF(1,0); - -int es_setvbuf (estream_t ES__RESTRICT stream, - char *ES__RESTRICT buf, int mode, size_t size); -void es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf); - -void es_set_binary (estream_t stream); - - -estream_t es_tmpfile (void); - -void es_opaque_set (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque); -void *es_opaque_get (estream_t stream); +#include "gpg-error.h" -void es_fname_set (estream_t stream, const char *fname); -const char *es_fname_get (estream_t stream); +/* Local prototypes for estream. */ +int _gpgrt_es_init (void); -#ifdef GNUPG_MAJOR_VERSION -int es_write_sanitized_utf8_buffer (estream_t stream, - const void *buffer, size_t length, - const char *delimiters, - size_t *bytes_written); -#endif /*GNUPG_MAJOR_VERSION*/ -#ifdef __cplusplus -} -#endif #endif /*ESTREAM_H*/ diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index 4bd28bf..8cdbaba 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -24,6 +24,7 @@ #define GPG_ERROR_H 1 #include <stddef.h> +#include <stdio.h> #ifdef __GNUC__ #define GPG_ERR_INLINE __inline__ @@ -37,7 +38,6 @@ #endif #endif - #ifdef __cplusplus extern "C" { #if 0 /* just to make Emacs auto-indent happy */ @@ -68,6 +68,9 @@ extern "C" { internal gettext API to standard names. This has only an effect on Windows platforms. + GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the + estream functions. + In addition to the error codes, Libgpg-error also provides a set of functions used by most GnuPG components. */ @@ -130,22 +133,37 @@ typedef unsigned int gpg_error_t; /* GCC feature test. */ -#undef _GPG_ERR_HAVE_CONSTRUCTOR #if __GNUC__ -#define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) +# define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#else +# define _GPG_ERR_GCC_VERSION 0 +#endif +#undef _GPG_ERR_HAVE_CONSTRUCTOR #if _GPG_ERR_GCC_VERSION > 30100 -#define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__)) -#define _GPG_ERR_HAVE_CONSTRUCTOR +# define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__)) +# define _GPG_ERR_HAVE_CONSTRUCTOR +#else +# define _GPG_ERR_CONSTRUCTOR #endif + +#if _GPG_ERR_GCC_VERSION >= 40400 +# define _GPGRT_GCC_A_PRINTF(f, a) __attribute__ ((format(__gnu_printf__,f,a))) +#elif _GPG_ERR_GCC_VERSION >= 20500 +# define _GPGRT_GCC_A_PRINTF(f, a) __attribute__ ((format(printf,f,a))) +#else +# define _GPGRT_GCC_A_PRINTF(f, a) #endif -#ifndef _GPG_ERR_CONSTRUCTOR -#define _GPG_ERR_CONSTRUCTOR +#if _GPG_ERR_GCC_VERSION >= 29200 +# define _GPGRT__RESTRICT __restrict__ +#else +# define _GPGRT__RESTRICT #endif + /* Initialization function. */ @@ -309,7 +327,344 @@ gpg_err_code_t gpgrt_yield (void); /* Estream */ +/* The definition of this struct is entirely private. You must not + use it for anything. It is only here so some functions can be + implemented as macros. */ +struct _gpgrt_stream_internal; +struct _gpgrt__stream +{ + /* The layout of this struct must never change. It may be grown, + but only if all functions which access the new members are + versioned. */ + + /* Various flags. */ + struct { + unsigned int magic: 16; + unsigned int writing: 1; + unsigned int reserved: 15; + } flags; + + /* A pointer to the stream buffer. */ + unsigned char *buffer; + + /* The size of the buffer in bytes. */ + size_t buffer_size; + + /* The length of the usable data in the buffer, only valid when in + read mode (see flags). */ + size_t data_len; + + /* The current position of the offset pointer, valid in read and + write mode. */ + size_t data_offset; + + size_t data_flushed; + unsigned char *unread_buffer; + size_t unread_buffer_size; + + /* The number of unread bytes. */ + size_t unread_data_len; + + /* A pointer to our internal data for this stream. */ + struct _gpgrt_stream_internal *intern; +}; + +/* The opaque type for an estream. */ +typedef struct _gpgrt__stream *gpgrt_stream_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt__stream *estream_t; +#endif + +typedef ssize_t (*gpgrt_cookie_read_function_t) (void *cookie, + void *buffer, size_t size); +typedef ssize_t (*gpgrt_cookie_write_function_t) (void *cookie, + const void *buffer, + size_t size); +typedef int (*gpgrt_cookie_seek_function_t) (void *cookie, + off_t *pos, int whence); +typedef int (*gpgrt_cookie_close_function_t) (void *cookie); + +struct _gpgrt_cookie_io_functions +{ + gpgrt_cookie_read_function_t func_read; + gpgrt_cookie_write_function_t func_write; + gpgrt_cookie_seek_function_t func_seek; + gpgrt_cookie_close_function_t func_close; +}; +typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t; +#define es_cookie_read_function_t gpgrt_cookie_read_function_t +#define es_cookie_write_function_t gpgrt_cookie_read_function_t +#define es_cookie_seek_function_t gpgrt_cookie_read_function_t +#define es_cookie_close_function_t gpgrt_cookie_read_function_t +#endif + +enum gpgrt_syshd_types + { + GPGRT_SYSHD_NONE = 0, /* No system handle available. */ + GPGRT_SYSHD_FD = 1, /* A file descriptor as returned by open(). */ + GPGRT_SYSHD_SOCK = 2, /* A socket as returned by socket(). */ + GPGRT_SYSHD_RVID = 3, /* A rendevous id (see libassuan's gpgcedev.c). */ + GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows). */ + }; + +struct _gpgrt_syshd +{ + enum gpgrt_syshd_types type; + union { + int fd; + int sock; + int rvid; + void *handle; + } u; +}; +typedef struct _gpgrt_syshd gpgrt_syshd_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt_syshd es_syshd_t; +#define ES_SYSHD_NONE GPGRT_SYSHD_NONE +#define ES_SYSHD_FD GPGRT_SYSHD_FD +#define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK +#define ES_SYSHD_RVID GPGRT_SYSHD_RVID +#define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE +#endif +gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path, + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data, + size_t data_n, size_t data_len, + unsigned int grow, + void *(*func_realloc) (void *mem, size_t size), + void (*func_free) (void *mem), + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_fopenmem (size_t memlimit, + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit, + const char *_GPGRT__RESTRICT mode, + const void *data, size_t datalen); +gpgrt_stream_t gpgrt_fdopen (int filedes, const char *mode); +gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode); +gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const char *mode); +gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode); +gpgrt_stream_t gpgrt_fpopen (FILE *fp, const char *mode); +gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode); +gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path, + const char *_GPGRT__RESTRICT mode, + gpgrt_stream_t _GPGRT__RESTRICT stream); +gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie, + const char *_GPGRT__RESTRICT mode, + gpgrt_cookie_io_functions_t functions); +int gpgrt_fclose (gpgrt_stream_t stream); +int gpgrt_fclose_snatch (gpgrt_stream_t stream, + void **r_buffer, size_t *r_buflen); +int gpgrt_onclose (gpgrt_stream_t stream, int mode, + void (*fnc) (gpgrt_stream_t, void*), void *fnc_value); +int gpgrt_fileno (gpgrt_stream_t stream); +int gpgrt_fileno_unlocked (gpgrt_stream_t stream); +int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd); +int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd); + +void _gpgrt_set_std_fd (int no, int fd); +gpgrt_stream_t _gpgrt_get_std_stream (int fd); + +#define gpgrt_stdin _gpgrt_get_std_stream (0) +#define gpgrt_stdout _gpgrt_get_std_stream (1) +#define gpgrt_stderr _gpgrt_get_std_stream (2) + + +void gpgrt_flockfile (gpgrt_stream_t stream); +int gpgrt_ftrylockfile (gpgrt_stream_t stream); +void gpgrt_funlockfile (gpgrt_stream_t stream); + +int gpgrt_feof (gpgrt_stream_t stream); +int gpgrt_feof_unlocked (gpgrt_stream_t stream); +int gpgrt_ferror (gpgrt_stream_t stream); +int gpgrt_ferror_unlocked (gpgrt_stream_t stream); +void gpgrt_clearerr (gpgrt_stream_t stream); +void gpgrt_clearerr_unlocked (gpgrt_stream_t stream); + +int gpgrt_fflush (gpgrt_stream_t stream); +int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence); +int gpgrt_fseeko (gpgrt_stream_t stream, off_t offset, int whence); +long int gpgrt_ftell (gpgrt_stream_t stream); +off_t gpgrt_ftello (gpgrt_stream_t stream); +void gpgrt_rewind (gpgrt_stream_t stream); + +int gpgrt_fgetc (gpgrt_stream_t stream); +int gpgrt_fputc (int c, gpgrt_stream_t stream); + +int _gpgrt_getc_underflow (gpgrt_stream_t stream); +int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); + +#define gpgrt_getc_unlocked(stream) \ + (((!(stream)->flags.writing) \ + && ((stream)->data_offset < (stream)->data_len) \ + && (! (stream)->unread_data_len)) \ + ? ((int) (stream)->buffer[((stream)->data_offset)++]) \ + : _gpgrt_getc_underflow ((stream))) + +#define gpgrt_putc_unlocked(c, stream) \ + (((stream)->flags.writing \ + && ((stream)->data_offset < (stream)->buffer_size) \ + && (c != '\n')) \ + ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \ + : _gpgrt_putc_overflow ((c), (stream))) + +#define gpgrt_getc(stream) gpgrt_fgetc (stream) +#define gpgrt_putc(c, stream) gpgrt_fputc (c, stream) + +int gpgrt_ungetc (int c, gpgrt_stream_t stream); + +int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT buffer, size_t bytes_to_read, + size_t *_GPGRT__RESTRICT bytes_read); +int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write, + size_t *_GPGRT__RESTRICT bytes_written); +int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t length, + const char *delimiters, + size_t *_GPGRT__RESTRICT bytes_written); +int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t length, + int reserved, + size_t *_GPGRT__RESTRICT bytes_written); + +size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems, + gpgrt_stream_t _GPGRT__RESTRICT stream); +size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size, size_t memb, + gpgrt_stream_t _GPGRT__RESTRICT stream); + +char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n, + gpgrt_stream_t _GPGRT__RESTRICT stream); +int gpgrt_fputs (const char *_GPGRT__RESTRICT s, + gpgrt_stream_t _GPGRT__RESTRICT stream); +int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s, + gpgrt_stream_t _GPGRT__RESTRICT stream); + +ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, + size_t *_GPGRT__RESTRICT n, + gpgrt_stream_t stream); +ssize_t gpgrt_read_line (gpgrt_stream_t stream, + char **addr_of_buffer, size_t *length_of_buffer, + size_t *max_length); +void gpgrt_free (void *a); + +int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) + _GPGRT_GCC_A_PRINTF(2,3); +int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) + _GPGRT_GCC_A_PRINTF(2,3); + +int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...) + _GPGRT_GCC_A_PRINTF(1,2); +int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...) + _GPGRT_GCC_A_PRINTF(1,2); + +int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) + _GPGRT_GCC_A_PRINTF(2,0); +int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) + _GPGRT_GCC_A_PRINTF(2,0); + +char *gpgrt_asprintf (const char *_GPGRT__RESTRICT format, ...) + _GPGRT_GCC_A_PRINTF(1,2); +char *gpgrt_vasprintf (const char *_GPGRT__RESTRICT format, va_list ap) + _GPGRT_GCC_A_PRINTF(1,0); + +int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buf, int mode, size_t size); +void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buf); + +void gpgrt_set_binary (gpgrt_stream_t stream); + +gpgrt_stream_t gpgrt_tmpfile (void); + +void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT opaque); +void *gpgrt_opaque_get (gpgrt_stream_t stream); + +void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname); +const char *gpgrt_fname_get (gpgrt_stream_t stream); + + +#ifdef GPGRT_ENABLE_ES_MACROS +# define es_fopen gpgrt_fopen +# define es_mopen gpgrt_mopen +# define es_fopenmem gpgrt_fopenmem +# define es_fopenmem_init gpgrt_fopenmem_init +# define es_fdopen gpgrt_fdopen +# define es_fdopen_nc gpgrt_fdopen_nc +# define es_sysopen gpgrt_sysopen +# define es_sysopen_nc gpgrt_sysopen_nc +# define es_fpopen gpgrt_fpopen +# define es_fpopen_nc gpgrt_fpopen_nc +# define es_freopen gpgrt_freopen +# define es_fopencookie gpgrt_fopencookie +# define es_fclose gpgrt_fclose +# define es_fclose_snatch gpgrt_fclose_snatch +# define es_onclose gpgrt_onclose +# define es_fileno gpgrt_fileno +# define es_fileno_unlocked gpgrt_fileno_unlocked +# define es_syshd gpgrt_syshd +# define es_syshd_unlocked gpgrt_syshd_unlocked +# define es_stdin _gpgrt_get_std_stream (0) +# define es_stdout _gpgrt_get_std_stream (1) +# define es_stderr _gpgrt_get_std_stream (2) +# define es_flockfile gpgrt_flockfile +# define es_ftrylockfile gpgrt_ftrylockfile +# define es_funlockfile gpgrt_funlockfile +# define es_feof gpgrt_feof +# define es_feof_unlocked gpgrt_feof_unlocked +# define es_ferror gpgrt_ferror +# define es_ferror_unlocked gpgrt_ferror_unlocked +# define es_clearerr gpgrt_clearerr +# define es_clearerr_unlocked gpgrt_clearerr_unlocked +# define es_fflush gpgrt_fflush +# define es_fseek gpgrt_fseek +# define es_fseeko gpgrt_fseeko +# define es_ftell gpgrt_ftell +# define es_ftello gpgrt_ftello +# define es_rewind gpgrt_rewind +# define es_fgetc gpgrt_fgetc +# define es_fputc gpgrt_fputc +# define es_getc_unlocked gpgrt_getc_unlocked +# define es_putc_unlocked gpgrt_putc_unlocked +# define es_getc gpgrt_getc +# define es_putc gpgrt_putc +# define es_ungetc gpgrt_ungetc +# define es_read gpgrt_read +# define es_write gpgrt_write +# define es_write_sanitized gpgrt_write_sanitized +# define es_write_hexstring gpgrt_write_hexstring +# define es_fread gpgrt_fread +# define es_fwrite gpgrt_fwrite +# define es_fgets gpgrt_fgets +# define es_fputs gpgrt_fputs +# define es_fputs_unlocked gpgrt_fputs_unlocked +# define es_getline gpgrt_getline +# define es_read_line gpgrt_read_line +# define es_free gpgrt_free +# define es_fprintf gpgrt_fprintf +# define es_fprintf_unlocked gpgrt_fprintf_unlocked +# define es_printf gpgrt_printf +# define es_printf_unlocked gpgrt_printf_unlocked +# define es_vfprintf gpgrt_vfprintf +# define es_vfprintf_unlocked gpgrt_vfprintf_unlocked +# define es_asprintf gpgrt_asprintf +# define es_vasprintf gpgrt_vasprintf +# define es_setvbuf gpgrt_setvbuf +# define es_setbuf gpgrt_setbuf +# define es_set_binary gpgrt_set_binary +# define es_tmpfile gpgrt_tmpfile +# define es_opaque_set gpgrt_opaque_set +# define es_opaque_get gpgrt_opaque_get +# define es_fname_set gpgrt_fname_set +# define es_fname_get gpgrt_fname_get +#endif /*GPGRT_ENABLE_ES_MACROS*/ #ifdef __cplusplus } |