diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-08 12:33:06 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-08 12:33:06 +0200 |
commit | 24feb9f37f302c006ba51502da817325200e74d0 (patch) | |
tree | d4451782449e5fcbae9cbe3778c51a8c6cb3c36d /backend/epson.c | |
parent | 76b69ebb381d40458339c9940135740797cbd2d4 (diff) | |
parent | cfd27ef2ad8b005fd47ab41ef29b71d9e3d48201 (diff) |
Merge tag 'upstream/1.0.25'
Upstream version 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, |