util.h 450 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #ifndef MIN
  3. #define MIN(a,b) ((a)<(b)?(a):(b))
  4. #endif
  5. #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
  6. #include <stdint.h>
  7. /*
  8. 64 bit crc from ArduPilot
  9. */
  10. uint64_t crc_crc64(const uint32_t *data, uint16_t num_words);
  11. /*
  12. decode a base64 string
  13. */
  14. int32_t base64_decode(const char *s, uint8_t *out, const uint32_t max_len);
  15. /*
  16. encode as base64, returning allocated string
  17. */
  18. char *base64_encode(const uint8_t *buf, int len);