diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-08-26 09:04:11 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-08-26 09:04:11 +0200 |
commit | 3621a04cf020cba747ba75136aec7a575890cceb (patch) | |
tree | 1cb7e00db51863beb015f349ac8990db9261a873 /src/xendian.h | |
parent | 94ea8d1ac53b3aada2c616f84b8e4686ae51054c (diff) |
Huge overhall; fix code; remove external deps
Diffstat (limited to 'src/xendian.h')
-rw-r--r-- | src/xendian.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/xendian.h b/src/xendian.h new file mode 100644 index 0000000..b43661f --- /dev/null +++ b/src/xendian.h @@ -0,0 +1,21 @@ +#ifndef TOTP_XENDIAN_H +#define TOTP_XENDIAN_H + +/* This header grabs the htobe64() and co. functions in a more + cross-platform manner. In general you will find these functions in + <sys/endian.h>, however Linux and OpenBSD include them in <endian.h>. + To make things even better this header doesn’t exist on MacOS so we + need to define wrapper macros for the htonXX() functions from + <arpa/inet.h>. */ + +#if defined(__OpenBSD__) || defined(__linux__) +# include <endian.h> +#elif defined(__APPLE__) +# include <arpa/inet.h> +# define htobe32(x) htonl(x) +# define htobe64(x) htonll(x) +#else +# include <sys/endian.h> +#endif + +#endif /* !TOTP_XENDIAN_H */ |