rs.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * rs.h
  3. *
  4. * Created on: Sep 14, 2017
  5. * Author: root
  6. */
  7. #ifndef LIB_RS_H_
  8. #define LIB_RS_H_
  9. #include "fec.h"
  10. // input:
  11. // code, generated by fec_new() function from fec.h
  12. // data[0....k-1 ], points to original data
  13. // size, data length
  14. //
  15. // output:
  16. // data[k....n-1], points to generated redundant data
  17. //
  18. // info:
  19. // the function will always succeed,except malloc fail.if malloc fail,it will call exit()
  20. void rs_encode(void *code, char *data[], int size);
  21. // input:
  22. // data[0.....n-1] points to original data and redundate data,in right order
  23. // if data[i] is missing ,set poniter data[i] to 0 (point it to null)
  24. //
  25. // outout:
  26. // data[0.....k-1] will point to the recovered original data.
  27. //
  28. // info:
  29. // return zero on success
  30. // if the number of no-zero pointers is less than k,the function will fail and return non-zero
  31. //
  32. // advanced info:
  33. // 1. rs_decode wont malloc memory for those zero pointers in data[0.....k-1]. instead it will re-use the memory of other non-zero pointers (and let data[0.....k-1] point to those memory).
  34. // 2. if the input data[0.....n-1] contains x non-zero pointers,after called rs_decode,there will still be exactly x non-zero poninters in data[0.....n-1],just the order may change.
  35. int rs_decode(void *code, char *data[], int size);
  36. void rs_encode2(int k, int n, char *data[], int size);
  37. int rs_decode2(int k, int n, char *data[], int size);
  38. #endif /* LIB_RS_H_ */