Index: animator/gc.h =================================================================== --- animator/gc.h (revision 5129) +++ animator/gc.h (revision 5130) @@ -9,6 +9,15 @@ #define NUM_GC 32 gc_t gc[NUM_GC]; +static gc_t *use_gc(int idx) +{ + if ((idx < 0) || (idx >= NUM_GC)) + return NULL; + if (!gc[idx].in_use) + return NULL; + return gc+idx; +} + static void cmd_makeGC(proto_node_t *args) { int n, found = 0; @@ -35,7 +44,7 @@ static void cmd_delGC(proto_node_t *args) { - char *gs = str(child1(args)); + char *gs = astr(child1(args)); if (gs != NULL) { int idx = atoi(gs); if ((idx >= 0) && (idx < NUM_GC)) @@ -55,7 +64,7 @@ { int idx; proto_node_t *ch1 = child1(args); - char *gs = str(ch1), *cs = str(next(ch1)); + char *gs = astr(ch1), *cs = astr(next(ch1)); if ((cs == NULL) || (gs == NULL)) return; @@ -69,7 +78,7 @@ { int idx; proto_node_t *ch1 = child1(args); - char *gs = str(ch1), *cs = str(next(ch1)); + char *gs = astr(ch1), *cs = astr(next(ch1)); if ((cs == NULL) || (gs == NULL)) return; @@ -84,7 +93,7 @@ char *end; double d; proto_node_t *ch1 = child1(args); - char *gs = str(ch1), *ws = str(next(ch1)); + char *gs = astr(ch1), *ws = astr(next(ch1)); if ((ws == NULL) || (gs == NULL)) return; @@ -98,7 +107,7 @@ { int idx; proto_node_t *ch1 = child1(args); - char *gs = str(ch1), *xs = str(next(ch1)); + char *gs = astr(ch1), *xs = astr(next(ch1)); if ((xs == NULL) || (gs == NULL)) return; Index: animator/hid_anim.c =================================================================== --- animator/hid_anim.c (revision 5129) +++ animator/hid_anim.c (revision 5130) @@ -17,9 +17,12 @@ static char *current_unit = NULL; +#include "gc.h" + + static void cmd_ver(proto_node_t *args) { - char *vs = str(child1(args)); + char *vs = astr(child1(args)); if (vs != NULL) { int ver = atoi(vs); if (ver != 1) { @@ -31,7 +34,7 @@ static void cmd_unit(proto_node_t *args) { - char *us = str(child1(args)); + char *us = astr(child1(args)); if (us != NULL) { if (current_unit != NULL) free(current_unit); @@ -39,6 +42,28 @@ } } +#define BADVAL -1024 +static void cmd_line(proto_node_t *args) +{ + proto_node_t *ch1 = child1(args); + int gci = aint(ch1, -1); + double x1, y1, x2, y2; + gc_t *gc; + + x1 = adbl(next(ch1), BADVAL); + y1 = adbl(next(next(ch1)), BADVAL); + x2 = adbl(next(next(next(ch1))), BADVAL); + y2 = adbl(next(next(next(next(ch1)))), BADVAL); + if ((gci == BADVAL) || (x1 == BADVAL) || (y1 == BADVAL) || (x2 == BADVAL) || (y2 == BADVAL)) + abort(); + gc = use_gc(gci); + if (gc == NULL) + abort(); + if (strcmp(gc->name + + draw_rline(x1, y1, x2, y2, gc->width, gc->cap == 'r'); +} + static void cmd_ready(proto_node_t *args) { send_begin(&pctx, "ready"); @@ -47,7 +72,6 @@ send_end(&pctx); } -#include "gc.h" static void read_netin(void) { @@ -62,7 +86,6 @@ case PRES_PROCEED: break; case PRES_GOT_MSG: - printf("cmd\n"); switch(cmds_sphash(pctx.pcmd)) { case cmds_ver: cmd_ver(pctx.targ); break; case cmds_unit: cmd_unit(pctx.targ); break; @@ -73,6 +96,7 @@ case cmds_cap: cmd_cap(pctx.targ); break; case cmds_linwid: cmd_linwid(pctx.targ); break; case cmds_setxor: cmd_setxor(pctx.targ); break; + case cmds_line: cmd_line(pctx.targ); break; /* ignore */ case cmds_inval: