summaryrefslogtreecommitdiffstats
path: root/backend_mitsu9550.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-01-13 15:44:29 -0500
committerSolomon Peachy <pizza@shaftnet.org>2019-01-13 15:44:29 -0500
commit096a383b3f6a0d96aefac5f8e7f8f2b7b001608e (patch)
treeecde602c18ab91120f3cc823924ad43ea7bd26d0 /backend_mitsu9550.c
parent5d42041f552a759c16c538285ffa2a5270447315 (diff)
downloadselphy_print-096a383b3f6a0d96aefac5f8e7f8f2b7b001608e.tar.gz
selphy_print-096a383b3f6a0d96aefac5f8e7f8f2b7b001608e.tar.bz2
selphy_print-096a383b3f6a0d96aefac5f8e7f8f2b7b001608e.zip
common: Add a global function to read the contents of a file.
Most backends now utilize it. The stragglers do something special.
Diffstat (limited to 'backend_mitsu9550.c')
-rw-r--r--backend_mitsu9550.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/backend_mitsu9550.c b/backend_mitsu9550.c
index a27afce..c6e0def 100644
--- a/backend_mitsu9550.c
+++ b/backend_mitsu9550.c
@@ -701,31 +701,20 @@ hdr_done:
/* Read in CP98xx data tables if necessary */
if (ctx->is_98xx && !job->is_raw && !ctx->m98xxdata) {
- int fd;
-
- DEBUG("Reading in 98xx data from disk\n");
- fd = open(MITSU_M98xx_DATATABLE_FILE, O_RDONLY);
- if (fd < 0) {
- ERROR("Unable to open 98xx data table file '%s'\n", MITSU_M98xx_DATATABLE_FILE);
- mitsu9550_cleanup_job(job);
- return CUPS_BACKEND_FAILED;
- }
+ int ret;
ctx->m98xxdata = malloc(DATATABLE_SIZE);
if (!ctx->m98xxdata) {
ERROR("Memory allocation Failure!\n");
mitsu9550_cleanup_job(job);
return CUPS_BACKEND_RETRY_CURRENT;
}
- remain = DATATABLE_SIZE;
- while (remain) {
- i = read(fd, ((uint8_t*)ctx->m98xxdata) + (DATATABLE_SIZE - remain), remain);
- if (i < 0) {
- mitsu9550_cleanup_job(job);
- return CUPS_BACKEND_CANCEL;
- }
- remain -= i;
+
+ DEBUG("Reading in 98xx data from disk\n");
+ if ((ret = dyesub_read_data(MITSU_M98xx_DATATABLE_FILE, ctx->m98xxdata, DATATABLE_SIZE, NULL))) {
+ ERROR("Unable to read 98xx data table file '%s'\n", MITSU_M98xx_DATATABLE_FILE);
+ free(ctx->m98xxdata);
+ return ret;
}
- close(fd);
}
if (job->is_raw) {
@@ -1738,7 +1727,7 @@ static const char *mitsu9550_prefixes[] = {
/* Exported */
struct dyesub_backend mitsu9550_backend = {
.name = "Mitsubishi CP9xxx family",
- .version = "0.44",
+ .version = "0.45",
.uri_prefixes = mitsu9550_prefixes,
.cmdline_usage = mitsu9550_cmdline,
.cmdline_arg = mitsu9550_cmdline_arg,