diff options
author | sin <sin@2f30.org> | 2015-11-17 16:52:18 +0000 |
---|---|---|
committer | sin <sin@2f30.org> | 2015-11-17 16:59:19 +0000 |
commit | e706c3f9a51e5b2e2b05b70fca71f870b7fc35f9 (patch) | |
tree | 9338b2dfa3a571403f5c7f49882bc284bce3b92d /png2ff.c | |
parent | ed7b08b8d22e0f039f93f70dd23280289edb27e5 (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 'png2ff.c')
-rw-r--r-- | png2ff.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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> @@ -43,9 +43,9 @@ main(int argc, char *argv[]) /* write header */ fprintf(stdout, "farbfeld"); - tmp32 = htobe32(width); + tmp32 = htonl(width); fwrite(&tmp32, sizeof(uint32_t), 1, stdout); - tmp32 = htobe32(height); + tmp32 = htonl(height); fwrite(&tmp32, sizeof(uint32_t), 1, stdout); /* write data */ @@ -53,7 +53,7 @@ main(int argc, char *argv[]) for (r = 0; r < height; ++r) { for (i = 0; i < png_row_len; i++) { /* ((2^16-1) / 255) == 257 */ - tmp16 = htobe16(257 * png_row_p[r][i]); + tmp16 = htons(257 * png_row_p[r][i]); fwrite(&tmp16, sizeof(uint16_t), 1, stdout); } } |