diff options
author | Haru <haru@dotalux.com> | 2015-06-18 02:29:43 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-08-15 00:51:39 +0200 |
commit | 1f4d2c86b3d9ef894d77f7f47e0c2337fb17738b (patch) | |
tree | 08a9e7b2b4fee9b86cdf2f5ea19ead5e842ed79a /src/common/showmsg.h | |
parent | 2ce7edfe772c319756a9e4feb46f33b201ccfae5 (diff) | |
download | hercules-1f4d2c86b3d9ef894d77f7f47e0c2337fb17738b.tar.gz hercules-1f4d2c86b3d9ef894d77f7f47e0c2337fb17738b.tar.bz2 hercules-1f4d2c86b3d9ef894d77f7f47e0c2337fb17738b.tar.xz hercules-1f4d2c86b3d9ef894d77f7f47e0c2337fb17738b.zip |
Added showmsg HPM interface
- The showmsg interface is automatically imported into plugins by the
HPM (just like previously, the various Show* functions were). This
change requires no actions from plugin developers.
- stdout_with_ansisequence is now available through
showmsg->stdout_with_ansisequence
- msg_silent is now available through showmsg->silent
- console_msg_log is now available through showmsg->console_log
- timestamp_format is now available through showmsg->timestamp_format
- Plugin-safe macros are provided, so that all Show* and Clear* calls
will require no changes.
- vShowMessage is provided through the public API, as va_list variant
of ShowMessage.
- vShowMessage_ is no longer part of the public API. If necessary,
va_list variants of the other Show* functions will be added at a
later time as follow-ups.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/showmsg.h')
-rw-r--r-- | src/common/showmsg.h | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 63e42ab57..6b119a1ce 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -7,11 +7,7 @@ #include "common/cbasetypes.h" -#ifdef HERCULES_CORE -# include <libconfig/libconfig.h> -#else -# include "common/HPMi.h" -#endif +#include <libconfig/libconfig.h> #include <stdarg.h> @@ -85,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))); +}; + +struct showmsg_interface *showmsg; + +/* 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))); +void showmsg_defaults(void); #endif #endif /* COMMON_SHOWMSG_H */ |