+
+void dispatch(LastReports *lasts, const char *message_prefix,
+ ProcessReport *const report_processors[MAXREPORTS],
+ const uint8_t *msg, int l) {
+ ProcessReport *pr= report_processors[msg[0]];
+ Last *last= &lasts->lasts[msg[0]];
+ if (!pr) {
+ if (!last->len)
+ fprintf(stderr,"%s:%s unexpected report 0x%02x\n",
+ progname, message_prefix, msg[0]);
+ last->len= l;
+ return;
+ }
+ if (last->len < l) {
+ last->msg= mrealloc(last->msg, l);
+ memset(last->msg + last->len, 0, l - last->len);
+ last->len= l;
+ }
+ pr(msg, l, last->msg);
+ memcpy(last->msg, msg, l);
+}
+