MCPcopy Create free account
hub / github.com/avast/retdec / processArgs

Function processArgs

src/unpackertool/unpacker.cpp:121–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121ExitCode processArgs(ArgHandler& handler, char argc, char** argv)
122{
123 // In case of failed parsing just print the help
124 if (!handler.parse(argc, argv))
125 {
126 Log::info() << handler << std::endl;
127 return EXIT_CODE_OK;
128 }
129
130 bool brute = handler["brute"]->used;
131
132 // --max-memory N
133 if (handler["max-memory"]->used)
134 {
135 auto maxMemoryLimitStr = handler["max-memory"]->input;
136
137 std::size_t maxMemoryLimit = 0;
138 auto conversionSucceeded = strToNum(maxMemoryLimitStr, maxMemoryLimit);
139 if (!conversionSucceeded)
140 {
141 Log::error() << "Invalid value for --max-memory: '"
142 << maxMemoryLimitStr << "'!\n";
143 return EXIT_CODE_MEMORY_LIMIT_ERROR;
144 }
145
146 auto limitingSucceeded = limitSystemMemory(maxMemoryLimit);
147 if (!limitingSucceeded)
148 {
149 Log::error() << "Failed to limit memory to "
150 << maxMemoryLimitStr << " bytes!\n";
151 return EXIT_CODE_MEMORY_LIMIT_ERROR;
152 }
153 }
154 // --max-memory-half-ram
155 else if (handler["max-memory-half-ram"]->used)
156 {
157 auto limitingSucceeded = limitSystemMemoryToHalfOfTotalSystemMemory();
158 if (!limitingSucceeded)
159 {
160 Log::error() << "Failed to limit memory to half of system RAM!\n";
161 return EXIT_CODE_MEMORY_LIMIT_ERROR;
162 }
163 }
164
165 // -h|--help
166 if (handler["help"]->used)
167 {
168 Log::info() << handler << std::endl;
169 }
170 // --version
171 else if (handler["version"]->used)
172 {
173 Log::info() << utils::version::getVersionStringLong() << std::endl;
174 }
175 // -p|--plugins
176 else if (handler["plugins"]->used)
177 {
178 Log::info() << "List of available plugins:" << std::endl;

Callers 1

_mainFunction · 0.70

Calls 9

strToNumFunction · 0.85
limitSystemMemoryFunction · 0.85
getVersionStringLongFunction · 0.85
detectPackersFunction · 0.85
unpackFileFunction · 0.85
getInfoMethod · 0.80
parseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected