123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef __TFP_PRINTF__
- #define __TFP_PRINTF__
- #include <stdarg.h>
- #ifndef TINYPRINTF_DEFINE_TFP_PRINTF
- # define TINYPRINTF_DEFINE_TFP_PRINTF 1
- #endif
- #ifndef TINYPRINTF_DEFINE_TFP_SPRINTF
- # define TINYPRINTF_DEFINE_TFP_SPRINTF 1
- #endif
- #ifndef TINYPRINTF_OVERRIDE_LIBC
- # define TINYPRINTF_OVERRIDE_LIBC 1
- #endif
- #if TINYPRINTF_DEFINE_TFP_SPRINTF
- #include <stddef.h>
- #endif
- #ifdef __GNUC__
- # define _TFP_SPECIFY_PRINTF_FMT(fmt_idx,arg1_idx) \
- __attribute__((format (printf, fmt_idx, arg1_idx)))
- #else
- # define _TFP_SPECIFY_PRINTF_FMT(fmt_idx,arg1_idx)
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct __sFile
- {
- int unused;
- };
- typedef struct __sFILE FILE;
- typedef void (*putcf) (void *, char);
- void tfp_format(void *putp, putcf putf, const char *fmt, va_list va);
- int tfp_vsscanf(const char* str, const char* format, ...);
- # if TINYPRINTF_OVERRIDE_LIBC
- # define sscanf tfp_vsscanf
- # endif
- #if TINYPRINTF_DEFINE_TFP_SPRINTF
- int tfp_vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
- int tfp_snprintf(char *str, size_t size, const char *fmt, ...) \
- _TFP_SPECIFY_PRINTF_FMT(3, 4);
- int tfp_vsprintf(char *str, const char *fmt, va_list ap);
- int tfp_sprintf(char *str, const char *fmt, ...) \
- _TFP_SPECIFY_PRINTF_FMT(2, 3);
- # if TINYPRINTF_OVERRIDE_LIBC
- # define vsnprintf tfp_vsnprintf
- # define snprintf tfp_snprintf
- # define vsprintf tfp_vsprintf
- # define sprintf tfp_sprintf
- # endif
- #endif
- #if TINYPRINTF_DEFINE_TFP_PRINTF
- void init_printf(void *putp, putcf putf);
- void tfp_printf(char *fmt, ...) _TFP_SPECIFY_PRINTF_FMT(1, 2);
- # if TINYPRINTF_OVERRIDE_LIBC
- # define printf(...) tfp_printf(__VA_ARGS__)
- # endif
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|