diff options
| -rw-r--r-- | configure.ac | 18 | ||||
| -rw-r--r-- | include/endianness.h | 66 | ||||
| -rw-r--r-- | src/afc.c | 1 | ||||
| -rw-r--r-- | src/afc.h | 1 | ||||
| -rw-r--r-- | src/property_list_service.c | 1 | ||||
| -rw-r--r-- | tools/idevicesyslog.c | 1 |
6 files changed, 80 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 1bb33fa..feb5d11 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -63,17 +63,19 @@ if test "x$have_vasprintf" = "xyes"; then | |||
| 63 | AC_DEFINE(HAVE_VASPRINTF,1,[define if vasprintf is available]) | 63 | AC_DEFINE(HAVE_VASPRINTF,1,[define if vasprintf is available]) |
| 64 | fi | 64 | fi |
| 65 | 65 | ||
| 66 | AC_DEFINE(LITTLE_ENDIAN,0,[little endian]) | 66 | AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"]) |
| 67 | AC_DEFINE(BIG_ENDIAN,1,[big endian]) | 67 | if test "x$ac_cv_have_endian" = "xno"; then |
| 68 | AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], []) | 68 | AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian]) |
| 69 | if test "x$ac_cv_c_bigendian" = "xyes"; then | 69 | AC_DEFINE(__BIG_ENDIAN,4321,[big endian]) |
| 70 | AC_DEFINE(BYTE_ORDER,1,[big endian byte order]) | 70 | AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], []) |
| 71 | else | 71 | if test "x$ac_cv_c_bigendian" = "xyes"; then |
| 72 | AC_DEFINE(BYTE_ORDER,0,[little endian byte order]) | 72 | AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order]) |
| 73 | else | ||
| 74 | AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order]) | ||
| 75 | fi | ||
| 73 | fi | 76 | fi |
| 74 | 77 | ||
| 75 | 78 | ||
| 76 | |||
| 77 | AC_ARG_WITH([swig], | 79 | AC_ARG_WITH([swig], |
| 78 | [AS_HELP_STRING([--without-swig], | 80 | [AS_HELP_STRING([--without-swig], |
| 79 | [build Python bindings using swig (default is yes)])], | 81 | [build Python bindings using swig (default is yes)])], |
diff --git a/include/endianness.h b/include/endianness.h new file mode 100644 index 0000000..a34cbf4 --- /dev/null +++ b/include/endianness.h | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | #ifndef ENDIANNESS_H | ||
| 2 | #define ENDIANNESS_H | ||
| 3 | |||
| 4 | #ifndef be16toh | ||
| 5 | #if __BYTE_ORDER == __BIG_ENDIAN | ||
| 6 | #define be16toh(x) (x) | ||
| 7 | #else | ||
| 8 | #define be16toh(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) | ||
| 9 | #endif | ||
| 10 | #endif | ||
| 11 | |||
| 12 | #ifndef __bswap_32 | ||
| 13 | #define __bswap_32(x) ((((x) & 0xFF000000) >> 24) \ | ||
| 14 | | (((x) & 0x00FF0000) >> 8) \ | ||
| 15 | | (((x) & 0x0000FF00) << 8) \ | ||
| 16 | | (((x) & 0x000000FF) << 24)) | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #ifndef be32toh | ||
| 20 | #if __BYTE_ORDER == __BIG_ENDIAN | ||
| 21 | #define be32toh(x) (x) | ||
| 22 | #else | ||
| 23 | #define be32toh(x) __bswap_32(x) | ||
| 24 | #endif | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifndef htobe32 | ||
| 28 | #define htobe32 be32toh | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifndef __bswap_64 | ||
| 32 | #define __bswap_64(x) ((((x) & 0xFF00000000000000ull) >> 56) \ | ||
| 33 | | (((x) & 0x00FF000000000000ull) >> 40) \ | ||
| 34 | | (((x) & 0x0000FF0000000000ull) >> 24) \ | ||
| 35 | | (((x) & 0x000000FF00000000ull) >> 8) \ | ||
| 36 | | (((x) & 0x00000000FF000000ull) << 8) \ | ||
| 37 | | (((x) & 0x0000000000FF0000ull) << 24) \ | ||
| 38 | | (((x) & 0x000000000000FF00ull) << 40) \ | ||
| 39 | | (((x) & 0x00000000000000FFull) << 56)) | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifndef htobe64 | ||
| 43 | #if __BYTE_ORDER == __BIG_ENDIAN | ||
| 44 | #define htobe64(x) (x) | ||
| 45 | #else | ||
| 46 | #define htobe64(x) __bswap_64(x) | ||
| 47 | #endif | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #ifndef be64toh | ||
| 51 | #define be64toh htobe64 | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #ifndef le64toh | ||
| 55 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
| 56 | #define le64toh(x) (x) | ||
| 57 | #else | ||
| 58 | #define le64toh(x) __bswap_64(x) | ||
| 59 | #endif | ||
| 60 | #endif | ||
| 61 | |||
| 62 | #ifndef htole64 | ||
| 63 | #define htole64 le64toh | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #endif /* ENDIANNESS_H */ | ||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include "afc.h" | 30 | #include "afc.h" |
| 31 | #include "idevice.h" | 31 | #include "idevice.h" |
| 32 | #include "debug.h" | 32 | #include "debug.h" |
| 33 | #include "endianness.h" | ||
| 33 | 34 | ||
| 34 | /** The maximum size an AFC data packet can be */ | 35 | /** The maximum size an AFC data packet can be */ |
| 35 | static const int MAXIMUM_PACKET_SIZE = (2 << 15); | 36 | static const int MAXIMUM_PACKET_SIZE = (2 << 15); |
| @@ -27,6 +27,7 @@ | |||
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | #include "libimobiledevice/afc.h" | 29 | #include "libimobiledevice/afc.h" |
| 30 | #include "endianness.h" | ||
| 30 | 31 | ||
| 31 | #define AFC_MAGIC "CFA6LPAA" | 32 | #define AFC_MAGIC "CFA6LPAA" |
| 32 | #define AFC_MAGIC_LEN (8) | 33 | #define AFC_MAGIC_LEN (8) |
diff --git a/src/property_list_service.c b/src/property_list_service.c index 0df04c7..2a15be5 100644 --- a/src/property_list_service.c +++ b/src/property_list_service.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include "property_list_service.h" | 27 | #include "property_list_service.h" |
| 28 | #include "idevice.h" | 28 | #include "idevice.h" |
| 29 | #include "debug.h" | 29 | #include "debug.h" |
| 30 | #include "endianness.h" | ||
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | * Convert an idevice_error_t value to an property_list_service_error_t value. | 33 | * Convert an idevice_error_t value to an property_list_service_error_t value. |
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index 05e614f..d306bfc 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | #include <libimobiledevice/libimobiledevice.h> | 28 | #include <libimobiledevice/libimobiledevice.h> |
| 29 | #include <libimobiledevice/lockdown.h> | 29 | #include <libimobiledevice/lockdown.h> |
| 30 | #include <endianness.h> | ||
| 30 | 31 | ||
| 31 | static int quit_flag = 0; | 32 | static int quit_flag = 0; |
| 32 | 33 | ||
