packet_read_short(pkt, (short *)&func);
- if(dec)
- {
- int ret = 0;
-
- if(func&0x8000)
- ret = decode_gldfunc(dec, func, pkt);
- else
- ret = decode_func(dec, func, pkt);
- if(ret<0)
- return -1;
- }
+ int ret = 0;
+
+ if(func&0x8000)
+ ret = decode_gldfunc(dec, func, pkt);
+ else
+ ret = decode_func(dec, func, pkt);
+ if(ret<0)
+ return -1;
return len;
}
packet_read_int(pkt, (int *)&code);
if(dec->gldError)
dec->gldError(dec->user_data, code);
+ else if(dec->unhandled)
+ dec->unhandled(dec->user_data, FUNC_GLDERROR);
+}
+
+static void decode_gldBreak(GlDecoder *dec, GlPacket *pkt)
+{
+ unsigned short func;
+ packet_read_short(pkt, (short *)&func);
+ if(dec->gldBreak)
+ dec->gldBreak(dec->user_data, func);
+ else if(dec->unhandled)
+ dec->unhandled(dec->user_data, FUNC_GLDBREAK);
}
static int decode_gldfunc(GlDecoder *dec, unsigned short func, GlPacket *pkt)
switch(func)
{
case FUNC_GLDERROR: decode_gldError(dec, pkt); break;
+ case FUNC_GLDBREAK: decode_gldBreak(dec, pkt); break;
default: return -1;
}
return 0;
for p in params:
w(', p_%s', p.name)
wl(');')
+wl(' else if(dec->unhandled)')
+wl(' dec->unhandled(dec->user_data, FUNC_%s);', func.name.upper())
wl(' return 0;')
wl('}')
:static int decode_func(GlDecoder *dec, unsigned short func, GlPacket *pkt)
w(', %s', p.ctype)
wl(');')
: void (*gldError)(void *, GLenum);
+: void (*gldBreak)(void *, unsigned short);
+: void (*unhandled)(void *, unsigned short);
:} GlDecoder;
static void init_print(GlDecoder *);
static void glprint_free(void *);
static void print_gldError(void *, GLenum);
+static void print_unhandled(void *, unsigned short);
GlDecoder *glprint_new(char *buffer, unsigned bufsize)
{
init_print(dec);
dec->gldError = print_gldError;
+ dec->unhandled = print_unhandled;
return dec;
}
GlPrintData *gpd = (GlPrintData *)user_data;
snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode"));
}
+
+static void print_unhandled(void *user_data, unsigned short func)
+{
+ GlPrintData *gpd = (GlPrintData *)user_data;
+ gpd->buffer[0] = 0;
+}
int ret = glprint->decode(data, len);
if(ret>=0)
- IO::print(*out, "%s\n", glprint->get_buffer());
+ {
+ const char *buf = glprint->get_buffer();
+ if(buf[0])
+ IO::print(*out, "%s\n", buf);
+ }
}
void Tracer::cmd_trace(const string &args)