summaryrefslogtreecommitdiff
path: root/ff2png.c
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2015-11-17 16:52:18 +0000
committersin <sin@2f30.org>2015-11-17 16:59:19 +0000
commite706c3f9a51e5b2e2b05b70fca71f870b7fc35f9 (patch)
tree9338b2dfa3a571403f5c7f49882bc284bce3b92d /ff2png.c
parented7b08b8d22e0f039f93f70dd23280289edb27e5 (diff)
Avoid using the non-portable endian.h conversion functions
Use the arpa/inet.h conversion functions which are standardized in POSIX.
Diffstat (limited to 'ff2png.c')
-rw-r--r--ff2png.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ff2png.c b/ff2png.c
index be6912e..8cded89 100644
--- a/ff2png.c
+++ b/ff2png.c
@@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
-#define _BSD_SOURCE
-#include <endian.h>
+#include <arpa/inet.h>
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -34,8 +34,8 @@ main(int argc, char *argv[])
fprintf(stderr, "invalid magic in header\n");
return 1;
}
- width = be32toh(*((uint32_t *)(hdr + 8)));
- height = be32toh(*((uint32_t *)(hdr + 12)));
+ width = ntohl(*((uint32_t *)(hdr + 8)));
+ height = ntohl(*((uint32_t *)(hdr + 12)));
/* load png */
png_struct_p = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -65,7 +65,7 @@ main(int argc, char *argv[])
return 1;
}
/* ((2^16-1) / 255) == 257 */
- png_row[j] = (uint8_t)(be16toh(tmp16) / 257);
+ png_row[j] = (uint8_t)(ntohs(tmp16) / 257);
}
png_write_row(png_struct_p, png_row);
}