+int gldecoder_decode(GlDecoder *dec, const char *data, unsigned len)
+{
+ unsigned pos = 0;
+ int pktlen;
+ short func;
+ int ret;
+
+ if(len<sizeof(int)+sizeof(short))
+ return -1;
+ pos += read_int(&pktlen, data);
+ if(len<pktlen)
+ return -1;
+ pos += read_short(&func, data+pos);
+ ret = decode_func(dec, func, data+pos);
+ if(ret<0)
+ return -1;
+ return pos+ret;
+}
+
+static unsigned read_char(char *v, const char *data)