return true;
}
+void Config::set(const std::string& section, const std::string& key, const std::string& value)
+{
+ jconfig[section][key] = value;
+}
+
+void Config::set(const std::string& section, const std::string& key, bool value)
+{
+ jconfig[section][key] = value;
+}
bool foreachInArray(const std::string& section, const std::string& key, std::function<void(const std::string&)> callback) const;
bool foreachPairInObject(const std::string& section, const std::string& key, std::function<void(const std::string&, const std::string&)> callback) const;
+ void set(const std::string& section, const std::string& key, const std::string& value);
+ void set(const std::string& section, const std::string& key, bool value);
+
private:
static Config* instance;
#endif
[[ noreturn ]] void shutdown(int code);
-const std::string& getCommandLineServer(); // NCONFIG
Config* config;
Log* logger;
LogNT* loggerNT;
Control* control;
-// Temporary, will move to Config system NCONFIG
-std::string argvServer;
-
#ifdef HANDLE_VT_SWITCHING
int fdtty;
struct vt_mode old_vtmode;
#ifndef WIN32
int main(int argc, char** argv)
{
- bool daemonize = true;
- bool debugEnabled = false;
bool crashed = false;
crashed = true;
break;
case 'd':
- debugEnabled = true; // and...
+ config->set("main", "debug", true); // and...
[[fallthrough]];
case 'n':
- daemonize = false;
+ config->set("main", "daemonize", false);
break;
case 's':
- argvServer = optarg;
+ config->set("main", "argv_server", optarg);
break;
case '?':
printf("Unknown option\n");
shutdown(1);
}
+ bool debugEnabled;
+ config->getBool("main", "debug", debugEnabled);
if (!logger->init(Log::DEBUG, "dummy", debugEnabled ? 1 : 0)) // NCONFIG x2
{
printf("Could not initialise log object. Aborting.\n");
// Daemonize --------------------------------------------------------------------------------------------------
- if (daemonize) // NCONFIG
+ bool daemonize;
+ config->getBool("main", "daemonize", daemonize);
+ if (daemonize)
{
// Fork away
pid_t forkTest = fork();
return clock_gettime(CLOCK_REALTIME, tp);
}
-const std::string& getCommandLineServer() // NCONFIG
-{
- return argvServer;
-}
*/
#include "defines.h"
+#include "config.h"
#include "video.h"
#include "colour.h"
#include "control.h"
std::unique_lock<std::mutex> ul(threadMutex, std::defer_lock);
- const std::string& commandLineServer = getCommandLineServer();
+ std::string commandLineServer;
+ Config::getInstance()->getString("main", "argv_server", commandLineServer);
if (!vdpc.init())
{