-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathrs.c
38 lines (30 loc) · 987 Bytes
/
rs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <assert.h>
#include "mln_rs.h"
#define COL 10
#define ROW 10
#define K 2
int main(int argc, char *argv[])
{
int i, j;
mln_rs_result_t *res, *dres;
uint8_t origin[COL * ROW] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
uint8_t *err[ROW + K] = {0};
assert((res = mln_rs_encode(origin, COL, ROW, K)) != NULL);
printf("res->num=%ld, res->len=%ld\n", res->num, res->len);
for (i = 0; i < mln_rs_result_get_num(res); ++i) {
err[i] = mln_rs_result_get_data_by_index(res, i);
}
err[0] = NULL;
err[1] = NULL;
assert((dres = mln_rs_decode(err,COL, ROW, K)) != NULL);
for (i = 0; i < mln_rs_result_get_num(dres); ++i) {
for (j = 0; j < COL; ++j) {
printf("%c", mln_rs_result_get_data_by_index(dres, i)[j]);
}
printf("\n");
}
mln_rs_result_free(res);
mln_rs_result_free(dres);
return 0;
}