Add Freescale Nexus decoder implementation
[babeltrace.git] / converter / nexus / main.cpp
1 /*
2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22
23 #include <iostream>
24 #include <string>
25 #include "Application.h"
26 #include "config.h"
27
28 using std::cout;
29 using std::endl;
30 using std::string;
31
32 void helpOption()
33 {
34 cout << "Usage: nexdump [options] <filename>" << endl;
35 cout << "Options:" << endl;
36 cout << " --help Display this information"
37 << endl;
38 cout << " --version Display version information"
39 << endl;
40 cout
41 << " --verbose Display decoded debug/trace information"
42 << endl;
43 cout
44 << " --fmlog Display FMan detail trace information"
45 << endl;
46 cout
47 << " --faddr Display Full Addresses in trace information"
48 << endl;
49 cout
50 << " --summary Display a summary of message count information"
51 << endl;
52 }
53
54 void versionOption()
55 {
56 cout << PACKAGE << " v" << VERSION << endl;
57 cout << "Copyright (C) 2013 Freescale Semiconductor" << endl;
58 }
59
60 int main(int argc, char * const argv[])
61 {
62
63 Application app;
64 string in_filename;
65
66 // process the options
67 for (int i = 1; i < argc; i++) {
68
69 string argStr = argv[i];
70 if (argStr.find("--help") == 0) {
71 helpOption();
72 return 0;
73
74 } else if (argStr.find("--version") == 0) {
75 versionOption();
76 return 0;
77
78 } else if (argStr.find("--verbose") == 0) {
79 app.verbose(true);
80
81 } else if (argStr.find("--summary") == 0) {
82 app.summary(true);
83
84 } else if (argStr.find("--faddr") == 0) {
85 app.enableFullAddrLog();
86
87 } else if (argStr.find("--fmlog") == 0) {
88 app.enableFmanLog();
89
90 } else if (in_filename.empty()) {
91 // treat as the filename
92 in_filename = argStr;
93
94 } else {
95 // error
96 helpOption();
97 return -1;
98 }
99 }
100
101 // check if filename not found
102 if (in_filename.empty()) {
103 helpOption();
104 return -1;
105 }
106
107 // begin operation
108 if (app.process(in_filename) == false) {
109 return -1;
110 }
111
112 return 0;
113 }
This page took 0.032333 seconds and 4 git commands to generate.