Subversion Repositories svn1-original

Rev

Rev 17 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 18
Line 59... Line 59...
59
#include    "proto.h"
59
#include    "proto.h"
60
 
60
 
61
void pri_awards(void);
61
void pri_awards(void);
62
void pri_master_index(void);
62
void pri_master_index(void);
63
char *placing ( int place );
63
char *placing ( int place );
-
 
64
void pri_name_index(void);
-
 
65
void pri_name_index_body( void );
64
 
66
 
65
 
67
 
66
menu_table  rpt_menu[] = {
68
menu_table  rpt_menu[] = {
67
    { '1', "Print team order", pri_team },
69
    { '1', "Print team order", pri_team },
68
    { '2', "Print end leg times", pri_leg },
70
    { '2', "Print end leg times", pri_leg },
Line 73... Line 75...
73
    { '7', "Update event and class placings", srt_place },
75
    { '7', "Update event and class placings", srt_place },
74
    { '8', "Display summary information", display_summary },
76
    { '8', "Display summary information", display_summary },
75
    { '9', "Print summary information", pri_summary },
77
    { '9', "Print summary information", pri_summary },
76
    { 'a', "Print Awards only", pri_awards },
78
    { 'a', "Print Awards only", pri_awards },
77
    { 'b', "Print Master Index only", pri_master_index },
79
    { 'b', "Print Master Index only", pri_master_index },
-
 
80
    { 'c', "Print Name Index only", pri_name_index },
78
 
81
 
79
#if defined(HI_TECH_C) || defined(__TURBOC__)
82
#if defined(HI_TECH_C) || defined(__TURBOC__)
80
    { 'S', "MS-DOS system", ms_system },
83
    { 'S', "MS-DOS system", ms_system },
81
#endif
84
#endif
82
    { 'q', "Return to main menu", 0 },
85
    { 'q', "Return to main menu", 0 },
Line 124... Line 127...
124
/*
127
/*
125
**  Data
128
**  Data
126
*/
129
*/
127
ty_s_data  *sort_data = 0;                       /* pointer to memory */
130
ty_s_data  *sort_data = 0;                       /* pointer to memory */
128
ty_s_aux   *sort_aux = 0;                        /* pointer to aux sort info */
131
ty_s_aux   *sort_aux = 0;                        /* pointer to aux sort info */
-
 
132
ty_s_namedata *sort_name_data = 0;                /* pointer to name info */
129
unsigned    sort_num;                            /* Number in the array */
133
unsigned    sort_num;                            /* Number in the array */
-
 
134
unsigned    sort_num_data;                       /* Number in the array */
130
 
135
 
131
/*
136
/*
132
**  A structure to hold statistical information
137
**  A structure to hold statistical information
133
*/
138
*/
134
typedef struct
139
typedef struct
Line 167... Line 172...
167
 
172
 
168
    if( sort_data )
173
    if( sort_data )
169
        free( ( char * ) sort_data );
174
        free( ( char * ) sort_data );
170
    if( sort_aux )
175
    if( sort_aux )
171
        free( ( char * ) sort_aux );
176
        free( ( char * ) sort_aux );
-
 
177
    if ( sort_name_data )
-
 
178
        free( ( char * ) sort_name_data );
172
    sort_data = ( ty_s_data * ) 0;
179
    sort_data = ( ty_s_data * ) 0;
173
    sort_aux = ( ty_s_aux * ) 0;
180
    sort_aux = ( ty_s_aux * ) 0;
-
 
181
    sort_name_data = ( ty_s_namedata * ) 0;
174
}
182
}
175
 
183
 
176
/*========================================================================
184
/*========================================================================
177
 *
185
 *
178
 *  Print in team order
186
 *  Print in team order
Line 264... Line 272...
264
        }
272
        }
265
    }
273
    }
266
    close_printer();
274
    close_printer();
267
}
275
}
268
 
276
 
-
 
277
/*========================================================================
-
 
278
 *
-
 
279
 *  Print in name order
-
 
280
 *
-
 
281
 *  Purpose:
-
 
282
 *      This function is called to print a list of all known competitors
-
 
283
 *      This function may also be used to create an HTML suite of files
-
 
284
 *      within the result set
-
 
285
 *
-
 
286
 *  Parameters:
-
 
287
 *      None
-
 
288
 *
-
 
289
 *  Returns:
-
 
290
 *      Nothing
-
 
291
 *
-
 
292
 *========================================================================*/
-
 
293
void pri_name_index( void )
-
 
294
{
-
 
295
    cur( 0, 5 );
-
 
296
    printf( "Team Member information - in name order\n" );
-
 
297
    printf( "\nPrinting competitor names\n" );
-
 
298
    flush_out();
-
 
299
    pri_name_index_body();
-
 
300
    printf( "Found %d names\n", sort_num_data );
-
 
301
    printf( "\nAny key to continue" );
-
 
302
    getinp();
-
 
303
}
-
 
304
 
-
 
305
/*========================================================================
-
 
306
 *
-
 
307
 *  Print in name order
-
 
308
 *
-
 
309
 *  Purpose:
-
 
310
 *      This function is called to print a list of all known competitors
-
 
311
 *      This function may also be used to create an HTML suite of files
-
 
312
 *      within the result set
-
 
313
 *
-
 
314
 *  Parameters:
-
 
315
 *      None
-
 
316
 *
-
 
317
 *  Returns:
-
 
318
 *      Nothing
-
 
319
 *
-
 
320
 *========================================================================*/
-
 
321
void pri_name_index_body( void )
-
 
322
{
-
 
323
    ty_s_namedata *ptr;
-
 
324
    unsigned    num;
-
 
325
    int i,k;
-
 
326
    int num_names;
-
 
327
 
-
 
328
    /*
-
 
329
    **  Determine the number of names to allow for
-
 
330
    *   Based on the total number of teams
-
 
331
    */
-
 
332
    num = config.max_team - config.min_team + 1 ;
-
 
333
    num *= MAX_MEMB;
-
 
334
 
-
 
335
    sort_name_data = ( ty_s_namedata * ) calloc ( num , sizeof( ty_s_namedata ) );
-
 
336
 
-
 
337
    if( sort_name_data == 0 )
-
 
338
    {
-
 
339
        printf( "\n\nError in allocating memory\n" );
-
 
340
        sleep( 5 );
-
 
341
        return;
-
 
342
    }
-
 
343
 
-
 
344
    /*
-
 
345
    **  Read all teams an extract name information
-
 
346
    */
-
 
347
    ptr = sort_name_data;
-
 
348
    for( i = config.min_team; i <= config.max_team; i++ )
-
 
349
    {
-
 
350
        if( valid_field( i ) && g_record( i, &team_buf ) )
-
 
351
        {
-
 
352
            num_names = 0;
-
 
353
            for( k = 0; k < MAX_MEMB; k++ )
-
 
354
            {
-
 
355
                if ( team_buf.members[k].name[0] )
-
 
356
                {
-
 
357
                    ptr->team = i;
-
 
358
                    ptr->leg = k;
-
 
359
                    ptr->class = team_buf.class;
-
 
360
                    strncpy( ptr->name,team_buf.members[k].name, sizeof(team_buf.members[k].name));
-
 
361
                    ptr++;
-
 
362
                    num_names++;
-
 
363
                }
-
 
364
            }
-
 
365
 
-
 
366
            if ( num_names == 0 )
-
 
367
            {
-
 
368
                ptr->team = i;
-
 
369
                ptr->leg = 0;
-
 
370
                ptr->class = team_buf.class;
-
 
371
                strncpy( ptr->name,team_buf.name, sizeof(team_buf.members[k].name));
-
 
372
                ptr++;
-
 
373
            }
-
 
374
 
-
 
375
        }
-
 
376
    }
-
 
377
    sort_num_data = ptr - sort_name_data;
-
 
378
 
-
 
379
    /*
-
 
380
    **  Now stort the entries by name:team:leg
-
 
381
    */
-
 
382
    qsort( ( char * ) sort_name_data, sort_num_data, sizeof( ty_s_namedata ), sort_comp_cname );
-
 
383
 
-
 
384
    /*
-
 
385
    **  Now generate the report
-
 
386
    */
-
 
387
 
-
 
388
    if( !open_printer( "", "competitor", 80, report_html, "Competitor Names" ) )
-
 
389
        return;
-
 
390
 
-
 
391
    /*
-
 
392
     * Print out the data 
-
 
393
     * Print out the header
-
 
394
     */
-
 
395
    print( "\n" );
-
 
396
 
-
 
397
    print_underline( TRUE );
-
 
398
    print( "%-*s %-*s %-*s %-*s", MAX_TM_NAME + 5, "Competitor name",
-
 
399
               6, "Leg",
-
 
400
               5, "Team",
-
 
401
               LEN_CLASS_NAME, "Category"
-
 
402
               );
-
 
403
    print_underline( FALSE ) ;
-
 
404
    print( "\n" );
-
 
405
 
-
 
406
    ptr = sort_name_data;
-
 
407
    for( k = 1; k <= sort_num_data; k++, ptr++ )
-
 
408
    {
-
 
409
        print( "%-*s", MAX_TM_NAME + 5, ptr->name );
-
 
410
        print( " " );
-
 
411
        
-
 
412
        if ( report_html ) print( "<A HREF=\"%s#Team_%04d\">", p_filename(filebase, "finish" ,"html"), ptr->team );
-
 
413
        print( "%-*d", 6, ptr->leg + 1 );
-
 
414
        if ( report_html ) print( "</A>" );
-
 
415
        print( " " );
-
 
416
 
-
 
417
        if ( report_html ) print( "<A HREF=\"%s#Team_%04d\">", p_filename(filebase, "name" ,"html"), ptr->team );
-
 
418
        print( "%-*d", 5, ptr->team );
-
 
419
        if ( report_html ) print( "</A>" );
-
 
420
        print( " " );
-
 
421
 
-
 
422
        if ( report_html ) print( "<A HREF=\"%s#Team_%04d\">",p_filename(filebase, config.team_class[ptr->class - 1].abr ,"html"), ptr->team );
-
 
423
        print( "%-*s", LEN_CLASS_NAME, ptr->class == 0 ? "" : config.team_class[ptr->class - 1].abr );
-
 
424
        if ( report_html ) print( "</A>" );
-
 
425
        print( " " );
-
 
426
 
-
 
427
        if ( ptr->multi ) print( "* ");
-
 
428
        print( "\n" );
-
 
429
    }
-
 
430
 
-
 
431
    print_legend( -1, 0 );
-
 
432
    close_printer();
-
 
433
    
-
 
434
}
269
 
435
 
270
/*========================================================================
436
/*========================================================================
271
 *
437
 *
272
 *  Print in given leg finishing time
438
 *  Print in given leg finishing time
273
 *
439
 *
Line 799... Line 965...
799
 
965
 
800
        print( "\n" );
966
        print( "\n" );
801
    }
967
    }
802
 
968
 
803
    print_class_stats( -1, TRUE );              /* Print statistics */
969
    print_class_stats( -1, TRUE );              /* Print statistics */
804
    print_legend(-1);                            /* Print the legend */
970
    print_legend(-1, 1 );                       /* Print the legend */
805
    close_printer();                            /* Close the printer */
971
    close_printer();                            /* Close the printer */
806
 
972
 
807
    /*
973
    /*
808
     * Now produce a breakdown on a class by class basis 
974
     * Now produce a breakdown on a class by class basis 
809
     * Now print out the class placement information
975
     * Now print out the class placement information
Line 829... Line 995...
829
        if( last_class != ptr->class )
995
        if( last_class != ptr->class )
830
        {
996
        {
831
            if( last_class >= 0 )
997
            if( last_class >= 0 )
832
            {
998
            {
833
                print_class_stats( last_class, TRUE );
999
                print_class_stats( last_class, TRUE );
834
                print_legend( last_class );
1000
                print_legend( last_class, 1 );
835
                close_printer();
1001
                close_printer();
836
            }
1002
            }
837
 
1003
 
838
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, ptr->class == 0 ? "" : config.team_class[ptr->class - 1].full_name );
1004
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, ptr->class == 0 ? "" : config.team_class[ptr->class - 1].full_name );
839
 
1005
 
Line 898... Line 1064...
898
 
1064
 
899
        print( "\n" );
1065
        print( "\n" );
900
    }
1066
    }
901
 
1067
 
902
    print_class_stats( last_class, TRUE );
1068
    print_class_stats( last_class, TRUE );
903
    print_legend(last_class);
1069
    print_legend(last_class,1);
904
    close_printer();
1070
    close_printer();
905
 
1071
 
906
 
1072
 
907
    /*
1073
    /*
908
    **  If we are generating an HTML report then we need to create the file
1074
    **  If we are generating an HTML report then we need to create the file
Line 929... Line 1095...
929
    if ( report_html )
1095
    if ( report_html )
930
    {
1096
    {
931
        pri_master_index();
1097
        pri_master_index();
932
    }
1098
    }
933
 
1099
 
-
 
1100
    pri_name_index_body();
-
 
1101
 
934
}
1102
}
935
 
1103
 
936
/*========================================================================
1104
/*========================================================================
937
 *
1105
 *
938
 *  Place to text
1106
 *  Place to text
Line 1229... Line 1397...
1229
 
1397
 
1230
    /*
1398
    /*
1231
    **  Names
1399
    **  Names
1232
    */
1400
    */
1233
    print( "<TABLE border=0 align=center>" );
1401
    print( "<TABLE border=0 align=center>" );
1234
    pri_master_index_entry( "name", "Teams by Name" );
1402
    pri_master_index_entry( "name", "Team list" );
-
 
1403
    pri_master_index_entry( "competitor", "Competitor list" );
1235
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
1404
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
1236
    pri_master_index_entry( "awards", "Prizes and Awards" );
1405
    pri_master_index_entry( "awards", "Prizes and Awards" );
1237
    print( "<tr><td>\n" );
1406
    print( "<tr><td>\n" );
1238
 
1407
 
1239
    print( "\n" );
1408
    print( "\n" );
Line 1324... Line 1493...
1324
               pi_place( team_buf.leg[config.num_legs].lec_place,
1493
               pi_place( team_buf.leg[config.num_legs].lec_place,
1325
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
1494
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
1326
    }
1495
    }
1327
 
1496
 
1328
    print_class_stats( -1, FALSE );             /* Print statistics */
1497
    print_class_stats( -1, FALSE );             /* Print statistics */
1329
    print_legend(-1);                             /* Print the legend */
1498
    print_legend(-1, 1);                        /* Print the legend */
1330
    close_printer();                            /* Close the printer */
1499
    close_printer();                            /* Close the printer */
1331
 
1500
 
1332
 
1501
 
1333
    /*
1502
    /*
1334
     * Now produce a breakdown on a class by class basis 
1503
     * Now produce a breakdown on a class by class basis 
Line 1355... Line 1524...
1355
        if( last_class != ptr->class )
1524
        if( last_class != ptr->class )
1356
        {
1525
        {
1357
            if( last_class >= 0 )
1526
            if( last_class >= 0 )
1358
            {
1527
            {
1359
                print_class_stats( last_class, TRUE );
1528
                print_class_stats( last_class, TRUE );
1360
                print_legend(last_class);
1529
                print_legend(last_class, 1);
1361
                close_printer();
1530
                close_printer();
1362
            }
1531
            }
1363
 
1532
 
1364
            report_title = tprintf( "Interim Category results for : %-*s", LEN_CLASS_NAME, team_buf.class == 0 ? "" : config.team_class[ptr->class - 1].full_name );
1533
            report_title = tprintf( "Interim Category results for : %-*s", LEN_CLASS_NAME, team_buf.class == 0 ? "" : config.team_class[ptr->class - 1].full_name );
1365
 
1534
 
Line 1396... Line 1565...
1396
               pi_place( team_buf.leg[config.num_legs].le_place,
1565
               pi_place( team_buf.leg[config.num_legs].le_place,
1397
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
1566
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
1398
    }
1567
    }
1399
 
1568
 
1400
    print_class_stats( last_class, FALSE );
1569
    print_class_stats( last_class, FALSE );
1401
    print_legend(last_class);
1570
    print_legend(last_class, 1);
1402
    close_printer();
1571
    close_printer();
1403
 
1572
 
1404
}
1573
}
1405
 
1574
 
1406
/*========================================================================
1575
/*========================================================================
Line 1560... Line 1729...
1560
 *  Purpose:
1729
 *  Purpose:
1561
 *      This function is called to Print the legend
1730
 *      This function is called to Print the legend
1562
 *
1731
 *
1563
 *  Parameters:
1732
 *  Parameters:
1564
 *      class       - Class currently being printed
1733
 *      class       - Class currently being printed
-
 
1734
 *      full        - Display full legend
1565
 *
1735
 *
1566
 *  Returns:
1736
 *  Returns:
1567
 *      Nothing
1737
 *      Nothing
1568
 *
1738
 *
1569
 *========================================================================*/
1739
 *========================================================================*/
1570
 
1740
 
1571
void print_legend ( int class )
1741
void print_legend ( int class, int full )
1572
{
1742
{
1573
 
1743
 
1574
    int         i;
1744
    int         i;
1575
    char        line[201];
1745
    char        line[201];
1576
    FILE       *adfile = NULL;
1746
    FILE       *adfile = NULL;
Line 1637... Line 1807...
1637
                if( !( ++count % 5 ) )
1807
                if( !( ++count % 5 ) )
1638
                    print( "\n" );
1808
                    print( "\n" );
1639
            }
1809
            }
1640
        }
1810
        }
1641
    }
1811
    }
-
 
1812
    print( "\n" );
1642
 
1813
 
1643
    /*
1814
    /*
1644
     * Other comments 
1815
     * Other comments 
1645
     */
1816
     */
-
 
1817
    if ( full )
1646
 
1818
    {
1647
    print( "\n\nPlace numbers (LP and EP)\n" );
1819
        print( "\nPlace numbers (LP and EP)\n" );
1648
    print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
1820
        print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
1649
    print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
1821
        print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
-
 
1822
    }
1650
 
1823
 
1651
    /*
1824
    /*
1652
     *  Insert the contents of the config.addendum file
1825
     *  Insert the contents of the config.addendum file
1653
     *  or a defualt message
1826
     *  or a defualt message
1654
     */
1827
     */
Line 2403... Line 2576...
2403
    return ( ( ta > 0 ) ? -1 : 1 );
2576
    return ( ( ta > 0 ) ? -1 : 1 );
2404
}
2577
}
2405
 
2578
 
2406
/*========================================================================
2579
/*========================================================================
2407
 *
2580
 *
-
 
2581
 *  qsort comparison function - competitor names
-
 
2582
 *
-
 
2583
 *  Purpose:
-
 
2584
 *      This function is called by qsort as a Sort comparison function
-
 
2585
 *
-
 
2586
 *  Parameters:
-
 
2587
 *      a       - 1st record
-
 
2588
 *      b       - 2nd record
-
 
2589
 *
-
 
2590
 *  Returns:
-
 
2591
 *      value to qsort
-
 
2592
 *
-
 
2593
 *========================================================================*/
-
 
2594
 
-
 
2595
int sort_comp_cname( const void * aa, const void * bb )
-
 
2596
{
-
 
2597
    ty_s_namedata * a = aa;
-
 
2598
    ty_s_namedata * b = bb;
-
 
2599
 
-
 
2600
 
-
 
2601
    int         i;                               /* One of those */
-
 
2602
 
-
 
2603
    /*
-
 
2604
    **  Sort by name
-
 
2605
    */
-
 
2606
    i = strcmp ( a->name, b->name );
-
 
2607
    if ( i )
-
 
2608
        return ( i );
-
 
2609
    a->multi=1;
-
 
2610
    b->multi=1;
-
 
2611
 
-
 
2612
    /*
-
 
2613
    **  Sort by Leg
-
 
2614
    */
-
 
2615
    i = a->leg - b->leg;
-
 
2616
    if ( i )
-
 
2617
        return ( i );
-
 
2618
 
-
 
2619
    /*
-
 
2620
    **  Sorting on Team Number
-
 
2621
    */
-
 
2622
    return ( a->team - b->team );
-
 
2623
 
-
 
2624
}
-
 
2625
 
-
 
2626
/*========================================================================
-
 
2627
 *
2408
 *  load report data into memory
2628
 *  load report data into memory
2409
 *
2629
 *
2410
 *  Purpose:
2630
 *  Purpose:
2411
 *      This routine will pull all the data into memory 
2631
 *      This routine will pull all the data into memory 
2412
 *      Not all the team data is loaded. Only that essential for the
2632
 *      Not all the team data is loaded. Only that essential for the