diff options
Diffstat (limited to 'common/estream-printf.h')
-rw-r--r-- | common/estream-printf.h | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/common/estream-printf.h b/common/estream-printf.h index bbf132b26..7035ff8a8 100644 --- a/common/estream-printf.h +++ b/common/estream-printf.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * - * $Id: estream-printf.h 54 2007-05-15 14:12:06Z wk $ + * $Id: estream-printf.h 56 2007-05-15 18:38:43Z wk $ */ #ifndef ESTREAM_PRINTF_H @@ -27,10 +27,61 @@ #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_". + + For the implementation of the code (estream-printf.c) the following + macros may be used to tune the implementation for certain systems: + + #define _ESTREAM_PRINTF_MALLOC foo_malloc + #define _ESTREAM_PRINTF_FREE foo_free + + Make estream_asprintf and estream_vasprintf use foo_malloc and + foo_free instead of the standard malloc and free functions to + allocate the memory returned to the caller. + + #define _ESTREAM_PRINTF_EXTRA_INCLUDE "foo.h" + + This includes the file "foo.h" which may provide prototypes for + the custom memory allocation functions. + */ + + +#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 estream_printf_out_t _ESTREAM_PREFIX(estream_printf_out_t) +#define estream_format _ESTREAM_PREFIX(estream_format) +#define estream_printf _ESTREAM_PREFIX(estream_printf) +#define estream_fprintf _ESTREAM_PREFIX(estream_fprintf) +#define estream_vfprintf _ESTREAM_PREFIX(estream_vfprintf) +#define estream_snprintf _ESTREAM_PREFIX(estream_snprintf) +#define estream_vsnprintf _ESTREAM_PREFIX(estream_vsnprintf) +#define estream_asprintf _ESTREAM_PREFIX(estream_asprintf) +#define estream_vasprintf _ESTREAM_PREFIX(estream_vasprintf) +#endif /*_ESTREAM_EXT_SYM_PREFIX*/ + +#ifndef _ESTREAM_GCC_A_PRINTF #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) -# define ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) +# define _ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) #else -# define ESTREAM_GCC_A_PRINTF( f, a ) +# define _ESTREAM_GCC_A_PRINTF( f, a ) +#endif +#endif /*_ESTREAM_GCC_A_PRINTF*/ + + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif #endif @@ -39,22 +90,25 @@ typedef int (*estream_printf_out_t) int estream_format (estream_printf_out_t outfnc, void *outfncarg, const char *format, va_list vaargs) - ESTREAM_GCC_A_PRINTF(3,0); + _ESTREAM_GCC_A_PRINTF(3,0); int estream_printf (const char *format, ...) - ESTREAM_GCC_A_PRINTF(1,2); + _ESTREAM_GCC_A_PRINTF(1,2); int estream_fprintf (FILE *fp, const char *format, ... ) - ESTREAM_GCC_A_PRINTF(2,3); + _ESTREAM_GCC_A_PRINTF(2,3); int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(2,0); + _ESTREAM_GCC_A_PRINTF(2,0); int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) - ESTREAM_GCC_A_PRINTF(3,4); + _ESTREAM_GCC_A_PRINTF(3,4); int estream_vsnprintf (char *buf,size_t bufsize, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(3,0); + _ESTREAM_GCC_A_PRINTF(3,0); int estream_asprintf (char **bufp, const char *format, ...) - ESTREAM_GCC_A_PRINTF(2,3); + _ESTREAM_GCC_A_PRINTF(2,3); int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(2,0); + _ESTREAM_GCC_A_PRINTF(2,0); +#ifdef __cplusplus +} +#endif #endif /*ESTREAM_PRINTF_H*/ |