// SPDX-FileCopyrightText: 2022 Enrique M.G. // // SPDX-License-Identifier: LGPL-2.1-or-later #include "libllxgvagate.hpp" #include #include #include #include #include #include #include #include #include using namespace lliurex; using namespace edupals; using namespace edupals::variant; using namespace std; int debug_level = LOG_ERR; std::chrono::time_point timestamp; void log(int priority,string message) { std::chrono::time_point now = std::chrono::steady_clock::now(); double secs = std::chrono::duration_cast(now - timestamp).count()/1000.0; if (priority > debug_level ) { return; } if (priority <= LOG_ERR) { clog<1) { cmd = result.args[1]; } if (cmd == "create") { if (getuid() != 0) { cerr<<"Root user expected"<2) { user = result.args[2]; } else { cout<<"user:"; cin>>user; } cout<<"password:"; // disable input echo termios oldt; tcgetattr(STDIN_FILENO, &oldt); termios newt = oldt; newt.c_lflag &= ~ECHO; tcsetattr(STDIN_FILENO, TCSANOW, &newt); cin>>password; // restore tcsetattr(STDIN_FILENO, TCSANOW, &oldt); clog<0) ? EX_OK : EX_DATAERR; } if (cmd == "cache") { string cmd2; if (result.args.size()>2) { cmd2 = result.args[2]; } else { help(); return EX_USAGE; } if (cmd2 == "list") { Gate gate(log); gate.open(); Variant cache = gate.get_cache(); for (int n=0;n