blob: b62aaee8326b64e9db49de8e73bd8dcd7084237a (
plain)
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
101
102
103
104
105
|
#include "uscxml/config.h"
#include "uscxml/Interpreter.h"
#include <glog/logging.h>
#ifdef HAS_SIGNAL_H
#include <signal.h>
#endif
#ifdef _WIN32
#include "XGetopt.h"
#endif
class VerboseMonitor : public uscxml::InterpreterMonitor {
void onStableConfiguration(uscxml::Interpreter* interpreter) {
printConfig(interpreter->getConfiguration());
}
void beforeCompletion(uscxml::Interpreter* interpreter) {
printConfig(interpreter->getConfiguration());
}
void printConfig(const Arabica::XPath::NodeSet<std::string>& config) {
std::string seperator;
std::cout << "Config: {";
for (int i = 0; i < config.size(); i++) {
std::cout << seperator << ATTR(config[i], "id");
seperator = ", ";
}
std::cout << "}" << std::endl;
}
};
void printUsageAndExit() {
printf("mmi-browser version " USCXML_VERSION " (" CMAKE_BUILD_TYPE " build - " CMAKE_COMPILER_STRING ")\n");
printf("Usage\n");
printf("\tmmi-browser");
#ifdef BUILD_AS_PLUGINS
printf(" [-p pluginPath]");
#endif
printf(" URL\n");
printf("\n");
printf("Options\n");
printf("\t-v : be verbose\n");
printf("\n");
exit(1);
}
int main(int argc, char** argv) {
using namespace uscxml;
#ifdef HAS_SIGNAL_H
signal(SIGPIPE, SIG_IGN);
#endif
if (argc < 2) {
printUsageAndExit();
}
bool verbose = false;
#ifndef _WIN32
opterr = 0;
#endif
int option;
while ((option = getopt(argc, argv, "vl:p:")) != -1) {
switch(option) {
case 'l':
google::InitGoogleLogging(optarg);
break;
case 'p':
uscxml::Factory::pluginPath = optarg;
break;
case 'v':
verbose = true;
break;
case '?':
break;
default:
printUsageAndExit();
break;
}
}
// for (int i = 0; i < argc; i++)
// std::cout << argv[i] << std::endl;
// std::cout << optind << std::endl;
Interpreter* interpreter = Interpreter::fromURI(argv[optind]);
if (interpreter) {
interpreter->setCmdLineOptions(argc, argv);
// interpreter->setCapabilities(Interpreter::CAN_NOTHING);
// interpreter->setCapabilities(Interpreter::CAN_BASIC_HTTP | Interpreter::CAN_GENERIC_HTTP);
if (verbose) {
VerboseMonitor* vm = new VerboseMonitor();
interpreter->addMonitor(vm);
}
interpreter->start();
while(interpreter->runOnMainThread(25));
delete interpreter;
}
return EXIT_SUCCESS;
}
|