Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=9633f73c7c2fc448cc4c29690c051b8aceab08d4
commit 9633f73c7c2fc448cc4c29690c051b8aceab08d4 Author: James Buren <[email protected]> Date: Mon Apr 28 08:54:58 2014 -0500 add dlopen stuff to main diff --git a/src-new/main.cpp b/src-new/main.cpp index e2c68ed..14353b2 100644 --- a/src-new/main.cpp +++ b/src-new/main.cpp @@ -1,8 +1,41 @@ -#include "ui.hpp" +#include <iostream> +#include <dlfcn.h> +#include "main.hpp" +static void *ui_handle = NULL; +static ui_new_t ui_new = NULL; +static ui_delete_t ui_delete = NULL; UI *ui = NULL; +static bool ui_load(const std::string &filename) +{ + if( + (ui_handle = dlopen(filename.c_str(), RTLD_NOW)) == NULL || + (ui_new = (ui_new_t) dlsym(ui_handle, "ui_new")) == NULL || + (ui_delete = (ui_delete_t) dlsym(ui_handle, "ui_delete")) == NULL + ) + { + std::cerr << "Failed to open UI: " << dlerror() << std::endl; + return false; + } + + return true; +} + int main(int argc, char **argv) { + if(!ui_load("./ui_newt.so")) + { + return 1; + } + + ui = ui_new(); + + ui->main(argc, argv); + + ui_delete(ui); + + dlclose(ui_handle); + return 0; } diff --git a/src-new/main.hpp b/src-new/main.hpp new file mode 100644 index 0000000..d055c1b --- /dev/null +++ b/src-new/main.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "ui.hpp" + +typedef UI *(*ui_new_t) (); + +typedef void (*ui_delete_t) (UI *); + +extern UI *ui; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
