31 lines
993 B
C++
31 lines
993 B
C++
#include "my_application.h"
|
|
#include <string.h>
|
|
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
for (int i = 1; i < argc; ++i) {
|
|
if (strcmp(argv[i], "--tui") == 0 || strcmp(argv[i], "-t") == 0) {
|
|
// Загрузка функции diagd_run_tui из bundled librust_lib_diagd.so
|
|
void* handle = dlopen("lib/librust_lib_diagd.so", RTLD_LAZY);
|
|
if (!handle) {
|
|
handle = dlopen("librust_lib_diagd.so", RTLD_LAZY);
|
|
}
|
|
if (handle) {
|
|
typedef int (*run_tui_fn)();
|
|
run_tui_fn run_tui = (run_tui_fn)dlsym(handle, "diagd_run_tui");
|
|
if (run_tui) {
|
|
int ret = run_tui();
|
|
dlclose(handle);
|
|
return ret;
|
|
}
|
|
}
|
|
fprintf(stderr, "Не удалось загрузить модуль TUI из librust_lib_diagd.so: %s\n", dlerror());
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
g_autoptr(MyApplication) app = my_application_new();
|
|
return g_application_run(G_APPLICATION(app), argc, argv);
|
|
}
|