Subversion Repositories svn1

Rev

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