qstat.c
/* Print an error message and the program usage notes
 */
Print an error message and the program usage notes
Print an error message and the program usage notes
void usage(char *msg, char **argv, char *a1)
{
	int i;
	server_type *type;
	server_type **sorted_types;
	if (msg)
	{
		fprintf(stderr, msg, a1);
	}
	printf("Usage: %s [options ...]\n", argv[0]);
	printf("\t[-default server-type] [-cfg file] [-f file] [host[:port]] ...\n");
	printf("Where host is an IP address or host name\n");
	sorted_types = (server_type **)malloc(sizeof(server_type*) * n_server_types);
	type = &types[0];
	for (i = 0; type->id != Q_UNKNOWN_TYPE; type++, i++)
	{
		sorted_types[i] = type;
	}
	quicksort((void **)sorted_types, 0, n_server_types - 1, (int(*)(void *, void*))type_option_compare);
	for (i = 0; i < n_server_types; i++)
	{
		type = sorted_types[i];
		printf("%s\t\tquery %s server\n", type->type_option, type->game_name);
	}
	quicksort((void **)sorted_types, 0, n_server_types - 1, (int(*)(void *, void*))type_string_compare);
	printf("-default\tset default server type:");
	for (i = 0; i < n_server_types; type++, i++)
	{
		type = sorted_types[i];
		printf(" %s", type->type_string);
	}
	puts("");
	printf("-nocfg\t\tIgnore qstat configuration loaded from any default location. Must be the first option on the command-line.\n");
	printf("-cfg\t\tread the extended types from given file not the default one\n");
	printf("-f\t\tread hosts from file\n");
	printf("-R\t\tfetch and display server rules\n");
	printf("-P\t\tfetch and display player info\n");
	printf("-sort\t\tsort servers and/or players\n");
	printf("-u\t\tonly display servers that are up\n");
	printf("-nf\t\tdo not display full servers\n");
	printf("-ne\t\tdo not display empty servers\n");
	printf("-nh\t\tdo not display header line.\n");
	printf("-cn\t\tdisplay color names instead of numbers\n");
	printf("-ncn\t\tdisplay color numbers instead of names\n");
	printf("-hc\t\tdisplay colors in #rrggbb format\n");
	printf("-tc\t\tdisplay time in clock format (DhDDmDDs)\n");
	printf("-tsw\t\tdisplay time in stop-watch format (DD:DD:DD)\n");
	printf("-ts\t\tdisplay time in seconds\n");
	printf("-pa\t\tdisplay player address\n");
	printf("-hpn\t\tdisplay player names in hex\n");
	printf("-hsn\t\tdisplay server names in hex\n");
	printf("-nh\t\tdo not display header\n");
	printf("-old\t\told style display\n");
	printf("-progress\tdisplay progress meter (text only)\n");
	printf("-retry\t\tnumber of retries, default is %d\n", DEFAULT_RETRIES);
	printf("-interval\tinterval between retries, default is %.2f seconds\n", DEFAULT_RETRY_INTERVAL / 1000.0);
	printf("-mi\t\tinterval between master server retries, default is %.2f seconds\n", (DEFAULT_RETRY_INTERVAL *4) / 1000.0);
	printf("-timeout\ttotal time in seconds before giving up\n");
	printf("-maxsim\t\tset maximum simultaneous queries\n");
	printf("-sendinterval\t\tset time in ms between sending packets, default %u\n", sendinterval);
	printf("-errors\t\tdisplay errors\n");
	printf("-allowserverdups\t\tallow adding multiple servers with same ip:port (needed for ts2)\n");
	printf("-of\t\toutput file\n");
	printf("-af\t\tLike -of, but append to the file\n");
	printf("-raw <delim>\toutput in raw format using <delim> as delimiter\n");
	printf("-mdelim <delim>\tFor rules with multi values use <delim> as delimiter\n");
	printf("-xml\t\toutput status data as an XML document\n");
	printf("-json\t\toutput status data as an JSON document\n");
	printf("-Th,-Ts,-Tpt\toutput templates: header, server and player\n");
	printf("-Tr,-Tt\t\toutput templates: rule, and trailer\n");
	printf("-srcport <range>\tSend packets from these network ports\n");
	printf("-srcip <IP>\tSend packets using this IP address\n");
	printf("-H\t\tresolve host names\n");
	printf("-Hcache\t\thost name cache file\n");
	printf("-carets\t\tDisplay carets in Quake 3 player names\n");
	printf("-d\t\tEnable debug options. Specify multiple times to increase debug level.\n");
#ifdef ENABLE_DUMP
	printf("-dump\t\twrite received raw packets to dumpNNN files which must not exist before\n");
	printf("-pkt <file>\tuse file as server reply instead of quering the server. Works only with TF_SINGLE_QUERY servers\n");
#endif
	printf("-htmlmode\tConvert <, >, and & to the equivalent HTML entities\n");
	printf("-htmlnames\tColorize Quake 3 and Tribes 2 player names using html font tags\n");
	printf("-nohtmlnames\tDo not colorize Quake 3 and Tribes 2 player names even if $HTML is used in an output template.\n");
	printf("-syncconnect\tProcess connect initialisation synchronously.\n");
	printf("-stripunprintable\tDisable stripping of unprintable characters.\n");
	printf("-showgameport\tAlways display the game port in QStat output.\n");
	printf("-noportoffset\tDont use builtin status port offsets ( assume query port was specified ).\n");
	printf("-raw-arg\tWhen used with -raw, always display the server address as it appeared in a file or on the command-line.\n");
	printf("-utf8\t\tUse the UTF-8 character encoding for XML output.\n");
	printf("-bom\t\tOutput Byte-Order-Mark for XML output.\n");
#ifdef _WIN32
	printf("-noconsole\t\tFree the console\n");
#endif
	printf("\n");
	printf("Sort keys:\n");
	printf("  servers: p=by-ping, g=by-game, i=by-IP-address, h=by-hostname, n=by-#-players, l=by-list-order\n");
	printf("  players: P=by-ping, F=by-frags, T=by-team, N=by-name\n");
	printf("\nqstat version %s\n", VERSION);
	exit(0);
}
void usage ( char * msg , char * * argv , char * a1 ) { int i ; server_type * type ; server_type * * sorted_types ; if ( msg ) { fprintf ( stderr , msg , a1 ) ; } printf ( " \n " , argv [ 0 ] ) ; printf ( " \t \n " ) ; printf ( " \n " ) ; sorted_types = ( server_type * * ) malloc ( sizeof ( server_type * ) * n_server_types ) ; type = & types [ 0 ] ; for ( i = 0 ; type -> id != Q_UNKNOWN_TYPE ; type ++ , i ++ ) { sorted_types [ i ] = type ; } quicksort ( ( void * * ) sorted_types , 0 , n_server_types - 1 , ( int ( * ) ( void * , void * ) ) type_option_compare ) ; for ( i = 0 ; i < n_server_types ; i ++ ) { type = sorted_types [ i ] ; printf ( " \t \t \n " , type -> type_option , type -> game_name ) ; } quicksort ( ( void * * ) sorted_types , 0 , n_server_types - 1 , ( int ( * ) ( void * , void * ) ) type_string_compare ) ; printf ( " \t " ) ; for ( i = 0 ; i < n_server_types ; type ++ , i ++ ) { type = sorted_types [ i ] ; printf ( " " , type -> type_string ) ; } puts ( " " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " , DEFAULT_RETRIES ) ; printf ( " \t \n " , DEFAULT_RETRY_INTERVAL / 1000.0 ) ; printf ( " \t \t \n " , ( DEFAULT_RETRY_INTERVAL * 4 ) / 1000.0 ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " , sendinterval ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; #ifdef ENABLE_DUMP printf ( " \t \t \n " ) ; printf ( " \t \n " ) ; #endif printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \n " ) ; printf ( " \t \t \n " ) ; printf ( " \t \t \n " ) ; #ifdef _WIN32 printf ( " \t \t \n " ) ; #endif printf ( " \n " ) ; printf ( " \n " ) ; printf ( " \n " ) ; printf ( " \n " ) ; printf ( " \n \n " , VERSION ) ; exit ( 0 ) ; }
Print an error message and the program usage notes
Print an error message and the program usage notes