BASIC_TYPES.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // C source file with the BASIC_TYPES.h function implementations
  2. // print_byte_dec()
  3. umax print_byte_dec(byte * src, umax size)
  4. {
  5. // check params
  6. if (src == NULL || size < BYTE_SIZE)
  7. return 0;
  8. printf("%u", *src);
  9. return BYTE_SIZE;
  10. }
  11. // print_byte_hex()
  12. umax print_byte_hex(byte * src, umax size)
  13. {
  14. // check params
  15. if (src == NULL || size < BYTE_SIZE)
  16. return 0;
  17. printf("%02X", *src);
  18. return BYTE_SIZE;
  19. }
  20. // print_char()
  21. umax print_char(byte * src, umax size)
  22. {
  23. // check params
  24. if (src == NULL || size < CHAR_SIZE)
  25. return 0;
  26. printf("%c", (char) *src);
  27. return CHAR_SIZE;
  28. }
  29. // print_umax_dec()
  30. umax print_umax_dec(byte * src, umax size)
  31. {
  32. // check params
  33. if (src == NULL || size < UMAX_SIZE)
  34. return 0;
  35. printf("%llu", *((umax *) src));
  36. return UMAX_SIZE;
  37. }
  38. // print_umax_hex()
  39. umax print_umax_hex(byte * src, umax size)
  40. {
  41. // check params
  42. if (src == NULL || size < UMAX_SIZE)
  43. return 0;
  44. printf("%llX", *((umax *) src));
  45. return UMAX_SIZE;
  46. }
  47. // print_smax()
  48. umax print_smax(byte * src, umax size)
  49. {
  50. // check params
  51. if (src == NULL || size < SMAX_SIZE)
  52. return 0;
  53. printf("%lld", *((smax *) src));
  54. return SMAX_SIZE;
  55. }
  56. // print_fmax()
  57. umax print_fmax(byte * src, umax size)
  58. {
  59. // check params
  60. if (src == NULL || size < FMAX_SIZE)
  61. return 0;
  62. printf("%lf", *((fmax *) src));
  63. return FMAX_SIZE;
  64. }
  65. // print_bool()
  66. umax print_bool(byte * src, umax size)
  67. {
  68. // check params
  69. if (src == NULL || size < BOOL_SIZE)
  70. return 0;
  71. printf("%d", *((bool *) src));
  72. return BOOL_SIZE;
  73. }