Subversion Repositories svn1

Rev

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

Rev Author Line No. Line
91 - 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
**************************************************************************/
94 - 30
#include    <QtGui/QApplication>
91 - 31
 
32
#include    <time.h>
33
#include    "consts.h"
34
#include    "structs.h"
35
#include    "proto.h"
94 - 36
 
37
#include    "qmconfigure.h"
38
#include    "mainwindow.h"
39
 
91 - 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
 
126 david 69
    QApplication a(argc, argv);
70
 
91 - 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 */
126 david 101
            {
102
                qWarning("Mutiple input files found");
103
            }
91 - 104
            file_name = argv[0];
105
        }
106
    }
107
 
108
    /*
126 david 109
    **  Validate parameters
110
    **  Filename must be supplied
94 - 111
    */
112
 
126 david 113
    if ( file_name == NULL )
112 david 114
    {
126 david 115
        qFatal("No marathon file name on command line");
112 david 116
    }
94 - 117
 
118
    /*
126 david 119
    **  Process the configuration file
91 - 120
    */
126 david 121
    if( !configure( file_name, FALSE ) )
91 - 122
    {
126 david 123
        qFatal("Program aborted. Config error" );
91 - 124
    }
125
 
126 david 126
    if( ! init_team_data() )
91 - 127
    {
126 david 128
        qFatal( "Program aborted. Team Data error" );
91 - 129
    }
130
 
126 david 131
    MainWindow w;
132
    w.show();
159 david 133
 
133 david 134
    MainWindow::showMessage ("Mara Started", 5000);
94 - 135
    return a.exec();
126 david 136
  }
91 - 137
 
138
/*============================================================================
139
 *
140
 *  Display general usage message
141
 *
142
 *  Purpose:
143
 *      Display general usage message
144
 *      Used on command line syntax error
145
 *      
146
 *  Parameters:
147
 *      None
148
 *      
149
 *  Returns:
150
 *      exit code 3
151
 *      
152
 *===========================================================================*/
153
 
154
void usage(void)
155
{
144 - 156
    qDebug( "Usage : mara [options] configuration_file\n" );
157
    qDebug( " or   : mara -v\n" );
158
    qDebug( "\n" );
159
    qDebug( "Options are:\n" );
160
    qDebug( "   -c       - Create configuration file\n" );
161
    qDebug( "   -q       - No splash screen\n" );
162
    qDebug( "   -v       - Display version then exit\n" );
163
    qDebug( "   -x<cmds> - Execute commnads\n" );
91 - 164
    exit( 3 );
165
}
166
 
167
 
168
/*============================================================================
169
**
170
**  Temp escape to DOS
171
**
172
**  Purpose:    Temp escape to DOS
173
**
174
**  Parameters: None
175
**      
176
**  Returns:    Nothing
177
**
178
**===========================================================================*/
179
 
158 david 180
//void ms_system(void)
181
//{
182
//    static char command[101] = "";               /* Save the command here */
91 - 183
 
158 david 184
//    cur( 0, 20 );
185
//    printf( "Command:" );
186
//    if( getstring( 100, command, Alphanum ) )
187
//    {
188
//        printf( "\n" );
189
//        system( command );
190
//        printf( "\nAny key to continue" );
191
//        getinp();
192
//    }
193
//}
91 - 194
 
195
#ifdef DISPLAY_STRUCTURES
196
/*============================================================================
197
**
198
**  Display structure information
199
**
200
**  Purpose:    Display internal structure information
201
**
202
**  Parameters: Nothing
203
**      
204
**  Returns:    Nothing directly
205
**
206
**===========================================================================*/
207
 
208
/*
209
**  esize - A macro to return the size of a structure element
210
**  element - print element information
211
*/
212
#define esize( st, el) ( sizeof(((st *)0)->el))
213
#define element( st, el) \
214
    printf( "Offset of %-15s :%4d, Size:%d   \n", #el, offsetof( st, el), esize(st, el) );
215
 
216
void display_structures(void)
217
{
218
    printf( "Structure: leg_type\n" );
219
    element( leg_type, start    );
220
    element( leg_type, end      );
221
    element( leg_type, elapsed  );
222
    element( leg_type, l_place  );
223
    element( leg_type, le_place );
224
    element( leg_type, lc_place );
225
    element( leg_type, lec_place);
226
    element( leg_type, manual   );
227
    printf( "Sizeof %-18s :%4d\n", "leg_type", sizeof(leg_type) );
228
 
229
 
230
    printf( "\n" );
231
    printf( "Structure: team_type\n" );
232
    element( team_type, numb   );
233
    element( team_type, name   );
234
    element( team_type, leg    );
235
    element( team_type, members);
236
    element( team_type, class  );
237
    element( team_type, country);
238
    element( team_type, flags  );
239
    printf( "Sizeof %-18s :%4d\n", "team_type", sizeof(team_type) );
240
 
241
    printf( "\n" );
242
    printf( "Structure: MARA_CFG\n" );
243
    element( MARA_CFG, event_name      );
244
    element( MARA_CFG, leg_name        );
245
    element( MARA_CFG, t_def           );
246
    element( MARA_CFG, num_legs        );
247
    element( MARA_CFG, num_teams       );
248
    element( MARA_CFG, max_team        );
249
    element( MARA_CFG, min_team        );
250
    element( MARA_CFG, team_class      );
251
    element( MARA_CFG, num_class       );
252
    element( MARA_CFG, country_name    );
253
    element( MARA_CFG, num_countries   );
254
    element( MARA_CFG, addendum        );
255
    element( MARA_CFG, datafilename    );
256
    printf( "Sizeof %-18s :%4d\n", "MARA_CFG", sizeof(MARA_CFG) );
257
}
258
#endif
259
/********************************* EOF ***********************************/
260