From ab878900afdb9c9caa58b7f84f0a12b6283edf2b Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 11 Mar 2014 04:19:59 +0100 Subject: Added --load-plugin commandline argument Signed-off-by: Haru --- src/map/map.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index a7e83cae3..b2d50292e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5356,6 +5356,7 @@ void map_helpscreen(bool do_exit) ShowInfo(" --inter-config Alternative inter-server configuration.\n"); ShowInfo(" --log-config Alternative logging configuration.\n"); ShowInfo(" --script-check Tests a script for errors, without running the server.\n"); + ShowInfo(" --load-plugin Loads an additional plugin (can be repeated).\n"); HPM->arg_help();/* display help for commands implemented thru HPM */ if( do_exit ) exit(EXIT_SUCCESS); @@ -5566,7 +5567,8 @@ int do_init(int argc, char *argv[]) { bool minimal = false; char *scriptcheck = NULL; - int i; + int i, extra_plugins_count = 0; + const char **extra_plugins = NULL; #ifdef GCOLLECT GC_enable_incremental(); @@ -5579,7 +5581,21 @@ int do_init(int argc, char *argv[]) HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; HPM->grabHPDataSub = HPM_map_grabHPData; - HPM->config_read(); + for( i = 1; i < argc; i++ ) { + const char* arg = argv[i]; + if( strcmp(arg, "--load-plugin") == 0 ) { + if( map->arg_next_value(arg, i, argc, true) ) { + RECREATE(extra_plugins, const char *, ++extra_plugins_count); + extra_plugins[extra_plugins_count-1] = argv[++i]; + } + } + } + HPM->config_read(extra_plugins, extra_plugins_count); + if (extra_plugins) { + aFree(extra_plugins); + extra_plugins = NULL; + extra_plugins_count = 0; + } HPM->event(HPET_PRE_INIT); @@ -5629,6 +5645,9 @@ int do_init(int argc, char *argv[]) runflag = CORE_ST_STOP; if( map->arg_next_value(arg, i, argc, true) ) scriptcheck = argv[++i]; + } else if( strcmp(arg, "load-plugin") == 0 ) { + if( map->arg_next_value(arg, i, argc, true) ) + i++; } else { ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); -- cgit v1.2.3-60-g2f50