backends: A 0-length read when doing our inital header load is
and EOF, so treat it as such and don't error out.
This commit is contained in:
parent
3cb593f36d
commit
2eb20f90f4
|
@ -367,11 +367,13 @@ static int canonselphy_early_parse(void *vctx, int data_fd)
|
|||
int printer_type, i;
|
||||
|
||||
if (!ctx)
|
||||
return 1;
|
||||
return -1;
|
||||
|
||||
/* Figure out printer this file is intended for */
|
||||
i = read(data_fd, ctx->buffer, MAX_HEADER);
|
||||
if (i < 0 || i != MAX_HEADER) {
|
||||
if (i == 0)
|
||||
return -1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
i, 0, MAX_HEADER);
|
||||
perror("ERROR: Read failed");
|
||||
|
@ -654,7 +656,7 @@ top:
|
|||
|
||||
struct dyesub_backend canonselphy_backend = {
|
||||
.name = "Canon SELPHY CP/ES",
|
||||
.version = "0.64",
|
||||
.version = "0.65",
|
||||
.multipage_capable = 1,
|
||||
.uri_prefix = "canonselphy",
|
||||
.init = canonselphy_init,
|
||||
|
|
|
@ -389,6 +389,8 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|||
/* Add in the size of this chunk */
|
||||
ctx->datalen += sizeof(struct dnpds40_cmd) + j;
|
||||
}
|
||||
if (!ctx->datalen)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -898,7 +900,7 @@ static int dnpds40_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
|||
/* Exported */
|
||||
struct dyesub_backend dnpds40_backend = {
|
||||
.name = "DNP DS40/DS80",
|
||||
.version = "0.22",
|
||||
.version = "0.23",
|
||||
.uri_prefix = "dnpds40",
|
||||
.multipage_capable = 1,
|
||||
.cmdline_usage = dnpds40_cmdline,
|
||||
|
|
|
@ -307,6 +307,8 @@ static int kodak1400_read_parse(void *vctx, int data_fd) {
|
|||
/* Read in then validate header */
|
||||
ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr));
|
||||
if (ret < 0 || ret != sizeof(ctx->hdr)) {
|
||||
if (ret == 0)
|
||||
return 1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, 0, (int)sizeof(ctx->hdr));
|
||||
perror("ERROR: Read failed");
|
||||
|
@ -566,7 +568,7 @@ top:
|
|||
|
||||
struct dyesub_backend kodak1400_backend = {
|
||||
.name = "Kodak 1400/805",
|
||||
.version = "0.27",
|
||||
.version = "0.28",
|
||||
.uri_prefix = "kodak1400",
|
||||
.multipage_capable = 1,
|
||||
.cmdline_usage = kodak1400_cmdline,
|
||||
|
|
|
@ -130,6 +130,8 @@ static int kodak605_read_parse(void *vctx, int data_fd) {
|
|||
/* Read in then validate header */
|
||||
ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr));
|
||||
if (ret < 0 || ret != sizeof(ctx->hdr)) {
|
||||
if (ret == 0)
|
||||
return 1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, 0, (int)sizeof(ctx->hdr));
|
||||
perror("ERROR: Read failed");
|
||||
|
@ -491,7 +493,7 @@ static int kodak605_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
|||
/* Exported */
|
||||
struct dyesub_backend kodak605_backend = {
|
||||
.name = "Kodak 605",
|
||||
.version = "0.14",
|
||||
.version = "0.15",
|
||||
.uri_prefix = "kodak605",
|
||||
.multipage_capable = 1,
|
||||
.cmdline_usage = kodak605_cmdline,
|
||||
|
|
|
@ -356,6 +356,8 @@ static int kodak6800_read_parse(void *vctx, int data_fd) {
|
|||
/* Read in then validate header */
|
||||
ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr));
|
||||
if (ret < 0 || ret != sizeof(ctx->hdr)) {
|
||||
if (ret == 0)
|
||||
return 1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, 0, (int)sizeof(ctx->hdr));
|
||||
perror("ERROR: Read failed");
|
||||
|
@ -604,7 +606,7 @@ skip_query:
|
|||
/* Exported */
|
||||
struct dyesub_backend kodak6800_backend = {
|
||||
.name = "Kodak 6800/6850",
|
||||
.version = "0.28",
|
||||
.version = "0.29",
|
||||
.uri_prefix = "kodak6800",
|
||||
.multipage_capable = 1,
|
||||
.cmdline_usage = kodak6800_cmdline,
|
||||
|
|
|
@ -136,6 +136,8 @@ static int mitsu70x_read_parse(void *vctx, int data_fd) {
|
|||
remain = sizeof(hdr);
|
||||
while (remain > 0) {
|
||||
i = read(data_fd, hdr + sizeof(hdr) - remain, remain);
|
||||
if (i == 0)
|
||||
return 1;
|
||||
if (i < 0)
|
||||
return i;
|
||||
remain -= i;
|
||||
|
|
|
@ -1370,6 +1370,9 @@ static void *shinkos2145_init(void)
|
|||
return NULL;
|
||||
memset(ctx, 0, sizeof(struct shinkos2145_ctx));
|
||||
|
||||
if (getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -1411,12 +1414,11 @@ static int shinkos2145_read_parse(void *vctx, int data_fd) {
|
|||
if (ctx->databuf)
|
||||
free(ctx->databuf);
|
||||
|
||||
if (getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
/* Read in then validate header */
|
||||
ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr));
|
||||
if (ret < 0 || ret != sizeof(ctx->hdr)) {
|
||||
if (ret == 0)
|
||||
return 1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, 0, (int)sizeof(ctx->hdr));
|
||||
perror("ERROR: Read failed");
|
||||
|
@ -1661,7 +1663,7 @@ static int shinkos2145_query_serno(struct libusb_device_handle *dev, uint8_t end
|
|||
|
||||
struct dyesub_backend shinkos2145_backend = {
|
||||
.name = "Shinko/Sinfonia CHC-S2145 (S2)",
|
||||
.version = "0.27",
|
||||
.version = "0.28",
|
||||
.multipage_capable = 1,
|
||||
.uri_prefix = "shinkos2145",
|
||||
.cmdline_usage = shinkos2145_cmdline,
|
||||
|
|
|
@ -103,6 +103,8 @@ static int updr150_read_parse(void *vctx, int data_fd) {
|
|||
i = read(data_fd, ctx->databuf + ctx->datalen, 4);
|
||||
if (i < 0)
|
||||
return i;
|
||||
if (i == 0)
|
||||
break;
|
||||
|
||||
ptr = (uint32_t *) ctx->databuf + ctx->datalen;
|
||||
len = le32_to_cpu(*ptr);
|
||||
|
@ -159,6 +161,9 @@ static int updr150_read_parse(void *vctx, int data_fd) {
|
|||
len -= i;
|
||||
}
|
||||
}
|
||||
if (!ctx->datalen)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -203,7 +208,7 @@ top:
|
|||
|
||||
struct dyesub_backend updr150_backend = {
|
||||
.name = "Sony UP-DR150",
|
||||
.version = "0.09",
|
||||
.version = "0.10",
|
||||
.uri_prefix = "sonyupdr150",
|
||||
.multipage_capable = 1,
|
||||
.init = updr150_init,
|
||||
|
|
Loading…
Reference in a new issue