static unsigned read_short(short *, const char *);
static unsigned read_int(int *, const char *);
-static int decode_func(GlDecoder *, short, const char *);
+static int decode_func(GlDecoder *, unsigned short, const char *);
+static int decode_gldfunc(GlDecoder *, unsigned short, const char *);
GlDecoder *gldecoder_new(void *user_data, void (*destroy)(void *))
{
{
unsigned pos = 0;
int pktlen;
- short func;
+ unsigned short func;
int ret;
if(len<sizeof(int)+sizeof(short))
pos += read_short(&func, data+pos);
if(dec)
{
- ret = decode_func(dec, func, data+pos);
+ if(func&0x8000)
+ ret = decode_gldfunc(dec, func, data+pos);
+ else
+ ret = decode_func(dec, func, data+pos);
if(ret<0)
return -1;
}
}
#include "gldecoder.funcs"
+
+static int decode_gldError(GlDecoder *dec, const char *data)
+{
+ unsigned pos = 0;
+ GLenum code;
+ pos += read_int(&code, data);
+ if(dec->gldError)
+ dec->gldError(dec->user_data, code);
+ return pos;
+}
+
+static int decode_gldfunc(GlDecoder *dec, unsigned short func, const char *data)
+{
+ switch(func)
+ {
+ case FUNC_GLDERROR: return decode_gldError(dec, data);
+ default: return -1;
+ }
+}