X-Git-Url: http://git.tdb.fi/?p=gldbg.git;a=blobdiff_plain;f=source%2Fglwrap.c;h=10bfc77fcb12cd56f21149444593f8df57de8d52;hp=f801a20aae2b71b3c4561215da9f250035df2240;hb=fab9ed5163a8f4ef5314bc67e48d1690d1126649;hpb=0205804a10fe3beb01ed0135fde052d13b045570 diff --git a/source/glwrap.c b/source/glwrap.c index f801a20..10bfc77 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -11,19 +11,16 @@ Distributed under the GPL #include #include #include -#include -#define INTERNAL __attribute__((visibility("internal"))) - -INTERNAL inline const char *get_lib_names(void) +static const char *get_lib_names(void) { const char *env = getenv("GLWRAP_LIBS"); if(env) return env; - return "libGL.so"; + return "libGL.so.1"; } -INTERNAL inline void *glsym(const char *name) +void *glsym(const char *name) { static void **gl_libs = NULL; unsigned i; @@ -77,117 +74,7 @@ INTERNAL inline void *glsym(const char *name) return NULL; } -INTERNAL char *buffer = 0; -INTERNAL char *write_pos; -INTERNAL struct iovec *iovecs = 0; -INTERNAL struct iovec *cur_vec; -INTERNAL unsigned length; - -INTERNAL inline void next_vec(void) -{ - if(write_pos!=cur_vec->iov_base) - { - cur_vec->iov_len = write_pos-(char *)cur_vec->iov_base; - length += cur_vec->iov_len; - ++cur_vec; - cur_vec->iov_base = write_pos; - } -} - -INTERNAL inline void write_bytes(const char *ptr, unsigned size) -{ - unsigned i; - for(i=0; iiov_base = (void *)data; - cur_vec->iov_len = size; - length += size; - ++cur_vec; - cur_vec->iov_base = write_pos; - } - else - write_int(0); -} - -INTERNAL inline void write_string(const char *s) -{ - write_data(s, strlen(s)+1); -} - -INTERNAL inline void write_string_array(const char **sa, unsigned size) -{ - unsigned i; - size /= sizeof(const char *); - write_int(size); - for(i=0; iiov_base = write_pos; - length = 0; - - write_int(0); - write_short(func); -} - -INTERNAL inline int get_out_fd(void) +int get_out_fd(void) { static int fd = -1; @@ -201,7 +88,7 @@ INTERNAL inline int get_out_fd(void) var = getenv("GLWRAP_FILE"); if(var) { - fd = open(var, O_WRONLY|O_CREAT, 0644); + fd = open(var, O_WRONLY|O_CREAT|O_TRUNC, 0644); if(fd==-1) { fprintf(stderr, "Couldn't open dumpfile %s for output: %s", var, strerror(errno)); @@ -215,26 +102,3 @@ INTERNAL inline int get_out_fd(void) return fd; } - -INTERNAL inline void send_partial_packet(void) -{ - next_vec(); - write_pos = buffer; - write_int(length|0x80000000); - writev(get_out_fd(), iovecs, cur_vec-iovecs); - - write_pos = buffer; - cur_vec = iovecs; - cur_vec->iov_base = write_pos; - length = 0; - - write_int(0); -} - -INTERNAL inline void send_packet(void) -{ - next_vec(); - write_pos = buffer; - write_int(length); - writev(get_out_fd(), iovecs, cur_vec-iovecs); -}