byte_arr.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef byte_arr_h
  2. #define byte_arr_h
  3. // all dependencies
  4. #include "../mem_space.h"
  5. #include "../endian.h"
  6. // functions to handle raw byte arrays
  7. // enum with byte shifting modes
  8. typedef enum
  9. {
  10. BYTESHIFT_RIGHT,
  11. BYTESHIFT_LEFT,
  12. } owl_byteshift_dir;
  13. // the second big type, owl_bytarr
  14. // it is basically a re-typedef of owl_mem_space
  15. // but with the intention to write and manage data on it
  16. typedef owl_mem_space owl_bytarr;
  17. // var_basic_types enum
  18. // the first variable types enum
  19. typedef enum
  20. {
  21. OWL_TYPE_BYTESHIFT_DIR = OWL_TYPE_ENDIAN + 1,
  22. OWL_TYPE_BYTARR,
  23. } owl_type_byte_arr_h;
  24. // bytarr functions
  25. owl_bool owl_check_bytarr_pointer(owl_byte * src, owl_umax size);
  26. owl_bool owl_check_bytarr_members(owl_byte * ptr, owl_umax size);
  27. owl_bool owl_check_bytarr_all(owl_bytarr * data, owl_umax size);
  28. owl_bytarr * owl_create_bytarr(owl_byte * data, owl_umax size);
  29. owl_umax owl_free_bytarr(owl_bytarr * arr);
  30. owl_umax owl_print_bytarr(owl_byte * src, owl_umax size);
  31. owl_bool owl_comp_bytarr(owl_byte * bytarr1, owl_byte * bytarr2);
  32. // specific functions
  33. owl_bytarr owl_copy_bytarr(owl_bytarr * src, owl_bytarr * dest);
  34. owl_umax owl_get_bytarr_mismatch_index(owl_bytarr * arr1, owl_bytarr * arr2);
  35. owl_bytarr owl_ignore_bytarr_bytes(owl_bytarr * arr, owl_bytarr * skip);
  36. owl_bytarr owl_search_bytarr(owl_bytarr * src, owl_bytarr * search);
  37. owl_umax owl_reverse_bytarr(owl_bytarr * arr);
  38. owl_bool owl_check_byteshift_dir(owl_byteshift_dir shift); // internal use
  39. owl_umax owl_bytarr_shift(owl_bytarr * arr, owl_byteshift_dir shift);
  40. owl_umax owl_bytarr_n_shift(owl_bytarr * arr, owl_byteshift_dir shift, owl_umax n);
  41. owl_umax owl_bytarr_circ_shift(owl_bytarr * arr, owl_byteshift_dir shift);
  42. owl_umax owl_bytarr_n_circ_shift(owl_bytarr * arr, owl_byteshift_dir shift, owl_umax n);
  43. owl_bytarr * owl_ins_bytarr(owl_bytarr * arr, owl_umax arr_ins_pos, owl_bytarr * insert);
  44. owl_umax owl_rm_bytarr(owl_bytarr * arr, owl_umax rm_pos, owl_umax rm_size);
  45. #include "byte_arr.c"
  46. #endif // byte_arr_h