DFhackCExport int SDL_Init(uint32_t flags) { // reroute stderr freopen("stderr.log", "w", stderr); // we don't reroute stdout until we figure out if this should be done at all // See: Console-linux.cpp // find real functions _SDL_Init = (int (*)( uint32_t )) dlsym(RTLD_NEXT, "SDL_Init"); _SDL_Quit = (void (*)( void )) dlsym(RTLD_NEXT, "SDL_Quit"); _SDL_PollEvent = (int (*)(SDL::Event*))dlsym(RTLD_NEXT,"SDL_PollEvent"); // check if we got them if(_SDL_Init && _SDL_Quit && _SDL_PollEvent) { fprintf(stderr,"dfhack: hooking successful\n"); } else { // bail, this would be a disaster otherwise fprintf(stderr,"dfhack: something went horribly wrong\n"); exit(1); } /* DFHack::Core & c = DFHack::Core::getInstance(); c.Init(); */ int ret = _SDL_Init(flags); return ret; }
DFhackCExport int SDL_Init(uint32_t flags) { if(!inited) FirstCall(); return _SDL_Init(flags); }