struct t_infolist * irc_info_infolist_irc_notify_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_notify *ptr_notify; /* make C compiler happy */ (void) data; (void) infolist_name; if (pointer && !irc_notify_valid (NULL, pointer)) return NULL; ptr_infolist = dogechat_infolist_new (); if (!ptr_infolist) return NULL; if (pointer) { /* build list with only one notify */ if (!irc_notify_add_to_infolist (ptr_infolist, pointer)) { dogechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with notify list of all servers matching arguments */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { if (!arguments || !arguments[0] || dogechat_string_match (ptr_server->name, arguments, 0)) { for (ptr_notify = ptr_server->notify_list; ptr_notify; ptr_notify = ptr_notify->next_notify) { if (!irc_notify_add_to_infolist (ptr_infolist, ptr_notify)) { dogechat_infolist_free (ptr_infolist); return NULL; } } } } return ptr_infolist; } return NULL; }
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; struct t_irc_notify *ptr_notify; 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 = NULL; ptr_channel = NULL; argv = weechat_string_split (arguments, ",", 0, 0, &argc); if (argv) { if (argc >= 1) { ptr_server = irc_server_search (argv[0]); if (!ptr_server) { weechat_string_free_split (argv); return NULL; } if (!pointer && (argc >= 2)) { pointer = irc_channel_search (ptr_server, argv[1]); if (!pointer) { weechat_string_free_split (argv); return NULL; } } } weechat_string_free_split (argv); 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_server, 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; } } } else if (weechat_strcasecmp (infolist_name, "irc_notify") == 0) { if (pointer && !irc_notify_valid (NULL, pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { if (pointer) { /* build list with only one notify */ if (!irc_notify_add_to_infolist (ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } return ptr_infolist; } else { /* build list with notify list of all servers matchin 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)) { for (ptr_notify = ptr_server->notify_list; ptr_notify; ptr_notify = ptr_notify->next_notify) { if (!irc_notify_add_to_infolist (ptr_infolist, ptr_notify)) { weechat_infolist_free (ptr_infolist); return NULL; } } } } return ptr_infolist; } } } return NULL; }