basic_types.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_char 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_NONE,
  28. OWL_TYPE_BYTE,
  29. OWL_TYPE_CHAR,
  30. OWL_TYPE_UMAX,
  31. OWL_TYPE_SMAX,
  32. OWL_TYPE_FMAX,
  33. OWL_TYPE_BOOL,
  34. } owl_type_basic_types_h;
  35. // mask enum as an integer type for
  36. // variable type function arguments
  37. typedef owl_type_basic_types_h owl_type;
  38. // creating and destroying is not
  39. // necessary with these simple data types
  40. // internal use function
  41. owl_bool owl_check_ptr(void * ptr, owl_umax size);
  42. // printing functions
  43. owl_umax owl_print_byte_bin(owl_byte * mem, owl_umax mem_size);
  44. owl_umax owl_print_byte_dec(owl_byte * mem, owl_umax mem_size);
  45. owl_umax owl_print_byte_hex(owl_byte * mem, owl_umax mem_size);
  46. owl_umax owl_print_char_dec(owl_byte * mem, owl_umax mem_size);
  47. owl_umax owl_print_char_char(owl_byte * mem, owl_umax mem_size);
  48. owl_umax owl_print_umax_dec(owl_byte * mem, owl_umax mem_size);
  49. owl_umax owl_print_umax_hex(owl_byte * mem, owl_umax mem_size);
  50. owl_umax owl_print_smax_dec(owl_byte * mem, owl_umax mem_size);
  51. owl_umax owl_print_fmax(owl_byte * mem, owl_umax mem_size);
  52. owl_umax owl_print_bool(owl_byte * mem, owl_umax mem_size);
  53. // compare functions and some defs
  54. #define owl_comp_less -1
  55. #define owl_comp_equal 0
  56. #define owl_comp_greater 1
  57. #define owl_comp_err 2
  58. owl_char owl_comp_byte(owl_byte * byte1, owl_byte * byte2);
  59. owl_char owl_comp_char(owl_byte * char1, owl_byte * char2);
  60. owl_char owl_comp_umax(owl_byte * umax1, owl_byte * umax2);
  61. owl_char owl_comp_smax(owl_byte * smax1, owl_byte * smax2);
  62. owl_char owl_comp_fmax(owl_byte * fmax1, owl_byte * fmax2);
  63. owl_char owl_comp_bool(owl_byte * bool1, owl_byte * bool2);
  64. #include "basic_types.c"
  65. #endif // basic_types_h