-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cxx
More file actions
122 lines (115 loc) · 3.21 KB
/
main.cxx
File metadata and controls
122 lines (115 loc) · 3.21 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// lddgraph
// Small C++ tool which creates dependencies graphs of dynamically linked
// binaries using ldd and Graphviz.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This code is licensed under the terms specified in the LICENSE.BSD file
// https://github.com/bbenoist/lddgraph/blob/master/LICENSE.BSD
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <iostream>
#include "progname.h"
#include "lddgraph.hxx"
#include "help.hxx"
#include "version.hxx"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using namespace std;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static const struct option longopts[] =
{
{ "ignore", required_argument, NULL, 'i' },
{ "ignore-text", required_argument, NULL, 'I' },
{ "image", required_argument, NULL, 'e' },
{ "image-format", required_argument, NULL, 'f' },
{ "graphviz", required_argument, NULL, 'g' },
{ "ld-trace-loaded-objects", no_argument, NULL, 't' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
{ "binary", required_argument, NULL, 'b' },
{ NULL, 0, NULL, 0 }
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Entry point for lddgraph
int main(int argc, char* argv[])
{
program_name = argv[0];
/* Prints output when no arguments where specified */
if (argc < 2)
{
printhelp();
exit(EXIT_SUCCESS);
}
lddgraph lddg;
int optc;
while ((optc = getopt_long (argc, argv, "b:vhi:I:e:f:g:tqV", longopts, NULL)) != -1)
{
switch (optc)
{
case 'v':
{
printversion();
exit(EXIT_SUCCESS);
} break;
case 'h':
{
printhelp();
exit(EXIT_SUCCESS);
} break;
case 'i':
{
vector<string> ignorelist = lddg.getignorelist();
string val = optarg;
ignorelist.push_back(trim(val));
lddg.setignorelist(ignorelist);
} break;
case 'I':
{
vector<string> ignorepatterns = lddg.getignorepatterns();
string val = optarg;
ignorepatterns.push_back(trim(val));
lddg.setignorepatterns(ignorepatterns);
} break;
case 'e':
{
lddg.setimgmode(true);
lddg.setimgoutput(optarg);
} break;
case 'f':
{
lddg.setimgformat(optarg);
} break;
case 'g':
{
lddg.setgvmode(true);
lddg.setgvoutput(optarg);
} break;
case 't':
{
lddg.setuseldd(false);
} break;
case 'q':
{
lddg.setquiet(true);
} break;
case 'V':
{
lddg.setverbose(true);
} break;
default:
{
abort();
} break;
}
}
lddg.setinput(argv[argc - 1]);
// Start the lddgraph processing
if (lddg.run())
exit(EXIT_SUCCESS);
else
exit(EXIT_FAILURE);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~