summaryrefslogtreecommitdiff
path: root/src/common/showmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/showmsg.c')
-rw-r--r--src/common/showmsg.c87
1 files changed, 45 insertions, 42 deletions
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 14342fe5e..b9bcef9b2 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -2,23 +2,26 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#include "../common/cbasetypes.h"
-#include "../common/strlib.h" // StringBuf
+#define HERCULES_CORE
+
#include "showmsg.h"
-#include "core.h" //[Ind] - For SERVER_TYPE
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h> // atexit
#include <string.h>
-#include <stdarg.h>
#include <time.h>
-#include <stdlib.h> // atexit
#include "../../3rdparty/libconfig/libconfig.h"
+#include "../common/cbasetypes.h"
+#include "../common/core.h" //[Ind] - For SERVER_TYPE
+#include "../common/strlib.h" // StringBuf
+
#ifdef WIN32
-#include "../common/winapi.h"
+# include "../common/winapi.h"
#else // not WIN32
-#include <unistd.h>
+# include <unistd.h>
#endif // WIN32
#if defined(DEBUGLOGMAP)
@@ -85,10 +88,10 @@ int console_msg_log = 0;//[Ind] msg error logging
// XXX adapted from eApp (comments are left untouched) [flaviojs]
///////////////////////////////////////////////////////////////////////////////
-// ansi compatible printf with control sequence parser for windows
+// ANSI compatible printf with control sequence parser for windows
// fast hack, handle with care, not everything implemented
//
-// \033[#;...;#m - Set Graphics Rendition (SGR)
+// \033[#;...;#m - Set Graphics Rendition (SGR)
//
// printf("\x1b[1;31;40m"); // Bright red on black
// printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented)
@@ -107,19 +110,19 @@ int console_msg_log = 0;//[Ind] msg error logging
// 8 - Concealed (invisible)
//
// \033[#A - Cursor Up (CUU)
-// Moves the cursor up by the specified number of lines without changing columns.
+// Moves the cursor up by the specified number of lines without changing columns.
// If the cursor is already on the top line, this sequence is ignored. \e[A is equivalent to \e[1A.
//
// \033[#B - Cursor Down (CUD)
-// Moves the cursor down by the specified number of lines without changing columns.
+// Moves the cursor down by the specified number of lines without changing columns.
// If the cursor is already on the bottom line, this sequence is ignored. \e[B is equivalent to \e[1B.
//
// \033[#C - Cursor Forward (CUF)
-// Moves the cursor forward by the specified number of columns without changing lines.
+// Moves the cursor forward by the specified number of columns without changing lines.
// If the cursor is already in the rightmost column, this sequence is ignored. \e[C is equivalent to \e[1C.
//
// \033[#D - Cursor Backward (CUB)
-// Moves the cursor back by the specified number of columns without changing lines.
+// Moves the cursor back by the specified number of columns without changing lines.
// If the cursor is already in the leftmost column, this sequence is ignored. \e[D is equivalent to \e[1D.
//
// \033[#E - Cursor Next Line (CNL)
@@ -132,19 +135,19 @@ int console_msg_log = 0;//[Ind] msg error logging
// Moves the cursor to indicated column in current row. \e[G is equivalent to \e[1G.
//
// \033[#;#H - Cursor Position (CUP)
-// Moves the cursor to the specified position. The first # specifies the line number,
-// the second # specifies the column. If you do not specify a position, the cursor moves to the home position:
+// Moves the cursor to the specified position. The first # specifies the line number,
+// the second # specifies the column. If you do not specify a position, the cursor moves to the home position:
// the upper-left corner of the screen (line 1, column 1).
//
// \033[#;#f - Horizontal & Vertical Position
// (same as \033[#;#H)
//
// \033[s - Save Cursor Position (SCP)
-// The current cursor position is saved.
+// The current cursor position is saved.
//
// \033[u - Restore cursor position (RCP)
// Restores the cursor position saved with the (SCP) sequence \033[s.
-// (addition, restore to 0,0 if nothinh was saved before)
+// (addition, restore to 0,0 if nothing was saved before)
//
// \033[#J - Erase Display (ED)
@@ -210,7 +213,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
WriteFile(handle, p, (DWORD)(q-p), &written, 0);
if( q[1]!='[' )
- { // write the escape char (whatever purpose it has)
+ { // write the escape char (whatever purpose it has)
if(0==WriteConsole(handle, q, 1, &written, 0) )
WriteFile(handle,q, 1, &written, 0);
p=q+1; //and start searching again
@@ -230,7 +233,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
q=q+2;
for(;;)
{
- if( ISDIGIT(*q) )
+ if( ISDIGIT(*q) )
{ // add number to number array, only accept 2digits, shift out the rest
// so // \033[123456789m will become \033[89m
numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0');
@@ -279,7 +282,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
}
//case '2': // not existing
//case '3': // blinking (not implemented)
- //case '4': // unterline (not implemented)
+ //case '4': // underline (not implemented)
//case '6': // not existing
//case '8': // concealed (not implemented)
//case '9': // not existing
@@ -347,12 +350,12 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
else if(num==2)
{ // Number of chars on screen.
cnt = info.dwSize.X * info.dwSize.Y;
- SetConsoleCursorPosition(handle, origin);
+ SetConsoleCursorPosition(handle, origin);
}
else// 0 and default
{ // number of chars from cursor to end
origin = info.dwCursorPosition;
- cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X;
+ cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X;
}
FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp);
FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp);
@@ -386,7 +389,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
else if( *q == 'H' || *q == 'f' )
{ // \033[#;#H - Cursor Position (CUP)
// \033[#;#f - Horizontal & Vertical Position
- // The first # specifies the line number, the second # specifies the column.
+ // The first # specifies the line number, the second # specifies the column.
// The default for both is 1
info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0;
info.dwCursorPosition.Y = (numpoint && numbers[numpoint-1])?(numbers[numpoint-1]>>4)*10+((numbers[numpoint-1]&0x0F)-1):0;
@@ -483,7 +486,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
--q;
}
// skip the sequencer and search again
- p = q+1;
+ p = q+1;
break;
}// end while
}
@@ -539,7 +542,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
{ // find the escape character
fprintf(file, "%.*s", (int)(q-p), p); // write up to the escape
if( q[1]!='[' )
- { // write the escape char (whatever purpose it has)
+ { // write the escape char (whatever purpose it has)
fprintf(file, "%.*s", 1, q);
p=q+1; //and start searching again
}
@@ -552,7 +555,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
q=q+2;
while(1)
{
- if( ISDIGIT(*q) )
+ if( ISDIGIT(*q) )
{
++q;
// and next character
@@ -621,7 +624,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
--q;
}
// skip the sequencer and search again
- p = q+1;
+ p = q+1;
break;
}// end while
}
@@ -651,7 +654,7 @@ int FPRINTF(FILE *file, const char *fmt, ...)
char timestamp_format[20] = ""; //For displaying Timestamps
-int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
+int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
{
va_list apcopy;
char prefix[100];
@@ -660,7 +663,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
#endif
if (!string || *string == '\0') {
- ShowError("Empty string passed to _vShowMessage().\n");
+ ShowError("Empty string passed to vShowMessage_().\n");
return 1;
}
if(
@@ -731,7 +734,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
strcat(prefix,CL_RED"[Fatal Error]"CL_RESET":");
break;
default:
- ShowError("In function _vShowMessage() -> Invalid flag passed.\n");
+ ShowError("In function vShowMessage_() -> Invalid flag passed.\n");
return 1;
}
@@ -779,12 +782,12 @@ void ClearScreen(void)
ShowMessage(CL_CLS); // to prevent empty string passed messages
#endif
}
-int _ShowMessage(enum msg_type flag, const char *string, ...)
+int ShowMessage_(enum msg_type flag, const char *string, ...)
{
int ret;
va_list ap;
va_start(ap, string);
- ret = _vShowMessage(flag, string, ap);
+ ret = vShowMessage_(flag, string, ap);
va_end(ap);
return ret;
}
@@ -793,37 +796,37 @@ int _ShowMessage(enum msg_type flag, const char *string, ...)
void ShowMessage(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_NONE, string, ap);
+ vShowMessage_(MSG_NONE, string, ap);
va_end(ap);
}
void ShowStatus(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_STATUS, string, ap);
+ vShowMessage_(MSG_STATUS, string, ap);
va_end(ap);
}
void ShowSQL(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_SQL, string, ap);
+ vShowMessage_(MSG_SQL, string, ap);
va_end(ap);
}
void ShowInfo(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_INFORMATION, string, ap);
+ vShowMessage_(MSG_INFORMATION, string, ap);
va_end(ap);
}
void ShowNotice(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_NOTICE, string, ap);
+ vShowMessage_(MSG_NOTICE, string, ap);
va_end(ap);
}
void ShowWarning(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_WARNING, string, ap);
+ vShowMessage_(MSG_WARNING, string, ap);
va_end(ap);
}
void ShowConfigWarning(config_setting_t *config, const char *string, ...)
@@ -834,25 +837,25 @@ void ShowConfigWarning(config_setting_t *config, const char *string, ...)
StrBuf->AppendStr(&buf, string);
StrBuf->Printf(&buf, " (%s:%d)\n", config_setting_source_file(config), config_setting_source_line(config));
va_start(ap, string);
- _vShowMessage(MSG_WARNING, StrBuf->Value(&buf), ap);
+ vShowMessage_(MSG_WARNING, StrBuf->Value(&buf), ap);
va_end(ap);
StrBuf->Destroy(&buf);
}
void ShowDebug(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_DEBUG, string, ap);
+ vShowMessage_(MSG_DEBUG, string, ap);
va_end(ap);
}
void ShowError(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_ERROR, string, ap);
+ vShowMessage_(MSG_ERROR, string, ap);
va_end(ap);
}
void ShowFatalError(const char *string, ...) {
va_list ap;
va_start(ap, string);
- _vShowMessage(MSG_FATALERROR, string, ap);
+ vShowMessage_(MSG_FATALERROR, string, ap);
va_end(ap);
}