diff options
Diffstat (limited to 'src/common/showmsg.h')
-rw-r--r-- | src/common/showmsg.h | 166 |
1 files changed, 86 insertions, 80 deletions
diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 48e763c25..728691ba3 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,15 +5,11 @@ #ifndef COMMON_SHOWMSG_H #define COMMON_SHOWMSG_H -#include <stdarg.h> +#include "common/hercules.h" -#include "../common/cbasetypes.h" +#include <libconfig/libconfig.h> -#ifdef HERCULES_CORE -# include "../../3rdparty/libconfig/libconfig.h" -#else -# include "../common/HPMi.h" -#endif +#include <stdarg.h> // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color @@ -23,58 +19,55 @@ // \033[0m : reset color parameter // \033[1m : use bold for font -#define CL_RESET "\033[0m" -#define CL_CLS "\033[2J" -#define CL_CLL "\033[K" +#define CL_RESET "\033[0m" +#define CL_CLS "\033[2J" +#define CL_CLL "\033[K" // font settings -#define CL_BOLD "\033[1m" -#define CL_NORM CL_RESET -#define CL_NORMAL CL_RESET -#define CL_NONE CL_RESET -// foreground color and bold font (bright color on windows) -#define CL_WHITE "\033[1;37m" -#define CL_GRAY "\033[1;30m" -#define CL_RED "\033[1;31m" -#define CL_GREEN "\033[1;32m" -#define CL_YELLOW "\033[1;33m" -#define CL_BLUE "\033[1;34m" -#define CL_MAGENTA "\033[1;35m" -#define CL_CYAN "\033[1;36m" +#define CL_BOLD "\033[1m" +#define CL_NORM CL_RESET +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET // background color -#define CL_BG_BLACK "\033[40m" -#define CL_BG_RED "\033[41m" -#define CL_BG_GREEN "\033[42m" -#define CL_BG_YELLOW "\033[43m" -#define CL_BG_BLUE "\033[44m" -#define CL_BG_MAGENTA "\033[45m" -#define CL_BG_CYAN "\033[46m" -#define CL_BG_WHITE "\033[47m" +#define CL_BG_BLACK "\033[40m" +#define CL_BG_RED "\033[41m" +#define CL_BG_GREEN "\033[42m" +#define CL_BG_YELLOW "\033[43m" +#define CL_BG_BLUE "\033[44m" +#define CL_BG_MAGENTA "\033[45m" +#define CL_BG_CYAN "\033[46m" +#define CL_BG_WHITE "\033[47m" // foreground color and normal font (normal color on windows) -#define CL_LT_BLACK "\033[0;30m" -#define CL_LT_RED "\033[0;31m" -#define CL_LT_GREEN "\033[0;32m" -#define CL_LT_YELLOW "\033[0;33m" -#define CL_LT_BLUE "\033[0;34m" -#define CL_LT_MAGENTA "\033[0;35m" -#define CL_LT_CYAN "\033[0;36m" -#define CL_LT_WHITE "\033[0;37m" +#define CL_LT_BLACK "\033[0;30m" +#define CL_LT_RED "\033[0;31m" +#define CL_LT_GREEN "\033[0;32m" +#define CL_LT_YELLOW "\033[0;33m" +#define CL_LT_BLUE "\033[0;34m" +#define CL_LT_MAGENTA "\033[0;35m" +#define CL_LT_CYAN "\033[0;36m" +#define CL_LT_WHITE "\033[0;37m" // foreground color and bold font (bright color on windows) -#define CL_BT_BLACK "\033[1;30m" -#define CL_BT_RED "\033[1;31m" -#define CL_BT_GREEN "\033[1;32m" -#define CL_BT_YELLOW "\033[1;33m" -#define CL_BT_BLUE "\033[1;34m" -#define CL_BT_MAGENTA "\033[1;35m" -#define CL_BT_CYAN "\033[1;36m" -#define CL_BT_WHITE "\033[1;37m" +#define CL_BT_BLACK "\033[1;30m" +#define CL_BT_RED "\033[1;31m" +#define CL_BT_GREEN "\033[1;32m" +#define CL_BT_YELLOW "\033[1;33m" +#define CL_BT_BLUE "\033[1;34m" +#define CL_BT_MAGENTA "\033[1;35m" +#define CL_BT_CYAN "\033[1;36m" +#define CL_BT_WHITE "\033[1;37m" -#define CL_WTBL "\033[37;44m" // white on blue -#define CL_XXBL "\033[0;44m" // default on blue -#define CL_PASS "\033[0;32;42m" // green on green +// foreground color and bold font (bright color on windows) +#define CL_WHITE CL_BT_WHITE +#define CL_GRAY CL_BT_BLACK +#define CL_RED CL_BT_RED +#define CL_GREEN CL_BT_GREEN +#define CL_YELLOW CL_BT_YELLOW +#define CL_BLUE CL_BT_BLUE +#define CL_MAGENTA CL_BT_MAGENTA +#define CL_CYAN CL_BT_CYAN -#define CL_SPACE " " // space equivalent of the print messages +#define CL_SPACE " " // space aquivalent of the print messages enum msg_type { MSG_NONE, @@ -88,35 +81,48 @@ enum msg_type { MSG_FATALERROR }; +struct showmsg_interface { + bool stdout_with_ansisequence; //If the color ANSI sequences are to be used. [flaviojs] + int silent; //Specifies how silent the console is. [Skotlex] + int console_log; //Specifies what error messages to log. [Ind] + char timestamp_format[20]; //For displaying Timestamps [Skotlex] + + void (*init) (void); + void (*final) (void); + + void (*clearScreen) (void); + int (*showMessageV) (const char *string, va_list ap); + + void (*showMessage) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showStatus) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showSQL) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showInfo) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showNotice) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showWarning) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showDebug) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showError) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showFatalError) (const char *, ...) __attribute__((format(printf, 1, 2))); + void (*showConfigWarning) (config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); +}; + +/* the purpose of these macros is simply to not make calling them be an annoyance */ +#define ClearScreen() (showmsg->clearScreen()) +#define vShowMessage(fmt, list) (showmsg->showMessageV((fmt), (list))) +#define ShowMessage(fmt, ...) (showmsg->showMessage((fmt), ##__VA_ARGS__)) +#define ShowStatus(fmt, ...) (showmsg->showStatus((fmt), ##__VA_ARGS__)) +#define ShowSQL(fmt, ...) (showmsg->showSQL((fmt), ##__VA_ARGS__)) +#define ShowInfo(fmt, ...) (showmsg->showInfo((fmt), ##__VA_ARGS__)) +#define ShowNotice(fmt, ...) (showmsg->showNotice((fmt), ##__VA_ARGS__)) +#define ShowWarning(fmt, ...) (showmsg->showWarning((fmt), ##__VA_ARGS__)) +#define ShowDebug(fmt, ...) (showmsg->showDebug((fmt), ##__VA_ARGS__)) +#define ShowError(fmt, ...) (showmsg->showError((fmt), ##__VA_ARGS__)) +#define ShowFatalError(fmt, ...) (showmsg->showFatalError((fmt), ##__VA_ARGS__)) +#define ShowConfigWarning(config, fmt, ...) (showmsg->showConfigWarning((config), (fmt), ##__VA_ARGS__)) + #ifdef HERCULES_CORE -extern int stdout_with_ansisequence; //If the color ANSI sequences are to be used. [flaviojs] -extern int msg_silent; //Specifies how silent the console is. [Skotlex] -extern int console_msg_log; //Specifies what error messages to log. [Ind] -extern char timestamp_format[20]; //For displaying Timestamps [Skotlex] - -extern void ClearScreen(void); -extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap); - - extern void ShowMessage(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowStatus(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowSQL(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowInfo(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowNotice(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowWarning(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowDebug(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowError(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowFatalError(const char *, ...) __attribute__((format(printf, 1, 2))); - extern void ShowConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); -#else - HPExport void (*ShowMessage) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowStatus) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowSQL) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowInfo) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowNotice) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowWarning) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowDebug) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowError) (const char *, ...) __attribute__((format(printf, 1, 2))); - HPExport void (*ShowFatalError) (const char *, ...) __attribute__((format(printf, 1, 2))); -#endif +void showmsg_defaults(void); +#endif // HERCULES_CORE + +HPShared struct showmsg_interface *showmsg; #endif /* COMMON_SHOWMSG_H */ |