Added the load() plugin function

This commit is contained in:
Scoopta 2020-03-13 17:08:35 -07:00
parent 60502adf83
commit 8d4a9e22b2
2 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,13 @@ Defining this function is required. This function is called to setup your plugin
.B struct map* config
\- all of the config options that the user defined for your mode. Information on how to access this can be found in \fBwofi\-map(3)\fR.
.TP
.B void load(struct mode* mode)
Defining this function is optional. This function is called before ALL others and provides your mode pointer as early as possible.
.B struct mode* mode
\- used to identify your mode, it is passed to a large number of the API functions to identify your mode.
.TP
.B const char** get_arg_names(void)
Defining this function is optional. This function is called to get an array of config options which can be set by the user. All of these options have the name of your mode prefixed on the front so if your array is for example \fB{"opt1", "opt2"}\fR the config options defined will be \fBmode-opt1=\fIvalue\fR and \fBmode-opt2=\fIvalue\fR where mode is the name of the shared object.

View File

@ -1192,12 +1192,14 @@ static void* load_mode(char* _mode, struct mode* mode_ptr, struct map* props) {
mode_ptr->name = strdup(_mode);
void (*init)(struct mode* _mode, struct map* props);
void (*load)(struct mode* _mode);
const char** (*get_arg_names)(void);
size_t (*get_arg_count)(void);
bool (*no_entry)(void);
if(dso == NULL) {
mode_ptr->dso = NULL;
init = get_plugin_proc(_mode, "_init");
load = get_plugin_proc(_mode, "_load");
get_arg_names = get_plugin_proc(_mode, "_get_arg_names");
get_arg_count = get_plugin_proc(_mode, "_get_arg_count");
mode_ptr->mode_exec = get_plugin_proc(_mode, "_exec");
@ -1211,6 +1213,7 @@ static void* load_mode(char* _mode, struct mode* mode_ptr, struct map* props) {
free(full_name);
free(plugins_dir);
init = dlsym(plugin, "init");
load = dlsym(plugin, "load");
get_arg_names = dlsym(plugin, "get_arg_names");
get_arg_count = dlsym(plugin, "get_arg_count");
mode_ptr->mode_exec = dlsym(plugin, "exec");
@ -1218,6 +1221,10 @@ static void* load_mode(char* _mode, struct mode* mode_ptr, struct map* props) {
no_entry = dlsym(plugin, "no_entry");
}
if(load != NULL) {
load(mode_ptr);
}
const char** arg_names = NULL;
size_t arg_count = 0;
if(get_arg_names != NULL && get_arg_count != NULL) {