init
This commit is contained in:
46
launcher/launcher.cpp
Normal file
46
launcher/launcher.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
#include "dlfcn.h"
|
||||
#include "libgen.h"
|
||||
|
||||
#define MAX_PATH 4096
|
||||
|
||||
static char szLauncherPath[MAX_PATH];
|
||||
static char szEnginePath[MAX_PATH];
|
||||
static char szTier0Path[MAX_PATH];
|
||||
|
||||
void *pEngineLib;
|
||||
void *pTier0Lib;
|
||||
typedef void (*EngineMainFn)(int argc, char** argv);
|
||||
EngineMainFn pEngineMain;
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
readlink("/proc/self/exe",szLauncherPath, MAX_PATH);
|
||||
dirname(szLauncherPath);
|
||||
|
||||
snprintf(szEnginePath, MAX_PATH, "%s/libengine.so", szLauncherPath);
|
||||
snprintf(szTier0Path, MAX_PATH, "%s/libtier0.so", szLauncherPath);
|
||||
|
||||
pTier0Lib = dlopen(szTier0Path, RTLD_NOW | RTLD_GLOBAL);
|
||||
if ( !pTier0Lib ) {
|
||||
printf("Failed to open libtier0.so\n");
|
||||
printf("\t%s\n",dlerror());
|
||||
}
|
||||
pEngineLib = dlopen(szEnginePath, RTLD_NOW | RTLD_GLOBAL);
|
||||
if ( !pEngineLib ) {
|
||||
printf("Failed to open libengine.so\n");
|
||||
printf("\t%s\n",dlerror());
|
||||
}
|
||||
pEngineMain = (EngineMainFn)dlsym(pEngineLib, "FunnyMain");
|
||||
if ( !pEngineMain ) {
|
||||
printf("Symbol not found: FunnyMain\n");
|
||||
}
|
||||
|
||||
// chdir to right directory
|
||||
dirname(szLauncherPath);
|
||||
chdir(szLauncherPath);
|
||||
|
||||
pEngineMain(argc, argv);
|
||||
dlclose(pEngineLib);
|
||||
};
|
||||
Reference in New Issue
Block a user