/* show-hiscore.c -- The main function for get_highscore_client(). Created on: 2008/12/06 19:21:52 ~yas/dsys/highscore/centralized/show-hiscore.c */ #include /* stderr, fprintf() */ #include /* strtol() */ #include "highscore-tcp.h" static void show_score( char *host, int port, int top ); static void usage( char *comname ) { fprintf(stderr,"Usage: %% %s host portno n\n", comname); exit( 1 ); } main( int argc, char *argv[], char *envp[] ) { int top, portno ; char *name, *server ; if( argc != 4 ) usage( argv[0] ); server = argv[1]; portno = strtol( argv[2], 0, 10); top = strtol( argv[3], 0, 10); show_score( server, portno, top ); } static void show_score( char *server, int portno, int top ) { score_record_t records[HIGHSCORE_MAX_RECORDS]; int n, i ; if( top > HIGHSCORE_MAX_RECORDS ) { fprintf(stderr,"Warning: top too large: %d\n",top); top = HIGHSCORE_MAX_RECORDS; } n = get_highscore_client( server, portno, records, top ); if( n >= 0 ) { printf("%d hiscore record(s) received\n", n ); for( i=0; i