Example #1
0
extern int send_bits_gamelist_del(t_connection * c, t_game const * game)
{
    t_packet * p;

    if (!game) {
        eventlog(eventlog_level_error,"send_bits_gamelist_del","got NULL game");
        return -1;
    }
    p = packet_create(packet_class_bits);
    if (!p) {
        eventlog(eventlog_level_error,"send_bits_gamelist_del","could not create packet");
        return -1;
    }
    packet_set_size(p,sizeof(t_bits_gamelist_del));
    packet_set_type(p,BITS_GAMELIST_DEL);
    /***/
    bn_int_set(&p->u.bits_gamelist_del.id,game_get_id(game));
    /***/
    if (c) {
        /* send the packet on the connection */
        bits_packet_generic(p,BITS_ADDR_PEER);
        send_bits_packet_on(p,c);
    } else {
        /* broadcast the packet */
        bits_packet_generic(p,BITS_ADDR_BCAST);
        handle_bits_packet(bits_loopback_connection,p); /* also remove the game from this server */
        send_bits_packet(p);
    }
    packet_del_ref(p);
    return 0;
}
Example #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);
				}
Example #3
0
		static int _glist_cb_simple(t_game *game, void *data)
		{
			static int number;
			char clienttag_str[5];

			if (!data) {
				number = 1;
				return 0;
			}

			std::fprintf((std::FILE*)data, "game%d=%s,%u,%s\n", number, tag_uint_to_str(clienttag_str, game_get_clienttag(game)), game_get_id(game), game_get_name(game));
			number++;

			return 0;
		}