struct t_infolist * fset_info_infolist_fset_option_cb (const void *pointer, void *data, const char *infolist_name, void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_fset_option *ptr_fset_option; int num_options, i; /* make C compiler happy */ (void) pointer; (void) data; (void) infolist_name; if (obj_pointer && !fset_option_valid (obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; if (obj_pointer) { /* build list with only one option */ if (!fset_option_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all options matching arguments */ num_options = weechat_arraylist_size (fset_options); for (i = 0; i < num_options; i++) { ptr_fset_option = weechat_arraylist_get (fset_options, i); if (ptr_fset_option && (!arguments || !arguments[0] || weechat_string_match (ptr_fset_option->name, arguments, 0))) { if (!fset_option_add_to_infolist (ptr_infolist, ptr_fset_option)) { weechat_infolist_free (ptr_infolist); return NULL; } } } return ptr_infolist; } return NULL; }
struct t_infolist * script_info_infolist_script_script_cb (const void *pointer, void *data, const char *infolist_name, void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_script_repo *ptr_script; /* make C compiler happy */ (void) pointer; (void) data; (void) infolist_name; if (obj_pointer && !script_repo_script_valid (obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; if (obj_pointer) { /* build list with only one script */ if (!script_repo_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all scripts matching arguments */ for (ptr_script = scripts_repo; ptr_script; ptr_script = ptr_script->next_script) { if (!arguments || !arguments[0] || weechat_string_match (ptr_script->name_with_extension, arguments, 0)) { if (!script_repo_add_to_infolist (ptr_infolist, ptr_script)) { weechat_infolist_free (ptr_infolist); return NULL; } } } return ptr_infolist; } return NULL; }
struct t_infolist * logger_info_get_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_logger_buffer *ptr_logger_buffer; /* make C compiler happy */ (void) data; (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; if (weechat_strcasecmp (infolist_name, "logger_buffer") == 0) { if (pointer && !logger_buffer_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one logger buffer */ if (!logger_buffer_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all logger buffers */ for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer; ptr_logger_buffer = ptr_logger_buffer->next_buffer) { if (!logger_buffer_add_to_infolist (ptr_infolist, ptr_logger_buffer)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } } } return NULL; }
struct t_infolist * relay_info_get_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_relay_client *ptr_client; /* make C compiler happy */ (void) data; (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; if (weechat_strcasecmp (infolist_name, "relay") == 0) { if (pointer && !relay_client_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one relay */ if (!relay_client_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all relays */ for (ptr_client = relay_clients; ptr_client; ptr_client = ptr_client->next_client) { if (!relay_client_add_to_infolist (ptr_infolist, ptr_client)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } } } return NULL; }
struct t_infolist * alias_info_infolist_alias_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_alias *ptr_alias; /* make C compiler happy */ (void) data; (void) infolist_name; (void) arguments; if (pointer && !alias_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; if (pointer) { /* build list with only one alias */ if (!alias_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all aliases matching arguments */ for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias) { if (!arguments || !arguments[0] || weechat_string_match (ptr_alias->name, arguments, 0)) { if (!alias_add_to_infolist (ptr_infolist, ptr_alias)) { weechat_infolist_free (ptr_infolist); return NULL; } } } return ptr_infolist; } return NULL; }
struct t_infolist * xfer_info_infolist_xfer_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_xfer *ptr_xfer; /* make C compiler happy */ (void) data; (void) infolist_name; (void) arguments; if (pointer && !xfer_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; if (pointer) { /* build list with only one xfer */ if (!xfer_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all xfers */ for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { if (!xfer_add_to_infolist (ptr_infolist, ptr_xfer)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } return NULL; }
int irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file) { struct t_infolist *infolist; struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; struct t_irc_redirect *ptr_redirect; struct t_irc_redirect_pattern *ptr_redirect_pattern; struct t_irc_notify *ptr_notify; struct t_irc_raw_message *ptr_raw_message; int rc; for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { /* save server */ infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_server_add_to_infolist (infolist, ptr_server)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_SERVER, infolist); weechat_infolist_free (infolist); if (!rc) return 0; /* save server channels and nicks */ for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { /* save channel */ infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_channel_add_to_infolist (infolist, ptr_channel)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_CHANNEL, infolist); weechat_infolist_free (infolist); if (!rc) return 0; for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { /* save nick */ infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_nick_add_to_infolist (infolist, ptr_nick)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_NICK, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } } /* save server redirects */ for (ptr_redirect = ptr_server->redirects; ptr_redirect; ptr_redirect = ptr_redirect->next_redirect) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_redirect_add_to_infolist (infolist, ptr_redirect)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_REDIRECT, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } /* save server notify list */ for (ptr_notify = ptr_server->notify_list; ptr_notify; ptr_notify = ptr_notify->next_notify) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_notify_add_to_infolist (infolist, ptr_notify)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_NOTIFY, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } } /* save raw messages */ for (ptr_raw_message = irc_raw_messages; ptr_raw_message; ptr_raw_message = ptr_raw_message->next_message) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_raw_add_to_infolist (infolist, ptr_raw_message)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_RAW_MESSAGE, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } /* save redirect patterns */ for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern; ptr_redirect_pattern = ptr_redirect_pattern->next_redirect) { /* save only temporary patterns (created by other plugins/scripts) */ if (ptr_redirect_pattern->temp_pattern) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!irc_redirect_pattern_add_to_infolist (infolist, ptr_redirect_pattern)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, IRC_UPGRADE_TYPE_REDIRECT_PATTERN, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } } return 1; }
int relay_upgrade_save_all_data (struct t_upgrade_file *upgrade_file) { struct t_infolist *infolist; struct t_relay_server *ptr_server; struct t_relay_client *ptr_client; struct t_relay_raw_message *ptr_raw_message; int rc; /* save servers */ for (ptr_server = relay_servers; ptr_server; ptr_server = ptr_server->next_server) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!relay_server_add_to_infolist (infolist, ptr_server)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, RELAY_UPGRADE_TYPE_SERVER, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } /* save clients */ for (ptr_client = last_relay_client; ptr_client; ptr_client = ptr_client->prev_client) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!relay_client_add_to_infolist (infolist, ptr_client)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, RELAY_UPGRADE_TYPE_CLIENT, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } /* save raw messages */ for (ptr_raw_message = relay_raw_messages; ptr_raw_message; ptr_raw_message = ptr_raw_message->next_message) { infolist = weechat_infolist_new (); if (!infolist) return 0; if (!relay_raw_add_to_infolist (infolist, ptr_raw_message)) { weechat_infolist_free (infolist); return 0; } rc = weechat_upgrade_write_object (upgrade_file, RELAY_UPGRADE_TYPE_RAW_MESSAGE, infolist); weechat_infolist_free (infolist); if (!rc) return 0; } return 1; }
struct t_infolist * irc_info_get_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; struct t_irc_ignore *ptr_ignore; char **argv; int argc; /* make C compiler happy */ (void) data; if (!infolist_name || !infolist_name[0]) return NULL; if (weechat_strcasecmp (infolist_name, "irc_server") == 0) { if (pointer && !irc_server_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one server */ if (!irc_server_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all servers matching arguments */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { if (!arguments || !arguments[0] || weechat_string_match (ptr_server->name, arguments, 0)) { if (!irc_server_add_to_infolist (ptr_infolist, ptr_server)) { weechat_infolist_free (ptr_infolist); return NULL; } } } return ptr_infolist; } } } else if (weechat_strcasecmp (infolist_name, "irc_channel") == 0) { if (arguments && arguments[0]) { ptr_server = irc_server_search (arguments); if (ptr_server) { if (pointer && !irc_channel_valid (ptr_server, pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one channel */ if (!irc_channel_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all channels of server */ for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { if (!irc_channel_add_to_infolist (ptr_infolist, ptr_channel)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } } } } } else if (weechat_strcasecmp (infolist_name, "irc_nick") == 0) { if (arguments && arguments[0]) { ptr_server = NULL; ptr_channel = NULL; argv = weechat_string_split (arguments, ",", 0, 0, &argc); if (argv) { if (argc >= 2) { ptr_server = irc_server_search (argv[0]); if (!ptr_server) { weechat_string_free_split (argv); return NULL; } ptr_channel = irc_channel_search (ptr_server, argv[1]); if (!ptr_channel) { weechat_string_free_split (argv); return NULL; } if (!pointer && (argc >= 3)) { pointer = irc_nick_search (ptr_channel, argv[2]); if (!pointer) { weechat_string_free_split (argv); return NULL; } } } weechat_string_free_split (argv); if (ptr_server && ptr_channel) { if (pointer && !irc_nick_valid (ptr_channel, pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one nick */ if (!irc_nick_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all nicks of channel */ for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { if (!irc_nick_add_to_infolist (ptr_infolist, ptr_nick)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } } } } } } else if (weechat_strcasecmp (infolist_name, "irc_ignore") == 0) { if (pointer && !irc_ignore_valid (pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one ignore */ if (!irc_ignore_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with all ignore */ for (ptr_ignore = irc_ignore_list; ptr_ignore; ptr_ignore = ptr_ignore->next_ignore) { if (!irc_ignore_add_to_infolist (ptr_infolist, ptr_ignore)) { weechat_infolist_free (ptr_infolist); return NULL; } } return ptr_infolist; } } } return NULL; }
void irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick, const char *arguments, char *message) { char *dcc_args, *pos, *pos_file, *pos_addr, *pos_port, *pos_size; char *pos_start_resume, *filename; struct t_infolist *infolist; struct t_infolist_item *item; char charset_modifier[256]; if (!arguments || !arguments[0]) return; if (strncmp (arguments, "SEND ", 5) == 0) { arguments += 5; while (arguments[0] == ' ') { arguments++; } dcc_args = strdup (arguments); if (!dcc_args) { weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return; } /* DCC filename */ pos_file = dcc_args; while (pos_file[0] == ' ') { pos_file++; } /* look for file size */ pos_size = strrchr (pos_file, ' '); if (!pos_size) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_size; pos_size++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* look for DCC port */ pos_port = strrchr (pos_file, ' '); if (!pos_port) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_port; pos_port++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* look for DCC IP address */ pos_addr = strrchr (pos_file, ' '); if (!pos_addr) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_addr; pos_addr++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* remove double quotes around filename */ filename = irc_ctcp_dcc_filename_without_quotes (pos_file); /* add DCC file via xfer plugin */ infolist = weechat_infolist_new (); if (infolist) { item = weechat_infolist_new_item (infolist); if (item) { weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name); weechat_infolist_new_var_string (item, "plugin_id", server->name); weechat_infolist_new_var_string (item, "type", "file_recv"); weechat_infolist_new_var_string (item, "protocol", "dcc"); weechat_infolist_new_var_string (item, "remote_nick", nick); weechat_infolist_new_var_string (item, "local_nick", server->nick); weechat_infolist_new_var_string (item, "filename", (filename) ? filename : pos_file); weechat_infolist_new_var_string (item, "size", pos_size); weechat_infolist_new_var_string (item, "proxy", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY)); weechat_infolist_new_var_string (item, "address", pos_addr); weechat_infolist_new_var_integer (item, "port", atoi (pos_port)); weechat_hook_signal_send ("xfer_add", WEECHAT_HOOK_SIGNAL_POINTER, infolist); } weechat_infolist_free (infolist); } weechat_hook_signal_send ("irc_dcc", WEECHAT_HOOK_SIGNAL_STRING, message); if (filename) free (filename); free (dcc_args); } else if (strncmp (arguments, "RESUME ", 7) == 0) { arguments += 7; while (arguments[0] == ' ') { arguments++; } dcc_args = strdup (arguments); if (!dcc_args) { weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return; } /* DCC filename */ pos_file = dcc_args; while (pos_file[0] == ' ') { pos_file++; } /* look for resume start position */ pos_start_resume = strrchr (pos_file, ' '); if (!pos_start_resume) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_start_resume; pos_start_resume++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* look for DCC port */ pos_port = strrchr (pos_file, ' '); if (!pos_port) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_port; pos_port++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* remove double quotes around filename */ filename = irc_ctcp_dcc_filename_without_quotes (pos_file); /* accept resume via xfer plugin */ infolist = weechat_infolist_new (); if (infolist) { item = weechat_infolist_new_item (infolist); if (item) { weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name); weechat_infolist_new_var_string (item, "plugin_id", server->name); weechat_infolist_new_var_string (item, "type", "file_recv"); weechat_infolist_new_var_string (item, "filename", (filename) ? filename : pos_file); weechat_infolist_new_var_integer (item, "port", atoi (pos_port)); weechat_infolist_new_var_string (item, "start_resume", pos_start_resume); weechat_hook_signal_send ("xfer_accept_resume", WEECHAT_HOOK_SIGNAL_POINTER, infolist); } weechat_infolist_free (infolist); } weechat_hook_signal_send ("irc_dcc", WEECHAT_HOOK_SIGNAL_STRING, message); if (filename) free (filename); free (dcc_args); } else if (strncmp (arguments, "ACCEPT ", 7) == 0) { arguments += 7; while (arguments[0] == ' ') { arguments++; } dcc_args = strdup (arguments); if (!dcc_args) { weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return; } /* DCC filename */ pos_file = dcc_args; while (pos_file[0] == ' ') { pos_file++; } /* look for resume start position */ pos_start_resume = strrchr (pos_file, ' '); if (!pos_start_resume) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_start_resume; pos_start_resume++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* look for DCC port */ pos_port = strrchr (pos_file, ' '); if (!pos_port) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos = pos_port; pos_port++; while (pos[0] == ' ') { pos--; } pos[1] = '\0'; /* remove double quotes around filename */ filename = irc_ctcp_dcc_filename_without_quotes (pos_file); /* resume file via xfer plugin */ infolist = weechat_infolist_new (); if (infolist) { item = weechat_infolist_new_item (infolist); if (item) { weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name); weechat_infolist_new_var_string (item, "plugin_id", server->name); weechat_infolist_new_var_string (item, "type", "file_recv"); weechat_infolist_new_var_string (item, "filename", (filename) ? filename : pos_file); weechat_infolist_new_var_integer (item, "port", atoi (pos_port)); weechat_infolist_new_var_string (item, "start_resume", pos_start_resume); weechat_hook_signal_send ("xfer_start_resume", WEECHAT_HOOK_SIGNAL_POINTER, infolist); } weechat_infolist_free (infolist); } weechat_hook_signal_send ("irc_dcc", WEECHAT_HOOK_SIGNAL_STRING, message); if (filename) free (filename); free (dcc_args); } else if (strncmp (arguments, "CHAT ", 5) == 0) { arguments += 5; while (arguments[0] == ' ') { arguments++; } dcc_args = strdup (arguments); if (!dcc_args) { weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return; } /* CHAT type */ pos_file = dcc_args; while (pos_file[0] == ' ') { pos_file++; } /* DCC IP address */ pos_addr = strchr (pos_file, ' '); if (!pos_addr) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos_addr[0] = '\0'; pos_addr++; while (pos_addr[0] == ' ') { pos_addr++; } /* look for DCC port */ pos_port = strchr (pos_addr, ' '); if (!pos_port) { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return; } pos_port[0] = '\0'; pos_port++; while (pos_port[0] == ' ') { pos_port++; } if (weechat_strcasecmp (pos_file, "chat") != 0) { weechat_printf (server->buffer, _("%s%s: unknown DCC CHAT type " "received from %s%s%s: \"%s\""), weechat_prefix ("error"), IRC_PLUGIN_NAME, IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_RESET, pos_file); free (dcc_args); return; } /* add DCC chat via xfer plugin */ infolist = weechat_infolist_new (); if (infolist) { item = weechat_infolist_new_item (infolist); if (item) { weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name); weechat_infolist_new_var_string (item, "plugin_id", server->name); weechat_infolist_new_var_string (item, "type", "chat_recv"); weechat_infolist_new_var_string (item, "remote_nick", nick); weechat_infolist_new_var_string (item, "local_nick", server->nick); snprintf (charset_modifier, sizeof (charset_modifier), "irc.%s.%s", server->name, nick); weechat_infolist_new_var_string (item, "charset_modifier", charset_modifier); weechat_infolist_new_var_string (item, "proxy", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY)); weechat_infolist_new_var_string (item, "address", pos_addr); weechat_infolist_new_var_integer (item, "port", atoi (pos_port)); weechat_hook_signal_send ("xfer_add", WEECHAT_HOOK_SIGNAL_POINTER, infolist); } weechat_infolist_free (infolist); } weechat_hook_signal_send ("irc_dcc", WEECHAT_HOOK_SIGNAL_STRING, message); free (dcc_args); } }