mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 16:00:18 +00:00
Merge branch 'pluginreload'
This commit is contained in:
@@ -3498,6 +3498,39 @@ cmd_unload (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_reload (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
{
|
||||
#ifdef USE_PLUGIN
|
||||
int len, by_file = FALSE;
|
||||
|
||||
len = strlen (word[2]);
|
||||
#ifdef WIN32
|
||||
if (len > 4 && g_ascii_strcasecmp (word[2] + len - 4, ".dll") == 0)
|
||||
#else
|
||||
#if defined(__hpux)
|
||||
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".sl") == 0)
|
||||
#else
|
||||
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".so") == 0)
|
||||
#endif
|
||||
#endif
|
||||
by_file = TRUE;
|
||||
|
||||
switch (plugin_reload (sess, word[2], by_file))
|
||||
{
|
||||
case 0: /* error */
|
||||
PrintText (sess, _("No such plugin found.\n"));
|
||||
break;
|
||||
case 1: /* success */
|
||||
return TRUE;
|
||||
case 2: /* fake plugin, we know it exists but scripts should handle it. */
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static server *
|
||||
find_server_from_hostname (char *hostname)
|
||||
{
|
||||
@@ -3918,7 +3951,7 @@ const struct commands xc_cmds[] = {
|
||||
N_("RECONNECT [<host>] [<port>] [<password>], Can be called just as /RECONNECT to reconnect to the current server or with /RECONNECT ALL to reconnect to all the open servers")},
|
||||
#endif
|
||||
{"RECV", cmd_recv, 1, 0, 1, N_("RECV <text>, send raw data to HexChat, as if it was received from the IRC server")},
|
||||
|
||||
{"RELOAD", cmd_reload, 0, 0, 1, N_("RELOAD <name>, reloads a plugin or script")},
|
||||
{"SAY", cmd_say, 0, 0, 1,
|
||||
N_("SAY <text>, sends the text to the object in the current window")},
|
||||
{"SEND", cmd_send, 0, 0, 1, N_("SEND <nick> [<file>]")},
|
||||
|
||||
@@ -512,6 +512,44 @@ plugin_auto_load (session *sess)
|
||||
g_free (sub_dir);
|
||||
}
|
||||
|
||||
int
|
||||
plugin_reload (session *sess, char *name, int by_filename)
|
||||
{
|
||||
GSList *list;
|
||||
char *filename;
|
||||
char *ret;
|
||||
hexchat_plugin *pl;
|
||||
|
||||
list = plugin_list;
|
||||
while (list)
|
||||
{
|
||||
pl = list->data;
|
||||
/* static-plugins (plugin-timer.c) have a NULL filename */
|
||||
if ((by_filename && pl->filename && g_ascii_strcasecmp (name, pl->filename) == 0) ||
|
||||
(by_filename && pl->filename && g_ascii_strcasecmp (name, file_part (pl->filename)) == 0) ||
|
||||
(!by_filename && g_ascii_strcasecmp (name, pl->name) == 0))
|
||||
{
|
||||
/* statically linked plugins have a NULL filename */
|
||||
if (pl->filename != NULL && !pl->fake)
|
||||
{
|
||||
filename = g_strdup (pl->filename);
|
||||
plugin_free (pl, TRUE, FALSE);
|
||||
ret = plugin_load (sess, filename, NULL);
|
||||
g_free (filename);
|
||||
if (ret == NULL)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static GSList *
|
||||
|
||||
@@ -164,6 +164,7 @@ struct _hexchat_plugin
|
||||
#endif
|
||||
|
||||
char *plugin_load (session *sess, char *filename, char *arg);
|
||||
int plugin_reload (session *sess, char *name, int by_filename);
|
||||
void plugin_add (session *sess, char *filename, void *handle, void *init_func, void *deinit_func, char *arg, int fake);
|
||||
int plugin_kill (char *name, int by_filename);
|
||||
void plugin_kill_all (void);
|
||||
|
||||
Reference in New Issue
Block a user