xscreenshot

suckless screen capture tool
git clone git://git.2f30.org/xscreenshot.git
Log | Files | Refs | README | LICENSE

commit b0165f794fa7eee32c3c29933f60d05e122e9c4d
parent 99787cb985153f007e66f2fd53e2279ee6f7333c
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue Nov 17 21:20:54 +0100

Avoid using the non-portable endian.h conversion functions

Use the arpa/inet.h conversion functions which are standardized
in POSIX.

Idea copied over from farbfeld (thanks stateless!).

Diffstat:
config.mk | 2+-
xscreenshot.c | 9++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/config.mk b/config.mk @@ -14,7 +14,7 @@ INCS = -I${X11INC} LIBS = -L${X11LIB} -lX11 # flags -CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" +CPPFLAGS = -DVERSION=\"${VERSION}\" # debug CFLAGS = -O0 -g -std=c99 -Wall -pedantic ${INCS} ${CPPFLAGS} diff --git a/xscreenshot.c b/xscreenshot.c @@ -1,7 +1,6 @@ /* see LICENSE / README for more info */ #include <arpa/inet.h> -#include <endian.h> #include <errno.h> #include <stdio.h> #include <stdint.h> @@ -77,10 +76,10 @@ main(int argc, char *argv[]) for (h = 0; h < (uint32_t)img->height; h++) { for (w = 0; w < (uint32_t)img->width; w++) { tmp = XGetPixel(img, w, h); - rgba[0] = htobe16((tmp & img->red_mask) >> 8); - rgba[1] = htobe16(tmp & img->green_mask); - rgba[2] = htobe16((tmp & img->blue_mask) << 8); - rgba[3] = htobe16(65535); + rgba[0] = htons((tmp & img->red_mask) >> 8); + rgba[1] = htons(tmp & img->green_mask); + rgba[2] = htons((tmp & img->blue_mask) << 8); + rgba[3] = htons(65535); if (fwrite(&rgba, 4 * sizeof(uint16_t), 1, stdout) != 1) die("fwrite() failed");