X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgldecoder.c;h=999acccc9cec140d141f5db97f878af136282cdf;hb=fab9ed5163a8f4ef5314bc67e48d1690d1126649;hp=e11d13c46d51ef0a064415eecf7933b7cb0e6b10;hpb=c6b2f7585d51164dc32f4dd2a05855913e464c58;p=gldbg.git diff --git a/source/gldecoder.c b/source/gldecoder.c index e11d13c..999accc 100644 --- a/source/gldecoder.c +++ b/source/gldecoder.c @@ -1,7 +1,7 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ @@ -9,10 +9,10 @@ Distributed under the GPL #include #include "functions.h" #include "gldecoder.h" +#include "packet.h" -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, GlPacket *); +static int decode_gldfunc(GlDecoder *, unsigned short, GlPacket *); GlDecoder *gldecoder_new(void *user_data, void (*destroy)(void *)) { @@ -35,95 +35,46 @@ void gldecoder_delete(GlDecoder *dec) int gldecoder_decode(GlDecoder *dec, const char *data, unsigned len) { - unsigned pos = 0; - int pktlen; - short func; - int ret; + GlPacket *pkt; + unsigned short func; - if(lengldError) + dec->gldError(dec->user_data, code); } -static unsigned read_string(const unsigned char **v, const char *data) +static int decode_gldfunc(GlDecoder *dec, unsigned short func, GlPacket *pkt) { - return read_data((const void **)v, data); + switch(func) + { + case FUNC_GLDERROR: decode_gldError(dec, pkt); break; + default: return -1; + } + return 0; } - -#include "gldecoder.funcs"