Subversion Repositories svn1

Rev

Rev 171 | Rev 174 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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