Subversion Repositories svn1-original

Rev

Rev 157 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 - 1
/*************************************************************************
2
*           Copyright Xdel Technology Pty. Ltd. 1987
3
*           Copyright (C) 1995 Embedded Solutions
4
*                       All rights reserved
5
*
6
* file:     src\upload.c
7
*
8
* purpose:  Data upload functions
9
*           This module contains all the functions required to upload
10
*           data from the handheld calculators and insert the data
11
*           into the data base as well as functions and a menu to load
12
*           and unload specific data into the data base
13
*
14
* functions
15
*       upload                  - Get Leg to upload
16
*       ins_data                - Insert time info into data base
17
*       supload                 - Extended upload functions menu
18
*       tupload                 - Read in text team information
19
*       t_parse_number          - Parse a number from a CSV line of team text
20
*       t_parse_text            - Parse string from a CSV line of team text
21
*       p_del                   - Test for a delimiter.
22
*       tdnload                 - Generate team name file
23
*       dnload                  - Generate leg timing file
24
*       getfname                - Get a filename from the user
25
*
26
* programmer: David Purdie
27
*
28
* revision  date        by      reason
29
*           May 1990    Margherita Veroni
30
*                               The functions to upload data have been modified
31
*                               to allow leg start times to also be uploaded for
32
*                               any leg. Data being uploaded which contain errors
33
*                               are written to an error file
34
*
35
*   00.0    1-Apr-94    DDP     Changed tdnload() to produce a comma seperated
36
*                               file. This allows external users to see the
37
*                               field delimters better than tabs
38
*
39
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
40
*
41
**************************************************************************/
42
 
43
#include    <stdio.h>
44
 
45
#include    "consts.h"
46
#include    "structs.h"
47
#include    "proto.h"
48
 
49
/* Variable storage */
50
 
51
char        ufilename[40];                       /* Name of upload file */
52
FILE       *ufile;                               /* Upload file stream */
53
FILE       *efile;                               /* Error file stream */
54
char        line[300];                           /* Input line */
55
char        line_text[133];                      /* Output text */
56
int         last_loaded_leg = 0;                 /* Last leg that was loaded */
57
 
58
unsigned char manstart;                          /* Manual start time entry */
59
 
60
 
162 david 61
//menu_table  sup_menu[] = {
62
//    //{ '1', "Load team information from external file", tupload },
63
//    //{ '2', "Store team information from external file", tdnload_store },
64
//    //{ '3', "Create external team information file", tdnload },
65
//    { '4', "Create external leg data file", dnload },
66
//    { '5', "Upload time information", upload },
67
//    { 'q', "Return to main menu", 0 },
68
//    { '\0' }
69
//};
95 - 70
 
71
/*========================================================================
72
 *
73
 *  Get Leg to upload
74
 *
75
 *  Purpose:
76
 *      This function is called to Get Leg to upload
77
 *          Prompt user for leg number and start / end of leg
78
 *          Open disc file
79
 *          Read and parse text. Enter data into team information
80
 *          Maintain error file of errors.
81
 *
82
 *  Parameters:
83
 *      None
84
 *
85
 *  Returns:
86
 *      Nothing
87
 *
88
 *========================================================================*/
89
 
162 david 90
//void upload(void)
91
//{
92
//    int         hh, mm, ss;                      /* Team times */
93
//    int         error = 0;                       /* Count of errors */
94
//    int         ntms = 0;                        /* Number of teams uploaded */
95
//    char        stend[] = "E";                   /* Start or End time */
96
//    char       *filename;                        /* Name of file to open */
97
//    char       *err_filename;                    /* Name of an error file to open */
95 - 98
 
162 david 99
//    cur( 0, 5 );
100
//    while( TRUE )
101
//    {
102
//        leg = 0;
103
//        d_field( 0, 6, "Enter leg to upload :", D_NUMBER, 1, ( char * ) &leg, TRUE, M_UPDATE );
104
//        if( leg == 0 )
105
//            return;                              /* Null leg - just exit */
106
//        if( leg <= config.num_legs )             /* Valid leg number - Exit loop */
107
//            break;
108
//        beep();                                  /* Make a noise and wait for valid number */
109
//    }
95 - 110
 
162 david 111
//    /*
112
//    **  Save for check
113
//    */
114
//    last_loaded_leg = leg;
95 - 115
 
162 david 116
//    /*
117
//     * Find out if Start or End of leg times to be uploaded
118
//     */
95 - 119
 
162 david 120
//    do
121
//    {
122
//        d_field( 0, 7, "Start or End of leg to upload :", D_USTRING, 1, stend,
123
//                 TRUE, M_UPDATE );
124
//    } while( ( stend[0] != 'S' ) && ( stend[0] != 'E' ) );
125
//    manstart = ( ( stend[0] == 'S' ) ? TRUE : FALSE );
126
//    printf( "\n" );
95 - 127
 
162 david 128
//    /*
129
//     * Locate the required data file and prepare for processing
130
//     */
131
//    filename = tprintf( "%s%d" , manstart ? "Sleg" : "leg" , leg );
132
//    ufile = fopen( filename, "rt" );
133
//    if( ufile == 0 )
134
//    {
135
//        printf( "Cannot locate data file - %s\n", filename );
136
//        beep();
137
//        sleep( 5 );
138
//        return;
139
//    }
95 - 140
 
162 david 141
//    /*
142
//     * create an error file for this leg data
143
//     * duplicate times will stored here
144
//     */
145
//    err_filename = tprintf( "%s%d.err" , manstart ? "Sleg" : "leg" , leg );
146
//    efile = fopen( err_filename, "at" );
95 - 147
 
162 david 148
//    /*
149
//     * Process each entry in the file
150
//     */
95 - 151
 
162 david 152
//    if( leg > config.num_legs )
153
//        printf( "\nUploading leg%d start information\n", leg );
95 - 154
 
162 david 155
//    while( fgets( line, 101, ufile ) )
156
//    {
157
//        if( sscanf( line, "%d %d:%d:%d", &team, &hh, &mm, &ss ) != 4 )
158
//        {
159
//            printf( "Upload error - %s", line );
160
//            error++;
161
//        }
162
//        else
163
//        {
164
//            if( !ins_data( team, hh, mm, ss ) )
165
//                error++;
166
//            ntms++;
167
//        }
168
//    }
95 - 169
 
162 david 170
//    printf( "%d errors detected. %d teams uploaded. Any key to continue ", error, ntms );
171
//    getinp();
95 - 172
 
162 david 173
//    fclose( ufile );
174
//    fclose( efile );
175
//}
95 - 176
 
177
/*========================================================================
178
 *
179
 *  Insert time info into data base
180
 *
181
 *  Purpose:
182
 *      This helper function is called to Insert time info into data base
183
 *          Read record
184
 *          Read and convert time
185
 *          Write record
186
 *              Maintain error file
187
 *          Display errors on screen
188
 *
189
 *  Parameters:
190
 *      tm          Team
191
 *      hh          hours
192
 *      mm          minutes
193
 *      ss          seconds
194
 *
195
 *  Returns:
196
 *      Nothing
197
 *
198
 *========================================================================*/
199
 
162 david 200
//int ins_data( int tm, int hh, int mm, int ss )
201
//{
202
//    time_t      l_time;                          /* Leg time */
203
//    int         ok = TRUE;
95 - 204
 
162 david 205
//    /*
206
//     * Calculate the time for the team
207
//     */
95 - 208
 
162 david 209
//    l_time = conv_time( hh, mm, ss );
95 - 210
 
162 david 211
//    /*
212
//     * If an error is found - invalid team, team not found or dual time for team
213
//     * a message is output to the screen and the data is written to error file
214
//     * FALSE is returned
215
//     */
95 - 216
 
162 david 217
//    if( !valid_field( tm ) )
218
//    {
219
//        printf( "Invalid team - %d %2.2d:%2.2d:%2.2d\n", tm, hh, mm, ss );
220
//        fprintf( efile, "Invalid team - %d %2.2d:%2.2d:%2.2d\n", tm, hh, mm,
221
//                 ss );
222
//        ok = FALSE;
223
//        return ( ok );
224
//    }
225
//    if( !g_record( tm, &team_buf ) )
226
//    {
227
//        printf( "Team not found -% d %2.2d:%2.2d:%2.2d\n", tm, hh, mm, ss );
228
//        fprintf( efile, "Team not found - %d %2.2d:%2.2d:%2.2d\n", tm, hh, mm, ss );
229
//        ok = FALSE;
230
//    }
231
//    if( !manstart )
232
//    {                                            /* Normal upload */
233
//        if( team_buf.leg[leg].end > 0 && team_buf.leg[leg].end != l_time )
234
//        {
235
//            printf( "Dual time for %d - %2.2d:%2.2d:%2.2d and %s\n", tm, hh,
236
//                    mm, ss, time_a( team_buf.leg[leg].end ) );
237
//            fprintf( efile, "Dual time for %d - %2.2d:%2.2d:%2.2d and %s\n",
238
//                        tm, hh, mm, ss, time_a( team_buf.leg[leg].end )
239
//                    ); /* write  duplicate time to error file */
240
//            ok = FALSE;
241
//            return ( ok );                       /* keep time already in database */
242
//        }
243
//        team_buf.leg[leg].end = l_time;
244
//    }
245
//    else
246
//    {                                            /* Uplaod start time */
247
//        team_buf.leg[leg].start = l_time;
248
//        team_buf.leg[leg].manual = TRUE;
249
//    }
250
//    set_times( &team_buf );                      /* Calc start of next leg */
251
//    ( void ) test_times( &team_buf, 0 );         /* Calc elapsed times etc */
252
//    put_team_record( tm, &team_buf );
253
//    return ( ok );
254
//}
95 - 255
 
162 david 256
///*========================================================================
257
// *
258
// *  Extended upload functions menu
259
// *
260
// *  Purpose:
261
// *      This function is called to Extended upload functions
262
// *
263
// *  Parameters:
264
// *      None
265
// *
266
// *  Returns:
267
// *      Nothing
268
// *
269
// *========================================================================*/
95 - 270
 
162 david 271
//void supload(void)
272
//{
273
//    do_menu( "Extended data manipulation", "Select option", sup_menu ); /* Call a menu to do it */
274
//}
95 - 275
 
276
/*========================================================================
277
 *
278
 *  Read in text team information
279
 *
280
 *  Purpose:
281
 *      This function is called to do Read in text team information
282
 *      from a file
283
 *
284
 *      The source file is a comma seperated file and may contain the
285
 *      folowing items
286
 *
287
 *      Team Number     - Mandatory
288
 *      Team Name       - Mandatory
289
 *      Team Catagory   - Mandatory
290
 *
291
 *      Team Names ...  - Optional
292
 *
293
 *  Parameters:
294
 *      None
295
 *
296
 *  Returns:
297
 *      Nothing
298
 *
299
 *========================================================================*/
300
 
162 david 301
//void tupload(void)
302
//{
303
//    int         error = 0;
304
//    int         i;
305
//    char       *linep;
306
//    int         class_count[MAX_CLASS];
307
//    int         total;
95 - 308
 
162 david 309
//    cur( 0, 5 );
310
//    printf( "Read text file of team information" );
95 - 311
 
162 david 312
//    if( !getfname( "Enter name of the file to read :", ".csv" ) )
313
//        return;
314
//    printf( "\n" );
95 - 315
 
162 david 316
//    ufile = fopen( ufilename, "rt" );             /* Open the file for reading */
317
//    if( ufile == 0 )
318
//    {
319
//        printf( "Cannot locate data file - %s\n", ufilename );
320
//        beep();
321
//        sleep( 5 );
322
//        return;
323
//    }
95 - 324
 
162 david 325
//    memset ( class_count, 0, sizeof( class_count ));
95 - 326
 
162 david 327
//    /*
328
//    **  Get the data from the file
329
//    **  Read in lines one by one
330
//    */
331
//    while( fgets( line, sizeof(line) - 10 , ufile ) )
332
//    {
333
//        linep = line;
334
//        int has_data = 0;
335
//        /*
336
//        **  Skip blank lines
337
//        **  Skip leading white space
338
//        */
339
//        for ( linep = line; *linep; linep++ )
340
//        {
341
//            if ( *linep == (char)0xA0 || *linep == '"' || *linep == ',' || *linep == '\n' ||*linep == '\r')
342
//            {
343
//                continue;
344
//            }
345
//            has_data = 1;
346
//        }
347
//        if ( !has_data )
348
//            continue;
95 - 349
 
162 david 350
//        for ( linep = line; isspace( *linep ); linep++ )
351
//        {
352
//        }
353
//        if ( ! *linep )
354
//            continue;
95 - 355
 
162 david 356
//        /*
357
//        **  The first entry on the line should be team number
358
//        **  If it is not a valid team number then skip
359
//        */
360
//        if( ! t_parse_number( &linep, &team ) )
361
//        {
362
//            printf( "No team number: %-30s.\n", line );
363
//            error++;
364
//        }
365
//        else if( ! valid_field( team ) )
366
//        {
367
//            printf ( "Invalid team number: %d\n", team );
368
//            error++;
369
//        }
370
//        else
371
//        {
372
//            g_record( team, &team_buf );
95 - 373
 
162 david 374
//            /*
375
//            **  Extract a team information from the CSV file
376
//            **  These fields will be
377
//            **      - Team Name
378
//            **      - Category
379
//            **      - Member names
380
//            */
381
//            if ( t_parse_text( &linep, line_text ) )
382
//            {
383
//                strncpy (team_buf.name,line_text,MAX_TM_NAME);
384
//                if ( ! *line_text )
385
//                {
386
//                    printf( "Team: %d - No Team Name:%50.50s...\n", team, line );
387
//                }
388
//            }
95 - 389
 
162 david 390
//            if ( t_parse_text( &linep, line_text )  && *line_text)
391
//            {
392
//                int cat_found = 0;
393
//                team_buf.teamclass = lookup_class( line_text, NULL );
394
//                if ( team_buf.teamclass > 0)
395
//                {
396
//                    /*
397
//                    **  The team has a category
398
//                    **  Now flag the team as valid - it has ALL
399
//                    **  the basic information
400
//                    */
401
//                    team_buf.flags.valid = TRUE;
402
//                    cat_found =1;
95 - 403
 
162 david 404
//                    if ( team_buf.teamclass < MAX_CLASS )
405
//                        class_count[team_buf.teamclass]++;
406
//                }
95 - 407
 
162 david 408
//                if ( !cat_found )
409
//                {
410
//                    printf( "Team: %d - Invalid category:%s\n", team,line_text );
411
//                    error++;
412
//                }
413
//            }
414
//            else
415
//            {
416
//                printf( "Team: %d - No category:%50.50s...\n", team, line );
417
//                error++;
418
//            }
95 - 419
 
162 david 420
//            for( i = 0; i < MAX_MEMB; i++ )
421
//            {
422
//                if ( t_parse_text( &linep, line_text ) )
423
//                {
424
//                    strncpy (team_buf.members[i].name,line_text,MAX_PERSON_NAME);
425
//                }
95 - 426
 
162 david 427
//                int age;
428
//                if ( t_parse_number( &linep, &age ) )
429
//                {
430
//                    team_buf.members[i].age = age;
431
//                }
432
//            }
95 - 433
 
162 david 434
//            put_team_record( team, &team_buf );
435
//        }
95 - 436
 
162 david 437
///*
438
//**       printf( ">>>:%s\n", line );
439
//**       if ( 'q' == getinp() ) break;
440
//*/
95 - 441
 
162 david 442
//    }
95 - 443
 
162 david 444
//    /*
445
//    **  Display a few upload stats
446
//    */
447
//    total = 0;
448
//    for( i = 0; i < config.num_class; i++ )
449
//    {
450
//        printf( "%*s : %d\n", LEN_CLASS_NAME, config.team_class[i].full_name, class_count[i+1] );
451
//        total += class_count[i+1];
452
//    }
95 - 453
 
162 david 454
//    printf( "\n%*s : %d\n", LEN_CLASS_NAME, "Total Uploaded", total );
455
//    printf( "%*s : %d\n", LEN_CLASS_NAME, "Errors", error );
95 - 456
 
457
 
162 david 458
//    printf( "\nAny key to continue " );
459
//    getinp();
95 - 460
 
162 david 461
//    fclose( ufile );
462
//}
95 - 463
 
464
 
465
/*========================================================================
466
 *
467
 *  Parse a number from a CSV text file
468
 *
469
 *  Purpose:
470
 *      This helper function is called to Parse line of team text
471
 *
472
 *  Parameters:
473
 *      linep           Current input source pointer
474
 *                      Will be updated to point to end of the field
475
 *                      If the field is a valid number
476
 *      number          Number extracted
477
 *
478
 *  Returns:
479
 *      TRUE - Number extracted OK
480
 *      FALSE - No number extracted
481
 *
482
 *========================================================================*/
483
 
162 david 484
//bool t_parse_number( char **linep, int *number )
485
//{
486
//    long    lnumber;
487
//    char    *work = *linep;
488
//    char    *endp;
95 - 489
 
162 david 490
//    /*
491
//    **  Extract data from the CSV field
492
//    **  May need to remove quotes
493
//    **  Use temp work space
494
//    */
495
//    t_parse_text( &work, line_text);
95 - 496
 
162 david 497
//    /*
498
//    **  Expecting a number
499
//    **  strtol will remove leading white space
500
//    */
501
//    lnumber = strtol( line_text, &endp, 10 );
95 - 502
 
162 david 503
//    /*
504
//    **  A valid number ?
505
//    **  All the field must be numeric, otherwise it wasn't a number
506
//    */
507
//    if ( lnumber == 0 || *endp  )
508
//        return FALSE;
95 - 509
 
162 david 510
//    *number = (int) lnumber;
511
//    *linep = work;
512
//    return TRUE;
513
//}
95 - 514
 
515
/*========================================================================
516
 *
517
 *  Parse a text field from a CSV text file
518
 *
519
 *  Purpose:
520
 *      This helper function is called to Parse line of team text
521
 *
522
 *  Parameters:
523
 *      linep           Current input source pointer
524
 *                      Will be updated to point to end of the field
525
 *      number          Address of buffer to insert text into
526
 *
527
 *  Returns:
528
 *      TRUE - Field extracted OK
529
 *      FALSE - No field extracted
530
 *
531
 *========================================================================*/
532
 
162 david 533
//bool t_parse_text( char **linep, char *text )
534
//{
535
//    char    uch;
536
//    char    *textp = text;
537
//    bool    quoted = FALSE;
95 - 538
 
162 david 539
//    /*
540
//    **  If we have already reached the end of the line tne indicate
541
//    **  That there is no data
542
//    */
543
//    uch = **linep;
544
//    if ( uch == '\n' || uch == '\r' || uch == '\0' )
545
//        return ( FALSE );
95 - 546
 
162 david 547
//    /*
548
//    **  Extract the next record
549
//    */
550
//    while ( TRUE )
551
//    {
552
//        uch = **linep;
95 - 553
 
162 david 554
//        /*
555
//        **  End of the field
556
//        */
557
//        if ( uch == '\n' || uch == '\r' || uch == '\0' )
558
//            break;
95 - 559
 
162 david 560
//        (*linep)++;
95 - 561
 
162 david 562
//        /*
563
//        ** Ugly character from MS CSV files
564
//        */
565
//        if ( uch == (char) 0xA0 )
566
//        {
567
//            continue;
568
//        }
95 - 569
 
162 david 570
//        if ( !quoted && uch == ',' )
571
//        {
572
//            break;
573
//        }
95 - 574
 
162 david 575
//        /*
576
//        **  An unquoted " will start scanning for a matching quote
577
//        */
578
//        if ( !quoted && uch == '"' )
579
//        {
580
//            quoted = TRUE;
581
//            continue;
582
//        }
95 - 583
 
584
 
162 david 585
//        /*
586
//        **  A quoted " may be an embedded quote or the end of a quote
587
//        */
588
//        if ( quoted && uch == '"' )
589
//        {
590
//            if ( **linep != '"' )
591
//            {
592
//                quoted = FALSE;
593
//                continue;
594
//            }
95 - 595
 
162 david 596
//            /*
597
//            **  Skip one " and pick up the next
598
//            */
599
//            (*linep)++;
95 - 600
 
162 david 601
//        }
95 - 602
 
162 david 603
//        /*
604
//        **  Save this character
605
//        */
606
//        *textp++ = uch;
607
//    }
95 - 608
 
162 david 609
//    /*
610
//    **  Clean up the extracted string
611
//    */
612
//    *textp = 0;
613
//    compact ( text );
95 - 614
 
162 david 615
//    return ( TRUE );
616
//}
95 - 617
 
618
/*========================================================================
619
 *
620
 *  Test for a delimiter.
621
 *
622
 *  Purpose:
623
 *      This function is called to Test for a delimiter.
624
 *
625
 *  Parameters:
626
 *      c           Character to test
627
 *
628
 *  Returns:
629
 *      TRUE if a delimter (space, tab or comma)
630
 *
631
 *========================================================================*/
632
 
162 david 633
//char p_del( char *c )
634
//{
635
//    return ( *c == ' ' || *c == '\t' || *c == ',' || *c == '\0' || *c == '\n' || *c == '\r');
636
//}
95 - 637
 
162 david 638
//char p_eol( char *c )
639
//{
640
//    return ( *c == '\0' || *c == '\n' || *c == '\r' );
641
//}
95 - 642
 
643
/*========================================================================
644
 *
645
 *  Generate team name file
646
 *
647
 *  Purpose:
648
 *      This function is called to Generate team name file in the format
649
 *      that can be read by the load command
650
 *
651
 *      The file contains team number,Team name,Team class
652
 *      The operator is prompted to enter the name of the file
653
 *
654
 *  Parameters:
655
 *      None
656
 *
657
 *  Returns:
658
 *      Nothing
659
 *
660
 *========================================================================*/
661
 
162 david 662
//void tdnload_store(void)
663
//{
664
//    int         i;
665
//    int         j;
95 - 666
 
162 david 667
//    cur( 0, 5 );
668
//    printf( "Create text file of team information" );
95 - 669
 
162 david 670
//    if( !getfname( "Enter name of the file to create :", ".csv.txt" ) )
671
//        return;
672
//    printf( "\n" );
95 - 673
 
162 david 674
//    /*
675
//    **  Open printer, with known filename
676
//    */
677
//    if( !open_printer_name( ufilename, 2000, text, NULL ) )
678
//    {
679
//        beep();
680
//        sleep( 5 );
681
//        return;
682
//    }
95 - 683
 
162 david 684
//    /*
685
//    **  Print headings
686
//    */
687
//    csv_print( "%s",   "Team Number" );
688
//    csv_print( "%s",   "Team Name" );
689
//    csv_print( "%s",   "Class Abr");
95 - 690
 
162 david 691
//    for( j = 1; j <= config.num_legs; j++ )
692
//    {
693
//        csv_print( "%s", "Competitor Name");
694
//        csv_print( "%s", "Age");
695
//    }
696
//    csv_print("\n");
95 - 697
 
162 david 698
//    /*
699
//     * Put the data into the file
700
//     */
95 - 701
 
162 david 702
//    for( i = config.min_team; i <= config.max_team; i++ )
703
//    {
704
//        if( valid_field( i ) && g_record( i, &team_buf ) )
705
//        {
706
//            /*
707
//            **  Basic information
708
//            **      - Team number
709
//            **      - Full team name
710
//            */
711
//            csv_print( "%d",   team_buf.numb );
712
//            csv_print( "%s",   team_buf.name );
713
//            csv_print( "%s",    team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
714
//            for( j = 1; j <= config.num_legs; j++ )
715
//            {
716
//                csv_print( "%s", team_buf.members[j-1].name );
717
//                csv_print( "%d", team_buf.members[j-1].age );
718
//            }
719
//            csv_print( "\n" );
720
//        }
721
//    }
722
//    close_printer();
723
//}
95 - 724
 
725
/*========================================================================
726
 *
727
 *  Generate team name file
728
 *
729
 *  Purpose:
730
 *      This function is called to Generate team name file
731
 *
732
 *      The file contains team number,Team name,Team class
733
 *      The operator is prompted to enter the name of the file
734
 *
735
 *  Parameters:
736
 *      None
737
 *
738
 *  Returns:
739
 *      Nothing
740
 *
741
 *========================================================================*/
742
 
162 david 743
//void tdnload(void)
744
//{
745
//    int         i;
95 - 746
 
162 david 747
//    cur( 0, 5 );
748
//    printf( "Create text file of team information" );
95 - 749
 
162 david 750
//    if( !getfname( "Enter name of the file to create :", ".txt" ) )
751
//        return;
752
//    printf( "\n" );
95 - 753
 
162 david 754
//    ufile = fopen( ufilename, "wt" );             /* Open the file for writing */
755
//    if( ufile == 0 )
756
//    {
757
//        printf( "Cannot create data file - %s\n", ufilename );
758
//        beep();
759
//        sleep( 5 );
760
//        return;
761
//    }
95 - 762
 
162 david 763
//    /*
764
//     * Put the data into the file
765
//     */
95 - 766
 
162 david 767
//    for( i = config.min_team; i <= config.max_team; i++ )
768
//    {
769
//        if( valid_field( i ) && g_record( i, &team_buf ) )
770
//        {
771
//            fprintf( ufile, "%-5d,%-30s,%-5s\n",
772
//                     team_buf.numb,
773
//                     team_buf.name,
774
//                     team_buf.teamclass >
775
//                     0 ? config.team_class[team_buf.teamclass - 1].abr : "" );
776
//        }
777
//    }
778
//    fclose( ufile );
779
//}
95 - 780
 
781
/*========================================================================
782
 *
783
 *  Generate leg timing file
784
 *
785
 *  Purpose:
786
 *      This function is called to Generate leg timing file
787
 *
788
 *  Parameters:
789
 *      None
790
 *
791
 *  Returns:
792
 *      Nothing
793
 *
794
 *========================================================================*/
795
 
162 david 796
//void dnload(void)
797
//{
798
//    int         i;
799
//    char        stend[] = "E";
95 - 800
 
162 david 801
//    cur( 0, 5 );
802
//    printf( "Generate leg data files" );
803
//    while( TRUE )
804
//    {
805
//        leg = 0;
806
//        d_field( 0, 6, "Enter leg to save :", D_NUMBER, 1, ( char * ) &leg,
807
//                 TRUE, M_UPDATE );
808
//        if( leg == 0 )
809
//            return;                              /* Null leg - just exit */
810
//        if( leg <= config.num_legs )             /* Valid leg number - exit loop */
811
//            break;
812
//        beep();                                /* Make a noise and keep waiting for valid number */
95 - 813
 
162 david 814
//    }
95 - 815
 
816
 
162 david 817
//    /*
818
//     * Find out if Start or End of leg times to be saved
819
//     */
95 - 820
 
162 david 821
//    do
822
//    {
823
//        d_field( 0, 7, "Start of End of leg to save :", D_USTRING, 1, stend,
824
//                 TRUE, M_UPDATE );
825
//    } while( ( stend[0] != 'S' ) && ( stend[0] != 'E' ) );
826
//    manstart = ( stend[0] == 'S' ? TRUE : FALSE );
95 - 827
 
162 david 828
//    /*
829
//     * Locate the required data file and prepare for processing
830
//     */
95 - 831
 
162 david 832
//    printf( "\n" );
833
//    sprintf( ufilename, ( manstart ? "Sleg%d" : "leg%d" ), leg );   /* Create the file name */
834
//    ufile = fopen( ufilename, "wt" );             /* Open the file for writing */
835
//    if( ufile == 0 )
836
//    {
837
//        printf( "Cannot create data file - %s\n", ufilename );
838
//        beep();
839
//        sleep( 5 );
840
//        return;
841
//    }
95 - 842
 
162 david 843
//    /*
844
//     * Write the data to the data file
845
//     */
95 - 846
 
162 david 847
//    for( i = config.min_team; i <= config.max_team; i++ )
848
//    {
849
//        if( valid_field( i ) && g_record( i, &team_buf ) )
850
//        {
851
//            if( !manstart
852
//                && ( leg <= config.num_legs && team_buf.leg[leg].end >= 0 ) )
853
//                fprintf( ufile, "%d %s\n", i,
854
//                         time_a( team_buf.leg[leg].end ) );
95 - 855
 
162 david 856
//            if( manstart && team_buf.leg[leg].start >= 0 )
857
//                fprintf( ufile, "%d %s\n", i,
858
//                         time_a( team_buf.leg[leg].start ) );
859
//        }
860
//    }
861
//    fclose( ufile );
862
//}
95 - 863
 
864
/*========================================================================
865
 *
866
 *  Get a filename from the user
867
 *
868
 *  Purpose:
869
 *      This function is called to Get a filename from the user
870
 *
871
 *  Parameters:
872
 *      prompt      User prompt
873
 *      ext         File extension
874
 *
875
 *  Returns:
876
 *      TRUE: all is well
877
 *
878
 *========================================================================*/
879
 
162 david 880
//char getfname( const char *prompt, const char *ext )
881
//{
882
//    /*
883
//    **  Create a default name if non is present
884
//    */
885
//    if ( ! *ufilename )
886
//    {
887
//        sprintf( ufilename, "%s%s", filebase, ext );
888
//    }
95 - 889
 
162 david 890
//    d_field( 0, 6, prompt, D_STRING, 40, ufilename, TRUE, M_UPDATE );
891
//    if( abort_flag )
892
//        return ( FALSE );
95 - 893
 
162 david 894
//    compact( ufilename );
895
//    if( ufilename[0] )
896
//        return ( TRUE );
897
//    return ( FALSE );
898
//}
95 - 899
 
900
/********************************* EOF ***********************************/