diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-08 12:32:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-08 12:32:49 +0200 |
commit | cfd27ef2ad8b005fd47ab41ef29b71d9e3d48201 (patch) | |
tree | 56cb8849a5df91b19b72fd4f48c79c343cd9bc5e /backend/epson.c | |
parent | ba8d09abe681600aad991f4a75e904615b7ed29f (diff) |
Imported Upstream version 1.0.25upstream/1.0.25
Diffstat (limited to 'backend/epson.c')
-rw-r--r-- | backend/epson.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/backend/epson.c b/backend/epson.c index 2cae65a..6b111f2 100644 --- a/backend/epson.c +++ b/backend/epson.c @@ -818,6 +818,12 @@ typedef struct } EpsonIdentRec, *EpsonIdent; +typedef union +{ + EpsonHdrRec hdr; + EpsonIdentRec ident; +} EpsonHdrUnionRec, *EpsonHdrUnion; + typedef struct { @@ -843,7 +849,7 @@ typedef struct * */ -static EpsonHdr command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, +static EpsonHdrUnion command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, SANE_Status * status); static SANE_Status get_identity_information (SANE_Handle handle); static SANE_Status get_identity2_information (SANE_Handle handle); @@ -1844,21 +1850,24 @@ static Epson_Device *first_dev = NULL; /* first EPSON scanner in list */ static Epson_Scanner *first_handle = NULL; -static EpsonHdr +static EpsonHdrUnion command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, SANE_Status * status) { + EpsonHdrUnion hdrunion, hdrunion_bak; EpsonHdr head; u_char *buf; int count; - if (NULL == (head = walloc (EpsonHdrRec))) + if (NULL == (hdrunion = walloc (EpsonHdrUnionRec))) { DBG (1, "out of memory (line %d)\n", __LINE__); *status = SANE_STATUS_NO_MEM; - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; } + head = &(hdrunion->hdr); + send (s, cmd, cmd_size, status); if (SANE_STATUS_GOOD != *status) @@ -1869,7 +1878,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, *status = SANE_STATUS_GOOD; send (s, cmd, cmd_size, status); if (SANE_STATUS_GOOD != *status) - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; } buf = (u_char *) head; @@ -1892,7 +1901,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, } if (SANE_STATUS_GOOD != *status) - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; DBG (4, "code %02x\n", (int) head->code); @@ -1921,25 +1930,30 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, } if (SANE_STATUS_GOOD != *status) - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; DBG (4, "status %02x\n", (int) head->status); count = head->count2 * 255 + head->count1; DBG (4, "count %d\n", count); - if (NULL == (head = realloc (head, sizeof (EpsonHdrRec) + count))) + hdrunion_bak = hdrunion; + if (NULL == (hdrunion = realloc (hdrunion, + sizeof (EpsonHdrUnionRec) + count))) { + free(hdrunion_bak); DBG (1, "out of memory (line %d)\n", __LINE__); *status = SANE_STATUS_NO_MEM; - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; } + head = &(hdrunion->hdr); + buf = head->buf; receive (s, buf, count, status); if (SANE_STATUS_GOOD != *status) - return (EpsonHdr) 0; + return (EpsonHdrUnion) 0; break; @@ -1953,7 +1967,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, break; } - return head; + return hdrunion; } @@ -2333,7 +2347,7 @@ attach (const char *dev_name, Epson_Device * *devp, int type) /* * Extended status flag request (ESC f). - * this also requests the scanner device name from the the scanner + * this also requests the scanner device name from the scanner */ /* * because we are also using the device name from this command, |