util.h 901 B

1234567891011121314151617181920212223242526272829
  1. #include <stddef.h>
  2. #include <stdint.h>
  3. #include <stdarg.h>
  4. #define BUFF_SZ 96
  5. /*
  6. * buffer size for one commponent
  7. * if you are using `wifi.c` it must be at least 78 bytes
  8. */
  9. #define LEN(S) (sizeof(S) / sizeof *(S))
  10. #define ERRRET(B) \
  11. do { \
  12. (B)[0] = '\0'; \
  13. return; \
  14. } while (0)
  15. #define __unused __attribute__((__unused__))
  16. #define typeof_field(S, F) __typeof__(((S *)0)->F)
  17. #define TWICE(V) V, V
  18. #define STRINGIFY_AUX(X) #X
  19. #define STR(X) STRINGIFY_AUX(X)
  20. void bprintf(char *, const char *, ...);
  21. int pscanf(const char *, const char *, ...);
  22. int esnprintf(char *, size_t, const char *, ...);
  23. void fmt_human(char *, uintmax_t, unsigned short int);