From 581ff22b9bad7567a27980df31636f0c75ba5fc2 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 9 May 2014 06:20:52 +0200 Subject: Added support to return a different exit status to the OS. - This can be easily used by plugins. - See an example at http://github.com/HerculesWS/StaffPlugins/Haru/script_mapquit Signed-off-by: Haru --- src/char/char.c | 3 ++- src/common/core.c | 5 +++-- src/common/core.h | 2 +- src/login/login.c | 4 ++-- src/map/map.c | 5 +++-- src/map/map.h | 1 + 6 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index cf961fd93..77e393c0d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -5336,7 +5336,7 @@ int char_config_read(const char* cfgName) return 0; } -void do_final(void) { +int do_final(void) { int i; ShowStatus("Terminating...\n"); @@ -5373,6 +5373,7 @@ void do_final(void) { aFree(server[i].map); ShowStatus("Finished.\n"); + return EXIT_SUCCESS; } //------------------------------ diff --git a/src/common/core.c b/src/common/core.c index 798c832f0..49b272488 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -183,6 +183,7 @@ void core_defaults(void) { * CORE : MAINROUTINE *--------------------------------------*/ int main (int argc, char **argv) { + int retval = EXIT_SUCCESS; {// initialize program arguments char *p1 = SERVER_NAME = argv[0]; char *p2 = p1; @@ -253,7 +254,7 @@ int main (int argc, char **argv) { console->final(); - do_final(); + retval = do_final(); HPM->final(); timer->final(); sockt->final(); @@ -265,5 +266,5 @@ int main (int argc, char **argv) { iMalloc->final(); - return 0; + return retval; } diff --git a/src/common/core.h b/src/common/core.h index 5c2f2c9a5..e9f7c5961 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -35,7 +35,7 @@ enum server_types SERVER_TYPE; extern int do_init(int,char**); extern void set_server_type(void); extern void do_abort(void); -extern void do_final(void); +extern int do_final(void); /// The main loop continues until runflag is CORE_ST_STOP enum E_CORE_ST { diff --git a/src/login/login.c b/src/login/login.c index cb30de2f3..af59fcf38 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1689,8 +1689,7 @@ int login_config_read(const char* cfgName) //-------------------------------------- // Function called at exit of the server //-------------------------------------- -void do_final(void) -{ +int do_final(void) { int i; struct client_hash_node *hn = login_config.client_hash_nodes; @@ -1730,6 +1729,7 @@ void do_final(void) } ShowStatus("Finished.\n"); + return EXIT_SUCCESS; } //------------------------------ diff --git a/src/map/map.c b/src/map/map.c index d8663fb70..a5ec6d83b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5228,8 +5228,7 @@ int cleanup_db_sub(DBKey key, DBData *data, va_list va) { /*========================================== * map destructor *------------------------------------------*/ -void do_final(void) -{ +int do_final(void) { int i; struct map_session_data* sd; struct s_mapiterator* iter; @@ -5324,6 +5323,7 @@ void do_final(void) HPM->event(HPET_POST_FINAL); ShowStatus("Finished.\n"); + return map->retval; } int map_abort_sub(struct map_session_data* sd, va_list ap) { @@ -5865,6 +5865,7 @@ void map_defaults(void) { /* */ map->minimal = false; map->count = 0; + map->retval = EXIT_SUCCESS; sprintf(map->db_path ,"db"); sprintf(map->help_txt ,"conf/help.txt"); diff --git a/src/map/map.h b/src/map/map.h index 7373b516d..6b2e9d909 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -805,6 +805,7 @@ struct map_interface { /* vars */ bool minimal; + int retval; int count; int autosave_interval; -- cgit v1.2.3-70-g09d2