Subversion Repositories svn1-original

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 - 1
/*************************************************************************
2
*           Copyright (C) 1992 Embedded Solutions.
3
*                       All rights reserved
4
*
5
* file:         mara.c
6
*
7
* purpose:      Main entry point
8
*               Marathon program  program
9
*
10
* functions:
11
*       main                    - Main entry point
12
*       usage                   - Display general usage message
13
*       ms_system               - Temp escape to DOS
14
*       test_legal_version      - Test program version
15
*
16
*
17
* programmer: David Purdie (DDP)
18
*
19
* revision  date        by      reason
20
*           13-May-91   DDP     Added a nasty.
21
*                               This program will produce funny results if
22
*                               the system date is after 1-Jan-92.
23
*
24
*           25-Oct-91   DDP     Version 2.01 will not produce funny results
25
*
26
*   00.0    6-Nov-92    DDP     Ansified existing code
27
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
28
*
29
**************************************************************************/
98 - 30
#include    <QtGui/QApplication>
95 - 31
 
32
#include    <time.h>
33
#include    "consts.h"
34
#include    "structs.h"
35
#include    "proto.h"
98 - 36
 
37
#include    "qmconfigure.h"
38
#include    "mainwindow.h"
39
 
95 - 40
#undef      DISPLAY_STRUCTURES
41
 
42
/*============================================================================
43
 *  Main entry point
44
 *
45
 *  Purpose:
46
 *      Main enrty point
47
 *      Load configuration file
48
 *      Locate data base
49
 *      Perform copyright stuff
50
 *      Process top level menu
51
 *
52
 *  Parameters:
53
 *      argc    - number of arguments
54
 *      argv    - pointer to first argument pointer
55
 *      
56
 *      
57
 *  Returns:
58
 *      program exit code
59
 *          0 - All is well
60
 *          1 -
61
 *          2 - 
62
 *
63
 *===========================================================================*/
64
 
65
int main( int argc, char *argv[] )
66
{
67
    char       *file_name = NULL;
68
 
130 david 69
    QApplication a(argc, argv);
70
 
95 - 71
    /*
72
    **  Verify command arguments
73
    */
74
    if( argc < 2 )
75
        usage();
76
 
77
    /*
78
    **  Walk the user arguments and extract switches and file names
79
    */
80
    while( --argc )
81
    {
82
        argv++;
83
        if( argv[0][0] == '-' )
84
        {
85
            switch( argv[0][1] )
86
            {
87
                /*
88
                **  Unknown switch
89
                */
90
              default:
91
                usage();
92
            }
93
        }
94
        else
95
        {
96
            /*
97
            **  Parameter without a switch
98
            **  Must be the input file name
99
            */
100
            if( file_name )                   /* Already defined */
130 david 101
            {
102
                qWarning("Mutiple input files found");
103
            }
95 - 104
            file_name = argv[0];
105
        }
106
    }
107
 
108
    /*
130 david 109
    **  Validate parameters
110
    **  Filename must be supplied
98 - 111
    */
112
 
130 david 113
    if ( file_name == NULL )
116 david 114
    {
130 david 115
        qFatal("No marathon file name on command line");
116 david 116
    }
98 - 117
 
118
    /*
130 david 119
    **  Process the configuration file
95 - 120
    */
130 david 121
    if( !configure( file_name, FALSE ) )
95 - 122
    {
130 david 123
        qFatal("Program aborted. Config error" );
95 - 124
    }
125
 
130 david 126
    if( ! init_team_data() )
95 - 127
    {
130 david 128
        qFatal( "Program aborted. Team Data error" );
95 - 129
    }
130
 
130 david 131
    MainWindow w;
132
    w.show();
137 david 133
    MainWindow::showMessage ("Mara Started", 5000);
98 - 134
    return a.exec();
130 david 135
  }
95 - 136
 
137
/*============================================================================
138
 *
139
 *  Display general usage message
140
 *
141
 *  Purpose:
142
 *      Display general usage message
143
 *      Used on command line syntax error
144
 *      
145
 *  Parameters:
146
 *      None
147
 *      
148
 *  Returns:
149
 *      exit code 3
150
 *      
151
 *===========================================================================*/
152
 
153
void usage(void)
154
{
148 - 155
    qDebug( "Usage : mara [options] configuration_file\n" );
156
    qDebug( " or   : mara -v\n" );
157
    qDebug( "\n" );
158
    qDebug( "Options are:\n" );
159
    qDebug( "   -c       - Create configuration file\n" );
160
    qDebug( "   -q       - No splash screen\n" );
161
    qDebug( "   -v       - Display version then exit\n" );
162
    qDebug( "   -x<cmds> - Execute commnads\n" );
95 - 163
    exit( 3 );
164
}
165
 
166
 
167
/*============================================================================
168
**
169
**  Temp escape to DOS
170
**
171
**  Purpose:    Temp escape to DOS
172
**
173
**  Parameters: None
174
**      
175
**  Returns:    Nothing
176
**
177
**===========================================================================*/
178
 
162 david 179
//void ms_system(void)
180
//{
181
//    static char command[101] = "";               /* Save the command here */
95 - 182
 
162 david 183
//    cur( 0, 20 );
184
//    printf( "Command:" );
185
//    if( getstring( 100, command, Alphanum ) )
186
//    {
187
//        printf( "\n" );
188
//        system( command );
189
//        printf( "\nAny key to continue" );
190
//        getinp();
191
//    }
192
//}
95 - 193
 
194
#ifdef DISPLAY_STRUCTURES
195
/*============================================================================
196
**
197
**  Display structure information
198
**
199
**  Purpose:    Display internal structure information
200
**
201
**  Parameters: Nothing
202
**      
203
**  Returns:    Nothing directly
204
**
205
**===========================================================================*/
206
 
207
/*
208
**  esize - A macro to return the size of a structure element
209
**  element - print element information
210
*/
211
#define esize( st, el) ( sizeof(((st *)0)->el))
212
#define element( st, el) \
213
    printf( "Offset of %-15s :%4d, Size:%d   \n", #el, offsetof( st, el), esize(st, el) );
214
 
215
void display_structures(void)
216
{
217
    printf( "Structure: leg_type\n" );
218
    element( leg_type, start    );
219
    element( leg_type, end      );
220
    element( leg_type, elapsed  );
221
    element( leg_type, l_place  );
222
    element( leg_type, le_place );
223
    element( leg_type, lc_place );
224
    element( leg_type, lec_place);
225
    element( leg_type, manual   );
226
    printf( "Sizeof %-18s :%4d\n", "leg_type", sizeof(leg_type) );
227
 
228
 
229
    printf( "\n" );
230
    printf( "Structure: team_type\n" );
231
    element( team_type, numb   );
232
    element( team_type, name   );
233
    element( team_type, leg    );
234
    element( team_type, members);
235
    element( team_type, class  );
236
    element( team_type, country);
237
    element( team_type, flags  );
238
    printf( "Sizeof %-18s :%4d\n", "team_type", sizeof(team_type) );
239
 
240
    printf( "\n" );
241
    printf( "Structure: MARA_CFG\n" );
242
    element( MARA_CFG, event_name      );
243
    element( MARA_CFG, leg_name        );
244
    element( MARA_CFG, t_def           );
245
    element( MARA_CFG, num_legs        );
246
    element( MARA_CFG, num_teams       );
247
    element( MARA_CFG, max_team        );
248
    element( MARA_CFG, min_team        );
249
    element( MARA_CFG, team_class      );
250
    element( MARA_CFG, num_class       );
251
    element( MARA_CFG, country_name    );
252
    element( MARA_CFG, num_countries   );
253
    element( MARA_CFG, addendum        );
254
    element( MARA_CFG, datafilename    );
255
    printf( "Sizeof %-18s :%4d\n", "MARA_CFG", sizeof(MARA_CFG) );
256
}
257
#endif
258
/********************************* EOF ***********************************/
259