1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #ifndef BYTE_ARRAY_HEADER
- #define BYTE_ARRAY_HEADER
- // this header needs
- #include "../BASIC_TYPES.h"
- #include "../MEM_SPACE.h"
- #include "../ENDIAN.h"
- // functions to handle raw byte arrays
- // enum with byte shifting modes
- typedef enum
- {
- BYTESHIFT_RIGHT,
- BYTESHIFT_LEFT,
- } byteshift_type;
- bool check_byte_array(byte * arr, umax size);
- umax print_byte_array(byte * arr, umax size);
- bool check_byteshift_type(byteshift_type shift);
- byte * cp_mem_bytes(byte * src, umax length, byte * dest);
- umax comp_bytes_until_mismatch(byte * arr1, byte * arr2, umax size);
- bool comp_bytes(byte * arr1, byte * arr2, umax size);
- byte * ignore_bytes(byte * src, umax src_size, byte * skip, umax skip_size);
- byte * search_byte_pattern(byte * src, umax ssize, byte * pattern, umax psize);
- bool byte_shift(byte * arr, umax size, byteshift_type shift);
- bool byte_n_shift(byte * arr, umax size, byteshift_type shift, umax n);
- bool byte_circ_shift(byte * arr, umax size, byteshift_type shift);
- bool byte_n_circ_shift(byte * arr, umax size, byteshift_type shift, umax n);
- // the second big type, bytarr
- // it is basically a re-typedef of mem_space
- // but with the intention to write and manage data on it
- typedef mem_space bytarr;
- #define BYTARR_SIZE sizeof(bytarr)
- // var_basic_types enum
- // the first variable types enum
- typedef enum
- {
- VAR_BYTESHIFT_TYPE = VAR_ENDIAN_TYPE + 1,
- VAR_BYTARR,
- } var_byte_arr;
- // bytarr functions
- bytarr * create_bytarr(byte * arr, umax size);
- bool check_bytarr(bytarr * arr);
- umax free_bytarr(bytarr * arr);
- umax print_bytarr(byte * src, umax size);
- // copy of the above functions but to be used with the new structure
- bytarr cp_bytarr(bytarr * src, bytarr * dest);
- umax comp_bytarrs_until_mismatch(bytarr * arr1, bytarr * arr2);
- bool comp_bytarrs(bytarr * arr1, bytarr * arr2);
- bytarr ignore_bytarr_bytes(bytarr * arr, bytarr * skip);
- bytarr search_bytarr(bytarr * src, bytarr * search);
- bool bytarr_shift(bytarr * arr, byteshift_type shift);
- bool bytarr_n_shift(bytarr * arr, byteshift_type shift, umax n);
- bool bytarr_circ_shift(bytarr * arr, byteshift_type shift);
- bool bytarr_n_circ_shift(bytarr * arr, byteshift_type shift, umax n);
- bytarr * ins_bytarr(bytarr * arr, umax arr_ins_pos, bytarr * bytes);
- umax rm_bytarr(bytarr * arr, umax rm_pos, umax rm_size);
- #include "BYTE_ARR.c"
- #endif // BYTE_ARRAY_HEADER
|