From 26bf6b6dacd8029a1ed48255518a78dfb11b4ce4 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 4 Apr 2005 18:06:30 +0000 Subject: * Updated showmsg with Shinomori's improvements git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1404 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/showmsg.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/common/showmsg.c') diff --git a/src/common/showmsg.c b/src/common/showmsg.c index da21ad1e6..9901af81b 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -1,25 +1,22 @@ #include -#include #include #include #include "showmsg.h" -#include "malloc.h" char tmp_output[1024] = {"\0"}; #undef ShowMessage +// by MC Cameri int _vShowMessage(enum msg_type flag, const char *string, va_list ap) -{ // by MC Cameri - /* - _ShowMessage MUST be used instead of printf as of 10/24/2004. - Return: 0 = Successful, 1 = Failed. - */ +{ + // _ShowMessage MUST be used instead of printf as of 10/24/2004. + // Return: 0 = Successful, 1 = Failed. // int ret = 0; +// char *output; char prefix[40]; - char *output; - if (strlen(string) <= 0) { + if (!string || strlen(string) <= 0) { printf("Empty string passed to _ShowMessage().\n"); return 1; } @@ -49,11 +46,12 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) strcpy(prefix,CL_RED"[Fatal Error]"CL_RESET":"); break; default: - printf("In function _ShowMessage() -> Invalid flag passed.\n"); + printf("In function _ShowMessage() -> Invalid flag passed.\n"); return 1; } if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) + +/* output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) if (output == NULL) { return 1; // exit(1); // Kill server? Deadly @@ -64,7 +62,11 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) strcat(output,string); vprintf(output, ap); fflush(stdout); - aFree(output); + aFree(output);*/ + + printf ("%s ", prefix); + vprintf (string, ap); + fflush (stdout); } va_end(ap); @@ -86,7 +88,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) return 0; } -int _ShowMessage(enum msg_type flag, const char *string, ...) +int _ShowMessage(enum msg_type flag, const char *string, ...) { va_list ap; -- cgit v1.2.3-60-g2f50