Subversion Repositories svn1

Rev

Rev 112 | Rev 133 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 112 Rev 126
Line 37... Line 37...
37
#include    "qmconfigure.h"
37
#include    "qmconfigure.h"
38
#include    "mainwindow.h"
38
#include    "mainwindow.h"
39
 
39
 
40
#undef      DISPLAY_STRUCTURES
40
#undef      DISPLAY_STRUCTURES
41
 
41
 
42
char        invalid_copy;                        /* Quick nasty test of copy */
-
 
43
 
-
 
44
 
-
 
45
#if defined(HI_TECH_C) || defined(__TURBOC__)
-
 
46
extern unsigned _stklen = 8000;                  /* Create a long stack */
-
 
47
#endif
-
 
48
 
-
 
49
menu_table  main_menu[] = {
-
 
50
    { '1', "Enter team data", team_update },
-
 
51
    { '2', "Display team information", team_display },
-
 
52
    { '3', "Alter leg times", leg_mods },
-
 
53
    { '4', "Set leg start times", set_legs },
-
 
54
    { '5', "Report generation menu", report },
-
 
55
    { '6', "Data consistency check", data_check },
-
 
56
    { '7', "Team disqualification operations", f_disqualify },
-
 
57
    { '8', "Upload/Download functions", supload },
-
 
58
    { 'C', "Configuration menu", conf_menu },
-
 
59
    { 'S', "MS-DOS system", ms_system },
-
 
60
    { 'q', "Exit program", 0 },
-
 
61
    { '\0' }
-
 
62
};
-
 
63
 
-
 
64
/*============================================================================
42
/*============================================================================
65
 *  Main entry point
43
 *  Main entry point
66
 *
44
 *
67
 *  Purpose:
45
 *  Purpose:
68
 *      Main enrty point
46
 *      Main enrty point
Line 84... Line 62...
84
 *
62
 *
85
 *===========================================================================*/
63
 *===========================================================================*/
86
 
64
 
87
int main( int argc, char *argv[] )
65
int main( int argc, char *argv[] )
88
{
66
{
89
    int         gross_error = 0;
-
 
90
 
-
 
91
    bool        do_splash = TRUE;
67
    bool        do_splash = TRUE;
92
    bool        do_version = FALSE;
68
    bool        do_version = FALSE;
93
    bool        do_config = FALSE;
69
    bool        do_config = FALSE;
94
    char       *file_name = NULL;
70
    char       *file_name = NULL;
95
 
71
 
-
 
72
    QApplication a(argc, argv);
-
 
73
 
96
    /*
74
    /*
97
    **  Verify command arguments
75
    **  Verify command arguments
98
    */
76
    */
99
    if( argc < 2 )
77
    if( argc < 2 )
100
        usage();
78
        usage();
Line 137... Line 115...
137
            /*
115
            /*
138
            **  Parameter without a switch
116
            **  Parameter without a switch
139
            **  Must be the input file name
117
            **  Must be the input file name
140
            */
118
            */
141
            if( file_name )                   /* Already defined */
119
            if( file_name )                   /* Already defined */
-
 
120
            {
-
 
121
                qWarning("Mutiple input files found");
142
                usage();
122
            }
143
            file_name = argv[0];
123
            file_name = argv[0];
144
        }
124
        }
145
    }
125
    }
146
 
126
 
147
    /*
127
    /*
-
 
128
    **  Validate parameters
148
    **  Process the configuration file
129
    **  Filename must be supplied
149
    */
130
    */
150
    if( !configure( file_name, do_config ) )
-
 
151
    {
-
 
152
        printf( "Program aborted. Config error\n" );
-
 
153
        exit (1);
-
 
154
    }
-
 
155
 
131
 
156
    if( ! init_team_data() )
132
    if ( file_name == NULL )
157
    {
133
    {
158
        printf( "Program aborted. Team Data error\n" );
134
        qFatal("No marathon file name on command line");
159
        exit (1);
-
 
160
    }
135
    }
161
 
136
 
162
 
-
 
163
    QApplication a(argc, argv);
-
 
164
    MainWindow w;
-
 
165
    w.show();
-
 
166
 
-
 
167
 
-
 
168
    /*
137
    /*
169
    **  Parse the command line arguments
138
    **  Process the configuration file
170
    */
139
    */
171
    if ( do_splash )
140
    if( !configure( file_name, FALSE ) )
172
    {
141
    {
173
        printf( "Mara   Copyright David Purdie 1995-2008.\n" );
-
 
174
        printf( "       Version %s", VERSION );
-
 
175
#ifdef __MINGW32__
-
 
176
        printf( " (Mingwin)" );
-
 
177
#endif
-
 
178
#ifdef __TURBOC__
-
 
179
        printf( " (TurboC)" );
-
 
180
#endif
-
 
181
        printf( "\n" );
-
 
182
        printf( "       This program is not to be used without the permission of\n" );
-
 
183
        printf( "       David Purdie.\n" );
142
        qFatal("Program aborted. Config error" );
184
 
-
 
185
#ifdef DISPLAY_STRUCTURES
-
 
186
        display_structures();
-
 
187
#endif
-
 
188
    }
143
    }
189
 
144
 
190
    if ( do_version )
145
    if( ! init_team_data() )
191
    {
146
    {
192
        printf( "Version %s", VERSION );
-
 
193
#if END_VALID_DATE > 0
-
 
194
        printf( "P" );
-
 
195
#endif
-
 
196
 
-
 
197
#if defined(LIMIT_TEAMS) && (LIMIT_TEAMS > 0)
-
 
198
        printf( " (Limited teams)" );
147
        qFatal( "Program aborted. Team Data error" );
199
#endif
-
 
200
 
-
 
201
        printf( " %s %s\n", __DATE__, __TIME__ );
-
 
202
        exit( 0 );
-
 
203
    }
148
    }
204
 
149
 
205
    /*
-
 
206
    **  Validate parameters
-
 
207
    **  Filename must be supplied
-
 
208
    */
-
 
209
    if ( file_name == NULL )
150
    MainWindow w;
210
        usage();
151
    w.show();
211
    return a.exec();
152
    return a.exec();
212
    /*
-
 
213
    **  Wait for the user to read the copyright notice
-
 
214
    */
-
 
215
//    if ( do_splash )
-
 
216
//    {
-
 
217
//        while( getinp() >= ' ' );
-
 
218
//    }
-
 
219
 
-
 
220
    /*
-
 
221
    **  Init the screen subsystem
-
 
222
    */
-
 
223
    init_screen();
-
 
224
    test_legal_version();
-
 
225
 
-
 
226
    /*
-
 
227
    **  Main process operations
-
 
228
    **  This is wrapped in a loop to make it easy to skip to the
-
 
229
    **  exit process bypassing the body.
-
 
230
    */
-
 
231
    do
-
 
232
    {
-
 
233
        /*
-
 
234
        **  Process the configuration file
-
 
235
        */
-
 
236
        if( !configure( file_name, do_config ) )
-
 
237
        {
-
 
238
            printf( "Program aborted.\n" );
-
 
239
            gross_error = 1;
-
 
240
            break;
-
 
241
        }
-
 
242
 
-
 
243
        /*
-
 
244
        **  Initialise the team data file
-
 
245
        */
-
 
246
        if( ! init_team_data() )
-
 
247
        {
-
 
248
            gross_error = 2;
-
 
249
            break;
-
 
250
        }
-
 
251
 
-
 
252
        /*
-
 
253
        **  Process the top level menu
-
 
254
        */
-
 
255
        do_menu( config.event_name, "Select option", main_menu );
-
 
256
        fix_team_data();
-
 
257
        break;
-
 
258
 
-
 
259
    } while ( FALSE);
-
 
260
 
-
 
261
    /*
-
 
262
    **  Restore the screen to its original state
-
 
263
    */
-
 
264
    if ( ! gross_error )
-
 
265
        cur( 0, n_lines - 1 );
-
 
266
    fix_screen();
-
 
267
    printf( "End of marathon\n" );
-
 
268
    exit( gross_error );
-
 
269
}
153
  }
270
 
154
 
271
/*============================================================================
155
/*============================================================================
272
 *
156
 *
273
 *  Display general usage message
157
 *  Display general usage message
274
 *
158
 *
Line 325... Line 209...
325
        printf( "\nAny key to continue" );
209
        printf( "\nAny key to continue" );
326
        getinp();
210
        getinp();
327
    }
211
    }
328
}
212
}
329
 
213
 
330
/*============================================================================
-
 
331
**
-
 
332
**  Test program version
-
 
333
**
-
 
334
**  Purpose:    Determine if this version of the program has expired
-
 
335
**              test against a hard coded date.
-
 
336
**
-
 
337
**  Parameters: Nothing
-
 
338
**      
-
 
339
**  Returns:    Nothing directly
-
 
340
**
-
 
341
**===========================================================================*/
-
 
342
 
-
 
343
void test_legal_version(void)
-
 
344
{
-
 
345
 
-
 
346
#if END_VALID_DATE > 0
-
 
347
    time_t      today;
-
 
348
 
-
 
349
    time( &today );
-
 
350
    invalid_copy = ( today >= END_VALID_DATE );
-
 
351
    if( invalid_copy )
-
 
352
        printf( "\n\aThis is an illegal copy of this program\n" );
-
 
353
#else
-
 
354
    invalid_copy = FALSE;
-
 
355
#endif
-
 
356
}
-
 
357
 
-
 
358
#ifdef DISPLAY_STRUCTURES
214
#ifdef DISPLAY_STRUCTURES
359
/*============================================================================
215
/*============================================================================
360
**
216
**
361
**  Display structure information
217
**  Display structure information
362
**
218
**