From d7d60b7191020836d9d9e193383bf9c4bf8605b5 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 17 Jan 2014 22:54:25 -0500 Subject: [PATCH] backends: Enhance to add multipage capabilities. DNP ds40/ds80 and Sony UP-DR150/200 backends do NOT support this yet. Next up is to commit the core. --- backend_canonselphy.c | 24 +++++++++++++++++++++--- backend_kodak1400.c | 9 ++++++++- backend_kodak605.c | 6 +++++- backend_kodak6800.c | 6 +++++- backend_shinkos2145.c | 6 +++++- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/backend_canonselphy.c b/backend_canonselphy.c index e200eb2..80f6cc6 100644 --- a/backend_canonselphy.c +++ b/backend_canonselphy.c @@ -321,6 +321,8 @@ static void *canonselphy_init(void) /* Static initialization */ setup_paper_codes(); + ctx->buffer = malloc(MAX_HEADER); + return ctx; } @@ -352,6 +354,7 @@ static void canonselphy_teardown(void *vctx) { free(ctx->plane_c); if (ctx->footer) free(ctx->footer); + if (ctx->buffer) free(ctx->buffer); @@ -363,7 +366,8 @@ static int canonselphy_early_parse(void *vctx, int data_fd) struct canonselphy_ctx *ctx = vctx; int printer_type, i; - ctx->buffer = malloc(MAX_HEADER); + if (!ctx) + return 1; /* Figure out printer this file is intended for */ i = read(data_fd, ctx->buffer, MAX_HEADER); @@ -374,7 +378,6 @@ static int canonselphy_early_parse(void *vctx, int data_fd) return i; } - printer_type = parse_printjob(ctx->buffer, &ctx->bw_mode, &ctx->plane_len); for (i = 0; selphy_printers[i].type != -1; i++) { if (selphy_printers[i].type == printer_type) { @@ -403,6 +406,20 @@ static int canonselphy_read_parse(void *vctx, int data_fd) struct canonselphy_ctx *ctx = vctx; int i, remain; + if (!ctx) + return 1; + + if (ctx->header) + free(ctx->header); + if (ctx->plane_y) + free(ctx->plane_y); + if (ctx->plane_m) + free(ctx->plane_m); + if (ctx->plane_c) + free(ctx->plane_c); + if (ctx->footer) + free(ctx->footer); + /* Set up buffers */ ctx->plane_y = malloc(ctx->plane_len); ctx->plane_m = malloc(ctx->plane_len); @@ -637,7 +654,8 @@ top: struct dyesub_backend canonselphy_backend = { .name = "Canon SELPHY CP/ES", - .version = "0.63", + .version = "0.64", + .multipage_capable = 1, .uri_prefix = "canonselphy", .init = canonselphy_init, .attach = canonselphy_attach, diff --git a/backend_kodak1400.c b/backend_kodak1400.c index 84bdedf..6997a0c 100644 --- a/backend_kodak1400.c +++ b/backend_kodak1400.c @@ -297,6 +297,12 @@ static int kodak1400_read_parse(void *vctx, int data_fd) { if (!ctx) return 1; + if (ctx->plane_r) + free(ctx->plane_r); + if (ctx->plane_g) + free(ctx->plane_g); + if (ctx->plane_b) + free(ctx->plane_b); /* Read in then validate header */ ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr)); @@ -560,8 +566,9 @@ top: struct dyesub_backend kodak1400_backend = { .name = "Kodak 1400/805", - .version = "0.26", + .version = "0.27", .uri_prefix = "kodak1400", + .multipage_capable = 1, .cmdline_usage = kodak1400_cmdline, .cmdline_arg = kodak1400_cmdline_arg, .init = kodak1400_init, diff --git a/backend_kodak605.c b/backend_kodak605.c index b50fe1e..42db6b7 100644 --- a/backend_kodak605.c +++ b/backend_kodak605.c @@ -124,6 +124,9 @@ static int kodak605_read_parse(void *vctx, int data_fd) { if (!ctx) return 1; + if (ctx->databuf) + free(ctx->databuf); + /* Read in then validate header */ ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr)); if (ret < 0 || ret != sizeof(ctx->hdr)) { @@ -488,8 +491,9 @@ static int kodak605_cmdline_arg(void *vctx, int run, char *arg1, char *arg2) /* Exported */ struct dyesub_backend kodak605_backend = { .name = "Kodak 605", - .version = "0.13", + .version = "0.14", .uri_prefix = "kodak605", + .multipage_capable = 1, .cmdline_usage = kodak605_cmdline, .cmdline_arg = kodak605_cmdline_arg, .init = kodak605_init, diff --git a/backend_kodak6800.c b/backend_kodak6800.c index def1ea0..f6f2758 100644 --- a/backend_kodak6800.c +++ b/backend_kodak6800.c @@ -350,6 +350,9 @@ static int kodak6800_read_parse(void *vctx, int data_fd) { if (!ctx) return 1; + if (ctx->databuf) + free(ctx->databuf); + /* Read in then validate header */ ret = read(data_fd, &ctx->hdr, sizeof(ctx->hdr)); if (ret < 0 || ret != sizeof(ctx->hdr)) { @@ -601,8 +604,9 @@ skip_query: /* Exported */ struct dyesub_backend kodak6800_backend = { .name = "Kodak 6800/6850", - .version = "0.27", + .version = "0.28", .uri_prefix = "kodak6800", + .multipage_capable = 1, .cmdline_usage = kodak6800_cmdline, .cmdline_arg = kodak6800_cmdline_arg, .init = kodak6800_init, diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c index 9afb589..6e3ce74 100644 --- a/backend_shinkos2145.c +++ b/backend_shinkos2145.c @@ -1408,6 +1408,9 @@ static int shinkos2145_read_parse(void *vctx, int data_fd) { if (!ctx) return 1; + if (ctx->databuf) + free(ctx->databuf); + if (getenv("FAST_RETURN")) ctx->fast_return = 1; @@ -1658,7 +1661,8 @@ 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.26", + .version = "0.27", + .multipage_capable = 1, .uri_prefix = "shinkos2145", .cmdline_usage = shinkos2145_cmdline, .cmdline_arg = shinkos2145_cmdline_arg,