qstat.c
/**
 * JSON output
 * Contributed by Steve Teuber <steve@exprojects.org>
 */
JSON output
Contributed by Steve Teuber 
JSON output Contributed by Steve Teuber
void json_protocols()
{
	int i;
	server_type *type;
	server_type **sorted_types;
	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);
	printf("{\n");
	for (i = 0; i < n_server_types; i++)
	{
		type = sorted_types[i];
		if (i) printf(",\n");
		printf("\t\"%s\": \"%s\"", type->type_string, type->game_name);
	}
	printf("\n}\n");
	exit(0);
}
void json_protocols ( ) { int i ; server_type * type ; server_type * * sorted_types ; 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 ) ; printf ( " \n " ) ; for ( i = 0 ; i < n_server_types ; i ++ ) { type = sorted_types [ i ] ; if ( i ) printf ( " \n " ) ; printf ( " \t \" \" \" \" " , type -> type_string , type -> game_name ) ; } printf ( " \n \n " ) ; exit ( 0 ) ; }
JSON output
 Contributed by Steve Teuber <steve@exprojects.org>
JSON output Contributed by Steve Teuber <steve@exprojects . org >