src/glinject/glinject.c
/*
 * This method is called at library initialisation.
 */
This method is called at library initialisation.
This method is called at library initialisation .
void glinject_construct() {
	pthread_mutex_lock(&glinject_mutex);
	glinject_init();
	L = luaL_newstate();
	if (!L) {
		fprintf(stderr, "Lua initialization failed.");
		exit(EXIT_FAILURE);
	}
	luaL_openlibs(L);
	const char* path = getenv("GLXOSD_SCRIPTS_ROOT");
	if (path == NULL || strlen(path) == 0) {
		fprintf(stderr, "GLXOSD_SCRIPTS_ROOT is not set!");
		exit(EXIT_FAILURE);
	}
	lua_pushstring(L, path);
	lua_setfield(L, LUA_GLOBALSINDEX, "glxosdPackageRoot");
	char* bootstrap_suffix = "/glxosd/Bootstrap.lua";
	char* bootstrap_path = glinject_join_path(path, bootstrap_suffix);
	char* main_suffix = "/glxosd/Main.lua";
	char* main_path = glinject_join_path(path, main_suffix);
	glinject_run_file(bootstrap_path);
	glinject_link_glx_and_xlib();
	glinject_run_file(main_path);
	free(bootstrap_path);
	free(main_path);
	pthread_mutex_unlock(&glinject_mutex);
}
void glinject_construct ( ) { pthread_mutex_lock ( & glinject_mutex ) ; glinject_init ( ) ; L = luaL_newstate ( ) ; if ( ! L ) { fprintf ( stderr , " " ) ; exit ( EXIT_FAILURE ) ; } luaL_openlibs ( L ) ; const char * path = getenv ( " " ) ; if ( path == NULL || strlen ( path ) == 0 ) { fprintf ( stderr , " " ) ; exit ( EXIT_FAILURE ) ; } lua_pushstring ( L , path ) ; lua_setfield ( L , LUA_GLOBALSINDEX , " " ) ; char * bootstrap_suffix = " " ; char * bootstrap_path = glinject_join_path ( path , bootstrap_suffix ) ; char * main_suffix = " " ; char * main_path = glinject_join_path ( path , main_suffix ) ; glinject_run_file ( bootstrap_path ) ; glinject_link_glx_and_xlib ( ) ; glinject_run_file ( main_path ) ; free ( bootstrap_path ) ; free ( main_path ) ; pthread_mutex_unlock ( & glinject_mutex ) ; }
This method is called at library initialisation.
This method is called at library initialisation .
// Link core methods. // Create Lua state // Open Lua libraries // Find out the root of the GLXOSD script directory // Run the bootstrap script. // Link GLX and X11 because we now know the paths to libGL // and libX11 thanks to the bootstrap script. // Finally, run the main script. It can now use GLX and X11.