qstat.c
// Updates a servers port information.
// Sets the rules:
// _queryport <queryport>
// hostport <port>
Updates a servers port information.
Sets the rules:
_queryport 
hostport 
Updates a servers port information . Sets the rules : _queryport hostport
void change_server_port(struct qserver *server, unsigned short port, int force)
{
	if (port > 0 && port != server->port)
	{
		char arg[64];
		unsigned int ipaddr = ntohl(server->ipaddr);
		sprintf(arg, "%d.%d.%d.%d:%hu", ipaddr >> 24, (ipaddr >> 16) &0xff, (ipaddr >> 8) &0xff, ipaddr &0xff, port);
		if (show_game_port || force || server->flags &TF_SHOW_GAME_PORT)
		{
			free(server->arg);
			server->arg = strdup(arg);
			sprintf(arg, "%hu", server->port);
			add_rule(server, "_queryport", arg, NO_FLAGS);
			server->port = port;
		}
		if ( 0 != strcmp(server->arg, server->host_name) )
		{
			char *colon = strchr(server->host_name, ':');
			char *hostname = malloc( strlen(server->host_name) + 7 );
			if ( NULL == hostname )
			{
				fprintf(stderr, "Failed to malloc hostname memory\n");
			}
			else
			{
				if (colon)
				{
					*colon = '\0';
				}
				sprintf(hostname, "%s:%hu", server->host_name, port);
				free(server->host_name);
				server->host_name = hostname;
			}
		}
		sprintf(arg, "%hu", port);
		add_rule(server, "hostport", arg, OVERWITE_DUPLICATES);
	}
}
void change_server_port ( struct qserver * server , unsigned short port , int force ) { if ( port > 0 && port != server -> port ) { char arg [ 64 ] ; unsigned int ipaddr = ntohl ( server -> ipaddr ) ; sprintf ( arg , " " , ipaddr >> 24 , ( ipaddr >> 16 ) & 0xff , ( ipaddr >> 8 ) & 0xff , ipaddr & 0xff , port ) ; if ( show_game_port || force || server -> flags & TF_SHOW_GAME_PORT ) { free ( server -> arg ) ; server -> arg = strdup ( arg ) ; sprintf ( arg , " " , server -> port ) ; add_rule ( server , " " , arg , NO_FLAGS ) ; server -> port = port ; } if ( 0 != strcmp ( server -> arg , server -> host_name ) ) { char * colon = strchr ( server -> host_name , ' ' ) ; char * hostname = malloc ( strlen ( server -> host_name ) + 7 ) ; if ( NULL == hostname ) { fprintf ( stderr , " \n " ) ; } else { if ( colon ) { * colon = ' \0 ' ; } sprintf ( hostname , " " , server -> host_name , port ) ; free ( server -> host_name ) ; server -> host_name = hostname ; } } sprintf ( arg , " " , port ) ; add_rule ( server , " " , arg , OVERWITE_DUPLICATES ) ; } }
Updates a servers port information.
Updates a servers port information .
// valid port and changing // Update the servers hostname as required // Update the server arg // Add a rule noting the previous query port // Update the servers port // hostname isnt the query arg // dns hostname or hostname:port // Add a rule noting the servers hostport