forked from denis/a811
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
|
|
|
|
conf_12 check:
|
|
|
|
class datacheck:
|
|
type : (type?, [0,...,3], {2, 7, 19}, <x, >x)
|
|
length
|
|
funcptr
|
|
|
|
datachekc(type, typedef, length, ptr):
|
|
funcpotr = ptr
|
|
|
|
check(*data):
|
|
actdata = funcpotr(data)
|
|
switch(type):
|
|
case a: return actdata > typedef[0]
|
|
case b: return (actdata > typedef[0]) && (actdata < typedef[1])
|
|
|
|
|
|
map [pos] -> datacheck(0, [0,7], 16, (data) => return (data << 4) | (data >> 4))
|
|
map [pos+16] -> datacheck(0, [0,7], 16, (data) => return (data << 4) | (data >> 4))
|
|
|
|
map [pos] -> datacheck(1, [0], 8*16, (data) => uint8_t x = 0; for (int i = 0; i < 16; ++i) x | data[i]; return !x;)
|
|
|
|
|
|
func a(pos):
|
|
return map[pos]
|
|
|
|
pos not per byte but bit
|
|
|
|
|
|
a(pos).check
|
|
|
|
|
|
confch3ck():
|
|
isok = True
|
|
extralen = 0
|
|
chk;
|
|
for(int i = 0; i < (int)sizeof(conf_12) * 8;):
|
|
chk = map[i]
|
|
res = chk.check(&(((unsigned char *)conf_12)[i]))
|
|
i+=chk.length;
|
|
|
|
if not res:
|
|
isok = False
|
|
break;
|
|
if chk.type == set;
|
|
print("is fucked at byte x / bit y with length chk.length it is not part of set [chk.typedef]") |