Subversion Repositories svn1-original

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 - 1
/*************************************************************************
2
*           Copyright (C) 1995 Embedded Solutions
3
*                       All rights reserved
4
*
5
* file:     src\config.c
6
*
7
* purpose:  Configuration module
8
*           This module will read in the configuration file and set up
9
*           all the configuration parameters
10
*
11
* functions
12
*       compact                 - Compact a string
13
*       conf_menu               - Configuration Menu
14
*       configure               - Read in the configuration file
15
*       d_class                 - Update the class information
16
*       d_cntry                 - Display / Update Country list
17
*       d_config                - Configuration Update and Display
18
*       define_class            - Update the class information
19
*       define_config           - Alter the configuration file
20
*       define_country          - Define a new entry in the county list
21
*       display_class           - Display the class information
22
*       display_config          - Display the marathon configuration
23
*       display_country         - Display the current country list
24
*       f_comp_int              - Qsort callback: Sort by team
25
*       r_config                - Read in the configuration file
26
*       rd_config               - Read in the configuration file
27
*       valid_field             - Validate a team number
28
*       wt_config               - Write out the configuration file
29
*
30
* programmer: David Purdie
31
*
32
* revision  date        by      reason
33
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
34
*
35
**************************************************************************/
36
 
37
#include    "consts.h"
38
#include    "structs.h"
39
#include    "proto.h"
40
 
99 david 41
#include    "QApplication"
42
 
95 - 43
/*
44
**  Local definitions
45
*/
46
char        confile[20];                         /* Name of the config file */
47
char        datfile[20];                         /* Name of the data file */
48
char        filebase[20];                        /* Event file name base */
49
 
176 - 50
//MARA_CFG    config;                              /* Working configuration */
162 david 51
//MARA_CFG    newcfg;                              /* Play configuration */
95 - 52
 
162 david 53
//t_class_summary class_summary;                   /* Class summary data */
95 - 54
 
162 david 55
//menu_table  cnf_menu[] = {
56
//    {'1', "Display current configuration", display_config},
57
//    {'2', "Alter configuration", ( void ( * )( void ) ) define_config},
58
//    {'3', "Display category configuration", display_class},
59
//    {'4', "Alter category configuration", ( void ( * )( void ) ) define_class},
60
//    {'5', "Display country list", display_country},
61
//    {'6', "Alter country list", define_country},
62
//    {'7', "Display winners list", display_winners},
63
//    {'8', "Alter winners list",  ( void ( * )( void ) ) define_winners},
64
//    {'q', "Return to main menu", 0},
65
//    {'\0'}
66
//};
95 - 67
 
68
/*========================================================================
69
 *
70
 *  Read in the configuration file
71
 *
72
 *  Purpose:
73
 *      This function is called to read in the configuration file
74
 *
75
 *  Parameters:
76
 *      c_name      Name of the configuartion file
77
 *      mode        TRUE: Create the file
78
 *
79
 *  Returns:
80
 *      Returns TRUE if the system was configured ok
81
 *
82
 *========================================================================*/
83
 
84
bool configure( char *c_name, int mode )
85
{
86
 
87
    FILE        * fcon;
88
    bool        ok = FALSE;
89
 
90
    strncpy( filebase, c_name, 8 );
91
    strcpy( confile, filebase );
92
    strcat( confile, ".cnf" );
93
    strcpy( datfile, filebase );
94
    strcat( datfile, ".dat" );
95
 
176 - 96
    return true;
97
 
95 - 98
    fcon = fopen( confile, "rb" );
99
    if ( fcon )
100
        fclose( fcon );
101
 
102
    if( mode )
103
    {
162 david 104
//        if( fcon )
105
//        {
164 david 106
//            printf( "Configuration file already exists" );
162 david 107
//            ok = FALSE;
108
//        }
109
//        else
110
//        {
111
//            ok = define_config(  );              /* Generate the configuration */
112
//            if( ok )
113
//                ok = define_class(  );
114
//        }
95 - 115
    }
116
    else if( fcon )
117
        ok = rd_config(  );                      /* read in the existing config */
118
    else
119
    {
120
        ok = FALSE;
164 david 121
        printf( "Configuration file not found" );
95 - 122
    }
123
 
124
    /*
125
     **  Post read calculations and fixups
126
     */
127
    if( config.datafilename[0] )
128
    {
129
        strcpy( datfile, config.datafilename );
130
        strcat( datfile, ".dat" );
131
    }
132
    config.nonequestrian_class = lookup_class( config.nonequestrian_class_abr, &config );
133
    return ( ok );
134
}
135
 
162 david 136
///*========================================================================
137
// *
138
// *  Configuration Menu
139
// *
140
// *  Purpose:
141
// *      This function is called to display the configuartion menu
142
// *
143
// *  Parameters:
144
// *      None
145
// *
146
// *  Returns:
147
// *      Nothing
148
// *
149
// *========================================================================*/
95 - 150
 
162 david 151
//void conf_menu( void )
152
//{
153
//    do_menu( "Event configuration", "Select option", cnf_menu );
154
//}
95 - 155
 
156
/*========================================================================
157
 *
158
 *  Alter the configuration file
159
 *
160
 *  Purpose:
161
 *      This function is called to alter the configuration file
162
 *
163
 *  Parameters:
164
 *      None
165
 *
166
 *  Returns:
167
 *      TRUE    - Configuration changed
168
 *      FALSE   - Configuration not changed
169
 *
170
 *========================================================================*/
171
 
162 david 172
//bool define_config( void )
173
//{
174
//    int         i, j;
175
//    int         error;
176
//    bool        changed = FALSE;
177
//    int         num_teams;
95 - 178
 
162 david 179
//    /*
180
//     **  Copy working configuration into a temp structure for
181
//     **  use within the function
182
//     */
183
//    newcfg = config;
95 - 184
 
162 david 185
//    do
186
//    {
187
//        error = 0;
188
//        num_teams = 0;
189
//        d_config( &newcfg, M_UPDATE );
164 david 190
//        printf( "" );
95 - 191
 
162 david 192
//        compact( newcfg.event_name );               /* Rip of leading white_space */
193
//        for( i = 0; i < MAX_LEGS; i++ )
194
//            compact( newcfg.leg_name[i] );
195
//        compact( newcfg.addendum );
196
//        compact( newcfg.datafilename );
95 - 197
 
162 david 198
//        /*
199
//         * Do all sorts of consistency tests on the data
200
//         * Firstly - calculate the number of legs. Justify the data in the array
201
//         */
95 - 202
 
162 david 203
//        newcfg.num_legs = 0;
204
//        for( i = 0; i < MAX_LEGS; i++ )
205
//            if( newcfg.leg_name[i][0] )
206
//                newcfg.num_legs++;
207
//        for( i = newcfg.num_legs; i < MAX_LEGS; i++ )
208
//            if( newcfg.leg_name[i][0] )
209
//            {
164 david 210
//                printf( "Configuration error: Missing leg" );
162 david 211
//                error++;
212
//            }
95 - 213
 
214
 
162 david 215
//        /*
216
//         * Now do the team numbering stuff
217
//         */
95 - 218
 
162 david 219
//        for( i = 0; i < MAX_TMS_SPLIT; i++ )
220
//        {
221
//            if( newcfg.t_def[i].start == 0 && newcfg.t_def[i].end == 0 )
222
//                continue;
223
//            if( newcfg.t_def[i].start > newcfg.t_def[i].end )
224
//            {
225
//                printf
164 david 226
//                    ( "Team definition error : End greater than start. %d to %d",
162 david 227
//                      newcfg.t_def[i].start, newcfg.t_def[i].end );
228
//                error++;
229
//            }
230
//            for( j = 0; j < i; j++ )
231
//            {
232
//                if( ( newcfg.t_def[i].start >= newcfg.t_def[j].start
233
//                      && newcfg.t_def[i].start <= newcfg.t_def[j].end )
234
//                    || ( newcfg.t_def[i].end >= newcfg.t_def[j].start
235
//                         && newcfg.t_def[i].end <= newcfg.t_def[j].end ) )
236
//                {
237
//                    printf
164 david 238
//                        ( "Team definition error : Overlapping definition. %d to %d",
162 david 239
//                          newcfg.t_def[i].start, newcfg.t_def[i].end );
240
//                    error++;
241
//                }
242
//            }
243
//        }
95 - 244
 
162 david 245
//        /*
246
//         * Determine the number of team splits
247
//         * There may be blank entries - these will be removed by sorting the array
248
//         */
249
//        qsort( ( char * ) newcfg.t_def, MAX_TMS_SPLIT, sizeof( *newcfg.t_def ), f_comp_int );
250
//        for( newcfg.num_teams = 0; newcfg.num_teams < MAX_TMS_SPLIT; newcfg.num_teams++ )
251
//            if( !newcfg.t_def[newcfg.num_teams].start )
252
//                break;
95 - 253
 
162 david 254
//        newcfg.min_team = newcfg.t_def[0].start;
255
//        newcfg.max_team = newcfg.t_def[newcfg.num_teams - 1].end;
95 - 256
 
162 david 257
//        /*
258
//         **  Limit the number of entrants
259
//         */
260
//        for( i = 0; i < MAX_TMS_SPLIT; i++ )
261
//        {
262
//            if( newcfg.t_def[i].start )
263
//            {
264
//                num_teams += newcfg.t_def[i].end - newcfg.t_def[i].start + 1;
265
//            }
266
//        }
267
//#if defined(LIMIT_TEAMS) && (LIMIT_TEAMS > 0)
268
//        if( num_teams > LIMIT_TEAMS )
269
//        {
164 david 270
//            printf( "Maximum number of teams exceeded - reduce number of teams" );
162 david 271
//            error++;
272
//        }
273
//#endif
95 - 274
 
162 david 275
//#if defined (HI_TECH_C) || defined (__TURBOC__)
95 - 276
 
162 david 277
//        /*
278
//         * Ensure that the number of teams allocated can fit within available
279
//         * Memory space. Ie: Can we malloc the report data structures
280
//         */
281
//        {
282
//            long        sz;
95 - 283
 
162 david 284
//            sz = sizeof( ty_s_data ) > sizeof( ty_s_aux ) ?
285
//                sizeof( ty_s_data ) : sizeof( ty_s_aux );
286
//            if( sz * ( newcfg.max_team - newcfg.min_team + 2 ) > ( 1024L * 64L ) )
287
//            {
164 david 288
//                printf( "Too many teams: Reduce team spread." );
162 david 289
//                error++;
290
//            }
291
//        }
292
//#endif
95 - 293
 
162 david 294
//        /*
295
//         **  Ensure the non-equestrian class and the equestrian leg are valid
296
//         */
297
//        if( newcfg.equestrian_leg )
298
//        {
299
//            if( newcfg.equestrian_leg > newcfg.num_legs )
300
//            {
164 david 301
//                printf( "Invalid non-equestrian leg number." );
162 david 302
//                error++;
303
//            }
95 - 304
 
162 david 305
//            /*
306
//             **  Ensure that the entered non-equestrian class name does exist
307
//             */
308
//            newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
309
//            if( newcfg.nonequestrian_class == 0 )
164 david 310
//                printf( "WARNING: Non-equestrian class not found" );
162 david 311
//        }
95 - 312
 
162 david 313
//        abort_flag = FALSE;
314
//        if( error )
315
//        {
164 david 316
//            printf( "Configuration error - error must be corrected" );
162 david 317
//            printf( "Any key to continue " );
318
//            ( void ) getinp(  );
319
//            continue;
320
//        }
321
//        else
322
//        {
323
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
324
//            switch ( getfnc( "*YDEA" ) )
325
//            {
326
//            case 'Y':
327
//                error = ( newcfg.num_legs == 0 || newcfg.num_teams == 0 );
328
//                if( error )
164 david 329
//                    printf( "Configuration not installed. No legs or teams defined" );
162 david 330
//                else
331
//                {
332
//                    config = newcfg;
333
//                    wt_config(  );               /* Write out the data */
334
//                    changed = TRUE;
335
//                }
336
//                break;
95 - 337
 
162 david 338
//            case 'D':
339
//                break;
95 - 340
 
162 david 341
//            default:
342
//                error = TRUE;
343
//                break;
344
//            }
345
//        }
346
//    }
347
//    while( error );
95 - 348
 
162 david 349
//    return ( changed );
350
//}
95 - 351
 
352
 
353
/*========================================================================
354
 *
355
 *  Display the marathon configuration
356
 *
357
 *  Purpose:
358
 *      This function is called to Display the marathon configuration
359
 *
360
 *  Parameters:
361
 *      None
362
 *
363
 *  Returns:
364
 *      Nothing
365
 *
366
 *========================================================================*/
367
 
162 david 368
//void display_config( void )
369
//{
370
//    d_config( &config, M_DISPLAY );
95 - 371
 
162 david 372
//    cur( 0, n_lines - 1 );
373
//    printf( "Any key to return to main menu :" );
374
//    getinp(  );
375
//}
95 - 376
 
377
 
378
/*========================================================================
379
 *
380
 *  Display the class information
381
 *
382
 *  Purpose:
383
 *      This function is called to display the class information
384
 *
385
 *  Parameters:
386
 *      None
387
 *
388
 *  Returns:
389
 *      Nothing
390
 *
391
 *========================================================================*/
392
 
162 david 393
//void display_class( void )
394
//{
395
//    d_class( &config, M_DISPLAY );
95 - 396
 
162 david 397
//    cur( 0, n_lines - 1 );
398
//    printf( "Any key to continue :" );
399
//    getinp(  );
400
//}
95 - 401
 
402
/*========================================================================
403
 *
404
 *  Update the class information
405
 *
406
 *  Purpose:
407
 *      This function is called to update the class information
408
 *
409
 *  Parameters:
410
 *      None
411
 *
412
 *  Returns:
413
 *      Nothing
414
 *
415
 *========================================================================*/
416
 
162 david 417
//bool define_class( void )
418
//{
419
//    int         error;
420
//    int         i;
421
//    bool        changed = FALSE;
95 - 422
 
162 david 423
//    /*
424
//     **  Copy working configuration into a temp structure for
425
//     **  use within the function
426
//     */
427
//    newcfg = config;
95 - 428
 
162 david 429
//    do
430
//    {
431
//        error = 0;
432
//        d_class( &newcfg, M_UPDATE );
164 david 433
//        printf( "" );
95 - 434
 
162 david 435
//        /*
436
//         **  Now do the Class definitions
437
//         */
438
//        for( i = 0; i < MAX_CLASS; i++ )
439
//        {
440
//            compact( newcfg.team_class[i].abr );
441
//            compact( newcfg.team_class[i].full_name );
442
//        }
95 - 443
 
162 david 444
//        for( i = 0; i < MAX_CLASS; i++ )
445
//        {
446
//            if( ( newcfg.team_class[i].abr[0] == '\0' ) != ( newcfg.team_class[i].full_name[0] == '\0' ) )
447
//            {
164 david 448
//                printf( "Configuration error. Class without description" );
162 david 449
//                error++;
450
//            }
451
//            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.team_class[i].start < 0L )
452
//            {
164 david 453
//                printf( "Configuration error. Bad start time on class" );
162 david 454
//                error++;
455
//            }
456
//        }
95 - 457
 
162 david 458
//        newcfg.num_class = 0;
459
//        for( i = 0; i < MAX_CLASS; i++ )
460
//            if( newcfg.team_class[i].full_name[0] )
461
//                newcfg.num_class++;
95 - 462
 
162 david 463
//        for( i = newcfg.num_class; i < MAX_CLASS; i++ )
464
//            if( newcfg.team_class[i].full_name[0] )
465
//            {
164 david 466
//                printf( "Configuration error: Missing Class name. Gaps not allowed" );
162 david 467
//                error++;
468
//            }
95 - 469
 
162 david 470
//        if( newcfg.num_class == 0 )
471
//        {
164 david 472
//            printf( "Error: No categories defined" );
162 david 473
//            error++;
474
//        }
95 - 475
 
162 david 476
//        newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
477
//        if( newcfg.equestrian_leg && newcfg.nonequestrian_class == 0 )
164 david 478
//            printf( "WARNING: Non-equestrian class not found" );
95 - 479
 
162 david 480
//        abort_flag = FALSE;
481
//        if( error )
482
//        {
483
//            printf( "Any key to continue " );
484
//            getinp(  );
485
//        }
486
//        else
487
//        {
488
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
489
//            switch ( getfnc( "*YDEA" ) )
490
//            {
491
//            case 'Y':
492
//                config = newcfg;
493
//                wt_config(  );
494
//                changed = TRUE;
495
//                break;
95 - 496
 
162 david 497
//            case 'D':
498
//                break;
95 - 499
 
162 david 500
//            default:
501
//                error = TRUE;
502
//                break;
503
//            }
504
//        }
505
//    } while( error && ! abort_flag );
506
//    return ( changed );
507
//}
95 - 508
 
509
/*========================================================================
510
 *
511
 *  Update the class information
512
 *
513
 *  Purpose:
514
 *      This function is called to update the class information
515
 *      Display the marathon classes from the system parameters.
516
 *
517
 *      This routine can only be utilized after the screen system
518
 *      has been initialized.
519
 *
520
 *  Parameters:
521
 *      operation       Operation to perform
522
 *
523
 *  Returns:
524
 *      Nothing
525
 *
526
 *========================================================================*/
527
 
162 david 528
//void d_class( MARA_CFG * config, int operation )
529
//{
530
//    int         i, j, k;
531
//    int         maxitr;                          /* Max number of definitions during update */
532
//    int         opr;
95 - 533
 
162 david 534
//    abort_flag = FALSE;
535
//    if( operation == M_UPDATE )
536
//    {
537
//        opr = M_UPDATE;
538
//        d_class( config, M_PREDISPLAY );         /* Force display before update */
539
//    }
540
//    else
541
//    {
542
//        opr = M_DISPLAY;
543
//        clearscreen(  );
544
//    }
95 - 545
 
162 david 546
//    i = 0;                                       /* Set line 0 */
547
//    d_field( 0, i++, "Category definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
548
//    i++;
95 - 549
 
162 david 550
//    maxitr = ( operation == M_DISPLAY ) ? config->num_class : MAX_CLASS;
95 - 551
 
162 david 552
//    for( j = 0, k = 0; j < maxitr; j++ )
553
//    {
554
//        bool        non_equestrian = FALSE;
95 - 555
 
162 david 556
//        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, opr );
95 - 557
 
162 david 558
//        if( ( config->team_class[j].abr[0] == config->nonequestrian_class_abr[0] )
559
//            && ( config->team_class[j].abr[1] == config->nonequestrian_class_abr[1] ) )
560
//        {
561
//            non_equestrian = TRUE;
562
//        }
95 - 563
 
162 david 564
//        d_field( 8 + k, i, ":", D_STRING, LEN_CLASS_NAME,
565
//                 config->team_class[j].full_name, TRUE, opr );
95 - 566
 
162 david 567
//        if( !non_equestrian )
568
//            d_field( LEN_CLASS_NAME + 10 + k, i, "Start:", D_TIME, 8,
569
//                     ( char * ) &config->team_class[j].start, TRUE, opr );
95 - 570
 
162 david 571
//        /*
572
//         **  Step to next column or row
573
//         */
574
//        k += 40;
575
//        if( !( ( j + 1 ) % 2 ) )
576
//        {
577
//            k = 0;
578
//            i++;
579
//        }
580
//    }
581
//}
95 - 582
 
583
/*========================================================================
584
 *
585
 *  Configuration Update and Display
586
 *
587
 *  Purpose:
588
 *      This function is called to Configuration Update and Display
589
 *
590
 *  Parameters:
591
 *      operation       Operation to perform
592
 *
593
 *  Returns:
594
 *      Nothing
595
 *
596
 *========================================================================*/
597
 
162 david 598
//void d_config( MARA_CFG * config, int operation )
599
//{
600
//    int         i, j, k;
601
//    int         maxitr;                          /* Max number of definitions during update */
602
//    int         opr;
95 - 603
 
162 david 604
//    abort_flag = FALSE;
605
//    if( operation == M_UPDATE )
606
//    {
607
//        opr = M_UPDATE;
608
//        d_config( config, M_PREDISPLAY );        /* Force display before update */
609
//    }
610
//    else
611
//    {
612
//        opr = M_DISPLAY;
613
//        clearscreen(  );
614
//    }
615
//    i = 0;                                       /* Set line 0 */
95 - 616
 
162 david 617
//    d_field( 0, i++, "Marathon configuration", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
618
//    d_field( 0, ++i, "Name: ", D_STRING, MAX_EVENT_NAME, config->event_name, TRUE, opr );
95 - 619
 
162 david 620
//    /*
621
//     * display the leg names
622
//     */
95 - 623
 
162 david 624
//    i += 2;
625
//    maxitr = ( operation == M_DISPLAY ) ? config->num_legs : MAX_LEGS;
626
//    for( j = 1; j <= maxitr; j++, i++ )
627
//    {
628
//        d_field( 0, i, "Leg ", D_NUMBER, 1, ( char * ) &j, TRUE, M_DISPLAY );
629
//        d_field( 6, i, ": ", D_STRING, MAX_LEG_NAME, config->leg_name[j - 1], TRUE, opr );
630
//    }
631
//    abort_flag = FALSE;                          /* Trap aborts at the next field */
95 - 632
 
633
 
162 david 634
//    /*
635
//     * Display the team break definitions
636
//     */
95 - 637
 
162 david 638
//    i++;
95 - 639
 
162 david 640
//    d_field( 0, i++, "Valid team numbers are in the following ranges", D_NULL,
641
//             0, ( char * ) 0, TRUE, M_DISPLAY );
95 - 642
 
162 david 643
//    maxitr = ( operation == M_DISPLAY ) ? config->num_teams : MAX_TMS_SPLIT;
644
//    for( k = 0, j = 0; j < maxitr; j++ )
645
//    {
646
//        d_field( k + 0, i, "From ", D_NUMBER, 4, ( char * ) &config->t_def[j].start, TRUE, opr );
647
//        d_field( k + 9, i, " to ", D_NUMBER, 4, ( char * ) &config->t_def[j].end, TRUE, opr );
648
//        k += 20;
649
//        if( !( ( j + 1 ) % 4 ) )
650
//        {
651
//            k = 0;
652
//            i++;
653
//        }
654
//    }
95 - 655
 
162 david 656
//    /*
657
//     * Name of legend config->addendum file
658
//     */
95 - 659
 
162 david 660
//    abort_flag = FALSE;
661
//    i++;
662
//    d_field( 0, i++, "Legend addendum file :", D_STRING,
663
//             ( int ) sizeof( config->addendum ) - 1, ( char * ) config->addendum, TRUE, opr );
95 - 664
 
162 david 665
//    /*
666
//     * Name of the alternate data file
667
//     */
668
//    d_field( 0, i++, "Data filename :", D_STRING,
669
//             ( int ) sizeof( config->datafilename ) - 1,
670
//             ( char * ) config->datafilename, TRUE, opr );
95 - 671
 
162 david 672
//    /*
673
//     **  Non-equestrian configuration information
674
//     */
675
//    abort_flag = FALSE;
676
//    i++;
677
//    d_field( 0, i++, "Equestrian Leg :", D_NUMBER, 1, ( char * ) &config->equestrian_leg, TRUE, opr );
678
//    d_field( 0, i++, "Non-Equestrian Category :", D_USTRING,
679
//             ( int ) sizeof( config->nonequestrian_class_abr ) - 1,
680
//             ( char * ) config->nonequestrian_class_abr, TRUE, opr );
95 - 681
 
162 david 682
//    /*
683
//    **  Print control
684
//    */
685
//    abort_flag = FALSE;
686
//    i++;
687
//    d_field(  0, i,   "Lines Per Page :", D_NUMBER, 3, ( char * ) &config->lines_per_page, TRUE, opr );
688
//    d_field( 30, i++, "Perf Skip :", D_NUMBER, 1, ( char * ) &config->perf_skip, TRUE, opr );
689
//}
95 - 690
 
691
/*========================================================================
692
 *
693
 *  Display the current country list
694
 *
695
 *  Purpose:
696
 *      This function is called to Display the current country list
697
 *
698
 *  Parameters:
699
 *      None
700
 *
701
 *  Returns:
702
 *      Nothing
703
 *
704
 *========================================================================*/
705
 
162 david 706
//void display_country( void )
707
//{
708
//    d_cntry( &config, M_DISPLAY );
95 - 709
 
162 david 710
//    cur( 0, n_lines - 1 );
711
//    printf( "Any key to return to main menu :" );
712
//    ( void ) getinp(  );
713
//}
95 - 714
 
715
/*========================================================================
716
 *
717
 *  Define a new entry in the county list
718
 *
719
 *  Purpose:
720
 *      This function is called to Define a new entry in the county list
721
 *
722
 *  Parameters:
723
 *      None
724
 *
725
 *  Returns:
726
 *      Nothing
727
 *
728
 *========================================================================*/
729
 
162 david 730
//void define_country( void )
731
//{
732
//    int         error;
733
//    ty_t_country *ptr;
734
//    int         i;
95 - 735
 
162 david 736
//    /*
737
//     **  Copy working configuration into a temp structure for
738
//     **  use within the function
739
//     */
740
//    newcfg = config;
95 - 741
 
162 david 742
//    do
743
//    {
744
//        error = 0;
745
//        newcfg.num_countries = 0;
95 - 746
 
162 david 747
//        /*
748
//         * Get the operator to update the screen
749
//         */
95 - 750
 
162 david 751
//        d_cntry( &newcfg, M_UPDATE );               /* Update the country data */
164 david 752
//        printf( "" );
95 - 753
 
162 david 754
//        /*
755
//         * Now check the data that has been entered.
756
//         */
95 - 757
 
162 david 758
//        ptr = newcfg.country_name;
759
//        for( i = 0; i < MAX_COUNTRY; i++, ptr++ )
760
//        {
761
//            compact( ptr->abr );
762
//            compact( ptr->full_name );
763
//            if( ( ptr->abr[0] == '\0' ) != ( ptr->full_name[0] == '\0' ) )
764
//            {
765
//                error++;
164 david 766
//                printf( "Missing field" );
162 david 767
//            }
768
//            if( ptr->abr[0] )
769
//                newcfg.num_countries++;
770
//        }
95 - 771
 
162 david 772
//        if( error )
773
//        {
164 david 774
//            printf( "Configuration error - error must be corrected" );
162 david 775
//            printf( "Any key to continue " );
776
//            ( void ) getinp(  );
777
//        }
778
//        else
779
//        {
780
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
781
//            switch ( getfnc( "*YDEA" ) )
782
//            {
783
//            case 'Y':
784
//                config = newcfg;
785
//                wt_config(  );                   /* Write out the data */
786
//                break;
95 - 787
 
162 david 788
//            case 'D':
789
//                break;
95 - 790
 
162 david 791
//            default:
792
//                error = TRUE;
793
//                break;
794
//            }
795
//        }
796
//    } while( error );
797
//    return;
798
//}
95 - 799
 
800
 
801
/*========================================================================
802
 *
803
 *  Display / Update Country list
804
 *
805
 *  Purpose:
806
 *      This function is called to Display or Update Country list
807
 *
808
 *  Parameters:
809
 *      operation           Operation to perform
810
 *
811
 *  Returns:
812
 *      Nothing
813
 *
814
 *========================================================================*/
815
 
162 david 816
//void d_cntry( MARA_CFG * config, int operation )
817
//{
818
//    int         i, j, k;
819
//    int         opr;
95 - 820
 
162 david 821
//    abort_flag = FALSE;
822
//    if( operation == M_UPDATE )
823
//    {
824
//        opr = M_UPDATE;
825
//        d_cntry( config, M_PREDISPLAY );         /* Force display before update */
826
//    }
827
//    else
828
//    {
829
//        opr = M_DISPLAY;
830
//        clearscreen(  );
831
//    }
832
//    i = 0;                                       /* Set line 0 */
95 - 833
 
162 david 834
//    d_field( 0, i++, "Country classifications", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
95 - 835
 
162 david 836
//    /*
837
//     * Display the country names
838
//     */
95 - 839
 
162 david 840
//    i++;
95 - 841
 
162 david 842
//    for( j = 0, k = 0; j < MAX_COUNTRY; j++ )
843
//    {
844
//        d_field( 0 + k, i, "Country: ", D_STRING, 4,
845
//                 ( char * ) config->country_name[j].abr, TRUE, opr );
846
//        d_field( 13 + k, i, ": ", D_STRING, LEN_CNTRY_NAME,
847
//                 config->country_name[j].full_name, TRUE, opr );
95 - 848
 
162 david 849
//        k += 40;
850
//        if( !( ( j + 1 ) % 2 ) )
851
//        {
852
//            k = 0;
853
//            i++;
854
//        }
855
//    }
856
//}
95 - 857
 
858
/*========================================================================
859
 *
860
 *  Display the Winners List
861
 *
862
 *  Purpose:
863
 *      This function is called to Display the current winners list
864
 *
865
 *  Parameters:
866
 *      None
867
 *
868
 *  Returns:
869
 *      Nothing
870
 *
871
 *========================================================================*/
872
 
162 david 873
//void display_winners( void )
874
//{
875
//    calc_class_summary( & class_summary );
876
//    d_winners( &config, M_DISPLAY );
95 - 877
 
162 david 878
//    cur( 0, n_lines - 1 );
879
//    printf( "Any key to return to main menu :" );
880
//    ( void ) getinp(  );
881
//}
95 - 882
 
883
/*========================================================================
884
 *
885
 *  Update the winners information
886
 *
887
 *  Purpose:
888
 *      This function is called to update the winners information
889
 *
890
 *  Parameters:
891
 *      None
892
 *
893
 *  Returns:
894
 *      Nothing
895
 *
896
 *========================================================================*/
897
 
162 david 898
//bool define_winners( void )
899
//{
900
//    int         error;
901
//    int         i;
902
//    bool        changed = FALSE;
95 - 903
 
162 david 904
//    /*
905
//    **  Update the class summary info to give the user a hint
906
//    */
907
//    calc_class_summary( & class_summary );
95 - 908
 
162 david 909
//    /*
910
//     **  Copy working configuration into a temp structure for
911
//     **  use within the function
912
//     */
913
//    newcfg = config;
95 - 914
 
162 david 915
//    /*
916
//    **  Edit and sanity test the cnfig data until the user is happy
917
//    **  with it - or is ready to discard it.
918
//    */
919
//    do
920
//    {
921
//        error = 0;
922
//        d_winners ( &newcfg, M_UPDATE );
164 david 923
//        printf( "" );
95 - 924
 
162 david 925
//        /*
926
//        **  Sanity test of the data
927
//        */
928
//        for( i = 0; i < MAX_CLASS; i++ )
929
//        {
930
//            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.class_winners[i] == 0 )
931
//            {
164 david 932
//                printf( "  Warning: Class without winners: %s", newcfg.team_class[i].abr );
162 david 933
//            }
95 - 934
 
162 david 935
//            if ( newcfg.class_winners[i] > class_summary.teamclass[i+1].total )
936
//            {
164 david 937
//                printf( "  Warning: Num winners greater than those in class: %s", newcfg.team_class[i].abr );
162 david 938
//            }
939
//        }
95 - 940
 
941
 
162 david 942
//        newcfg.num_fame = 0;
943
//        for( i = 0; i < MAX_FAME; i++ )
944
//            if( newcfg.hall_fame[i][0] )
945
//                newcfg.num_fame++;
95 - 946
 
162 david 947
//        for( i = newcfg.num_fame; i < MAX_FAME; i++ )
948
//            if( newcfg.hall_fame[i][0] )
949
//            {
164 david 950
//                printf( "Configuration error: Missing Fame name. Gaps not allowed" );
162 david 951
//                error++;
952
//                break;
953
//            }
95 - 954
 
162 david 955
//        abort_flag = FALSE;
956
//        if( error )
957
//        {
958
//            printf( "Any key to continue " );
959
//            getinp(  );
960
//        }
961
//        else
962
//        {
963
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
964
//            switch ( getfnc( "*YDEA" ) )
965
//            {
966
//            case 'Y':
967
//                config = newcfg;
968
//                wt_config(  );
969
//                changed = TRUE;
970
//                break;
95 - 971
 
162 david 972
//            case 'D':
973
//                break;
95 - 974
 
162 david 975
//            default:
976
//                error = TRUE;
977
//                break;
978
//            }
979
//        }
980
//    } while( error && ! abort_flag );
981
//    return ( changed );
982
//}
95 - 983
 
984
 
985
/*========================================================================
986
 *
987
 *  Display / Update winners list
988
 *
989
 *  Purpose:
990
 *      This function is called to Display or Update winners list
991
 *
992
 *  Parameters:
993
 *      operation           Operation to perform
994
 *
995
 *  Returns:
996
 *      Nothing
997
 *
998
 *========================================================================*/
999
 
162 david 1000
//void d_winners( MARA_CFG * config, int operation )
1001
//{
1002
//    int         i, j, k;
1003
//    int         maxitr;                          /* Max number of definitions during update */
1004
//    int         opr;
95 - 1005
 
162 david 1006
//    abort_flag = FALSE;
1007
//    if( operation == M_UPDATE )
1008
//    {
1009
//        opr = M_UPDATE;
1010
//        d_winners( config, M_PREDISPLAY );         /* Force display before update */
1011
//    }
1012
//    else
1013
//    {
1014
//        opr = M_DISPLAY;
1015
//        clearscreen(  );
1016
//    }
95 - 1017
 
162 david 1018
//    i = 0;                                       /* Set line 0 */
1019
//    d_field( 0, i++, "Winner definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1020
//    i++;
95 - 1021
 
162 david 1022
//    maxitr = config->num_class;
95 - 1023
 
162 david 1024
//    for( j = 0, k = 0; j < maxitr; j++ )
1025
//    {
1026
//        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, M_DISPLAY );
95 - 1027
 
162 david 1028
//        d_field( 7 + k, i, ":", D_STRING, LEN_CLASS_NAME,
1029
//                 config->team_class[j].full_name, TRUE, M_DISPLAY );
95 - 1030
 
162 david 1031
//        d_field( LEN_CLASS_NAME + 9 + k, i, "Num:", D_NUMBER, 3,
1032
//                     ( char * ) &class_summary.teamclass[j+1].total, TRUE, M_DISPLAY );
95 - 1033
 
162 david 1034
//        d_field( LEN_CLASS_NAME + 9 + 7 + k, i, "Win:", D_NUMBER, 3,
1035
//                     ( char * ) &config->class_winners[j], TRUE, opr );
95 - 1036
 
162 david 1037
//        /*
1038
//         **  Step to next column or row
1039
//         */
1040
//        k += 40;
1041
//        if( !( ( j + 1 ) % 2 ) )
1042
//        {
1043
//            k = 0;
1044
//            i++;
1045
//        }
1046
//    }
95 - 1047
 
162 david 1048
//    abort_flag =  FALSE;
1049
//    i += 2;
1050
//    d_field( 0, i++, "Hall of Fame", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1051
//    for( j = 0, k = 0; j < MAX_FAME; j++ )
1052
//    {
1053
//        d_field( k, i, "Name : ", D_STRING, MAX_PERSON_NAME,
1054
//                 &config->hall_fame[j], TRUE, opr );
1055
//        k += 40;
1056
//        if( !( ( j + 1 ) % 2 ) )
1057
//        {
1058
//            k = 0;
1059
//            i++;
1060
//        }
1061
//    }
1062
//}
95 - 1063
 
1064
 
1065
/*========================================================================
1066
 *
1067
 *  Read in the configuration file
1068
 *
1069
 *  Purpose:
1070
 *      This function is called to read in the configuration file
1071
 *
1072
 *  Parameters:
1073
 *      None
1074
 *
1075
 *  Returns:
1076
 *      Nothing
1077
 *
1078
 *========================================================================*/
1079
 
1080
bool rd_config( void )
1081
{
1082
    FILE       *fcon;
1083
    int         ok;
1084
 
1085
 
1086
    fcon = fopen( confile, "rb" );
1087
    if( ! fcon )
1088
    {
164 david 1089
        printf( "Configuration file %s not found", confile );
95 - 1090
        return ( FALSE );
1091
    }
1092
    ok = r_config( fcon );
1093
 
1094
    fclose( fcon );
1095
    return ( ok );
1096
}
1097
 
1098
/*========================================================================
1099
 *
1100
 *  Read in the configuration file
1101
 *
1102
 *  Purpose:
1103
 *      This function is called to read in the configuration file
1104
 *      NOTE: Must be maintained with the Writer function
1105
 *
1106
 *  Parameters:
1107
 *      fcon        File number of the config file
1108
 *
1109
 *  Returns:
1110
 *      FALSE if an error is encountered
1111
 *
1112
 *========================================================================*/
1113
 
1114
bool r_config( FILE *fcon )
1115
{
1116
    int         len;                             /* Length of data read */
1117
 
1118
    /*
1119
     * Event name 
1120
     */
164 david 1121
printf( "Reading: Event Name" );
95 - 1122
    len = fread( config.event_name, sizeof( config.event_name ), 1 , fcon );
1123
    if( len != 1 )
1124
        return ( FALSE );
1125
 
1126
    /*
1127
     * Leg names 
1128
     */
164 david 1129
printf( "Reading: Leg Names" );
95 - 1130
    len = fread( config.leg_name, sizeof( config.leg_name ), 1 , fcon );
1131
    if( len != 1 )
1132
        return ( FALSE );
1133
 
1134
    /*
1135
     * Team definitions 
1136
     */
164 david 1137
printf( "Reading: Team Defs" );
95 - 1138
 
1139
    len = fread( config.t_def, sizeof( config.t_def ), 1 , fcon );
1140
    if( len != 1 )
1141
        return ( FALSE );
1142
 
1143
    /*
1144
     * Number of legs 
1145
     */
1146
 
164 david 1147
printf( "Reading: Leg Nums" );
95 - 1148
    len = fread( &config.num_legs, sizeof( config.num_legs ), 1 , fcon );
1149
    if( len != 1)
1150
        return ( FALSE );
1151
 
1152
    /*
1153
     * Number of team splits 
1154
     */
1155
 
164 david 1156
printf( "Reading: Team Splits" );
95 - 1157
    len = fread( &config.num_teams, sizeof( config.num_teams ), 1 , fcon );
1158
    if( len != 1 )
1159
        return ( FALSE );
1160
 
1161
    config.min_team = config.t_def[0].start;
1162
    config.max_team = config.t_def[config.num_teams - 1].end;
1163
 
1164
    /*
1165
     * Class information 
1166
     */
164 david 1167
printf( "Reading: Class Data" );
95 - 1168
    len = fread( config.team_class, sizeof( config.team_class ), 1 , fcon );
1169
    if( len != 1 )
1170
        return ( FALSE );
1171
    len = fread( &config.num_class, sizeof( config.num_class ), 1 , fcon );
1172
    if( len != 1 )
1173
        return ( FALSE );
1174
 
1175
    /*
1176
     * Country list 
1177
     */
1178
 
164 david 1179
printf( "Reading: Country Data, Name" );
95 - 1180
    len = fread( config.country_name, sizeof( config.country_name ), 1 , fcon );
1181
    if( len != 1 )
1182
        return ( FALSE );
164 david 1183
printf( "Reading: Country Data, Number" );
95 - 1184
    len = fread( &config.num_countries, sizeof( config.num_countries ), 1 , fcon );
1185
    if( len != 1 )
1186
        return ( FALSE );
1187
 
1188
    /*
1189
     * Addendum file 
1190
     */
1191
 
164 david 1192
printf( "Reading: Addendum File" );
95 - 1193
    len = fread( config.addendum, sizeof( config.addendum ), 1 , fcon );
1194
    if( len != 1 )
1195
        return ( feof( fcon ) );
1196
 
1197
    /*
1198
     * Name of the data file 
1199
     */
1200
 
164 david 1201
printf( "Reading: Name of data file" );
95 - 1202
    len = fread( config.datafilename, sizeof( config.datafilename ) , 1 , fcon );
1203
    if( len != 1 )
1204
        return ( feof( fcon ) );
1205
 
1206
    /*
1207
     **  Non-equestrian configuration information
1208
     */
164 david 1209
printf( "Reading: NonEquest" );
95 - 1210
    len = fread( config.nonequestrian_class_abr, sizeof( config.nonequestrian_class_abr ), 1 , fcon );
1211
    if( len != 1 )
1212
        return ( feof( fcon ) );
164 david 1213
printf( "Reading: NonEquest-2" );
95 - 1214
    len = fread( &config.equestrian_leg, sizeof( config.equestrian_leg ), 1 , fcon );
1215
    if( len != 1 )
1216
        return ( FALSE );
1217
 
1218
    /*
1219
    **  .txt file output control. Lines per page and perf-skipping
1220
    */
164 david 1221
printf( "Reading: Output Control" );
95 - 1222
    len = fread( &config.lines_per_page, sizeof( config.lines_per_page ), 1 , fcon );
1223
    if( len != 1 )
1224
        return ( feof( fcon ) );
1225
 
164 david 1226
printf( "Reading: Output Control-2" );
95 - 1227
    len = fread( &config.perf_skip, sizeof( config.perf_skip ), 1 , fcon );
1228
    if( len != 1 )
1229
        return ( FALSE );
1230
 
164 david 1231
printf( "Reading: Winners Info" );
95 - 1232
    len = fread( &config.class_winners, sizeof( config.class_winners ), 1 , fcon );
1233
    if( len != 1 )
1234
        return ( FALSE );
1235
 
164 david 1236
printf( "Reading: Hall of Fame Info" );
95 - 1237
    len = fread( &config.hall_fame, sizeof( config.hall_fame ), 1 , fcon );
1238
    if( len != 1 )
1239
        return ( FALSE );
1240
 
164 david 1241
printf( "Reading: Hall of Fame Numbers" );
95 - 1242
    len = fread( &config.num_fame, sizeof( config.num_fame ), 1 , fcon );
1243
    if( len != 1 )
1244
        return ( feof( fcon ) );
1245
 
1246
 
1247
    return ( TRUE );
1248
}
1249
 
1250
/*========================================================================
1251
 *
1252
 *  Write out the configuration file
1253
 *
1254
 *  Purpose:
1255
 *      This function is called to write the configuration file
1256
 *      NOTE: Must be maintained with the Reader function
1257
 *
1258
 *  Parameters:
1259
 *      None
1260
 *
1261
 *  Returns:
1262
 *      FALSE   : Error encountered
1263
 *
1264
 *========================================================================*/
1265
 
1266
bool wt_config( void )
1267
{
1268
    FILE        *fcon;
1269
 
1270
    /*
1271
     **  Open as a binary file
1272
     */
1273
    fcon = fopen( confile, "wb" );
1274
    if( !fcon )
1275
        return ( FALSE );
1276
 
1277
    /*
1278
     **  Write out multiple structures
1279
     **     Event name
1280
     **     Leg names
1281
     **     Team definitions
1282
     **     Number of legs
1283
     **     Number fo team splits
1284
     **     Class information
1285
     **     Number of defined classes
1286
     **     Country list
1287
     **     Number of defined countries
1288
     **     Legend config.addendum file name
1289
     **     Data file name
1290
     */
1291
 
1292
    fwrite( config.event_name, sizeof( config.event_name ), 1, fcon );
1293
    fwrite( config.leg_name, sizeof( config.leg_name ), 1, fcon );
1294
    fwrite( config.t_def, sizeof( config.t_def ), 1, fcon );
1295
    fwrite( &config.num_legs, sizeof( config.num_legs ), 1, fcon );
1296
    fwrite( &config.num_teams, sizeof( config.num_teams ), 1, fcon );
1297
    fwrite( config.team_class, sizeof( config.team_class ), 1, fcon );
1298
    fwrite( &config.num_class, sizeof( config.num_class ), 1, fcon );
1299
    fwrite( config.country_name, sizeof( config.country_name ), 1, fcon );
1300
    fwrite( &config.num_countries, sizeof( config.num_countries ), 1, fcon );
1301
    fwrite( config.addendum, sizeof( config.addendum ), 1, fcon );
1302
    fwrite( config.datafilename, sizeof( config.datafilename ), 1, fcon );
1303
    fwrite( config.nonequestrian_class_abr, sizeof( config.nonequestrian_class_abr ), 1, fcon );
1304
    fwrite( &config.equestrian_leg, sizeof( config.equestrian_leg ), 1, fcon );
1305
    fwrite( &config.lines_per_page, sizeof( config.lines_per_page ), 1, fcon );
1306
    fwrite( &config.perf_skip, sizeof( config.perf_skip ), 1, fcon );
1307
    fwrite( &config.class_winners, sizeof( config.class_winners ), 1, fcon );
1308
    fwrite( &config.hall_fame, sizeof( config.hall_fame ), 1, fcon );
1309
    fwrite( &config.num_fame, sizeof( config.num_fame ), 1, fcon );
1310
 
1311
    fclose( fcon );
1312
    return ( TRUE );
1313
}
1314
 
1315
/*========================================================================
1316
 *
1317
 *  Qsort callback: Sort by team
1318
 *
1319
 *  Purpose:
1320
 *      Function used by the team definition sort operation
1321
 *      It will compare two entries of the team def structure and return an
1322
 *      integer for gt eq lt conditions.
1323
 *      Note : If the start is 0 the team entry does exist and is placed at the
1324
 *      end of the sorted list.
1325
 *
1326
 *  Parameters:
1327
 *      a           comparision entry
1328
 *      b           comparision entry
1329
 *
1330
 *  Returns:
1331
 *      gt, eq, lt as required
1332
 *
1333
 *========================================================================*/
1334
 
1335
int f_comp_int( const void *aa, const void *bb )
1336
{
1337
    const ty_t_def *a = (ty_t_def *)aa;
1338
    const ty_t_def *b = (ty_t_def *)bb;
1339
 
1340
    if( a->start == 0 )
1341
        return ( 1 );
1342
    else if( b->start == 0 )
1343
        return ( -1 );
1344
    else
1345
        return ( a->start - b->start );
1346
}
1347
 
1348
/*========================================================================
1349
 *
1350
 *  Compact a string
1351
 *
1352
 *  Purpose:
1353
 *      This function is called remove leading and trailing spaces from
1354
 *      a string. Treats other non-printing characters as leading
1355
 *      spaces. This solves a problem when importing data from a
1356
 *      Microsoft CSV file with empty fields.
1357
 *
1358
 *  Parameters:
1359
 *      str     Address of the string to compact
1360
 *
1361
 *  Returns:
1362
 *      Nothing
1363
 *
1364
 *========================================================================*/
1365
 
1366
void compact( char *str )
1367
{
1368
    char       *ptr;
1369
 
1370
    ptr = str;
1371
    while( *str && ( isspace( *str ) || !isprint( *str ) ) )
1372
        str++;
1373
    strcpy( ptr, str );
1374
}
1375
 
1376
/*========================================================================
1377
 *
1378
 *  Validate a team number
1379
 *
1380
 *  Purpose:
1381
 *      This function is called to validate a team number
1382
 *
1383
 *  Parameters:
1384
 *      x       Number to validate
1385
 *
1386
 *  Returns:
1387
 *      TRUE    : Valid
1388
 *      FALSE   : Not valid
1389
 *
1390
 *========================================================================*/
1391
 
1392
bool valid_field( int x )
1393
{
1394
    int         i;
1395
 
1396
    for( i = 0; i < config.num_teams; i++ )
1397
    {
1398
        if( x <= config.t_def[i].end && x >= config.t_def[i].start )
1399
            return ( TRUE );
1400
        if( x < config.t_def[i].start )
1401
            break;                               /* Because the list is sorted */
1402
    }
1403
    return ( FALSE );
1404
}
1405
 
1406
/*========================================================================
1407
 *
1408
 *  Get a class descriptor from existing text
1409
 *
1410
 *  Purpose:
1411
 *      This function is called to Get a class descriptor
1412
 *
1413
 *  Parameters:
1414
 *      text    - User text to examine
1415
 *      config  - configuration dtaa to use
1416
 *
1417
 *  Returns:
1418
 *      An integer which is the index into the  config.team_class array
1419
 *      The integer is in the range 1 .. num_class
1420
 *      A value fo zero indicates the text was not found.
1421
 *
1422
 *========================================================================*/
1423
 
150 david 1424
int lookup_class( const char *text, MARA_CFG * config_ptr )
95 - 1425
{
1426
    int         i;
1427
 
1428
    if( config_ptr == NULL )
1429
        config_ptr = &config;
1430
 
1431
    /*
1432
     * Attempt to locate the entered class in the list of defined classes
1433
     */
1434
 
1435
    for( i = 0; i < config_ptr->num_class; i++ )
1436
    {
1437
        if( toupper(text[0]) == toupper(config_ptr->team_class[i].abr[0]) &&
1438
            toupper(text[1]) == toupper(config_ptr->team_class[i].abr[1]) )
1439
            return ( ++i );
1440
    }
1441
    return ( 0 );
1442
}
1443
 
1444
/********************************* EOF ***********************************/