void gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers, const char *plugin_name, const char *buffer_name, int *layout_number, int *layout_number_merge_order) { struct t_gui_layout_buffer *ptr_layout_buffer; int old_number, merge_order; *layout_number = 0; *layout_number_merge_order = 0; old_number = -1; merge_order = 0; for (ptr_layout_buffer = layout_buffers; ptr_layout_buffer; ptr_layout_buffer = ptr_layout_buffer->next_layout) { if (ptr_layout_buffer->number != old_number) { old_number = ptr_layout_buffer->number; merge_order = 0; } else merge_order++; if ((string_strcasecmp (ptr_layout_buffer->plugin_name, plugin_name) == 0) && (string_strcasecmp (ptr_layout_buffer->buffer_name, buffer_name) == 0)) { *layout_number = ptr_layout_buffer->number; *layout_number_merge_order = merge_order; return; } } }
int gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { /* make C compiler happy */ (void) data; if (string_strcasecmp (input_data, "e") == 0) { gui_color_buffer_extra_info ^= 1; gui_color_buffer_display (); } else if (string_strcasecmp (input_data, "r") == 0) { gui_color_buffer_display (); } else if (string_strcasecmp (input_data, "q") == 0) { gui_buffer_close (buffer); } else if (string_strcasecmp (input_data, "z") == 0) { gui_color_reset_pairs (); } return WEECHAT_RC_OK; }
void weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item, const char *where) { struct t_weelist_item *pos_item; if (!weelist || !item) return; if (weelist->items) { /* remove element if already in list */ pos_item = weelist_search (weelist, item->data); if (pos_item) weelist_remove (weelist, pos_item); } if (weelist->items) { /* search position for new element, according to pos asked */ pos_item = NULL; if (string_strcasecmp (where, WEECHAT_LIST_POS_BEGINNING) == 0) pos_item = weelist->items; else if (string_strcasecmp (where, WEECHAT_LIST_POS_END) == 0) pos_item = NULL; else pos_item = weelist_find_pos (weelist, item->data); if (pos_item) { /* insert data into the list (before position found) */ item->prev_item = pos_item->prev_item; item->next_item = pos_item; if (pos_item->prev_item) (pos_item->prev_item)->next_item = item; else weelist->items = item; pos_item->prev_item = item; } else { /* add data to the end */ item->prev_item = weelist->last_item; item->next_item = NULL; (weelist->last_item)->next_item = item; weelist->last_item = item; } } else { item->prev_item = NULL; item->next_item = NULL; weelist->items = item; weelist->last_item = item; } }
void gui_nicklist_nick_set (struct t_gui_buffer *buffer, struct t_gui_nick *nick, const char *property, const char *value) { long number; char *error; int nick_changed; if (!buffer || !nick || !property || !value) return; nick_changed = 0; if (string_strcasecmp (property, "color") == 0) { if (nick->color) string_shared_free (nick->color); nick->color = (value[0]) ? (char *)string_shared_get (value) : NULL; nick_changed = 1; } else if (string_strcasecmp (property, "prefix") == 0) { if (nick->prefix) string_shared_free (nick->prefix); nick->prefix = (value[0]) ? (char *)string_shared_get (value) : NULL; nick_changed = 1; } else if (string_strcasecmp (property, "prefix_color") == 0) { if (nick->prefix_color) string_shared_free (nick->prefix_color); nick->prefix_color = (value[0]) ? (char *)string_shared_get (value) : NULL; nick_changed = 1; } else if (string_strcasecmp (property, "visible") == 0) { error = NULL; number = strtol (value, &error, 10); if (error && !error[0]) nick->visible = (number) ? 1 : 0; nick_changed = 1; } if (nick_changed) { gui_nicklist_send_signal ("nicklist_nick_changed", buffer, nick->name); gui_nicklist_send_hsignal ("nicklist_nick_changed", buffer, NULL, nick); } }
const char * hdata_get_string (struct t_hdata *hdata, const char *property) { if (!hdata || !property) return NULL; if (string_strcasecmp (property, "var_keys") == 0) return hashtable_get_string (hdata->hash_var, "keys"); else if (string_strcasecmp (property, "var_values") == 0) return hashtable_get_string (hdata->hash_var, "values"); else if (string_strcasecmp (property, "var_keys_values") == 0) return hashtable_get_string (hdata->hash_var, "keys_values"); else if (string_strcasecmp (property, "var_prev") == 0) return hdata->var_prev; else if (string_strcasecmp (property, "var_next") == 0) return hdata->var_next; else if (string_strcasecmp (property, "list_keys") == 0) return hashtable_get_string (hdata->hash_list, "keys"); else if (string_strcasecmp (property, "list_values") == 0) return hashtable_get_string (hdata->hash_list, "values"); else if (string_strcasecmp (property, "list_keys_values") == 0) return hashtable_get_string (hdata->hash_list, "keys_values"); return NULL; }
const char * gui_color_search_config (const char *color_name) { struct t_config_option *ptr_option; if (color_name) { for (ptr_option = weechat_config_section_color->options; ptr_option; ptr_option = ptr_option->next_option) { if (string_strcasecmp (ptr_option->name, color_name) == 0) { if (ptr_option->min < 0) { return gui_color_get_custom ( gui_color_get_name (CONFIG_COLOR(ptr_option))); } return GUI_COLOR(ptr_option->min); } } } /* color not found */ return NULL; }
void * infolist_buffer (struct t_infolist *infolist, const char *var, int *size) { struct t_infolist_var *ptr_var; if (!infolist || !infolist->ptr_item || !var || !var[0]) return NULL; for (ptr_var = infolist->ptr_item->vars; ptr_var; ptr_var = ptr_var->next_var) { if (string_strcasecmp (ptr_var->name, var) == 0) { if (ptr_var->type == INFOLIST_BUFFER) { *size = ptr_var->size; return ptr_var->value; } else return NULL; } } /* variable not found */ return NULL; }
struct t_hook * gui_completion_search_command (struct t_weechat_plugin *plugin, const char *command) { struct t_hook *ptr_hook, *hook_for_other_plugin; hook_for_other_plugin = NULL; for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook; ptr_hook = ptr_hook->next_hook) { if (!ptr_hook->deleted && HOOK_COMMAND(ptr_hook, command) && HOOK_COMMAND(ptr_hook, command)[0] && (string_strcasecmp (HOOK_COMMAND(ptr_hook, command), command) == 0)) { if (ptr_hook->plugin == plugin) return ptr_hook; hook_for_other_plugin = ptr_hook; } } return hook_for_other_plugin; }
int gui_line_get_notify_level (struct t_gui_line *line) { int i; for (i = 0; i < line->data->tags_count; i++) { if (string_strcasecmp (line->data->tags_array[i], "notify_none") == 0) return -1; if (string_strcasecmp (line->data->tags_array[i], "notify_highlight") == 0) return GUI_HOTLIST_HIGHLIGHT; if (string_strcasecmp (line->data->tags_array[i], "notify_private") == 0) return GUI_HOTLIST_PRIVATE; if (string_strcasecmp (line->data->tags_array[i], "notify_message") == 0) return GUI_HOTLIST_MESSAGE; } return GUI_HOTLIST_LOW; }
int gui_nicklist_group_get_integer (struct t_gui_buffer *buffer, struct t_gui_nick_group *group, const char *property) { /* make C compiler happy */ (void) buffer; if (group && property) { if (string_strcasecmp (property, "visible") == 0) return group->visible; else if (string_strcasecmp (property, "level") == 0) return group->level; } return 0; }
const char * gui_nicklist_group_get_string (struct t_gui_buffer *buffer, struct t_gui_nick_group *group, const char *property) { /* make C compiler happy */ (void) buffer; if (group && property) { if (string_strcasecmp (property, "name") == 0) return group->name; else if (string_strcasecmp (property, "color") == 0) return group->color; } return NULL; }
int completion_list_add_plugins_commands_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { char *pos_space, *plugin_name; struct t_weechat_plugin *ptr_plugin; struct t_hook *ptr_hook; /* make C compiler happy */ (void) data; (void) completion_item; (void) buffer; if (completion->args) { pos_space = strchr (completion->args, ' '); if (pos_space) plugin_name = string_strndup (completion->args, pos_space - completion->args); else plugin_name = strdup (completion->args); if (plugin_name) { ptr_plugin = NULL; if (string_strcasecmp (plugin_name, PLUGIN_CORE) != 0) { /* * plugin name is different from "core", then search it in * plugin list */ ptr_plugin = plugin_search (plugin_name); if (!ptr_plugin) return WEECHAT_RC_OK; } for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook; ptr_hook = ptr_hook->next_hook) { if (!ptr_hook->deleted && (ptr_hook->plugin == ptr_plugin) && HOOK_COMMAND(ptr_hook, command) && HOOK_COMMAND(ptr_hook, command)[0]) { gui_completion_list_add (completion, HOOK_COMMAND(ptr_hook, command), 0, WEECHAT_LIST_POS_SORT); } } free (plugin_name); } } return WEECHAT_RC_OK; }
const char * plugin_api_prefix (const char *prefix) { if (!prefix) return gui_chat_prefix_empty; if (string_strcasecmp (prefix, "error") == 0) return gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]; if (string_strcasecmp (prefix, "network") == 0) return gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK]; if (string_strcasecmp (prefix, "action") == 0) return gui_chat_prefix[GUI_CHAT_PREFIX_ACTION]; if (string_strcasecmp (prefix, "join") == 0) return gui_chat_prefix[GUI_CHAT_PREFIX_JOIN]; if (string_strcasecmp (prefix, "quit") == 0) return gui_chat_prefix[GUI_CHAT_PREFIX_QUIT]; return gui_chat_prefix_empty; }
const char * gui_nicklist_nick_get_string (struct t_gui_buffer *buffer, struct t_gui_nick *nick, const char *property) { /* make C compiler happy */ (void) buffer; if (nick && property) { if (string_strcasecmp (property, "name") == 0) return nick->name; else if (string_strcasecmp (property, "color") == 0) return nick->color; else if (string_strcasecmp (property, "prefix") == 0) return nick->prefix; else if (string_strcasecmp (property, "prefix_color") == 0) return nick->prefix_color; } return NULL; }
int test_cmp_cb (void *data, struct t_arraylist *arraylist, void *pointer1, void *pointer2) { /* make C++ compiler happy */ (void) data; (void) arraylist; if (!pointer1 || !pointer2) return (pointer1) ? 1 : ((pointer2) ? -1 : 0); return string_strcasecmp ((const char *)pointer1, (const char *)pointer2); }
int secure_buffer_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { /* make C compiler happy */ (void) data; if (string_strcasecmp (input_data, "q") == 0) { gui_buffer_close (buffer); } return WEECHAT_RC_OK; }
int util_signal_search (const char *name) { int i; for (i = 0; util_signals[i].name; i++) { if (string_strcasecmp (util_signals[i].name, name) == 0) return util_signals[i].signal; } /* signal not found */ return -1; }
int gui_color_search (const char *color_name) { int i; for (i = 0; gui_weechat_colors[i].string; i++) { if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0) return i; } /* color not found */ return -1; }
int debug_dump_cb (void *data, const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ (void) data; (void) signal; (void) type_data; if (!signal_data || (string_strcasecmp ((char *)signal_data, "core") == 0)) debug_dump (0); return WEECHAT_RC_OK; }
void gui_nicklist_group_set (struct t_gui_buffer *buffer, struct t_gui_nick_group *group, const char *property, const char *value) { long number; char *error; int group_changed; if (!buffer || !group || !property || !value) return; group_changed = 0; if (string_strcasecmp (property, "color") == 0) { if (group->color) string_shared_free (group->color); group->color = (value[0]) ? (char *)string_shared_get (value) : NULL; group_changed = 1; } else if (string_strcasecmp (property, "visible") == 0) { error = NULL; number = strtol (value, &error, 10); if (error && !error[0]) group->visible = (number) ? 1 : 0; group_changed = 1; } if (group_changed) { gui_nicklist_send_signal ("nicklist_group_changed", buffer, group->name); gui_nicklist_send_hsignal ("nicklist_group_changed", buffer, group, NULL); } }
struct t_gui_nick_group * gui_nicklist_find_pos_group (struct t_gui_nick_group *groups, struct t_gui_nick_group *group) { struct t_gui_nick_group *ptr_group; for (ptr_group = groups; ptr_group; ptr_group = ptr_group->next_group) { if (string_strcasecmp (group->name, ptr_group->name) < 0) return ptr_group; } /* group will be inserted at end of list */ return NULL; }
void * gui_nicklist_group_get_pointer (struct t_gui_buffer *buffer, struct t_gui_nick_group *group, const char *property) { /* make C compiler happy */ (void) buffer; if (group && property) { if (string_strcasecmp (property, "parent") == 0) return group->parent; } return NULL; }
int weeurl_search_option (const char *name) { int i; for (i = 0; url_options[i].name; i++) { if (string_strcasecmp (url_options[i].name, name) == 0) { return i; } } /* option not found */ return -1; }
int weeurl_search_constant (struct t_url_constant *constants, const char *name) { int i; for (i = 0; constants[i].name; i++) { if (string_strcasecmp (constants[i].name, name) == 0) { return i; } } /* constant not found */ return -1; }
int gui_completion_word_compare_cb (void *data, struct t_arraylist *arraylist, void *pointer1, void *pointer2) { struct t_gui_completion_word *completion_word1, *completion_word2; /* make C compiler happy */ (void) data; (void) arraylist; completion_word1 = (struct t_gui_completion_word *)pointer1; completion_word2 = (struct t_gui_completion_word *)pointer2; return string_strcasecmp (completion_word1->word, completion_word2->word); }
void * gui_nicklist_nick_get_pointer (struct t_gui_buffer *buffer, struct t_gui_nick *nick, const char *property) { /* make C compiler happy */ (void) buffer; if (nick && property) { if (string_strcasecmp (property, "group") == 0) return nick->group; } return NULL; }
int gui_nicklist_nick_get_integer (struct t_gui_buffer *buffer, struct t_gui_nick *nick, const char *property) { /* make C compiler happy */ (void) buffer; if (nick && property) { if (string_strcasecmp (property, "visible") == 0) return nick->visible; } return 0; }
struct t_weelist_item * weelist_casesearch (struct t_weelist *weelist, const char *data) { struct t_weelist_item *ptr_item; if (!weelist || !data) return NULL; for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { if (string_strcasecmp (data, ptr_item->data) == 0) return ptr_item; } /* data not found in list */ return NULL; }
struct t_weelist_item * weelist_find_pos (struct t_weelist *weelist, const char *data) { struct t_weelist_item *ptr_item; if (!weelist || !data) return NULL; for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { if (string_strcasecmp (data, ptr_item->data) < 0) return ptr_item; } /* position not found, best position is at the end */ return NULL; }
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; }