3 This file is part of gldbg
4 Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
15 static const char *get_lib_names(void)
17 const char *env = getenv("GLWRAP_LIBS");
23 void *glsym(const char *name)
25 static void **gl_libs = NULL;
30 char *lib_names = strdup(get_lib_names());
34 for(i=0; lib_names[i]; ++i)
38 gl_libs = (void **)malloc((n_libs+1)*sizeof(void *));
43 if(lib_names[j]==':' || lib_names[j]==0)
45 int at_end = (lib_names[j]==0);
48 gl_libs[n_libs] = dlopen(lib_names+i, RTLD_NOW);
51 fprintf(stderr, "Could not open %s: %s\n", lib_names+i, dlerror());
67 for(i=0; gl_libs[i]; ++i)
69 void *sym = dlsym(gl_libs[i], name);
83 const char *var = getenv("GLWRAP_FD");
85 fd = strtol(var, NULL, 0);
88 var = getenv("GLWRAP_FILE");
91 fd = open(var, O_WRONLY|O_CREAT|O_TRUNC, 0644);
94 fprintf(stderr, "Couldn't open dumpfile %s for output: %s", var, strerror(errno));