Merge pull request #540 from LemonBoy/reset-autorun

/script reset can now also run the autorun scripts
This commit is contained in:
ailin-nemui 2016-09-19 22:14:57 +02:00 committed by GitHub
commit b3c6cdbb91
4 changed files with 18 additions and 1 deletions

View file

@ -12,6 +12,8 @@
RESET: Unloads all the scripts. RESET: Unloads all the scripts.
-permanent: In combination with EXEC, the code will be loaded into the -permanent: In combination with EXEC, the code will be loaded into the
memory. memory.
-autorun: When passed to RESET the scripts in the autorun folder are
reloaded.
If no argument is given, the list of active scripts will be displayed. If no argument is given, the list of active scripts will be displayed.

View file

@ -393,7 +393,7 @@ int perl_get_api_version(void)
return IRSSI_PERL_API_VERSION; return IRSSI_PERL_API_VERSION;
} }
static void perl_scripts_autorun(void) void perl_scripts_autorun(void)
{ {
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;

View file

@ -16,6 +16,8 @@ extern GSList *perl_scripts;
void perl_scripts_init(void); void perl_scripts_init(void);
/* Destroy all perl scripts and deinitialize perl interpreter */ /* Destroy all perl scripts and deinitialize perl interpreter */
void perl_scripts_deinit(void); void perl_scripts_deinit(void);
/* Load all the scripts in the autorun/ folder */
void perl_scripts_autorun(void);
/* Load a perl script, path must be a full path. */ /* Load a perl script, path must be a full path. */
PERL_SCRIPT_REC *perl_script_load_file(const char *path); PERL_SCRIPT_REC *perl_script_load_file(const char *path);

View file

@ -119,8 +119,20 @@ static void cmd_script_unload(const char *data)
static void cmd_script_reset(const char *data) static void cmd_script_reset(const char *data)
{ {
void *free_arg;
GHashTable *optlist;
if (!cmd_get_params(data, &free_arg, 0 | PARAM_FLAG_OPTIONS,
"script reset", &optlist))
return;
perl_scripts_deinit(); perl_scripts_deinit();
perl_scripts_init(); perl_scripts_init();
if (g_hash_table_lookup(optlist, "autorun") != NULL)
perl_scripts_autorun();
cmd_params_free(free_arg);
} }
static void cmd_script_list(void) static void cmd_script_list(void)
@ -251,6 +263,7 @@ void fe_perl_init(void)
command_bind("script list", NULL, (SIGNAL_FUNC) cmd_script_list); command_bind("script list", NULL, (SIGNAL_FUNC) cmd_script_list);
command_bind("load", NULL, (SIGNAL_FUNC) cmd_load); command_bind("load", NULL, (SIGNAL_FUNC) cmd_load);
command_set_options("script exec", "permanent"); command_set_options("script exec", "permanent");
command_set_options("script reset", "autorun");
signal_add("script error", (SIGNAL_FUNC) sig_script_error); signal_add("script error", (SIGNAL_FUNC) sig_script_error);
signal_add("complete command script load", (SIGNAL_FUNC) sig_complete_load); signal_add("complete command script load", (SIGNAL_FUNC) sig_complete_load);