|
@@ -1,18 +1,15 @@
|
|
#ifndef AFUN_STDIO_H
|
|
#ifndef AFUN_STDIO_H
|
|
#define AFUN_STDIO_H
|
|
#define AFUN_STDIO_H
|
|
#include <cstdio>
|
|
#include <cstdio>
|
|
-#include "macro.h"
|
|
|
|
|
|
+#include "tool.h"
|
|
#include "aFunToolExport.h"
|
|
#include "aFunToolExport.h"
|
|
|
|
|
|
namespace aFuntool {
|
|
namespace aFuntool {
|
|
AFUN_TOOL_EXPORT int fgets_stdin(char **dest, int len);
|
|
AFUN_TOOL_EXPORT int fgets_stdin(char **dest, int len);
|
|
AFUN_TOOL_EXPORT bool checkStdin();
|
|
AFUN_TOOL_EXPORT bool checkStdin();
|
|
AFUN_TOOL_EXPORT bool fclear_stdin();
|
|
AFUN_TOOL_EXPORT bool fclear_stdin();
|
|
- static bool clear_ferror(FILE *file) {return ferror(file) && (clearerr(file), ferror(file));}
|
|
|
|
- static bool clear_stdin() {
|
|
|
|
- return (ferror(stdin) || feof(stdin)) &&
|
|
|
|
- (clearerr(stdin), (ferror(stdin) || feof(stdin)));
|
|
|
|
- }
|
|
|
|
|
|
+ static bool clear_ferror(FILE *file);
|
|
|
|
+ static bool clear_stdin();
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef aFunWIN32_NO_CYGWIN
|
|
#ifdef aFunWIN32_NO_CYGWIN
|
|
@@ -37,64 +34,37 @@ namespace aFuntool {
|
|
AFUN_TOOL_EXPORT int fungetc_stdin(int ch);
|
|
AFUN_TOOL_EXPORT int fungetc_stdin(int ch);
|
|
|
|
|
|
AFUN_TOOL_EXPORT int fputs_std_(const char *str, FILE *std);
|
|
AFUN_TOOL_EXPORT int fputs_std_(const char *str, FILE *std);
|
|
- static int fputs_stdout(const char *str) {return fputs_std_(str, stdout);}
|
|
|
|
- static int fputs_stderr(const char *str) {return fputs_std_(str, stderr);}
|
|
|
|
|
|
+ static int fputs_stdout(const char *str);
|
|
|
|
+ static int fputs_stderr(const char *str);
|
|
|
|
|
|
AFUN_TOOL_EXPORT size_t vprintf_std_(FILE *std, size_t buf_len, const char *format, va_list ap);
|
|
AFUN_TOOL_EXPORT size_t vprintf_std_(FILE *std, size_t buf_len, const char *format, va_list ap);
|
|
- static size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap) {
|
|
|
|
- return vprintf_std_(stderr, buf_len, format, ap);
|
|
|
|
- }
|
|
|
|
- static size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap) {
|
|
|
|
- return vprintf_std_(stdout, buf_len, format, ap);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static size_t printf_stdout(size_t buf_len, const char *format, ...) {
|
|
|
|
- va_list ap;
|
|
|
|
- va_start(ap, format);
|
|
|
|
- size_t re = vprintf_std_(stdout, buf_len, format, ap);
|
|
|
|
- va_end(ap);
|
|
|
|
- return re;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static size_t printf_stderr(size_t buf_len, const char *format, ...) {
|
|
|
|
- va_list ap;
|
|
|
|
- va_start(ap, format);
|
|
|
|
- size_t re = vprintf_std_(stderr, buf_len, format, ap);
|
|
|
|
- va_end(ap);
|
|
|
|
- return re;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ static size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap);
|
|
|
|
+ static size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap);
|
|
|
|
+
|
|
|
|
+ static size_t printf_stdout(size_t buf_len, const char *format, ...);
|
|
|
|
+ static size_t printf_stderr(size_t buf_len, const char *format, ...);
|
|
}
|
|
}
|
|
|
|
|
|
#else
|
|
#else
|
|
|
|
|
|
namespace aFuntool {
|
|
namespace aFuntool {
|
|
- static int fgetc_stdin(){ return fgetc(stdout); }
|
|
|
|
- static int fgets_stdin_(char *buf, int len, FILE *file){ return fgets(buf, len, file) != nullptr; }
|
|
|
|
- static int fungetc_stdin(char ch){ return ungetc(ch, stdin); }
|
|
|
|
-
|
|
|
|
- static int fputs_stdout(const char *str){ return fputs(str, stdout); }
|
|
|
|
- static int fputs_stderr(const char *str){ return fputs(str, stderr); }
|
|
|
|
-
|
|
|
|
- static int vprintf_stdout(size_t, const char *format, va_list ap){ return vfprintf(stdout, format, ap); }
|
|
|
|
- static int vprintf_stderr(size_t, const char *format, va_list ap){ return vfprintf(stderr, format, ap); }
|
|
|
|
-
|
|
|
|
- static size_t printf_stdout(size_t, const char *format, ...) {
|
|
|
|
- va_list ap;
|
|
|
|
- va_start(ap, format);
|
|
|
|
- size_t re = vfprintf(stdout, format, ap);
|
|
|
|
- va_end(ap);
|
|
|
|
- return re;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static size_t printf_stderr(size_t, const char *format, ...) {
|
|
|
|
- va_list ap;
|
|
|
|
- va_start(ap, format);
|
|
|
|
- size_t re = vfprintf(stderr, format, ap);
|
|
|
|
- va_end(ap);
|
|
|
|
- return re;
|
|
|
|
- }
|
|
|
|
|
|
+ static int fgetc_stdin();
|
|
|
|
+ static int fgets_stdin_(char *buf, int len, FILE *file);
|
|
|
|
+ static int fungetc_stdin(char ch);
|
|
|
|
+
|
|
|
|
+ static int fputs_stdout(const char *str);
|
|
|
|
+ static int fputs_stderr(const char *str);
|
|
|
|
|
|
|
|
+ static int vprintf_stdout(size_t, const char *format, va_list ap);
|
|
|
|
+ static int vprintf_stderr(size_t, const char *format, va_list ap);
|
|
|
|
+
|
|
|
|
+ static size_t printf_stdout(size_t, const char *format, ...);
|
|
|
|
+ static size_t printf_stderr(size_t, const char *format, ...);
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
|
|
+#include "stdio_.inline.h"
|
|
|
|
+
|
|
#endif //AFUN_STDIO_H
|
|
#endif //AFUN_STDIO_H
|