From 25d8b69b628d05dfc9fc60338a103ebfafd96192 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 22 Feb 2014 16:53:51 +0000 Subject: [PATCH] replace netowrk converts by ours git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14773 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/digita/commands.c | 8 ++++---- camlibs/digita/digita.c | 12 ++++++------ camlibs/digita/digita.h | 1 + camlibs/digita/serial.c | 14 +++++++------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/camlibs/digita/commands.c b/camlibs/digita/commands.c index 7668073be..6a88a05f1 100644 --- a/camlibs/digita/commands.c +++ b/camlibs/digita/commands.c @@ -80,11 +80,11 @@ int digita_get_storage_status(CameraPrivateLibrary *dev, int *taken, } if (taken) - *taken = ntohl(ss.takencount); + *taken = be32toh(ss.takencount); if (available) - *available = ntohl(ss.availablecount); + *available = be32toh(ss.availablecount); if (rawcount) - *rawcount = ntohl(ss.rawcount); + *rawcount = be32toh(ss.rawcount); return 0; } @@ -187,7 +187,7 @@ int digita_get_file_data(CameraPrivateLibrary *dev, int thumbnail, return gfdr->cmd.result; } - memcpy(buffer, tbuf + sizeof(*gfdr), ntohl(gfdr->tag.length) + (thumbnail ? 16 : 0)); + memcpy(buffer, tbuf + sizeof(*gfdr), be32toh(gfdr->tag.length) + (thumbnail ? 16 : 0)); memcpy(tag, &gfdr->tag, sizeof(*tag)); free(tbuf); diff --git a/camlibs/digita/digita.c b/camlibs/digita/digita.c index 53d87ec28..096a7cff3 100644 --- a/camlibs/digita/digita.c +++ b/camlibs/digita/digita.c @@ -246,7 +246,7 @@ static unsigned char *digita_file_get(Camera *camera, const char *folder, return NULL; } - buflen = ntohl(tag.filesize); + buflen = be32toh(tag.filesize); if (thumbnail) buflen += 16; @@ -256,8 +256,8 @@ static unsigned char *digita_file_get(Camera *camera, const char *folder, return NULL; } - len = ntohl(tag.filesize); - pos = ntohl(tag.length); + len = be32toh(tag.filesize); + pos = be32toh(tag.length); id = gp_context_progress_start (context, len, _("Getting file...")); while (pos < len) { gp_context_progress_update (context, id, pos); @@ -273,7 +273,7 @@ static unsigned char *digita_file_get(Camera *camera, const char *folder, free (data); return NULL; } - pos += ntohl(tag.length); + pos += be32toh(tag.length); } gp_context_progress_stop (context, id); @@ -351,9 +351,9 @@ static int get_file_func(CameraFilesystem *fs, const char *folder, char *ppm; memcpy((void *)&height, data + 4, 4); - height = ntohl(height); + height = be32toh(height); memcpy((void *)&width, data + 8, 4); - width = ntohl(width); + width = be32toh(width); GP_DEBUG( "picture size %dx%d", width, height); GP_DEBUG( "data size %d", buflen - 16); diff --git a/camlibs/digita/digita.h b/camlibs/digita/digita.h index 77d17c629..542663d07 100644 --- a/camlibs/digita/digita.h +++ b/camlibs/digita/digita.h @@ -25,6 +25,7 @@ #include #include +#include #define DIGITA_GET_PRODUCT_INFO 0x01 #define DIGITA_GET_IMAGE_SPECS 0x02 diff --git a/camlibs/digita/serial.c b/camlibs/digita/serial.c index 5ff9c41d9..4f1bcb93a 100644 --- a/camlibs/digita/serial.c +++ b/camlibs/digita/serial.c @@ -115,7 +115,7 @@ static int poll_and_wait(gp_port *dev, int length, int bob, int eob) return -1; if (gp_port_read(dev, (void *)&s, sizeof(s)) < 0) return -1; - poll_reply = ntohs(s); + poll_reply = be16toh(s); } while (poll_reply & POLL_NAK); return 0; @@ -156,7 +156,7 @@ static int poll_and_reply(gp_port *dev, int *length, int *eob, int nak) if (gp_port_read(dev, (void *)&s, sizeof(s)) < 0) return -1; - poll = ntohs(s); + poll = be16toh(s); if (length) *length = poll & POLL_LENGTH_MASK; if (eob) @@ -275,9 +275,9 @@ int digita_serial_open(CameraPrivateLibrary *dev, Camera *camera) } memcpy((void *)&s, &buffer[2], 2); - GP_DEBUG("Vendor: 0x%04x", ntohs(s)); + GP_DEBUG("Vendor: 0x%04x", be16toh(s)); memcpy((void *)&s, &buffer[4], 2); - GP_DEBUG("Product: 0x%04x", ntohs(s)); + GP_DEBUG("Product: 0x%04x", be16toh(s)); /* * Send the beacon acknowledgement @@ -316,11 +316,11 @@ int digita_serial_open(CameraPrivateLibrary *dev, Camera *camera) } memcpy((void *)&s, &buffer[6], sizeof(s)); - dev->deviceframesize = ntohs(s); + dev->deviceframesize = be16toh(s); memcpy((void *)&l, &buffer[2], sizeof(l)); - GP_DEBUG("negotiated %d", ntohl(l)); - settings.serial.speed = ntohl(l); + GP_DEBUG("negotiated %d", be32toh(l)); + settings.serial.speed = be32toh(l); usleep(100000); /* Wait before */