static void dump_join(IRC_CHANNEL_REC *channel, CLIENT_REC *client) { GSList *tmp, *nicks; GString *str; int first; proxy_outserver(client, "JOIN %s", channel->name); str = g_string_new(NULL); create_names_start(str, channel, client); first = TRUE; nicks = nicklist_getnicks(CHANNEL(channel)); for (tmp = nicks; tmp != NULL; tmp = tmp->next) { NICK_REC *nick = tmp->data; if (str->len >= 500) { g_string_append_c(str, '\n'); proxy_outdata(client, "%s", str->str); create_names_start(str, channel, client); first = TRUE; } if (first) first = FALSE; else g_string_append_c(str, ' '); if (nick->other) g_string_append_c(str, nick->other); else if (nick->op) g_string_append_c(str, '@'); else if (nick->halfop) g_string_append_c(str, '%'); else if (nick->voice) g_string_append_c(str, '+'); g_string_append(str, nick->nick); } g_slist_free(nicks); g_string_append_c(str, '\n'); proxy_outdata(client, "%s", str->str); g_string_free(str, TRUE); proxy_outdata(client, ":%s 366 %s %s :End of /NAMES list.\n", client->proxy_address, client->nick, channel->name); /* this is needed because the topic may be encoded into other charsets internaly */ if (channel->topic != NULL) { proxy_outdata(client, ":%s 332 %s %s :%s\n", client->proxy_address, client->nick, channel->name, recode_out(channel->topic, channel->name)); } }
static void proxy_server_disconnected(CLIENT_REC *client, IRC_SERVER_REC *server) { GSList *tmp; proxy_outdata(client, ":%s NOTICE %s :Connection lost to server %s\r\n", client->proxy_address, client->nick, server->connrec->address); for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { IRC_CHANNEL_REC *rec = tmp->data; proxy_outserver(client, "PART %s :Connection lost to server", rec->name); } }
void proxy_dump_data(CLIENT_REC *client) { GString *isupport_out, *paramstr; char **paramlist, **tmp; int count; proxy_client_reset_nick(client); /* welcome info */ proxy_outdata(client, ":%s 001 %s :Welcome to the Internet Relay Network\n", client->proxy_address, client->nick); proxy_outdata(client, ":%s 002 %s :Your host is irssi-proxy, running version %s\n", client->proxy_address, client->nick, IRSSI_VERSION); proxy_outdata(client, ":%s 003 %s :This server was created ...\n", client->proxy_address, client->nick); if (client->server == NULL || !client->server->emode_known) proxy_outdata(client, ":%s 004 %s %s %s oirw abiklmnopqstv\n", client->proxy_address, client->nick, client->proxy_address, IRSSI_VERSION); else proxy_outdata(client, ":%s 004 %s %s %s oirw abeIiklmnopqstv\n", client->proxy_address, client->nick, client->proxy_address, IRSSI_VERSION); if (client->server != NULL && client->server->isupport_sent) { isupport_out = g_string_new(NULL); g_hash_table_foreach(client->server->isupport, proxy_dump_data_005, isupport_out); if (isupport_out->len > 0) g_string_truncate(isupport_out, isupport_out->len-1); proxy_outdata(client, ":%s 005 %s ", client->proxy_address, client->nick); paramstr = g_string_new(NULL); paramlist = g_strsplit(isupport_out->str, " ", -1); count = 0; tmp = paramlist; for (;; tmp++) { if (*tmp != NULL) { g_string_sprintfa(paramstr, "%s ", *tmp); if (++count < 15) continue; } count = 0; if (paramstr->len > 0) g_string_truncate(paramstr, paramstr->len-1); g_string_sprintfa(paramstr, " :are supported by this server\n"); proxy_outdata(client, "%s", paramstr->str); g_string_truncate(paramstr, 0); g_string_sprintf(paramstr, ":%s 005 %s ", client->proxy_address, client->nick); if (*tmp == NULL || tmp[1] == NULL) break; } g_string_free(isupport_out, TRUE); g_string_free(paramstr, TRUE); g_strfreev(paramlist); } proxy_outdata(client, ":%s 251 %s :There are 0 users and 0 invisible on 1 servers\n", client->proxy_address, client->nick); proxy_outdata(client, ":%s 255 %s :I have 0 clients, 0 services and 0 servers\n", client->proxy_address, client->nick); proxy_outdata(client, ":%s 422 %s :MOTD File is missing\n", client->proxy_address, client->nick); /* user mode / away status */ if (client->server != NULL) { if (client->server->usermode != NULL) { proxy_outserver(client, "MODE %s :+%s", client->server->nick, client->server->usermode); } if (client->server->usermode_away) { proxy_outdata(client, ":%s 306 %s :You have been marked as being away\n", client->proxy_address, client->nick); } /* Send channel joins */ g_slist_foreach(client->server->channels, (GFunc) dump_join, client); } }