summaryrefslogtreecommitdiff
path: root/src/common/HPM.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-11-09 02:07:09 +0100
committerHaru <haru@dotalux.com>2015-01-18 21:35:36 +0100
commitce08d6238d902590dbfb650f889a8ab8887356bf (patch)
tree218266957f961e71a51a307b432b02ed9647243a /src/common/HPM.h
parent0285ddf7cee2f6569a513fe6118c43f99fd71279 (diff)
downloadhercules-ce08d6238d902590dbfb650f889a8ab8887356bf.tar.gz
hercules-ce08d6238d902590dbfb650f889a8ab8887356bf.tar.bz2
hercules-ce08d6238d902590dbfb650f889a8ab8887356bf.tar.xz
hercules-ce08d6238d902590dbfb650f889a8ab8887356bf.zip
Command line arguments handling overhaul
- login_server, char_server, map_server as well as the tools (mapcache) now have a common command line arguments handling mechanism. - All of them now accept `--help` (`-h`), `--version` (`-v`) and `--load-plugin`. - login_server now accepts `--login-config` and `--lan-config` instead of relying on positional arguments to override those files. The old syntax will no longer work, please update your custom startup scripts. - char_server now accepts `--char-config`, `--inter-config`, `--lan-config` instead of relying on positional arguments. The old syntax will no longer work, please update your custom startup scripts. - mapcache now accepts `--grf-list`, `--map-list`, `--map-cache`, `--rebuild` in place of, respectively, `-grf`, `-list`, `-cache`, `-rebuild`. - A new macro `CMDLINEARG()` is provided, to help defining new command line argument handlers (i.e. in plugins). the `addArg()` call is still required, but its syntax has changed. The `help` argument is now of type `const char *` rather than a function pointer, and it is supposed to contain the message to show in the `--help` screen. Pass `NULL` if no help message is desired. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/HPM.h')
-rw-r--r--src/common/HPM.h20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/common/HPM.h b/src/common/HPM.h
index 973bc6cca..e99b0f2ae 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -82,14 +82,6 @@ struct HPMFileNameCache {
char *name;
};
-struct HPMArgData {
- unsigned int pluginID;
- char *name;/* e.g. "--my-arg","-v","--whatever" */
- void (*help) (void);/* to display when --help is used */
- void (*func) (char *param);/* NULL when no param is available */
- bool has_param;/* because of the weird "--arg<space>param" instead of the "--arg=param" */
-};
-
struct HPDataOperationStorage {
void **HPDataSRCPtr;
unsigned int *hdatac;
@@ -123,8 +115,9 @@ struct HPM_interface {
/* config listen */
struct HPConfListenStorage *confs[HPCT_MAX];
unsigned int confsc[HPCT_MAX];
- /* --command-line */
- DBMap *arg_db;
+ /** Plugins requested through the command line */
+ char **cmdline_plugins;
+ int cmdline_plugins_count;
/* funcs */
void (*init) (void);
void (*final) (void);
@@ -137,16 +130,13 @@ struct HPM_interface {
void *(*import_symbol) (char *name, unsigned int pID);
void (*share) (void *, char *);
void (*symbol_defaults) (void);
- void (*config_read) (const char * const *extra_plugins, int extra_plugins_count);
+ void (*config_read) (void);
bool (*populate) (struct hplugin *plugin,const char *filename);
void (*symbol_defaults_sub) (void);//TODO drop
char *(*pid2name) (unsigned int pid);
unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point);
void (*load_sub) (struct hplugin *plugin);
bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID);
- bool (*parse_arg) (const char *arg, int* index, char *argv[], bool param);
- void (*arg_help) (void);
- int (*arg_db_clear_sub) (DBKey key, DBData *data, va_list args);
void (*grabHPData) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
/* for server-specific HPData e.g. map_session_data */
bool (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
@@ -158,6 +148,8 @@ struct HPM_interface {
void (*datacheck_final) (void);
};
+CMDLINEARG(loadplugin);
+
struct HPM_interface *HPM;
void hpm_defaults(void);