tool-stdio.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef AFUN_STDIO_H
  2. #define AFUN_STDIO_H
  3. #include <cstdio>
  4. #include "tool.h"
  5. #include "aFunToolExport.h"
  6. namespace aFuntool {
  7. AFUN_TOOL_EXPORT int fgets_stdin(char **dest, int len);
  8. AFUN_TOOL_EXPORT bool checkStdin();
  9. AFUN_TOOL_EXPORT bool fclear_stdin();
  10. static bool clear_ferror(FILE *file);
  11. static bool clear_stdin();
  12. }
  13. #ifdef aFunWIN32_NO_CYGWIN
  14. #ifdef _MSC_VER
  15. #pragma warning(disable : 5105) // 关闭 5105 的警告输出 (Windows.h中使用)
  16. #endif
  17. #include <conio.h>
  18. #include <io.h>
  19. #include <Windows.h>
  20. namespace aFuntool {
  21. AFUN_TOOL_EXPORT void stdio_signal_init(bool signal);
  22. AFUN_TOOL_EXPORT bool stdio_check_signal();
  23. AFUN_TOOL_EXPORT int convertMultiByte(char **dest, const char *str, UINT from, UINT to); // win32 特有函数
  24. AFUN_TOOL_EXPORT int convertWideByte(wchar_t **dest, const char *str, UINT from); // win32 特有函数
  25. AFUN_TOOL_EXPORT int convertFromWideByte(char **dest, const wchar_t *str, UINT to);
  26. AFUN_TOOL_EXPORT int fgetc_stdin();
  27. AFUN_TOOL_EXPORT char *fgets_stdin_(char *buf, size_t len);
  28. AFUN_TOOL_EXPORT int fungetc_stdin(int ch);
  29. AFUN_TOOL_EXPORT int fputs_std_(const char *str, FILE *std);
  30. static int fputs_stdout(const char *str);
  31. static int fputs_stderr(const char *str);
  32. AFUN_TOOL_EXPORT size_t vprintf_std_(FILE *std, size_t buf_len, const char *format, va_list ap);
  33. static size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap);
  34. static size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap);
  35. static size_t printf_stdout(size_t buf_len, const char *format, ...);
  36. static size_t printf_stderr(size_t buf_len, const char *format, ...);
  37. }
  38. #else
  39. namespace aFuntool {
  40. static int fgetc_stdin();
  41. static int fgets_stdin_(char *buf, int len, FILE *file);
  42. static int fungetc_stdin(char ch);
  43. static int fputs_stdout(const char *str);
  44. static int fputs_stderr(const char *str);
  45. static int vprintf_stdout(size_t, const char *format, va_list ap);
  46. static int vprintf_stderr(size_t, const char *format, va_list ap);
  47. static size_t printf_stdout(size_t, const char *format, ...);
  48. static size_t printf_stderr(size_t, const char *format, ...);
  49. }
  50. #endif
  51. #include "tool-stdio.inline.h"
  52. #endif //AFUN_STDIO_H