/[diana_filewatcher]/branches/smhi/src/main.cc
ViewVC logotype

Contents of /branches/smhi/src/main.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download)
Thu Dec 31 10:04:51 2009 UTC (9 years, 9 months ago) by stefan.fagerstrom@smhi.se
File size: 2658 byte(s)
miString fix
1 /** @file main.cc
2 * Main class for coserver4. Only used for initialization.
3 * Run with -gui for GUI.
4 * @author Martin Lilleeng Sćtra <martinls@met.no>
5 */
6
7 // Qt-includes
8 #include <QApplication>
9 #include <stdlib.h>
10 #include <puTools/miCommandLine.h>
11 #include <qUtilities/QLetterCommands.h>
12 #include "CoFileWatcher.h"
13
14 #define _DEBUG
15
16 int main(int argc, char *argv[])
17 {
18 #ifdef _DEBUG
19 cerr << "FileWatcher main program called" << endl;
20 #endif
21 QApplication app(argc, argv);
22
23 #ifdef _DEBUG
24 cerr << "argc: " << argc << endl;
25
26 for(int i=0;i<argc;i++) {
27 cerr << "argv: " << miString(argv[i]) << endl;
28 }
29 #endif
30
31 // parsing commandline-arguments
32 vector<miCommandLine::option> opt(7);
33 miutil::miString logfile;
34
35 opt[0].flag = 'd';
36 opt[0].alias = "dynamic";
37 opt[0].hasArg = false;
38
39 opt[1].flag = 'v';
40 opt[1].alias = "visual";
41 opt[1].hasArg = false;
42
43 opt[2].flag = 'p';
44 opt[2].alias = "port";
45 opt[2].hasArg = true;
46
47 opt[3].flag = 'L';
48 opt[3].alias = "log4cxx-properties-file";
49 opt[3].hasArg = true;
50
51 opt[4].flag = 'w';
52 opt[4].alias = "dir-to-watch";
53 opt[4].hasArg = true;
54
55 opt[5].flag = 'c';
56 opt[5].alias = "coserver-path";
57 opt[5].hasArg = true;
58
59 miCommandLine cl(opt, qApp->argc(), qApp->argv());
60
61 quint16 port;
62 quint16 fileport;
63
64 if (cl.hasFlag('p')) {
65 cerr << "P flag sent" << endl;
66 //istringstream os((cl.arg('p'))[0]);
67 //os >> port;
68
69 if (cl.arg('p').size() >= 0) {
70 port = miutil::miString(cl.arg('p')[0]).toInt(0);
71 } else {
72 #ifdef _DEBUG
73 cerr << "cl.arg('p').size() == 0" << cl.arg('p').size() << endl;
74 #endif
75 port = qmstrings::port;
76 }
77 /* } else if (server->readPortFromFile(fileport) == 0) {
78 cerr << "Port read from file: " << fileport << endl;
79 port = fileport;
80 //} else if (portFromRange == false) {
81 */
82 } else {
83 #ifdef _DEBUG
84 cerr << "Flag p not set!!!" << endl;
85 #endif
86 port = qmstrings::port;
87 }
88 if (cl.arg('L').size() > 0) {
89 logfile = cl.arg('L')[0];
90 } else {
91 logfile = "";
92 }
93 miutil::miString dir = "";
94 if (cl.hasFlag('w'))
95 {
96 if (cl.arg('w').size() > 0)
97 dir = cl.arg('w')[0];
98 }
99
100 #ifdef _DEBUG
101 cerr << "Port is really set to: " << port << endl;
102 #endif
103
104 string logPropFilename = "";
105 if (cl.hasFlag('L')) {
106 if(cl.arg('L').size() > 0)
107 logPropFilename = cl.arg('L')[0];
108 }
109
110 string coserver_path = "";
111
112 if (cl.hasFlag('c')) {
113 if(cl.arg('c').size() > 0)
114 coserver_path = cl.arg('c')[0];
115 }
116
117 CoFileWatcher watcher(port, cl.hasFlag('w'), dir, cl.hasFlag('v'), cl.hasFlag('c'), coserver_path, cl.hasFlag('L'), logPropFilename);
118 /*
119 if (!server->ready())
120 exit(1);
121 */
122 return app.exec();
123 }

Properties

Name Value
svn:executable *

svn@met.no
ViewVC Help
Powered by ViewVC 1.1.5