lha_endian.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright (c) 2011, 2012, Simon Howard
  3. Permission to use, copy, modify, and/or distribute this software
  4. for any purpose with or without fee is hereby granted, provided
  5. that the above copyright notice and this permission notice appear
  6. in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  8. WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  9. WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  10. AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  11. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef LHASA_LHA_ENDIAN_H
  17. #define LHASA_LHA_ENDIAN_H
  18. #include <inttypes.h>
  19. /**
  20. * Decode a 16-bit little-endian unsigned integer.
  21. *
  22. * @param buf Pointer to buffer containing value to decode.
  23. * @return Decoded value.
  24. */
  25. uint16_t lha_decode_uint16(uint8_t *buf);
  26. /**
  27. * Decode a 32-bit little-endian unsigned integer.
  28. *
  29. * @param buf Pointer to buffer containing value to decode.
  30. * @return Decoded value.
  31. */
  32. uint32_t lha_decode_uint32(uint8_t *buf);
  33. /**
  34. * Decode a 64-bit little-endian unsigned integer.
  35. *
  36. * @param buf Pointer to buffer containing value to decode.
  37. * @return Decoded value.
  38. */
  39. uint64_t lha_decode_uint64(uint8_t *buf);
  40. /**
  41. * Decode a 16-bit big-endian unsigned integer.
  42. *
  43. * @param buf Pointer to buffer containing value to decode.
  44. * @return Decoded value.
  45. */
  46. uint16_t lha_decode_be_uint16(uint8_t *buf);
  47. /**
  48. * Decode a 32-bit big-endian unsigned integer.
  49. *
  50. * @param buf Pointer to buffer containing value to decode.
  51. * @return Decoded value.
  52. */
  53. uint32_t lha_decode_be_uint32(uint8_t *buf);
  54. #endif /* #ifndef LHASA_LHA_ENDIAN_H */