xprintf.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*------------------------------------------------------------------------*/
  2. /* Universal string handler for user console interface (C)ChaN, 2021 */
  3. /*------------------------------------------------------------------------*/
  4. #ifndef XPRINTF_DEF
  5. #define XPRINTF_DEF
  6. #include <string.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define XF_USE_OUTPUT 1 /* 1: Enable output functions */
  11. #define XF_CRLF 0 /* 1: Convert \n ==> \r\n in the output char */
  12. #define XF_USE_DUMP 0 /* 1: Enable put_dump function */
  13. #define XF_USE_LLI 0 /* 1: Enable long long integer in size prefix ll */
  14. #define XF_USE_FP 0 /* 1: Enable support for floating point in type e and f */
  15. #define XF_DPC '.' /* Decimal separator for floating point */
  16. #define XF_USE_INPUT 0 /* 1: Enable input functions */
  17. #define XF_INPUT_ECHO 0 /* 1: Echo back input chars in xgets function */
  18. #if defined(__GNUC__) && __GNUC__ >= 10
  19. #pragma GCC diagnostic ignored "-Wcast-function-type"
  20. #endif
  21. #if XF_USE_OUTPUT
  22. #define xdev_out(func) xfunc_output = (void(*)(int))(func)
  23. extern void (*xfunc_output)(int);
  24. void xputc (int chr);
  25. void xfputc (void (*func)(int), int chr);
  26. void xputs (const char* str);
  27. void xfputs (void (*func)(int), const char* str);
  28. void xprintf (const char* fmt, ...);
  29. void xsprintf (char* buff, const char* fmt, ...);
  30. void xfprintf (void (*func)(int), const char* fmt, ...);
  31. void put_dump (const void* buff, unsigned long addr, int len, size_t width);
  32. #endif
  33. #if XF_USE_INPUT
  34. #define xdev_in(func) xfunc_input = (int(*)(void))(func)
  35. extern int (*xfunc_input)(void);
  36. int xgets (char* buff, int len);
  37. int xatoi (char** str, long* res);
  38. int xatof (char** str, double* res);
  39. #endif
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif