This part of the program runs at startup, and parses input of from the user, and then starts up the desired program mode.
| 312 | // and parses input of from the user, and then |
| 313 | // starts up the desired program mode. |
| 314 | int main(int argc, char *argv[]) { |
| 315 | |
| 316 | bool log_trace = false; |
| 317 | for (int i = 1; i < argc; ++i) { |
| 318 | if (argv[i] && strcasecmp(argv[i], "--log_trace") == 0) { |
| 319 | log_trace = true; |
| 320 | for (int j = i; j < argc - 1; ++j) { |
| 321 | argv[j] = argv[j + 1]; |
| 322 | } |
| 323 | --argc; |
| 324 | --i; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | #if defined(RNS_MEM_LOG) |
| 329 | RNS::loglevel(RNS::LOG_MEM); |
| 330 | #else |
| 331 | if (log_trace) { |
| 332 | RNS::loglevel(RNS::LOG_TRACE); |
| 333 | } |
| 334 | else { |
| 335 | RNS::loglevel(RNS::LOG_NOTICE); |
| 336 | } |
| 337 | #endif |
| 338 | |
| 339 | // Register the signal handler for SIGINT |
| 340 | signal(SIGINT, cleanup_handler); |
| 341 | |
| 342 | // Setup non-blocking input |
| 343 | int flags = fcntl(STDIN_FILENO, F_GETFL, 0); |
| 344 | fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); |
| 345 | |
| 346 | try { |
| 347 | |
| 348 | // Initialize and register filesystem |
| 349 | microStore::FileSystem filesystem{microStore::Adapters::UniversalFileSystem()}; |
| 350 | filesystem.init(); |
| 351 | RNS::Utilities::OS::register_filesystem(filesystem); |
| 352 | |
| 353 | // Initialize and register interface |
| 354 | udp_interface = new UDPInterface(); |
| 355 | udp_interface.mode(RNS::Type::Interface::MODE_GATEWAY); |
| 356 | RNS::Transport::register_interface(udp_interface); |
| 357 | udp_interface.start(); |
| 358 | |
| 359 | // Initialize and start Reticulum |
| 360 | reticulum.transport_enabled(false); |
| 361 | reticulum.probe_destination_enabled(true); |
| 362 | reticulum.start(); |
| 363 | } |
| 364 | catch (const std::exception& e) { |
| 365 | ERRORF("!!! Exception in Reticulum startup: %s", e.what()); |
| 366 | } |
| 367 | |
| 368 | if (argc <= 1) { |
| 369 | printf("\nMust specify a destination for client mode, or \"-s\" or \"--server\" for server mode.\n\n"); |
| 370 | return -1; |
| 371 | } |
nothing calls this directly
no test coverage detected