void irc_upgrade_set_buffer_callbacks () { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; const char *type; infolist = weechat_infolist_get ("buffer", NULL, NULL); if (infolist) { while (weechat_infolist_next (infolist)) { if (weechat_infolist_pointer (infolist, "plugin") == weechat_irc_plugin) { ptr_buffer = weechat_infolist_pointer (infolist, "pointer"); weechat_buffer_set_pointer (ptr_buffer, "close_callback", &irc_buffer_close_cb); weechat_buffer_set_pointer (ptr_buffer, "input_callback", &irc_input_data_cb); type = weechat_buffer_get_string (ptr_buffer, "localvar_type"); if (type && (strcmp (type, "channel") == 0)) { weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback", &irc_buffer_nickcmp_cb); } if (strcmp (weechat_infolist_string (infolist, "name"), IRC_RAW_BUFFER_NAME) == 0) { irc_raw_buffer = ptr_buffer; } } } weechat_infolist_free (infolist); } }
void relay_upgrade_set_buffer_callbacks () { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; infolist = weechat_infolist_get ("buffer", NULL, NULL); if (infolist) { while (weechat_infolist_next (infolist)) { if (weechat_infolist_pointer (infolist, "plugin") == weechat_relay_plugin) { ptr_buffer = weechat_infolist_pointer (infolist, "pointer"); weechat_buffer_set_pointer (ptr_buffer, "close_callback", &relay_buffer_close_cb); weechat_buffer_set_pointer (ptr_buffer, "input_callback", &relay_buffer_input_cb); if (strcmp (weechat_infolist_string (infolist, "name"), RELAY_BUFFER_NAME) == 0) { relay_buffer = ptr_buffer; } if (strcmp (weechat_infolist_string (infolist, "name"), RELAY_RAW_BUFFER_NAME) == 0) { relay_raw_buffer = ptr_buffer; } } } weechat_infolist_free (infolist); } }
void exec_buffer_set_callbacks () { struct t_infolist *ptr_infolist; struct t_gui_buffer *ptr_buffer; const char *plugin_name; ptr_infolist = weechat_infolist_get ("buffer", NULL, ""); if (ptr_infolist) { while (weechat_infolist_next (ptr_infolist)) { ptr_buffer = weechat_infolist_pointer (ptr_infolist, "pointer"); plugin_name = weechat_infolist_string (ptr_infolist, "plugin_name"); if (ptr_buffer && plugin_name && (strcmp (plugin_name, EXEC_PLUGIN_NAME) == 0)) { weechat_buffer_set_pointer (ptr_buffer, "close_callback", &exec_buffer_close_cb); weechat_buffer_set_pointer (ptr_buffer, "input_callback", &exec_buffer_input_cb); } } weechat_infolist_free (ptr_infolist); } }
void logger_list () { struct t_infolist *ptr_infolist; struct t_logger_buffer *ptr_logger_buffer; struct t_gui_buffer *ptr_buffer; char status[128]; weechat_printf (NULL, ""); weechat_printf (NULL, _("Logging on buffers:")); ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL); if (ptr_infolist) { while (weechat_infolist_next (ptr_infolist)) { ptr_buffer = weechat_infolist_pointer (ptr_infolist, "pointer"); if (ptr_buffer) { ptr_logger_buffer = logger_buffer_search_buffer (ptr_buffer); if (ptr_logger_buffer) { snprintf (status, sizeof (status), _("logging (level: %d)"), ptr_logger_buffer->log_level); } else { snprintf (status, sizeof (status), "%s", _("not logging")); } weechat_printf (NULL, " %s[%s%d%s]%s (%s) %s%s%s: %s%s%s%s", weechat_color("chat_delimiters"), weechat_color("chat"), weechat_infolist_integer (ptr_infolist, "number"), weechat_color("chat_delimiters"), weechat_color("chat"), weechat_infolist_string (ptr_infolist, "plugin_name"), weechat_color("chat_buffer"), weechat_infolist_string (ptr_infolist, "name"), weechat_color("chat"), status, (ptr_logger_buffer) ? " (" : "", (ptr_logger_buffer) ? ((ptr_logger_buffer->log_filename) ? ptr_logger_buffer->log_filename : _("log not started")) : "", (ptr_logger_buffer) ? ")" : ""); } } weechat_infolist_free (ptr_infolist); } }
void logger_start_buffer_all (int write_info_line) { struct t_infolist *ptr_infolist; ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL); if (ptr_infolist) { while (weechat_infolist_next (ptr_infolist)) { logger_start_buffer (weechat_infolist_pointer (ptr_infolist, "pointer"), write_info_line); } weechat_infolist_free (ptr_infolist); } }
void logger_adjust_log_filenames () { struct t_infolist *ptr_infolist; struct t_logger_buffer *ptr_logger_buffer; struct t_gui_buffer *ptr_buffer; char *log_filename; ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL); if (ptr_infolist) { while (weechat_infolist_next (ptr_infolist)) { ptr_buffer = weechat_infolist_pointer (ptr_infolist, "pointer"); ptr_logger_buffer = logger_buffer_search_buffer (ptr_buffer); if (ptr_logger_buffer && ptr_logger_buffer->log_filename) { log_filename = logger_get_filename (ptr_logger_buffer->buffer); if (log_filename) { if (strcmp (log_filename, ptr_logger_buffer->log_filename) != 0) { /* * log filename has changed (probably due to day * change),then we'll use new filename */ logger_stop (ptr_logger_buffer, 1); logger_start_buffer (ptr_buffer, 1); } free (log_filename); } } } weechat_infolist_free (ptr_infolist); } }
void relay_weechat_msg_add_infolist (struct t_relay_weechat_msg *msg, const char *name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; const char *fields; char **list_fields; void *buf_ptr; int num_fields, i, buf_size; int pos_count_items, count_items, pos_count_vars, count_vars; uint32_t count32; ptr_infolist = weechat_infolist_get (name, pointer, arguments); if (!ptr_infolist) return; /* start infolist in message */ relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INFOLIST); relay_weechat_msg_add_string (msg, name); /* count of items will be set later, with number of items in infolist */ pos_count_items = msg->data_size; count_items = 0; relay_weechat_msg_add_int (msg, 0); while (weechat_infolist_next (ptr_infolist)) { fields = weechat_infolist_fields (ptr_infolist); if (fields) { list_fields = weechat_string_split (fields, ",", 0, 0, &num_fields); if (list_fields) { count_items++; pos_count_vars = msg->data_size; count_vars = 0; relay_weechat_msg_add_int (msg, 0); for (i = 0; i < num_fields; i++) { if (strlen (list_fields[i]) > 2) { count_vars++; relay_weechat_msg_add_string (msg, list_fields[i] + 2); switch (list_fields[i][0]) { case 'i': relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INT); relay_weechat_msg_add_int (msg, weechat_infolist_integer (ptr_infolist, list_fields[i] + 2)); break; case 's': relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_STRING); relay_weechat_msg_add_string (msg, weechat_infolist_string (ptr_infolist, list_fields[i] + 2)); break; case 'p': relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_POINTER); relay_weechat_msg_add_pointer (msg, weechat_infolist_pointer (ptr_infolist, list_fields[i] + 2)); break; case 'b': relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_BUFFER); buf_ptr = weechat_infolist_buffer (ptr_infolist, list_fields[i] + 2, &buf_size); relay_weechat_msg_add_buffer (msg, buf_ptr, buf_size); break; case 't': relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_TIME); relay_weechat_msg_add_time (msg, weechat_infolist_time (ptr_infolist, list_fields[i] + 2)); break; } } } /* set count of variables in item */ count32 = htonl ((uint32_t)count_vars); relay_weechat_msg_set_bytes (msg, pos_count_vars, &count32, 4); weechat_string_free_split (list_fields); } } } /* set count of items */ count32 = htonl ((uint32_t)count_items); relay_weechat_msg_set_bytes (msg, pos_count_items, &count32, 4); weechat_infolist_free (ptr_infolist); }
struct t_weelist * script_buffer_get_script_usage (struct t_script_repo *script) { struct t_weelist *list; char hdata_name[128], str_option[256], str_info[1024]; int config_files; struct t_hdata *hdata_script, *hdata_config, *hdata_bar_item; void *ptr_script, *callback_pointer; struct t_config_file *ptr_config; struct t_gui_bar_item *ptr_bar_item; struct t_infolist *infolist; config_files = 0; snprintf (hdata_name, sizeof (hdata_name), "%s_script", script_language[script->language]); hdata_script = weechat_hdata_get (hdata_name); if (!hdata_script) return NULL; ptr_script = script_buffer_get_script_pointer (script, hdata_script); if (!ptr_script) return NULL; list = weechat_list_new (); /* get configuration files created by the script */ hdata_config = weechat_hdata_get ("config_file"); ptr_config = weechat_hdata_get_list (hdata_config, "config_files"); while (ptr_config) { callback_pointer = weechat_hdata_pointer ( hdata_config, ptr_config, "callback_reload_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), _("configuration file \"%s\" (options %s.*)"), weechat_hdata_string (hdata_config, ptr_config, "filename"), weechat_hdata_string (hdata_config, ptr_config, "name")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); config_files++; } ptr_config = weechat_hdata_move (hdata_config, ptr_config, 1); } /* get the commands created by the script */ infolist = weechat_infolist_get ("hook", NULL, "command"); if (infolist) { while (weechat_infolist_next (infolist)) { callback_pointer = weechat_infolist_pointer (infolist, "callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), _("command /%s"), weechat_infolist_string (infolist, "command")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } } weechat_infolist_free (infolist); } /* get the completions created by the script */ infolist = weechat_infolist_get ("hook", NULL, "completion"); if (infolist) { while (weechat_infolist_next (infolist)) { callback_pointer = weechat_infolist_pointer (infolist, "callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), _("completion %%(%s)"), weechat_infolist_string (infolist, "completion_item")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } } weechat_infolist_free (infolist); } /* get the infos created by the script */ infolist = weechat_infolist_get ("hook", NULL, "info"); if (infolist) { while (weechat_infolist_next (infolist)) { callback_pointer = weechat_infolist_pointer (infolist, "callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), "info \"%s\"", weechat_infolist_string (infolist, "info_name")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } } weechat_infolist_free (infolist); } /* get the infos (hashtable) created by the script */ infolist = weechat_infolist_get ("hook", NULL, "info_hashtable"); if (infolist) { while (weechat_infolist_next (infolist)) { callback_pointer = weechat_infolist_pointer (infolist, "callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), "info_hashtable \"%s\"", weechat_infolist_string (infolist, "info_name")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } } weechat_infolist_free (infolist); } /* get the infolists created by the script */ infolist = weechat_infolist_get ("hook", NULL, "infolist"); if (infolist) { while (weechat_infolist_next (infolist)) { callback_pointer = weechat_infolist_pointer (infolist, "callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), "infolist \"%s\"", weechat_infolist_string (infolist, "infolist_name")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } } weechat_infolist_free (infolist); } /* get the bar items created by the script */ hdata_bar_item = weechat_hdata_get ("bar_item"); ptr_bar_item = weechat_hdata_get_list (hdata_bar_item, "gui_bar_items"); while (ptr_bar_item) { callback_pointer = weechat_hdata_pointer (hdata_bar_item, ptr_bar_item, "build_callback_pointer"); if (callback_pointer == ptr_script) { snprintf (str_info, sizeof (str_info), _("bar item \"%s\""), weechat_hdata_string (hdata_bar_item, ptr_bar_item, "name")); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } ptr_bar_item = weechat_hdata_move (hdata_bar_item, ptr_bar_item, 1); } /* get the script options (in plugins.var) */ snprintf (str_option, sizeof (str_option), "plugins.var.%s.%s.*", script_language[script->language], weechat_hdata_string (hdata_script, ptr_script, "name")); infolist = weechat_infolist_get ("option", NULL, str_option); if (infolist) { if (weechat_infolist_next (infolist)) { snprintf (str_info, sizeof (str_info), _("options %s%s%s"), str_option, (config_files > 0) ? " " : "", (config_files > 0) ? _("(old options?)") : ""); weechat_list_add (list, str_info, WEECHAT_LIST_POS_END, NULL); } weechat_infolist_free (infolist); } return list; }