unsigned inverted:1, updated:1;
} SegState;
+static FILE *debug;
static SegState *state;
static SegmovfeatState *states_head;
static Display *d;
static void si_off(ParseState *ps) {
}
+static void si_train(ParseState *ps) {
+
+}
+
typedef struct MuxEventInfo MuxEventInfo;
typedef void MuxEventFn(ParseState *ps);
{ "?movpos", "_*_feat", si_movpos },
{ "?picio out on", "", si_on },
{ "?picio out off", "", si_off },
+ { "?train", "_*_has", si_train },
{ "=connected", "", si_connected },
{ "=permission", "", 0 },
static void sock_input_line(ParseState *ps) {
const MuxEventInfo *mxi;
const char *got, *expected;
- int l;
+ int l, c;
if (!ps->remain || !ps->remain[0])
return;
+ ps->thisword= ps->remain;
for (mxi=muxeventinfos; mxi->prefix; mxi++) {
got= ps->remain;
expected= mxi->prefix;
- if (*expected=='?') { got++; expected++; }
- l= strlen(expected);
+ l= ps->lthisword= strlen(expected);
+ if (*expected=='?') { got++; expected++; l--; }
if (memcmp(got, expected, l)) continue;
if (!got[l] || got[l]==' ') goto found;
}
return;
found:
if (!mxi->fn) return;
- ps->thisword= ps->remain;
- ps->lthisword= l;
- ps->remain += l;
-fprintf(stderr,"calling <%s> with <%.*s|%s>\n",
- mxi->prefix, ps->lthisword,ps->thisword, ps->remain);
+ ps->remain= got + l;
+ if ((c= *ps->remain)) { assert(c==' '); ps->remain++; }
+ if (debug) fprintf(debug,"calling <%s> with <%.*s|%s>\n",
+ mxi->prefix, ps->lthisword,ps->thisword, ps->remain);
mxi->fn(ps);
}
printf("%d\n%d\n", ui_plan_data.xsz, ui_plan_data.ysz);
if (ferror(stdout) || fflush(stdout)) diee("print stdout");
exit(0);
+ } else if (!strcmp(arg,"--debug")) {
+ debug= stderr;
} else if (arg[0]=='@') {
char *node, *comma;
const char *service;