char * script_config_get_dir () { const char *weechat_home; char *path, *path2; weechat_home = weechat_info_get ("weechat_dir", NULL); path = weechat_string_expand_home (weechat_config_string (script_config_scripts_dir)); path2 = weechat_string_replace ((path) ? path : weechat_config_string (script_config_scripts_dir), "%h", weechat_home); if (path && path2) { free (path); path = NULL; } if (path2) return path2; if (path) return path; return strdup (weechat_config_string (script_config_scripts_dir)); }
void buflist_config_change_format (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ (void) pointer; (void) data; (void) option; if (buflist_config_format_buffer_eval) free (buflist_config_format_buffer_eval); buflist_config_format_buffer_eval = buflist_config_add_eval_for_formats ( weechat_config_string (buflist_config_format_buffer)); if (buflist_config_format_buffer_current_eval) free (buflist_config_format_buffer_current_eval); buflist_config_format_buffer_current_eval = buflist_config_add_eval_for_formats ( weechat_config_string (buflist_config_format_buffer_current)); if (buflist_config_format_hotlist_eval) free (buflist_config_format_hotlist_eval); buflist_config_format_hotlist_eval = buflist_config_add_eval_for_formats ( weechat_config_string (buflist_config_format_hotlist)); buflist_bar_item_update (0); }
const char * irc_ctcp_get_reply (struct t_irc_server *server, const char *ctcp) { struct t_config_option *ptr_option; char option_name[512]; snprintf (option_name, sizeof (option_name), "%s.%s", server->name, ctcp); /* search for CTCP in config file, for server */ ptr_option = weechat_config_search_option (irc_config_file, irc_config_section_ctcp, option_name); if (ptr_option) return weechat_config_string (ptr_option); /* search for CTCP in config file */ ptr_option = weechat_config_search_option (irc_config_file, irc_config_section_ctcp, ctcp); if (ptr_option) return weechat_config_string (ptr_option); /* * no CTCP reply found in config, then return default reply, or NULL * for unknown CTCP */ return irc_ctcp_get_default_reply (ctcp); }
void script_config_unhold (const char *name_with_extension) { char **items, *hold; int num_items, i, length; length = strlen (weechat_config_string (script_config_scripts_hold)) + 1; hold = malloc (length); if (hold) { hold[0] = '\0'; items = weechat_string_split (weechat_config_string (script_config_scripts_hold), ",", 0, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) { if (strcmp (items[i], name_with_extension) != 0) { if (hold[0]) strcat (hold, ","); strcat (hold, items[i]); } } weechat_string_free_split (items); } weechat_config_option_set (script_config_scripts_hold, hold, 0); free (hold); } }
int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) { weechat_plugin = plugin; SilcClientParams params; if (silc_plugin_config_init() < 0) { weechat_log_printf("could not initialize SILC plugin config"); return WEECHAT_RC_ERROR; } if (silc_plugin_config_read() < 0) { weechat_log_printf("could not read SILC plugin config file"); return WEECHAT_RC_ERROR; } memset(¶ms, 0, sizeof(params)); params.threads = TRUE; silc_plugin = silc_calloc(1, sizeof(*silc_plugin)); if (!silc_plugin) { weechat_log_printf("could not allocate plugin context"); return WEECHAT_RC_ERROR; } weechat_log_printf("SILC plugin context allocated"); silc_plugin->client = silc_client_alloc(&ops, ¶ms, silc_plugin, NULL); if (!silc_plugin->client) { weechat_log_printf("could not allocate SILC client"); return WEECHAT_RC_ERROR; } weechat_log_printf("SILC client allocated"); if (!silc_client_init(silc_plugin->client, weechat_config_string(option_default_username), silc_net_localhost(), weechat_config_string(option_default_realname), silc_running, silc_plugin)) { weechat_log_printf("could not initialize SILC client"); return WEECHAT_RC_ERROR; } // tick the client once to complete the initialization silc_client_run_one(silc_plugin->client); weechat_log_printf("SILC client initialized"); silc_plugin_get_keypair("weechat", "", 1, &silc_plugin->public_key, &silc_plugin->private_key); server_list = malloc(sizeof(struct SilcPluginServer)); memset(server_list, 0, sizeof(struct SilcPluginServer)); weechat_hook_command("silc", "This is the SILC plugin", "", "", NULL, &command_silc, NULL); weechat_hook_timer(50, 0, 0, &timer_silc, NULL); silc_bar_init(); return WEECHAT_RC_OK; }
const char * weechat_aspell_get_dict (struct t_gui_buffer *buffer) { char *name, *option_name, *ptr_end; struct t_config_option *ptr_option; name = weechat_aspell_build_option_name (buffer); if (!name) return NULL; option_name = strdup (name); if (option_name) { ptr_end = option_name + strlen (option_name); while (ptr_end >= option_name) { ptr_option = weechat_aspell_config_get_dict (option_name); if (ptr_option) { free (option_name); free (name); return weechat_config_string (ptr_option); } ptr_end--; while ((ptr_end >= option_name) && (ptr_end[0] != '.')) { ptr_end--; } if ((ptr_end >= option_name) && (ptr_end[0] == '.')) ptr_end[0] = '\0'; } ptr_option = weechat_aspell_config_get_dict (option_name); free (option_name); free (name); if (ptr_option) return weechat_config_string (ptr_option); } else free (name); /* nothing found => return default dictionary (if set) */ if (weechat_config_string (weechat_aspell_config_check_default_dict) && weechat_config_string (weechat_aspell_config_check_default_dict)[0]) return weechat_config_string (weechat_aspell_config_check_default_dict); /* no default dictionary set */ return NULL; }
const char * logger_get_mask_for_buffer (struct t_gui_buffer *buffer) { char *name, *option_name, *ptr_end; struct t_config_option *ptr_option; name = logger_build_option_name (buffer); if (!name) return NULL; option_name = strdup (name); if (option_name) { ptr_end = option_name + strlen (option_name); while (ptr_end >= option_name) { ptr_option = logger_config_get_mask (option_name); if (ptr_option) { free (option_name); free (name); return weechat_config_string (ptr_option); } ptr_end--; while ((ptr_end >= option_name) && (ptr_end[0] != '.')) { ptr_end--; } if ((ptr_end >= option_name) && (ptr_end[0] == '.')) ptr_end[0] = '\0'; } ptr_option = logger_config_get_mask (option_name); free (option_name); free (name); if (ptr_option) return weechat_config_string (ptr_option); } else free (name); /* nothing found => return default mask (if set) */ if (weechat_config_string (logger_config_file_mask) && weechat_config_string (logger_config_file_mask)[0]) return weechat_config_string (logger_config_file_mask); /* no default mask set */ return NULL; }
void relay_weechat_alloc (struct t_relay_client *client) { struct t_relay_weechat_data *weechat_data; const char *password; password = weechat_config_string (relay_config_network_password); client->protocol_data = malloc (sizeof (*weechat_data)); if (client->protocol_data) { RELAY_WEECHAT_DATA(client, password_ok) = (password && password[0]) ? 0 : 1; #ifdef HAVE_ZLIB RELAY_WEECHAT_DATA(client, compression) = 1; #else RELAY_WEECHAT_DATA(client, compression) = 0; #endif RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (16, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_INTEGER, NULL, NULL); RELAY_WEECHAT_DATA(client, hook_signal_buffer) = NULL; RELAY_WEECHAT_DATA(client, hook_signal_nicklist) = NULL; RELAY_WEECHAT_DATA(client, buffers_nicklist) = weechat_hashtable_new (16, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); RELAY_WEECHAT_DATA(client, hook_timer_nicklist) = NULL; } }
void relay_config_change_network_allowed_ips (void *data, struct t_config_option *option) { const char *allowed_ips; /* make C compiler happy */ (void) data; (void) option; if (relay_config_regex_allowed_ips) { regfree (relay_config_regex_allowed_ips); free (relay_config_regex_allowed_ips); relay_config_regex_allowed_ips = NULL; } allowed_ips = weechat_config_string (relay_config_network_allowed_ips); if (allowed_ips && allowed_ips[0]) { relay_config_regex_allowed_ips = malloc (sizeof (*relay_config_regex_allowed_ips)); if (relay_config_regex_allowed_ips) { if (weechat_string_regcomp (relay_config_regex_allowed_ips, allowed_ips, REG_EXTENDED | REG_ICASE) != 0) { free (relay_config_regex_allowed_ips); relay_config_regex_allowed_ips = NULL; } } } }
void relay_config_change_irc_backlog_tags (void *data, struct t_config_option *option) { char **items; int num_items, i; /* make C compiler happy */ (void) data; (void) option; if (!relay_config_hashtable_irc_backlog_tags) { relay_config_hashtable_irc_backlog_tags = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); } else weechat_hashtable_remove_all (relay_config_hashtable_irc_backlog_tags); items = weechat_string_split (weechat_config_string (relay_config_irc_backlog_tags), ";", 0, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) { weechat_hashtable_set (relay_config_hashtable_irc_backlog_tags, items[i], NULL); } weechat_string_free_split (items); } }
void logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line) { time_t seconds; struct tm *date_tmp; char buf_time[256]; if (!logger_buffer) return; if (logger_buffer->log_enabled && logger_buffer->log_file) { if (write_info_line && weechat_config_boolean (logger_config_file_info_lines)) { buf_time[0] = '\0'; seconds = time (NULL); date_tmp = localtime (&seconds); if (date_tmp) { strftime (buf_time, sizeof (buf_time) - 1, weechat_config_string (logger_config_file_time_format), date_tmp); } logger_write_line (logger_buffer, _("%s\t**** End of log ****"), buf_time); } fclose (logger_buffer->log_file); logger_buffer->log_file = NULL; } logger_buffer_free (logger_buffer); }
int irc_mode_smart_filtered (struct t_irc_server *server, char mode) { const char *ptr_modes; ptr_modes = weechat_config_string (irc_config_look_smart_filter_mode); /* if empty value, there's no smart filtering on mode messages */ if (!ptr_modes || !ptr_modes[0]) return 0; /* if var is "*", ALL modes are smart filtered */ if (strcmp (ptr_modes, "*") == 0) return 1; /* if var is "+", modes from server prefixes are filtered */ if (strcmp (ptr_modes, "+") == 0) return strchr (irc_server_get_prefix_modes (server), mode) ? 1 : 0; /* * if var starts with "-", smart filter all modes except following modes * example: "-kl": smart filter all modes but not k/l */ if (ptr_modes[0] == '-') return (strchr (ptr_modes + 1, mode)) ? 0 : 1; /* * explicit list of modes to smart filter * example: "ovh": smart filter modes o/v/h */ return (strchr (ptr_modes, mode)) ? 1 : 0; }
const char * charset_get (struct t_config_section *section, const char *name, struct t_config_option *default_charset) { char *option_name, *ptr_end; struct t_config_option *ptr_option; option_name = strdup (name); if (option_name) { ptr_end = option_name + strlen (option_name); while (ptr_end >= option_name) { ptr_option = weechat_config_search_option (charset_config_file, section, option_name); if (ptr_option) { free (option_name); return weechat_config_string (ptr_option); } ptr_end--; while ((ptr_end >= option_name) && (ptr_end[0] != '.')) { ptr_end--; } if ((ptr_end >= option_name) && (ptr_end[0] == '.')) ptr_end[0] = '\0'; } ptr_option = weechat_config_search_option (charset_config_file, section, option_name); free (option_name); if (ptr_option) return weechat_config_string (ptr_option); } /* nothing found => return default decode/encode charset (if set) */ if (weechat_config_string (default_charset) && weechat_config_string (default_charset)[0]) return weechat_config_string (default_charset); /* no default charset set */ return NULL; }
int logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, const char **tags, int displayed, int highlight, const char *prefix, const char *message) { struct t_logger_buffer *ptr_logger_buffer; struct tm *date_tmp; char buf_time[256]; int line_log_level, prefix_is_nick; /* make C compiler happy */ (void) data; (void) displayed; (void) highlight; logger_get_line_tag_info (tags_count, tags, &line_log_level, &prefix_is_nick); if (line_log_level >= 0) { ptr_logger_buffer = logger_buffer_search_buffer (buffer); if (ptr_logger_buffer && ptr_logger_buffer->log_enabled && (date > 0) && (line_log_level <= ptr_logger_buffer->log_level)) { buf_time[0] = '\0'; date_tmp = localtime (&date); if (date_tmp) { strftime (buf_time, sizeof (buf_time) - 1, weechat_config_string (logger_config_file_time_format), date_tmp); } logger_write_line (ptr_logger_buffer, "%s\t%s%s%s\t%s", buf_time, (prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_prefix) : "", (prefix) ? prefix : "", (prefix && prefix_is_nick) ? weechat_config_string (logger_config_file_nick_suffix) : "", message); } } return WEECHAT_RC_OK; }
void script_buffer_refresh (int clear) { struct t_script_repo *ptr_script; int line; char str_title[1024]; if (!script_buffer) return; if (clear) { weechat_buffer_clear (script_buffer); script_buffer_selected_line = (script_repo_count_displayed > 0) ? 0 : -1; } if (script_buffer_detail_script) { snprintf (str_title, sizeof (str_title), "%s", _("Alt+key/input: v=back to list d=jump to diff")); } else { snprintf (str_title, sizeof (str_title), _("%d/%d scripts (filter: %s) | Sort: %s | " "Alt+key/input: i=install, r=remove, l=load, L=reload, " "u=unload, A=autoload, h=(un)hold, v=view script | " "Input: q=close, $=refresh, s:x,y=sort, words=filter, " "*=reset filter | Mouse: left=select, right=install/remove"), script_repo_count_displayed, script_repo_count, (script_repo_filter) ? script_repo_filter : "*", weechat_config_string (script_config_look_sort)); } weechat_buffer_set (script_buffer, "title", str_title); if (script_buffer_detail_script) { /* detail on a script */ script_buffer_display_detail_script (script_buffer_detail_script); } else { /* list of scripts */ line = 0; for (ptr_script = scripts_repo; ptr_script; ptr_script = ptr_script->next_script) { if (ptr_script->displayed) { script_buffer_display_line_script (line, ptr_script); line++; } } } }
void trigger_command_display_trigger (struct t_trigger *trigger, int verbose) { trigger_command_display_trigger_internal ( trigger->name, weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]), weechat_config_string (trigger->options[TRIGGER_OPTION_HOOK]), weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]), weechat_config_string (trigger->options[TRIGGER_OPTION_CONDITIONS]), trigger->hooks_count, trigger->hook_count_cb, trigger->hook_count_cmd, trigger->regex_count, trigger->regex, trigger->commands_count, trigger->commands, weechat_config_integer (trigger->options[TRIGGER_OPTION_RETURN_CODE]), verbose); }
void script_config_hold (const char *name_with_extension) { char **items, *hold; int num_items, i, length; length = strlen (weechat_config_string (script_config_scripts_hold)) + 1 + strlen (name_with_extension) + 1; hold = malloc (length); if (hold) { hold[0] = '\0'; items = weechat_string_split ( weechat_config_string (script_config_scripts_hold), ",", WEECHAT_STRING_SPLIT_STRIP_LEFT | WEECHAT_STRING_SPLIT_STRIP_RIGHT | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) { if (strcmp (items[i], name_with_extension) != 0) { if (hold[0]) strcat (hold, ","); strcat (hold, items[i]); } } weechat_string_free_split (items); } if (hold[0]) strcat (hold, ","); strcat (hold, name_with_extension); weechat_config_option_set (script_config_scripts_hold, hold, 0); free (hold); } }
void relay_network_set_ssl_cert_key (int verbose) { #ifdef HAVE_GNUTLS char *certkey_path, *certkey_path2; int ret; gnutls_certificate_free_credentials (relay_gnutls_x509_cred); gnutls_certificate_allocate_credentials (&relay_gnutls_x509_cred); relay_network_init_ssl_cert_key_ok = 0; certkey_path = weechat_string_expand_home (weechat_config_string (relay_config_network_ssl_cert_key)); if (certkey_path) { certkey_path2 = weechat_string_replace (certkey_path, "%h", weechat_info_get ("weechat_dir", NULL)); if (certkey_path2) { ret = gnutls_certificate_set_x509_key_file (relay_gnutls_x509_cred, certkey_path2, certkey_path2, GNUTLS_X509_FMT_PEM); if (ret >= 0) { relay_network_init_ssl_cert_key_ok = 1; if (verbose) { weechat_printf (NULL, _("%s: SSL certificate and key have been " "set"), RELAY_PLUGIN_NAME); } } else { if (verbose) { weechat_printf (NULL, _("%s%s: warning: no SSL certificate/key " "found (option relay.network.ssl_cert_key)"), weechat_prefix ("error"), RELAY_PLUGIN_NAME); } } free (certkey_path2); } free (certkey_path); } #else /* make C compiler happy */ (void) verbose; #endif }
const char * script_config_get_diff_command () { const char *diff_command; char *dir_separator; static char result[64]; struct stat st; char *path, **paths, bin[4096]; int num_paths, i, rc; diff_command = weechat_config_string (script_config_look_diff_command); if (!diff_command || !diff_command[0]) return NULL; if (strcmp (diff_command, "auto") == 0) { dir_separator = weechat_info_get ("dir_separator", ""); path = getenv ("PATH"); result[0] = '\0'; if (dir_separator && path) { paths = weechat_string_split (path, ":", WEECHAT_STRING_SPLIT_STRIP_LEFT | WEECHAT_STRING_SPLIT_STRIP_RIGHT | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS, 0, &num_paths); if (paths) { for (i = 0; i < num_paths; i++) { snprintf (bin, sizeof (bin), "%s%s%s", paths[i], dir_separator, "git"); rc = stat (bin, &st); if ((rc == 0) && (S_ISREG(st.st_mode))) { snprintf (result, sizeof (result), "git diff --no-index"); break; } } weechat_string_free_split (paths); } } if (dir_separator) free (dir_separator); if (!result[0]) snprintf (result, sizeof (result), "diff"); return result; } return diff_command; }
char * rmodifier_hide_string (const char *string) { int length, i; char *result; if (!string || !string[0]) return NULL; length = weechat_utf8_strlen (string); result = malloc ((length * strlen (weechat_config_string (rmodifier_config_look_hide_char))) + 1); if (!result) return NULL; result[0] = '\0'; for (i = 0; i < length; i++) { strcat (result, weechat_config_string (rmodifier_config_look_hide_char)); } return result; }
struct t_trigger * trigger_new_with_options (const char *name, struct t_config_option **options) { struct t_trigger *new_trigger; int i; new_trigger = trigger_alloc (name); if (!new_trigger) return NULL; for (i = 0; i < TRIGGER_NUM_OPTIONS; i++) { new_trigger->options[i] = options[i]; } trigger_add (new_trigger, &triggers, &last_trigger); triggers_count++; if (trigger_regex_split (weechat_config_string (new_trigger->options[TRIGGER_OPTION_REGEX]), &new_trigger->regex_count, &new_trigger->regex) < 0) { weechat_printf (NULL, _("%s%s: invalid regular expression in trigger " "\"%s\""), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, name); } trigger_split_command (weechat_config_string (new_trigger->options[TRIGGER_OPTION_COMMAND]), &new_trigger->commands_count, &new_trigger->commands); if (weechat_config_boolean (new_trigger->options[TRIGGER_OPTION_ENABLED])) trigger_hook (new_trigger); return new_trigger; }
char * script_config_get_xml_filename () { char *path, *filename; int length; path = weechat_string_eval_path_home ( weechat_config_string (script_config_scripts_path), NULL, NULL, NULL); length = strlen (path) + 64; filename = malloc (length); if (filename) snprintf (filename, length, "%s/plugins.xml.gz", path); free (path); return filename; }
static void _wec_config_blacklist_update(gpointer data, struct t_config_option *option) { g_return_if_fail(option == _wec_context.config.restrictions.blacklist); g_hash_table_remove_all(_wec_context.blacklist); const gchar *nick, *s; nick = weechat_config_string(option); while ( ( s = g_utf8_strchr(nick, -1, ' ') ) != NULL ) { g_hash_table_add(_wec_context.blacklist, g_strndup(nick, s - nick)); nick = s + 1; } g_hash_table_add(_wec_context.blacklist, g_strdup(nick)); }
void relay_network_set_priority () { #ifdef HAVE_GNUTLS if (gnutls_priority_init (relay_gnutls_priority_cache, weechat_config_string ( relay_config_network_ssl_priorities), NULL) != GNUTLS_E_SUCCESS) { weechat_printf (NULL, _("%s%s: unable to initialize priority for SSL"), weechat_prefix ("error"), RELAY_PLUGIN_NAME); free (relay_gnutls_priority_cache); relay_gnutls_priority_cache = NULL; } #endif }
void weechat_aspell_speller_remove_unused () { struct t_hashtable *used_spellers; struct t_infolist *infolist; if (weechat_aspell_plugin->debug) { weechat_printf (NULL, "%s: removing unused spellers", ASPELL_PLUGIN_NAME); } /* create a hashtable that will contain all used spellers */ used_spellers = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); if (!used_spellers) return; /* collect used spellers and store them in hashtable "used_spellers" */ weechat_aspell_speller_add_dicts_to_hash (used_spellers, weechat_config_string (weechat_aspell_config_check_default_dict)); infolist = weechat_infolist_get ("option", NULL, "aspell.dict.*"); if (infolist) { while (weechat_infolist_next (infolist)) { weechat_aspell_speller_add_dicts_to_hash (used_spellers, weechat_infolist_string (infolist, "value")); } weechat_infolist_free (infolist); } /* * look at current spellers, and remove spellers that are not in hashtable * "used_spellers" */ weechat_hashtable_map (weechat_aspell_spellers, &weechat_aspell_speller_remove_unused_cb, used_spellers); weechat_hashtable_free (used_spellers); }
const char * irc_notify_get_tags (struct t_config_option *option, const char *type, const char *nick) { static char string[1024]; const char *tags; tags = weechat_config_string (option); snprintf (string, sizeof (string), "irc_notify,irc_notify_%s,nick_%s%s%s", type, nick, (tags && tags[0]) ? "," : "", (tags && tags[0]) ? tags : ""); return string; }
void trigger_config_change_trigger_command (const void *pointer, void *data, struct t_config_option *option) { struct t_trigger *ptr_trigger; /* make C compiler happy */ (void) pointer; (void) data; ptr_trigger = trigger_search_with_option (option); if (!ptr_trigger) return; trigger_split_command (weechat_config_string (option), &ptr_trigger->commands_count, &ptr_trigger->commands); }
struct t_trigger * trigger_copy (struct t_trigger *trigger, const char *name) { if (!name || !name[0] || !trigger_name_valid (name) || trigger_search (name)) { return NULL; } return trigger_new ( name, weechat_config_string (trigger->options[TRIGGER_OPTION_ENABLED]), weechat_config_string (trigger->options[TRIGGER_OPTION_HOOK]), weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]), weechat_config_string (trigger->options[TRIGGER_OPTION_CONDITIONS]), weechat_config_string (trigger->options[TRIGGER_OPTION_REGEX]), weechat_config_string (trigger->options[TRIGGER_OPTION_COMMAND]), weechat_config_string (trigger->options[TRIGGER_OPTION_RETURN_CODE]), weechat_config_string (trigger->options[TRIGGER_OPTION_POST_ACTION])); }
void weechat_aspell_config_change_commands (const void *pointer, void *data, struct t_config_option *option) { const char *value; int i; /* make C compiler happy */ (void) pointer; (void) data; if (weechat_aspell_commands_to_check) { weechat_string_free_split (weechat_aspell_commands_to_check); weechat_aspell_commands_to_check = NULL; weechat_aspell_count_commands_to_check = 0; } if (weechat_aspell_length_commands_to_check) { free (weechat_aspell_length_commands_to_check); weechat_aspell_length_commands_to_check = NULL; } value = weechat_config_string (option); if (value && value[0]) { weechat_aspell_commands_to_check = weechat_string_split (value, ",", 0, 0, &weechat_aspell_count_commands_to_check); if (weechat_aspell_count_commands_to_check > 0) { weechat_aspell_length_commands_to_check = malloc (weechat_aspell_count_commands_to_check * sizeof (int)); for (i = 0; i < weechat_aspell_count_commands_to_check; i++) { weechat_aspell_length_commands_to_check[i] = strlen (weechat_aspell_commands_to_check[i]); } } } }
void trigger_config_change_trigger_regex (const void *pointer, void *data, struct t_config_option *option) { struct t_trigger *ptr_trigger; /* make C compiler happy */ (void) pointer; (void) data; ptr_trigger = trigger_search_with_option (option); if (!ptr_trigger) return; switch (trigger_regex_split (weechat_config_string (option), &ptr_trigger->regex_count, &ptr_trigger->regex)) { case 0: /* OK */ break; case -1: /* format error */ weechat_printf (NULL, _("%s%s: invalid format for option \"regex\", " "see /help trigger.trigger.%s.regex"), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, ptr_trigger->name); break; case -2: /* regex compilation error */ weechat_printf (NULL, _("%s%s: invalid regular expression in option " "\"regex\", see /help trigger.trigger.%s.regex"), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, ptr_trigger->name); break; case -3: /* memory error */ weechat_printf (NULL, _("%s%s: not enough memory"), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME); break; } }