#include "color.h" #include "const.h" #include "menu.h" #include "signal.h" #include "strings.h" #include #include #include #include #include #include void PrintHelp() { std::cout << RED R"( ____ ____ /\ _`\ /\ _`\ \ \ \L\ \ __ _ __ __ \ \ \/\ \ ___ ___ ____ \ \ ,__/'__`\ /\`'__\/'__`\ \ \ \ \ \ / __`\ /'___\ /',__\ \ \ \/\ \L\.\_\ \ \//\ \L\.\_\ \ \_\ \/\ \L\ \/\ \__//\__, `\ \ \_\ \__/.\_\\ \_\\ \__/.\_\\ \____/\ \____/\ \____\/\____/ \/_/\/__/\/_/ \/_/ \/__/\/_/ \/___/ \/___/ \/____/\/___/)" << RESET "\n" << loc_strings->usage << ":\n" << NAME << " [" << loc_strings->options << "]\n" << "-h\t\t" << loc_strings->print_this_help << "\n" << "-V\t\t" << loc_strings->print_version << "\n"; exit(0); } void PrintVersion() { std::cout << NAME << " " << loc_strings->version << ": " << VERSION << "\n"; exit(0); } int main(int argc, char *argv[]) { // signal handlers std::signal(SIGTERM, safe_exit); std::signal(SIGINT, safe_exit); std::signal(SIGQUIT, safe_exit); std::signal(SIGHUP, safe_exit); // error signal handlers signal(SIGSEGV, safe_exit); // set locale { std::locale loc(""); std::regex czech_regex("czech|cz", std::regex_constants::icase | std::regex_constants::ECMAScript); if (std::regex_search(loc.name(), czech_regex)) { loc_strings = &czech_strings; } else { loc_strings = &english_strings; } } int opt; while ((opt = getopt(argc, argv, "hV")) != -1) { switch (opt) { case 'h': PrintHelp(); break; case 'V': PrintVersion(); break; default: std::cerr << RED "[ERROR]" << RESET " " << loc_strings->invalid_option << ": " << (char)optopt << "\n" << loc_strings->try_str << ": -h\n"; return EINVAL; } } menu(); return 0; }