summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/GNUmakefile16
-rw-r--r--src/common/Makefile16
-rw-r--r--src/common/core.c25
-rw-r--r--src/common/showmsg.c8
-rw-r--r--src/common/showmsg.h26
5 files changed, 60 insertions, 31 deletions
diff --git a/src/common/GNUmakefile b/src/common/GNUmakefile
index d1a8ee0c6..b15d4d481 100644
--- a/src/common/GNUmakefile
+++ b/src/common/GNUmakefile
@@ -1,13 +1,13 @@
txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o
-core.o: core.c core.h
-socket.o: socket.c socket.h mmo.h
-timer.o: timer.c timer.h
-grfio.o: grfio.c grfio.h
-db.o: db.c db.h
-lock.o: lock.h
-nullpo.o: nullpo.c nullpo.h
-malloc.o: malloc.c malloc.h
+core.o: core.c core.h showmsg.h
+socket.o: socket.c socket.h mmo.h showmsg.h
+timer.o: timer.c timer.h showmsg.h
+grfio.o: grfio.c grfio.h showmsg.h
+db.o: db.c db.h showmsg.h
+lock.o: lock.h showmsg.h
+nullpo.o: nullpo.c nullpo.h showmsg.h
+malloc.o: malloc.c malloc.h showmsg.h
showmsg.o: showmsg.c showmsg.h
clean:
diff --git a/src/common/Makefile b/src/common/Makefile
index d1a8ee0c6..b15d4d481 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -1,13 +1,13 @@
txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o
-core.o: core.c core.h
-socket.o: socket.c socket.h mmo.h
-timer.o: timer.c timer.h
-grfio.o: grfio.c grfio.h
-db.o: db.c db.h
-lock.o: lock.h
-nullpo.o: nullpo.c nullpo.h
-malloc.o: malloc.c malloc.h
+core.o: core.c core.h showmsg.h
+socket.o: socket.c socket.h mmo.h showmsg.h
+timer.o: timer.c timer.h showmsg.h
+grfio.o: grfio.c grfio.h showmsg.h
+db.o: db.c db.h showmsg.h
+lock.o: lock.h showmsg.h
+nullpo.o: nullpo.c nullpo.h showmsg.h
+malloc.o: malloc.c malloc.h showmsg.h
showmsg.o: showmsg.c showmsg.h
clean:
diff --git a/src/common/core.c b/src/common/core.c
index 6bf68c47f..167b38efb 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -7,11 +7,13 @@
#include <unistd.h>
#endif
#include <signal.h>
+#include <string.h>
#include "core.h"
#include "socket.h"
#include "timer.h"
#include "version.h"
+#include "showmsg.h"
#ifdef MEMWATCH
#include "memwatch.h"
@@ -51,6 +53,23 @@ static void sig_proc(int sn)
}
}
+int get_svn_revision(char *svnentry) { // Warning: minor syntax checking
+ char line[1024];
+ int rev = 0;
+ FILE *fp;
+ if ((fp = fopen(svnentry, "r")) == NULL) {
+ return 0;
+ } else {
+ while (fgets(line,1023,fp)) if (strstr(line,"revision=")) break;
+ fclose(fp);
+ if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev)==1)
+ return rev;
+ else
+ return 0;
+ }
+// return 0;
+}
+
/*======================================
* CORE : Display title
*--------------------------------------
@@ -58,6 +77,7 @@ static void sig_proc(int sn)
static void display_title(void)
{
+ int revision;
// for help with the console colors look here:
// http://www.edoceo.com/liberum/?doc=printf-with-color
// some code explanation (used here):
@@ -82,6 +102,11 @@ static void display_title(void)
printf("\033[0;44m (\033[1m \033[0;44m)\033[K\033[0m\n"); // yellow writing (33)
printf("\033[0;44m (\033[1;33m Advanced Fusion Maps (c) 2003-2004 The Fusion Project \033[0;44m)\033[K\033[0m\n"); // yellow writing (33)
printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n\n"); // reset color
+
+ if ((revision = get_svn_revision(".svn\\entries"))>0) {
+ snprintf(tmp_output,sizeof(tmp_output),"SVN Revision: %d.\n",revision);
+ ShowInfo(tmp_output);
+ }
}
// Added by Gabuzomeu
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 28bf58edc..56c41b89d 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -3,7 +3,9 @@
#include <string.h>
#include "showmsg.h"
-int _ShowMessage(const char *string, int flag){ // by MC Cameri
+char tmp_output[1024] = "\0";
+
+int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri
/*
_ShowMessage MUST be used instead of printf as of 10/24/2004.
Return: 0 = Successful, 1 = Failed.
@@ -12,7 +14,7 @@ int _ShowMessage(const char *string, int flag){ // by MC Cameri
char prefix[40];
char *output;
if (strlen(string) <= 0) {
- ShowMessage("Empty string passed to ShowMessage().\n",MSG_ERROR);
+ ShowError("Empty string passed to ShowMessage().\n");
return 1;
}
switch (flag) {
@@ -40,7 +42,7 @@ int _ShowMessage(const char *string, int flag){ // by MC Cameri
strcpy(prefix,"\033[1;31m[Fatal Error]\033[0;0m: ");
break;
default:
- ShowMessage("In function ShowMessage() -> Invalid flag passed.\n",MSG_ERROR);
+ ShowError("In function _ShowMessage() -> Invalid flag passed.\n");
return 1;
}
output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string))+1);
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index 2389410b3..03ffe310b 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -1,14 +1,20 @@
#ifndef _SHOWMSG_H_
#define _SHOWMSG_H_
+extern char tmp_output[1024];
+
+enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR};
+
+extern int _ShowMessage(const char *string, enum msg_type flag);
+
/* MSG_XX */
#define ShowMsg(string,flag) _ShowMessage(string,flag)
- #define DisplayMsg(string,flag) _ShowMessage(string,flag)
- #define ShowMessage(string,flag) _ShowMessage(string,flag)
+// #define DisplayMsg(string,flag) _ShowMessage(string,flag)
+// #define ShowMessage(string,flag) _ShowMessage(string,flag)
/* MSG_STATUS */
#define ShowStatus(string) _ShowMessage(string,MSG_STATUS)
- #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS)
+// #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS)
/* MSG_SQL*/
// #define ShowSQL(string) _ShowMessage(string,MSG_SQL)
@@ -16,33 +22,29 @@
/* MSG_INFORMATION */
#define ShowInfo(string) _ShowMessage(string,MSG_INFORMATION)
- #define DisplayInfo(string) _ShowMessage(string,MSG_INFORMATION)
+// #define DisplayInfo(string) _ShowMessage(string,MSG_INFORMATION)
// #define ShowInformation(string) _ShowMessage(string,MSG_INFORMATION)
// #define DisplayInformation(string) _ShowMessage(string,MSG_INFORMATION)
/* MSG_NOTICE */
#define ShowNotice(string) _ShowMessage(string,MSG_NOTICE)
- #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE)
+// #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE)
/* */
#define ShowWarning(string) _ShowMessage(string,MSG_WARNING)
- #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING)
+// #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING)
// #define Warn(string) _ShowMessage(string,MSG_WARNING)
/* MSG_ERROR */
#define ShowError(string) _ShowMessage(string,MSG_ERROR)
- #define DisplayError(string) _ShowMessage(string,MSG_ERROR)
+// #define DisplayError(string) _ShowMessage(string,MSG_ERROR)
// #define OutputError(string) _ShowMessage(string,MSG_ERROR)
/* MSG_FATALERROR */
#define ShowFatalError(string) _ShowMessage(string,MSG_FATALERROR)
- #define DisplayFatalError(string) _ShowMessage(string,MSG_ERROR)
+// #define DisplayFatalError(string) _ShowMessage(string,MSG_ERROR)
// #define Terminate(string) _ShowMessage(string,MSG_FATALERROR)
// #define Kill(string) _ShowMessage(string,MSG_FATALERROR)
// #define AbortEx(string) _ShowMessage(string,MSG_FATALERROR)
-enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR};
-
-extern int _ShowMessage(const char *string, int flag);
-
#endif