int plugin_show_help(session *sess, char *cmd) { GSList *list; xchat_hook *hook; list = plugin_hook_find(hook_list, HOOK_COMMAND, cmd); if (list) { hook = (xchat_hook*)list->data; if (hook->help_text) { PrintText(sess, hook->help_text); return 1; } } return 0; }
static int plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[], hexchat_event_attrs *attrs, int type) { GSList *list, *next; hexchat_hook *hook; int ret, eat = 0; list = hook_list; while (1) { list = plugin_hook_find (list, type, name); if (!list) goto xit; hook = list->data; next = list->next; hook->pl->context = sess; /* run the plugin's callback function */ switch (hook->type) { case HOOK_COMMAND: ret = ((hexchat_cmd_cb *)hook->callback) (word, word_eol, hook->userdata); break; case HOOK_PRINT_ATTRS: ret = ((hexchat_print_attrs_cb *)hook->callback) (word, attrs, hook->userdata); break; case HOOK_SERVER: ret = ((hexchat_serv_cb *)hook->callback) (word, word_eol, hook->userdata); break; case HOOK_SERVER_ATTRS: ret = ((hexchat_serv_attrs_cb *)hook->callback) (word, word_eol, attrs, hook->userdata); break; default: /*case HOOK_PRINT:*/ ret = ((hexchat_print_cb *)hook->callback) (word, hook->userdata); break; } if ((ret & HEXCHAT_EAT_HEXCHAT) && (ret & HEXCHAT_EAT_PLUGIN)) { eat = 1; goto xit; } if (ret & HEXCHAT_EAT_PLUGIN) goto xit; /* stop running plugins */ if (ret & HEXCHAT_EAT_HEXCHAT) eat = 1; /* eventually we'll return 1, but continue running plugins */ list = next; } xit: /* really remove deleted hooks now */ list = hook_list; while (list) { hook = list->data; next = list->next; if (!hook || hook->type == HOOK_DELETED) { hook_list = g_slist_remove (hook_list, hook); g_free (hook); } list = next; } return eat; }
static int plugin_hook_run(session *sess, char *name, char *word[], char *word_eol[], int type) { GSList *list, *next; xchat_hook *hook; int ret, eat = 0; list = hook_list; while (1) { list = plugin_hook_find(list, type, name); if (!list) goto xit; hook = (xchat_hook*)list->data; next = list->next; hook->pl->context = sess; // run the plugin's callback function switch (type) { case HOOK_COMMAND: ret = ((xchat_cmd_cb*)hook->callback)(word, word_eol, hook->userdata); break; case HOOK_SERVER: ret = ((xchat_serv_cb*)hook->callback)(word, word_eol, hook->userdata); break; default: //case HOOK_PRINT: ret = ((xchat_print_cb*)hook->callback)(word, hook->userdata); break; } if ((ret & XCHAT_EAT_XCHAT) && (ret & XCHAT_EAT_PLUGIN)) { eat = 1; goto xit; } if (ret & XCHAT_EAT_PLUGIN) goto xit; // stop running plugins if (ret & XCHAT_EAT_XCHAT) eat = 1; // eventually we'll return 1, but continue running plugins list = next; } xit: // really remove deleted hooks now list = hook_list; while (list) { hook = (xchat_hook*)list->data; next = list->next; if (hook->type == HOOK_DELETED) { hook_list = g_slist_remove(hook_list, hook); free(hook); } list = next; } return eat; }