| 1 | #include <stdarg.h> |
| 2 | #include <stdio.h> |
| 3 | #include <wchar.h> |
| 4 | |
| 5 | #include "global_vars.h" |
| 6 | |
| 7 | void pr_warning(const char* format, ...) { |
| 8 | va_list args; |
| 9 | |
| 10 | va_start(args, format); |
| 11 | fprintf(stdout, format, args); |
| 12 | va_end(args); |
| 13 | fflush(stdout); |
| 14 | } |
| 15 | |
| 16 | void pr_error(const char *format, ...) { |
| 17 | va_list args; |
| 18 | |
| 19 | va_start(args, format); |
| 20 | fprintf(stderr, format, args); |
| 21 | va_end(args); |
| 22 | fflush(stderr); |
| 23 | } |
| 24 | |
| 25 | #if DEBUG |
| 26 | void pr_debug(const char *format, ...) { |
| 27 | va_list args; |
| 28 | |
| 29 | va_start(args, format); |
| 30 | fprintf(stderr, format, args); |
| 31 | va_end(args); |
| 32 | fflush(stderr); |
| 33 | } |
| 34 | #else |
| 35 | void pr_debug(const char *format, ...); |
| 36 | #endif /* DEBUG */ |
| 37 | |
| 38 | void wpr_warning(const wchar_t *format, ...) { |
| 39 | va_list args; |
| 40 | |
| 41 | va_start(args, format); |
| 42 | fwprintf(stdout, format, args); |
| 43 | va_end(args); |
| 44 | fflush(stdout); |
| 45 | } |
| 46 | |
| 47 | void wpr_error(const wchar_t *format, ...) { |
| 48 | va_list args; |
| 49 | |
| 50 | va_start(args, format); |
| 51 | fwprintf(stderr, format, args); |
| 52 | va_end(args); |
| 53 | fflush(stderr); |
| 54 | } |
| 55 | |
| 56 | void wprint_token_stdout() { |
| 57 | if (tokenType == MOT || tokenType == MOTCLE) { |
| 58 | fwprintf(stdout, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value); |
| 59 | } else { |
| 60 | fwprintf(stdout, L"%20s\n", tokenTypestr[tokenType]); |
| 61 | } |
| 62 | fflush(stdout); |
| 63 | } |
| 64 | |
| 65 | void wprint_token_target() { |
| 66 | if (tokenType == MOT || tokenType == MOTCLE) { |
| 67 | fwprintf(target, L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value); |
| 68 | } else { |
| 69 | fwprintf(target, L"%20s\n", tokenTypestr[tokenType]); |
| 70 | } |
| 71 | } |