Index: animator/hid_anim.c =================================================================== --- animator/hid_anim.c (revision 4707) +++ animator/hid_anim.c (revision 4708) @@ -9,10 +9,35 @@ static proto_ctx_t pctx; P_net_socket s_netin, s_netout; +static proto_node_t *child1(proto_node_t *lst) +{ + if (lst->is_list) + return lst->data.l.first_child; + return NULL; +} + +static int is_list(proto_node_t *nd) +{ + return (nd != NULL) && nd->is_list; +} + +static int is_str(proto_node_t *nd) +{ + return (nd != NULL) && !nd->is_list; +} + +static char *str(proto_node_t *nd) +{ + if ((nd != NULL) && !nd->is_list) + return nd->data.s.str; + return NULL; +} + static void cmd_ver(proto_node_t *args) { - if ((args->data.l.first_child != NULL) && (!args->data.l.first_child->is_list)) { - int ver = atoi(args->data.l.first_child->data.s.str); + char *vs = str(child1(args)); + if (vs != NULL) { + int ver = atoi(vs); if (ver != 1) { fprintf(stderr, "protocol version mismatc: ver=%d (expected 1)\n", ver); exit(1);