PyObject_HEAD
/* expose these */
- int kk;
- int mm;
+ unsigned short kk;
+ unsigned short mm;
/* internal */
fec_t* fec_matrix;
py_raise_fec_error("Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", self->mm);
return -1;
}
- if (self->mm > 255) {
- py_raise_fec_error("Precondition violation: second argument is required to be less than or equal to 255, but it was %d", self->mm);
+ if (inm > 256) {
+ py_raise_fec_error("Precondition violation: second argument is required to be less than or equal to 256, but it was %d", self->mm);
return -1;
}
if (ink > inm) {
py_raise_fec_error("Precondition violation: first argument is required to be less than or equal to the second argument, but they were %d and %d respectively", ink, inm);
return -1;
}
- self->kk = (unsigned char)ink;
- self->mm = (unsigned char)inm;
+ self->kk = (unsigned short)ink;
+ self->mm = (unsigned short)inm;
self->fec_matrix = fec_new(self->kk, self->mm);
return 0;
PyObject_HEAD
/* expose these */
- int kk;
- int mm;
+ unsigned short kk;
+ unsigned short mm;
/* internal */
fec_t* fec_matrix;
py_raise_fec_error("Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", self->mm);
return -1;
}
- if (self->mm > 255) {
- py_raise_fec_error("Precondition violation: second argument is required to be less than or equal to 255, but it was %d", self->mm);
+ if (inm > 256) {
+ py_raise_fec_error("Precondition violation: second argument is required to be less than or equal to 256, but it was %d", self->mm);
return -1;
}
if (ink > inm) {
py_raise_fec_error("Precondition violation: first argument is required to be less than or equal to the second argument, but they were %d and %d respectively", ink, inm);
return -1;
}
- self->kk = (unsigned char)ink;
- self->mm = (unsigned char)inm;
+ self->kk = (unsigned short)ink;
+ self->mm = (unsigned short)inm;
self->fec_matrix = fec_new(self->kk, self->mm);
return 0;
* p = coefficients of the matrix (p_i)
* q = values of the polynomial (known)
*/
-int
-_invert_vdm (gf * src, int k) {
- int i, j, row, col;
+void
+_invert_vdm (gf* src, unsigned k) {
+ unsigned i, j, row, col;
gf *b, *c, *p;
gf t, xx;
if (k == 1) /* degenerate case, matrix must be p^0 = 1 */
- return 0;
+ return;
/*
* c holds the coefficient of P(x) = Prod (x - p_i), i=0..k-1
* b holds the coefficient for the matrix inversion
free (c);
free (b);
free (p);
- return 0;
+ return;
}
static int fec_initialized = 0;
import fec
+from base64 import b32encode
+def ab(x): # debuggery
+ if len(x) >= 3:
+ return "%s:%s" % (len(x), b32encode(x[-3:]),)
+ elif len(x) == 2:
+ return "%s:%s" % (len(x), b32encode(x[-2:]),)
+ elif len(x) == 1:
+ return "%s:%s" % (len(x), b32encode(x[-1:]),)
+ elif len(x) == 0:
+ return "%s:%s" % (len(x), "--empty--",)
+
def _h(k, m, ss):
# sys.stdout.write("k: %s, m: %s, len(ss): %r, len(ss[0]): %r" % (k, m, len(ss), len(ss[0]),)) ; sys.stdout.flush()
encer = fec.Encoder(k, m)
decoded = decer.decode(blocks, nums)
# sys.stdout.write("decoded.\n") ; sys.stdout.flush()
assert len(decoded) == len(ss), (len(decoded), len(ss),)
- assert tuple([str(s) for s in decoded]) == tuple([str(s) for s in ss]), (tuple([str(s) for s in decoded]), tuple([str(s) for s in ss]),)
+ assert tuple([str(s) for s in decoded]) == tuple([str(s) for s in ss]), (tuple([ab(str(s)) for s in decoded]), tuple([ab(str(s)) for s in ss]),)
def randstr(n):
return ''.join(map(chr, map(random.randrange, [0]*n, [256]*n)))