int completion_list_add_infolists_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_hook *ptr_hook; /* make C compiler happy */ (void) data; (void) completion_item; (void) buffer; for (ptr_hook = weechat_hooks[HOOK_TYPE_INFOLIST]; ptr_hook; ptr_hook = ptr_hook->next_hook) { if (!ptr_hook->deleted && (HOOK_INFOLIST(ptr_hook, infolist_name)) && (HOOK_INFOLIST(ptr_hook, infolist_name)[0])) gui_completion_list_add (completion, HOOK_INFOLIST(ptr_hook, infolist_name), 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; }
void hook_infolist_print_log (struct t_hook *hook) { if (!hook || !hook->hook_data) return; log_printf (" infolist data:"); log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFOLIST(hook, callback)); log_printf (" infolist_name . . . . : '%s'", HOOK_INFOLIST(hook, infolist_name)); log_printf (" description . . . . . : '%s'", HOOK_INFOLIST(hook, description)); log_printf (" pointer_description . : '%s'", HOOK_INFOLIST(hook, pointer_description)); log_printf (" args_description. . . : '%s'", HOOK_INFOLIST(hook, args_description)); }
struct t_infolist * hook_infolist_get (struct t_weechat_plugin *plugin, const char *infolist_name, void *pointer, const char *arguments) { struct t_hook *ptr_hook, *next_hook; struct t_infolist *value; /* make C compiler happy */ (void) plugin; if (!infolist_name || !infolist_name[0]) return NULL; hook_exec_start (); ptr_hook = weechat_hooks[HOOK_TYPE_INFOLIST]; while (ptr_hook) { next_hook = ptr_hook->next_hook; if (!ptr_hook->deleted && !ptr_hook->running && (string_strcasecmp (HOOK_INFOLIST(ptr_hook, infolist_name), infolist_name) == 0)) { ptr_hook->running = 1; value = (HOOK_INFOLIST(ptr_hook, callback)) (ptr_hook->callback_pointer, ptr_hook->callback_data, infolist_name, pointer, arguments); ptr_hook->running = 0; hook_exec_end (); return value; } ptr_hook = next_hook; } hook_exec_end (); /* infolist not found */ return NULL; }
int hook_infolist_add_to_infolist (struct t_infolist_item *item, struct t_hook *hook) { if (!item || !hook || !hook->hook_data) return 0; if (!infolist_new_var_pointer (item, "callback", HOOK_INFOLIST(hook, callback))) return 0; if (!infolist_new_var_string (item, "infolist_name", HOOK_INFOLIST(hook, infolist_name))) return 0; if (!infolist_new_var_string (item, "description", HOOK_INFOLIST(hook, description))) return 0; if (!infolist_new_var_string (item, "description_nls", (HOOK_INFOLIST(hook, description) && HOOK_INFOLIST(hook, description)[0]) ? _(HOOK_INFOLIST(hook, description)) : "")) return 0; if (!infolist_new_var_string (item, "pointer_description", HOOK_INFOLIST(hook, pointer_description))) return 0; if (!infolist_new_var_string (item, "pointer_description_nls", (HOOK_INFOLIST(hook, pointer_description) && HOOK_INFOLIST(hook, pointer_description)[0]) ? _(HOOK_INFOLIST(hook, pointer_description)) : "")) return 0; if (!infolist_new_var_string (item, "args_description", HOOK_INFOLIST(hook, args_description))) return 0; if (!infolist_new_var_string (item, "args_description_nls", (HOOK_INFOLIST(hook, args_description) && HOOK_INFOLIST(hook, args_description)[0]) ? _(HOOK_INFOLIST(hook, args_description)) : "")) return 0; return 1; }
void hook_infolist_free_data (struct t_hook *hook) { if (!hook || !hook->hook_data) return; if (HOOK_INFOLIST(hook, infolist_name)) { free (HOOK_INFOLIST(hook, infolist_name)); HOOK_INFOLIST(hook, infolist_name) = NULL; } if (HOOK_INFOLIST(hook, description)) { free (HOOK_INFOLIST(hook, description)); HOOK_INFOLIST(hook, description) = NULL; } if (HOOK_INFOLIST(hook, pointer_description)) { free (HOOK_INFOLIST(hook, pointer_description)); HOOK_INFOLIST(hook, pointer_description) = NULL; } if (HOOK_INFOLIST(hook, args_description)) { free (HOOK_INFOLIST(hook, args_description)); HOOK_INFOLIST(hook, args_description) = NULL; } free (hook->hook_data); hook->hook_data = NULL; }