diff --git a/ChangeLog b/ChangeLog index 18cc795..2781b6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2021-11-15: +- JSON read changed, space was interpreted as '\n' - adding support for multiple drivers 2021-10-25: diff --git a/configuration.cc b/configuration.cc index 1523f23..4de2964 100644 --- a/configuration.cc +++ b/configuration.cc @@ -71,12 +71,9 @@ void Configuration::SaveConfig(std::string filename) { cb = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videofmt")); cbe = gtk_bin_get_child(GTK_BIN(cb)); jp.AddObject("video_format", (string) gtk_entry_get_text(GTK_ENTRY(cbe))); - if (videodev != NULL) { - jp.AddObject("device", videodev->GetDevice()); - } - else { - jp.AddObject("device", ""); - } + cb = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videodev")); + cbe = gtk_bin_get_child(GTK_BIN(cb)); + jp.AddObject("device", (string) gtk_entry_get_text(GTK_ENTRY(cbe))); // // save button config diff --git a/json.cc b/json.cc index a788aba..ffeff35 100644 --- a/json.cc +++ b/json.cc @@ -1,9 +1,15 @@ -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include #include "json.h" @@ -386,20 +392,21 @@ string JSONParse::ToString() { * 0 .. on Success */ int JSONParse::LoadFromFile(string filename) { - ifstream in(filename); - string tmp, input; + int fd; + struct stat fs; + char *buffer; - if (!in) return -1; + if (stat(filename.c_str(), &fs) != 0) return -1; + buffer = (char *) malloc (fs.st_size+1); + memset (buffer, 0x0, fs.st_size+1); - input = ""; - while (!in.eof()) { - if (input.length() > 0) input += ("\n" + tmp); - else input = tmp; - in >> tmp; - } - Set(input); + fd = open(filename.c_str(), O_RDONLY); + if (fd < 0) return -1; + read (fd, buffer, fs.st_size); + close (fd); - in.close(); + Set(buffer); + free (buffer); return 0; };