From 0ddc2fdfbeb0c2974411939551854fb400764305 Mon Sep 17 00:00:00 2001 From: reg_ Date: Thu, 5 Apr 2012 10:07:54 +0000 Subject: [PATCH] Started kiwix launcher for static releases --- src/launcher/kiwix-launcher.c | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/launcher/kiwix-launcher.c diff --git a/src/launcher/kiwix-launcher.c b/src/launcher/kiwix-launcher.c new file mode 100644 index 0000000..d9b8406 --- /dev/null +++ b/src/launcher/kiwix-launcher.c @@ -0,0 +1,52 @@ + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +const char * sep = "\\"; +#else +const char * sep = "/"; +#endif + +int main() { + + char cwd[1024]; + + if (getcwd(cwd, sizeof(cwd)) != NULL) { + char env[1024] = "LD_LIBRARY_PATH="; + strcat(env, cwd); + putenv(env); + // fprintf(stdout, "Current working dir: %s\n", cwd); + } else + perror("Unable to find current directory"); + + char *path = (char *)malloc(2048); + strcpy(path, cwd); + strcat(path, sep); + strcat(path, "xulrunner"); + strcat(path, sep); + strcat(path, "xulrunner"); + // fprintf(stdout, "path: %s\n", path); + + char *inifile = (char *)malloc(2048); + strcpy(inifile, cwd); + strcat(inifile, sep); + strcat(inifile, "application.ini"); + // fprintf(stdout, "ini: %s\n", inifile); + + + if (file_exist(path) == 0) { + perror("Unable to find xulrunner binary"); + } + + return execl(path, "xulrunner", inifile, NULL); +} + +int file_exist (char *filename) { + struct stat buffer; + return (stat (filename, &buffer) == 0); +}