basic_types.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // names of everything are prefixed to avoid library collisions
  2. #ifndef basic_types_h
  3. #define basic_types_h
  4. // all dependencies
  5. #include <stdio.h>
  6. // basic integer types
  7. // minimum and maximum
  8. typedef unsigned char owl_byte;
  9. typedef char owl_char;
  10. typedef unsigned long long int owl_umax;
  11. typedef long long int owl_smax;
  12. // useful in some cases
  13. #define NOT_NULL ((void *) NULL + 1)
  14. // this library assumes 1 byte = 8 bits
  15. #define OWL_BYTE_BITS 8
  16. // float and boolean
  17. typedef double owl_fmax;
  18. typedef owl_byte owl_bool;
  19. #define owl_false 0
  20. #define owl_true 1
  21. #define owl_bool_err 2
  22. // owl_type_basic_types_h enum
  23. // this enum will be extended each time a new type (without
  24. // including these enums) is introduced into the library
  25. typedef enum
  26. {
  27. OWL_TYPE_BYTE,
  28. OWL_TYPE_CHAR,
  29. OWL_TYPE_UMAX,
  30. OWL_TYPE_SMAX,
  31. OWL_TYPE_FMAX,
  32. OWL_TYPE_BOOL,
  33. } owl_type_basic_types_h;
  34. // mask enum as an integer type for
  35. // variable type function arguments
  36. typedef owl_type_basic_types_h owl_type;
  37. // creating and destroying is not
  38. // necessary with these simple data types
  39. // internal use function
  40. owl_bool owl_check_ptr(void * ptr, owl_umax size);
  41. // printing functions
  42. owl_umax owl_print_byte_bin(owl_byte * mem, owl_umax mem_size);
  43. owl_umax owl_print_byte_dec(owl_byte * mem, owl_umax mem_size);
  44. owl_umax owl_print_byte_hex(owl_byte * mem, owl_umax mem_size);
  45. owl_umax owl_print_char_dec(owl_byte * mem, owl_umax mem_size);
  46. owl_umax owl_print_char_char(owl_byte * mem, owl_umax mem_size);
  47. owl_umax owl_print_umax_dec(owl_byte * mem, owl_umax mem_size);
  48. owl_umax owl_print_umax_hex(owl_byte * mem, owl_umax mem_size);
  49. owl_umax owl_print_smax_dec(owl_byte * mem, owl_umax mem_size);
  50. owl_umax owl_print_fmax(owl_byte * mem, owl_umax mem_size);
  51. owl_umax owl_print_bool(owl_byte * mem, owl_umax mem_size);
  52. // compare functions
  53. owl_bool owl_comp_byte(owl_byte * byte1, owl_byte * byte2);
  54. owl_bool owl_comp_char(owl_byte * char1, owl_byte * char2);
  55. owl_bool owl_comp_umax(owl_byte * umax1, owl_byte * umax2);
  56. owl_bool owl_comp_smax(owl_byte * smax1, owl_byte * smax2);
  57. owl_bool owl_comp_fmax(owl_byte * fmax1, owl_byte * fmax2);
  58. owl_bool owl_comp_bool(owl_byte * bool1, owl_byte * bool2);
  59. #include "basic_types.c"
  60. #endif // basic_types_h