3 This file is part of gldbg
4 Copyright © 2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
10 #include "functions.h"
11 #include "gldecoder.h"
13 GlDecoder *gldecoder_new(void *user_data, void (*destroy)(void *))
17 dec = (GlDecoder *)malloc(sizeof(GlDecoder));
18 memset(dec, 0, sizeof(GlDecoder));
19 dec->user_data = user_data;
20 dec->destroy = destroy;
25 void gldecoder_delete(GlDecoder *dec)
28 dec->destroy(dec->user_data);
32 unsigned read_char(char *v, const char *data, unsigned len)
38 unsigned read_short(short *v, const char *data, unsigned len)
44 unsigned read_int(int *v, const char *data, unsigned len)
50 unsigned read_long(long *v, const char *data, unsigned len)
56 unsigned read_ulong(unsigned long *v, const char *data, unsigned len)
58 *v = *(unsigned long *)data;
59 return sizeof(unsigned long);
62 unsigned read_longlong(long long *v, const char *data, unsigned len)
64 *v = *(long long *)data;
65 return sizeof(long long);
68 unsigned read_float(float *v, const char *data, unsigned len)
74 unsigned read_double(double *v, const char *data, unsigned len)
77 return sizeof(double);
80 unsigned read_pointer(void **v, const char *data, unsigned len)
83 return sizeof(void *);
86 unsigned read_data(const void **v, const char *data, unsigned len)
90 pos += read_int(&vlen, data, len);
95 unsigned read_string(const unsigned char **v, const char *data, unsigned len)
97 return read_data((const void **)v, data, len);
100 #include "gldecoder.funcs"