Ejemplo n.º 1
0
static int _handle_list_command(t_connection * conn, int numparams, char ** params, char * text)
{
    char temp[MAX_IRC_MESSAGE_LEN];

    irc_send(conn,RPL_LISTSTART,"Channel :Users Names"); /* backward compatibility */

    if (numparams==0) {
        t_elem const * curr;

        LIST_TRAVERSE_CONST(channellist(),curr)
        {
            t_channel const * channel = (const t_channel*)elem_get_data(curr);
            char const * tempname;
            char * topic = channel_get_topic(channel_get_name(channel));

            tempname = irc_convert_channel(channel,conn);

            /* FIXME: AARON: only list channels like in /channels command */
            if (topic) {
                if (std::strlen(tempname)+1+20+1+1+std::strlen(topic)<MAX_IRC_MESSAGE_LEN)
                    snprintf(temp, sizeof(temp), "%s %u :%s",tempname,channel_get_length(channel),topic);
                else
                    eventlog(eventlog_level_warn,__FUNCTION__,"LISTREPLY length exceeded");
            }
            else {
                if (std::strlen(tempname)+1+20+1+1<MAX_IRC_MESSAGE_LEN)
                    snprintf(temp, sizeof(temp), "%s %u :",tempname,channel_get_length(channel));
                else
                    eventlog(eventlog_level_warn,__FUNCTION__,"LISTREPLY length exceeded");
            }
            irc_send(conn,RPL_LIST,temp);
        }
Ejemplo n.º 2
0
		int output_standard_writer(std::FILE * fp)
		{
			t_elem const	*curr;
			t_connection	*conn;
			t_channel const	*channel;
			t_game *game;

			char const		*channel_name;
			int			number;
			char		clienttag_str[5];
			int uptime = server_get_uptime();


			if (prefs_get_XML_status_output())
			{
				int seconds;
				int minutes;
				int hours;
				int days;

				days = (uptime / (60 * 60 * 24));
				hours = (uptime / (60 * 60)) % 24;
				minutes = (uptime / 60) % 60;
				seconds = uptime % 60;

				std::fprintf(fp, "<?xml version=\"1.0\"?>\n<status>\n");
				std::fprintf(fp, "\t\t<Version>%s</Version>\n", PVPGN_VERSION);
				std::fprintf(fp, "\t\t<Uptime>\n");
				std::fprintf(fp, "\t\t\t<Days>%d</Days>\n", days);
				std::fprintf(fp, "\t\t\t<Hours>%d</Hours>\n", hours);
				std::fprintf(fp, "\t\t\t<Minutes>%d</Minutes>\n", minutes);
				std::fprintf(fp, "\t\t\t<Seconds>%d</Seconds>\n", seconds);
				std::fprintf(fp, "\t\t</Uptime>\n");
				std::fprintf(fp, "\t\t<Users>\n");
				std::fprintf(fp, "\t\t<Number>%d</Number>\n", connlist_login_get_length());

				LIST_TRAVERSE_CONST(connlist(), curr)
				{
					conn = (t_connection*)elem_get_data(curr);
					if (conn_get_account(conn))
						std::fprintf(fp, "\t\t<user><name>%s</name><clienttag>%s</clienttag><version>%s</version>", conn_get_username(conn), tag_uint_to_str(clienttag_str, conn_get_clienttag(conn)), conn_get_clientver(conn));

					if ((game = conn_get_game(conn)))
						std::fprintf(fp, "<gameid>%u</gameid>", game_get_id(game));
					std::fprintf(fp, "</user>\n");
				}

				std::fprintf(fp, "\t\t</Users>\n");
				std::fprintf(fp, "\t\t<Games>\n");
				std::fprintf(fp, "\t\t<Number>%d</Number>\n", gamelist_get_length());

				gamelist_traverse(_glist_cb_xml, fp);

				std::fprintf(fp, "\t\t</Games>\n");
				std::fprintf(fp, "\t\t<Channels>\n");
				std::fprintf(fp, "\t\t<Number>%d</Number>\n", channellist_get_length());

				LIST_TRAVERSE_CONST(channellist(), curr)
				{
					channel = (t_channel*)elem_get_data(curr);
					channel_name = channel_get_name(channel);
					std::fprintf(fp, "\t\t<channel>%s</channel>\n", channel_name);
				}