summaryrefslogtreecommitdiff
path: root/src/char_sql/char.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-08 08:35:32 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-08 08:35:32 +0000
commit4e5a65295ad732fd53630d8c29912ec047038d9d (patch)
tree863815cddc095c55fa3c7645e4c52cffc9e744b9 /src/char_sql/char.c
parent8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc (diff)
downloadhercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.gz
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.bz2
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.xz
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.zip
- Added a precompiler error when the shutdown defines are not found.
- Added parse_console to the plugin API. - Added plugin for parsing the console. (working with cygwin) - Added the console plugin to plugin_athena.conf commented out. - Copied the parse_console code form login txt to login sql and char. - Added propper plugin version compatibility tests. - Better output when a plugin fails to load. ----- The console plugin (at it's 3rd version) uses two pipes and another thread. - the other thread reads data from stdin and sends it through one of the pipes - the other pipe serves as semaphore (and terminator) to that thread - the normal thread checks if the pipe has data once every timer cycle, if data is found it invokes parse_console with that data Worth noting: the first version didn't use another thread and just checked if data was available on the input stream, but apparently that can't be done to standard input in windows It's only been tested on cygwin (and should work on most *nix systems), can't test native windows right now because I'm having trouble exporting the required plugin variables in VS8 src/plugins/Makefile hasn't been updated because it's not working properly for me git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9631 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/char.c')
-rw-r--r--src/char_sql/char.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 4851fbaca..2cf237317 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -3648,27 +3648,33 @@ int parse_char(int fd) {
}
// Console Command Parser [Wizputer]
-int parse_console(char *buf) {
- char *type,*command;
-
- type = (char *)aMalloc(64);
- command = (char *)aMalloc(64);
-
- memset(type,0,64);
- memset(command,0,64);
-
- ShowNotice("Console: %s\n",buf);
-
- if ( sscanf(buf, "%[^:]:%[^\n]", type , command ) < 2 )
- sscanf(buf,"%[^\n]",type);
-
- ShowNotice("Type of command: %s || Command: %s \n",type,command);
-
- if(buf) aFree(buf);
- if(type) aFree(type);
- if(command) aFree(command);
+int parse_console(char* buf)
+{
+ char command[256];
+
+ memset(command, 0, sizeof(command));
+
+ sscanf(buf, "%[^\n]", command);
+
+ //login_log("Console command :%s" RETCODE, command);
+
+ if( strcmpi("shutdown", command) == 0 ||
+ strcmpi("exit", command) == 0 ||
+ strcmpi("quit", command) == 0 ||
+ strcmpi("end", command) == 0 )
+ runflag = 0;
+ else if( strcmpi("alive", command) == 0 ||
+ strcmpi("status", command) == 0 )
+ ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
+ else if( strcmpi("help", command) == 0 ){
+ printf(CL_BOLD"Help of commands:"CL_RESET"\n");
+ printf(" To shutdown the server:\n");
+ printf(" 'shutdown|exit|qui|end'\n");
+ printf(" To know if server is alive:\n");
+ printf(" 'alive|status'\n");
+ }
- return 0;
+ return 0;
}
// MAP send all