Index: animator/hid_anim.c =================================================================== --- animator/hid_anim.c (revision 4732) +++ animator/hid_anim.c (revision 4733) @@ -46,7 +46,47 @@ send_end(&pctx); } +typedef struct { + unsigned in_use:1; +} gc_t; +#define NUM_GC 32 +gc_t gc[NUM_GC]; + +static void cmd_makeGC(proto_node_t *args) +{ + int n, found = 0; + + send_begin(&pctx, "MakeGC"); + send_open(&pctx, 0); + for(n = 0; n < NUM_GC; n++) { + if (!gc[n].in_use) { + found = 1; + memset(gc+n, 0, sizeof(gc_t)); + gc[n].in_use = 1; + sendf(&pctx, "%d", n); + break; + } + } + + if (!found) + sends(&pctx, "-1"); + + send_close(&pctx); + send_end(&pctx); +} + + +static void cmd_delGC(proto_node_t *args) +{ + char *gs = str(child1(args)); + if (gs != NULL) { + int idx = atoi(gs); + if ((idx >= 0) && (idx < NUM_GC)) + gc[idx].in_use = 0; + } +} + static void read_netin(void) { P_size_t len, n; @@ -65,6 +105,14 @@ case cmds_ver: cmd_ver(pctx.targ); break; case cmds_unit: cmd_unit(pctx.targ); break; case cmds_ready: cmd_ready(pctx.targ); break; + case cmds_makeGC: cmd_makeGC(pctx.targ); break; + case cmds_delGC: cmd_delGC(pctx.targ); break; + + /* ignore */ + case cmds_inval: + case cmds_umask: + case cmds_setly: + break; } proto_node_free(pctx.targ); break;