direwolf.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* direwolf.h - Common stuff used many places. */
  2. // TODO: include this file first before anything else in each .c file.
  3. #ifndef DIREWOLF_H
  4. #define DIREWOLF_H
  5. #include <stdio.h>
  6. #define SLEEP_SEC(n) sleep(n)
  7. #define SLEEP_MS(n) usleep((n)*1000)
  8. #ifndef G_UNKNOWN
  9. #include "latlong.h"
  10. #endif
  11. /* Conversion Macros */
  12. #define DW_METERS_TO_FEET(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 3.2808399)
  13. #define DW_FEET_TO_METERS(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.3048)
  14. #define DW_KM_TO_MILES(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.621371192)
  15. #define DW_KNOTS_TO_MPH(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 1.15077945)
  16. #define DW_KNOTS_TO_METERS_PER_SEC(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.51444444444)
  17. #define DW_MPH_TO_KNOTS(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.868976)
  18. #define DW_MPH_TO_METERS_PER_SEC(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.44704)
  19. #define DW_MBAR_TO_INHG(x) ((x) == G_UNKNOWN ? G_UNKNOWN : (x) * 0.0295333727)
  20. #define SOCK_SEND(s,data,size) send(s,data,size, MSG_NOSIGNAL)
  21. #define SOCK_RECV(s,data,size) recv(s,data,size,0)
  22. /* Platform differences for string functions. */
  23. // Don't recall why for everyone.
  24. char *strcasestr(const char *S, const char *FIND);
  25. // These prevent /usr/include/gps.h from providing its own definition.
  26. #define HAVE_STRLCAT 1
  27. #define HAVE_STRLCPY 1
  28. #define DEBUG_STRL 0
  29. #if DEBUG_STRL
  30. #define strlcpy(dst,src,siz) strlcpy_debug(dst,src,siz,__FILE__,__func__,__LINE__)
  31. #define strlcat(dst,src,siz) strlcat_debug(dst,src,siz,__FILE__,__func__,__LINE__)
  32. size_t strlcpy_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz, const char *file, const char *func, int line);
  33. size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz, const char *file, const char *func, int line);
  34. #else
  35. #define strlcpy(dst,src,siz) strlcpy_debug(dst,src,siz)
  36. #define strlcat(dst,src,siz) strlcat_debug(dst,src,siz)
  37. size_t strlcpy_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz);
  38. size_t strlcat_debug(char *__restrict__ dst, const char *__restrict__ src, size_t siz);
  39. #endif /* DEBUG_STRL */
  40. #endif /* ifndef DIREWOLF_H */