Index: animator/Makefile =================================================================== --- animator/Makefile (revision 4731) +++ animator/Makefile (revision 4732) @@ -3,7 +3,7 @@ CFLAGS = -Wall -g -I$(TRUNK) LDLIBS = $P/libporty_net_async.a $P/libporty_net.a $(TRUNK)/src_plugins/hid_remote/base64.o SPHASH = $(TRUNK)/src_3rd/sphash/sphash -OBJS= hid_anim.o cmds_hash.o +OBJS= hid_anim.o cmds_hash.o compat.o hid_anim: $(OBJS) $(CC) $(OBJS) $(LDLIBS) -o $@ Index: animator/compat.c =================================================================== --- animator/compat.c (nonexistent) +++ animator/compat.c (revision 4732) @@ -0,0 +1,8 @@ +char *pcb_strdup(const char *s) +{ + int l = strlen(s); + char *o; + o = malloc(l+1); + memcpy(o, s, l+1); + return o; +} Index: animator/compat.h =================================================================== --- animator/compat.h (nonexistent) +++ animator/compat.h (revision 4732) @@ -0,0 +1,2 @@ +char *pcb_strdup(const char *s); + Index: animator/hid_anim.c =================================================================== --- animator/hid_anim.c (revision 4731) +++ animator/hid_anim.c (revision 4732) @@ -9,10 +9,13 @@ #include "src_plugins/hid_remote/proto_lowsend.h" #include "src_plugins/hid_remote/proto_lowparse.h" #include "cmds_hash.h" +#include "compat.h" static proto_ctx_t pctx; P_net_socket s_netin, s_netout; +static char *current_unit = NULL; + static void cmd_ver(proto_node_t *args) { char *vs = str(child1(args)); @@ -25,6 +28,16 @@ } } +static void cmd_unit(proto_node_t *args) +{ + char *us = str(child1(args)); + if (us != NULL) { + if (current_unit != NULL) + free(current_unit); + current_unit = pcb_strdup(us); + } +} + static void cmd_ready(proto_node_t *args) { send_begin(&pctx, "ready"); @@ -50,6 +63,7 @@ printf("cmd\n"); switch(cmds_sphash(pctx.pcmd)) { case cmds_ver: cmd_ver(pctx.targ); break; + case cmds_unit: cmd_unit(pctx.targ); break; case cmds_ready: cmd_ready(pctx.targ); break; } proto_node_free(pctx.targ);