-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
100 lines (77 loc) · 2 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* This application is free software and is released under the terms of
* the BSD license. See LICENSE file for details.
*
* Copyright (c) 2010 Volker Poplawski ([email protected])
*/
#include <QtWidgets>
#include <iostream>
#include <getopt.h>
#include <locale.h>
#include "global.h"
#include "mainWindow.h"
#include <map>
void printUsage( const QString& appname )
{
std::cout << "Usage: " << appname.toStdString() << " [OPTIONS] [ASTERIXFILE]" << std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << " -h Print this text" << std::endl;
std::cout << " --specs DIRECTORY Add specifications from DIRECTORY" << std::endl;
// std::cout << " -V Print version and exit" << std::endl;
std::cout << std::endl;
}
void processCommandLine( int argc, char** argv )
{
const char* optstring = "h?";
int option_index;
int c;
// extern char* optarg;
extern int optind;
static struct option long_options[] = {
{"specs", required_argument, 0, 0},
{0, 0, 0, 0}
};
while(1) {
if ((c = getopt_long( argc, argv, optstring, long_options, &option_index )) == -1)
break; // no more recognized options
switch (c) {
case 0: // longoption
{
if (option_index == 0)
{
g_specsDirectory = QString::fromUtf8(optarg);
}
}
break;
case 'h':
case '?':
printUsage( argv[0] );
exit( 0 );
break;
case 'V':
exit( 0 );
break;
default:
break;
}
}
// options left over?
if (optind < argc) {
g_openFileName = argv[optind++];
if (optind < argc) {
printUsage( argv[0] );
exit( 1 );
}
}
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setApplicationName("asterixInspector");
processCommandLine(argc, argv);
// UAP parser uses sscanf() to parse floats. Force sane locale.
setlocale(LC_NUMERIC, "C");
MainWindow w;
w.show();
return app.exec();
}