int val;
yylval.a_value.data = d = (unsigned char *)malloc( 32 );
yylval.a_value.datalen = 0;
- while (p) {
- strncpy(x, p, 2); x[2] = '\0';
- sscanf(x, "%02x", &val);
- *d++ = val;
- ++yylval.a_value.datalen;
+ while (*p) {
+ strncpy(x, p, 2); x[2] = '\0';
+ sscanf(x, "%02x", &val);
+ *d++ = val;
+ ++yylval.a_value.datalen;
+ p += 2;
+ if (*p == '@')
+ break;
+ p++;
}
return L_BYTEARRAY; }
static void set_switch_bytearray(struct bytearray val)
{
- Xswitch->s.type = SND_SW_TYPE_LAST + 1;
+ Xswitch->s.type = SND_SW_TYPE_USER;
if (val.datalen > 32)
yyerror("Byte array too large for switch.");
csw->s.value.data32[0] = usw->s.value.data32[0];
}
break;
+ case SND_SW_TYPE_USER_READ_ONLY:
+ break;
+ case SND_SW_TYPE_USER:
+ if (usw->s.type != SND_SW_TYPE_USER) {
+ error("A wrong type %i for the switch %s. The type user is expected. Skipping...", usw->s.type, sw_id(usw->s.name, cardno, devno, id));
+ return 1;
+ }
+ if (memcmp(csw->s.value.data8, usw->s.value.data8, 32)) {
+ csw->change = 1;
+ memcpy(csw->s.value.data8, usw->s.value.data8, 32);
+ }
+ break;
default:
error("The switch type %i is not known.", csw->s.type);
}
s = "list";
sprintf(v, "%u", sw->value.item_number);
break;
+ case SND_SW_TYPE_USER_READ_ONLY:
+ return;
default:
s = "unknown";
}
fprintf(out, v);
if (sw->type < 0 || sw->type > SND_SW_TYPE_LIST_ITEM) {
/* TODO: some well known types should be verbose */
- fprintf(out, "rawdata(");
+ fprintf(out, "rawdata(@");
for (idx = 0; idx < 31; idx++) {
- fprintf(out, "@%02x:", sw->value.data8[idx]);
+ fprintf(out, "%02x:", sw->value.data8[idx]);
}
- fprintf(out, "%02x@)\n", sw->value.data8[31]);
+ fprintf(out, "%02x@)", sw->value.data8[31]);
}
}
__end: