|
|
|
@ -196,7 +196,7 @@ static int dnpds40_do_cmd(struct dnpds40_ctx *ctx,
|
|
|
|
|
data, len)))
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint8_t * dnpds40_resp_cmd(struct dnpds40_ctx *ctx,
|
|
|
|
@ -262,7 +262,7 @@ static int dnpds40_query_serno(struct libusb_device_handle *dev, uint8_t endp_up
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(&ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -271,7 +271,7 @@ static int dnpds40_query_serno(struct libusb_device_handle *dev, uint8_t endp_up
|
|
|
|
|
|
|
|
|
|
free(resp);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void *dnpds40_init(void)
|
|
|
|
@ -331,7 +331,7 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|
|
|
|
uint32_t matte = 0, multicut = 0, dpi = 0;
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
if (ctx->databuf) {
|
|
|
|
|
free(ctx->databuf);
|
|
|
|
@ -351,7 +351,7 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|
|
|
|
ctx->databuf = malloc(MAX_PRINTJOB_LEN);
|
|
|
|
|
if (!ctx->databuf) {
|
|
|
|
|
ERROR("Memory allocation failure!\n");
|
|
|
|
|
return 2;
|
|
|
|
|
return CUPS_BACKEND_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (run) {
|
|
|
|
@ -364,12 +364,12 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|
|
|
|
if (i == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (i < (int) sizeof(struct dnpds40_cmd))
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_CANCEL;
|
|
|
|
|
|
|
|
|
|
if (ctx->databuf[ctx->datalen + 0] != 0x1b ||
|
|
|
|
|
ctx->databuf[ctx->datalen + 1] != 0x50) {
|
|
|
|
|
ERROR("Unrecognized header data format @%d!\n", ctx->datalen);
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Parse out length of data chunk, if any */
|
|
|
|
@ -456,9 +456,9 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|
|
|
|
ctx->last_matte = matte;
|
|
|
|
|
|
|
|
|
|
if (!ctx->datalen)
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_CANCEL;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dnpds40_main_loop(void *vctx, int copies) {
|
|
|
|
@ -472,7 +472,7 @@ static int dnpds40_main_loop(void *vctx, int copies) {
|
|
|
|
|
char buf[9];
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
/* Parse job to figure out quantity offset. */
|
|
|
|
|
if (copies > 1 && ctx->qty_offset) {
|
|
|
|
@ -491,7 +491,7 @@ top:
|
|
|
|
|
dnpds40_build_cmd(&cmd, "STATUS", "", 0);
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
|
/* If we're not idle */
|
|
|
|
@ -502,7 +502,7 @@ top:
|
|
|
|
|
dnpds40_build_cmd(&cmd, "INFO", "FREE_PBUFFER", 0);
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
|
/* Check to see if we have sufficient buffers */
|
|
|
|
@ -520,7 +520,7 @@ top:
|
|
|
|
|
}
|
|
|
|
|
free(resp);
|
|
|
|
|
ERROR("Printer Status: %s\n", dnpds40_statuses((char*)resp));
|
|
|
|
|
return 1;
|
|
|
|
|
return CUPS_BACKEND_RETRY_CURRENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Send the stream over as individual data chunks */
|
|
|
|
@ -535,7 +535,7 @@ top:
|
|
|
|
|
|
|
|
|
|
if ((ret = send_data(ctx->dev, ctx->endp_down,
|
|
|
|
|
ptr, i)))
|
|
|
|
|
return ret;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
ptr += i;
|
|
|
|
|
}
|
|
|
|
@ -556,7 +556,7 @@ top:
|
|
|
|
|
|
|
|
|
|
if (resp) free(resp);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
@ -570,7 +570,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -583,7 +583,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -596,7 +596,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -610,7 +610,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -623,7 +623,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -636,7 +636,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -649,7 +649,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -663,7 +663,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -678,7 +678,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -691,7 +691,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -704,7 +704,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -712,8 +712,7 @@ static int dnpds40_get_info(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
free(resp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
|
|
|
@ -727,7 +726,7 @@ static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -740,7 +739,7 @@ static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -753,7 +752,7 @@ static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -791,7 +790,7 @@ static int dnpds40_get_status(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -813,7 +812,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -826,7 +825,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -839,7 +838,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -852,7 +851,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -865,7 +864,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -878,7 +877,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
resp = dnpds40_resp_cmd(ctx, &cmd, &len);
|
|
|
|
|
if (!resp)
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
|
|
|
|
|
dnpds40_cleanup_string((char*)resp, len);
|
|
|
|
|
|
|
|
|
@ -886,7 +885,7 @@ static int dnpds40_get_counters(struct dnpds40_ctx *ctx)
|
|
|
|
|
|
|
|
|
|
free(resp);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return CUPS_BACKEND_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dnpds40_clear_counter(struct dnpds40_ctx *ctx, char counter)
|
|
|
|
@ -961,7 +960,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
|
|
|
|
|
if (optarg[0] != 'A' &&
|
|
|
|
|
optarg[0] != 'B' &&
|
|
|
|
|
optarg[0] != 'M')
|
|
|
|
|
return -1;
|
|
|
|
|
return CUPS_BACKEND_FAILED;
|
|
|
|
|
if (ctx) {
|
|
|
|
|
j = dnpds40_clear_counter(ctx, optarg[0]);
|
|
|
|
|
break;
|
|
|
|
@ -992,7 +991,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
|
|
|
|
|
/* Exported */
|
|
|
|
|
struct dyesub_backend dnpds40_backend = {
|
|
|
|
|
.name = "DNP DS40/DS80/DSRX1",
|
|
|
|
|
.version = "0.31",
|
|
|
|
|
.version = "0.32",
|
|
|
|
|
.uri_prefix = "dnpds40",
|
|
|
|
|
.cmdline_usage = dnpds40_cmdline,
|
|
|
|
|
.cmdline_arg = dnpds40_cmdline_arg,
|
|
|
|
|