Massive overhaul of command line handling.
Completely untested with real printers. That happens tonight! :)
This commit is contained in:
parent
3a5abe1bf8
commit
d7db0bbdbe
144
README
144
README
|
@ -94,48 +94,51 @@
|
|||
of the internal backends. Alternatively you may set the BACKEND
|
||||
environment variable to force a specific backend to be used:
|
||||
|
||||
BACKEND=backend \
|
||||
gutenprint52+usb [ args ]
|
||||
BACKEND=backend gutenprint52+usb [ arguments ]
|
||||
|
||||
(OR)
|
||||
|
||||
gutenprint52+usb -B backend [ arguments ]
|
||||
|
||||
(OR)
|
||||
|
||||
backend [ args ]
|
||||
backend [ arguments ]
|
||||
|
||||
That said, all internal backends support these invocation options
|
||||
That said, all internal backends support these invocation options:
|
||||
|
||||
backend filename
|
||||
backend - < filename
|
||||
somecommand | backend -
|
||||
backend [ backend-specific-argument ]
|
||||
backend [ arguments ] filename
|
||||
backend [ arguments ]- < filename
|
||||
somecommand | backend [ arguments ]-
|
||||
backend [ arguments ]
|
||||
|
||||
The 'filename' here refers to the raw spool data generated by
|
||||
Gutenprint (eg via its gimp plugin) or the Windows print-to-file
|
||||
output.
|
||||
|
||||
You can enable full data dumps by defining the DYESUB_DEBUG
|
||||
environment variable.
|
||||
Extra debugging output can be enabled by setting the DYESUB_DEBUG
|
||||
environment variable or passing the '-D' argument on the command line.
|
||||
|
||||
If there is more than one device present that the backend handles,
|
||||
the backend will choose the first supported device it finds. If you
|
||||
wish to specify the specific device when operating in standalone
|
||||
mode, set the 'DEVICE' environment variable to the target device's
|
||||
serial number. For example:
|
||||
If you have multiple models of the same printer family connected
|
||||
simultaneously, the backend will choose the first one it finds. If you
|
||||
wish to target a specific device, you may specify its serial number
|
||||
in the 'DEVICE' environment variable or by passing the '-S serialnum'
|
||||
argument on the command line. For example:
|
||||
|
||||
DEVICE=N782 backend filename
|
||||
DEVICE=N782 backend filename [ arguments ]
|
||||
backend -S N782 filename [ arguments ]
|
||||
|
||||
All backends support an additional operational mode, to test out
|
||||
unknown models. To use this mode, specify the VID, PID and its
|
||||
type as environment variables. For example:
|
||||
internal device type as arguments or environment variables. For example:
|
||||
|
||||
EXTRA_VID=04a9 EXTRA_PID=3ab1 EXTRA_TYPE=3 backend filename
|
||||
EXTRA_VID=04a9 EXTRA_PID=3ab1 EXTRA_TYPE=7 backend filename
|
||||
backend -V 04a9 -P 3ab1 -T 7 filename
|
||||
|
||||
EXTRA_VID is the USB VID, in hex
|
||||
EXTRA_PID is the USB PID, in hex
|
||||
EXTRA_TYPE is: 4 for SELPHY CP520/820/910 (or other CP-series model)
|
||||
(See P_ANY enum in backend_common.h for more types)
|
||||
|
||||
If you have a model the spooler doesn't recognize but it works with
|
||||
a VID/PID/TYPE specification, please let me know via e-mail.
|
||||
The VID and PID are specified in hexidecimal, and the TYPE is
|
||||
the P_XXX enumeration defined in backend_common.h. '7' corresponds to
|
||||
most Canon SELPHY CP models (eg the CP520, CP820, and CP910). If
|
||||
you are able to successfuly print using this technique, please let
|
||||
us know so we can add the apppriate entry to the internal database.
|
||||
|
||||
Finally, some backends may support additional arguments; see below:
|
||||
|
||||
|
@ -166,13 +169,9 @@
|
|||
Kodak 1400
|
||||
Kodak 805
|
||||
|
||||
This backend supports additional commands:
|
||||
|
||||
kodak1400 [command [arg] ]
|
||||
|
||||
Valid commands:
|
||||
|
||||
-stc filename Set tone curve [1]
|
||||
-C filename Set tone curve [1]
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -190,14 +189,10 @@
|
|||
Kodak 6800
|
||||
Kodak 6850
|
||||
|
||||
This backend supports additional commands:
|
||||
|
||||
kodak6800 [command [arg] ]
|
||||
|
||||
Valid commands:
|
||||
|
||||
-qtc filename Query tone curve [1]
|
||||
-stc filename Set tone curve [1]
|
||||
-c filename Query tone curve [1]
|
||||
-C filename Set tone curve [1]
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -216,9 +211,9 @@
|
|||
|
||||
Valid commands:
|
||||
|
||||
-qs Query printer status (Not fully decoded yet)
|
||||
-qm Query supported media (Not fully decoded yet)
|
||||
-stc filename Set tone curve [1]
|
||||
-C filename Set tone curve [1]
|
||||
-m Query supported media (not fully decoded)
|
||||
-s Query printer status (not fully decoded)
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -243,29 +238,24 @@
|
|||
configured to use the 'DRV' (as opposed to 'DLL') operating mode. See
|
||||
the printer documentation for details on how to set this.
|
||||
|
||||
This backend supports additional commands:
|
||||
|
||||
shinkos2145 [command [arg] ]
|
||||
|
||||
Valid commands:
|
||||
|
||||
-qs Query printer status
|
||||
-qm Query media information
|
||||
-qf Query firmware version
|
||||
-qe Query Error log
|
||||
-qu Query User String
|
||||
-qtu filename Query User tone curve (stored in flash) [1]
|
||||
-qtc filename Query Current tone curve (stored in RAM) [1]
|
||||
-su somestring Set User String to 'somestring'
|
||||
-stu filename Set User tone curve (stored in flash) [1]
|
||||
-stc filename Set Current tone curve (stored in RAM) [1]
|
||||
-pc id Cancel print job 'id' [2]
|
||||
-fl Flash printer LEDs for five seconds.
|
||||
-ru Reset User tone curve to default [3]
|
||||
-rp Reset printer to factory defaults
|
||||
-b1 Enable printer control panel buttons
|
||||
-b0 Disable printer control panel buttons
|
||||
-f Enable fast return [4]
|
||||
-b [ 0 | 1 ] Disable or Enable the printer control panel.
|
||||
-c filename Query User tone curve from flash [1]
|
||||
-C filename Store User tone curve in flash [1]
|
||||
-e Query Error log
|
||||
-f Enable Fast return from prints [2]
|
||||
-F Flash printer LEDs for 5 seconds
|
||||
-i Query printer firmware information
|
||||
-l filename Query Current tone curve from RAM [1]
|
||||
-L filename Store Current tone curve in RAM [1]
|
||||
-m Query media information
|
||||
-r Reset User tone curve to default [4]
|
||||
-R Reset printer to factory defaults
|
||||
-s Query printer status
|
||||
-u Query user string
|
||||
-U somestring Set user string to 'somestring'
|
||||
-X id Cancel print job 'id' [3]
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -275,19 +265,19 @@
|
|||
Values are unsigned 16-bit big endian, between 0 and 2047
|
||||
(ie only 11 bits used)
|
||||
|
||||
[2] Job ID is the Internal Job ID (reported via status)
|
||||
This cancels a multi-copy print job.
|
||||
To see which jobs are active/pending, see the output of the
|
||||
'-qs' command, specifically the 'Bank' output.
|
||||
|
||||
[3] Default printer tone curve is a linear 'val << 3'
|
||||
|
||||
[4] This terminates the backend as soon as the printer has acknowledged
|
||||
[2] This terminates the backend as soon as the printer has acknowledged
|
||||
the print job, without waiting for the print job to complete.
|
||||
This can also be enabled by setting the 'FAST_RETURN' environment
|
||||
variable. This is the default behavior when using this backend
|
||||
with CUPS.
|
||||
|
||||
[3] Job ID is the Internal Job ID (reported via status)
|
||||
This cancels a multi-copy print job.
|
||||
To see which jobs are active/pending, see the output of the
|
||||
'-qs' command, specifically the 'Bank' output.
|
||||
|
||||
[4] Default printer tone curve is a linear 'val << 3'
|
||||
|
||||
***************************************************************************
|
||||
BACKEND=sonyupdr150
|
||||
|
||||
|
@ -313,13 +303,9 @@
|
|||
|
||||
Mitsubishi CP-K60DW-S
|
||||
|
||||
This backend supports additional commands:
|
||||
|
||||
mitsu70x [command [arg] ]
|
||||
|
||||
Valid commands:
|
||||
|
||||
-qs Query printer status (Only partially decoded)
|
||||
-s Query printer status (Only partially decoded)
|
||||
|
||||
***************************************************************************
|
||||
BACKEND=dnpds40
|
||||
|
@ -350,12 +336,10 @@
|
|||
|
||||
Valid commands:
|
||||
|
||||
-qs Query printer status
|
||||
-qi Query printer info (resolution, etc)
|
||||
-qc Query printer counters
|
||||
-cca Clear 'A' Counter
|
||||
-ccb Clear 'B' Counter
|
||||
-ccm Clear 'M' Counter
|
||||
-scp num Set 'P' Counter to 'num'
|
||||
-i Query printer information (resolution, etc)
|
||||
-n Query printer counters
|
||||
-N [ A | B | M ] Reset Counter A/B/M
|
||||
-p num Set 'P' counter to 'num'
|
||||
-s Query printer status
|
||||
|
||||
***************************************************************************
|
||||
|
|
189
backend_common.c
189
backend_common.c
|
@ -27,11 +27,18 @@
|
|||
|
||||
#include "backend_common.h"
|
||||
|
||||
#define BACKEND_VERSION "0.38"
|
||||
#define BACKEND_VERSION "0.39"
|
||||
#ifndef URI_PREFIX
|
||||
#error "Must Define URI_PREFIX"
|
||||
#endif
|
||||
|
||||
/* Global variables */
|
||||
int dyesub_debug = 0;
|
||||
int extra_vid = -1;
|
||||
int extra_pid = -1;
|
||||
int extra_type = -1;
|
||||
char *use_serno = NULL;
|
||||
|
||||
/* Support Functions */
|
||||
|
||||
#define ID_BUF_SIZE 2048
|
||||
|
@ -391,15 +398,14 @@ static int find_and_enumerate(struct libusb_context *ctx,
|
|||
|
||||
match:
|
||||
if (!match) {
|
||||
if (getenv("EXTRA_PID") && getenv("EXTRA_TYPE") && getenv("EXTRA_VID")) {
|
||||
int pid = strtol(getenv("EXTRA_PID"), NULL, 16);
|
||||
int vid = strtol(getenv("EXTRA_VID"), NULL, 16);
|
||||
int type = atoi(getenv("EXTRA_TYPE"));
|
||||
if (vid == desc.idVendor &&
|
||||
pid == desc.idProduct) {
|
||||
if (extra_pid != -1 &&
|
||||
extra_vid != -1 &&
|
||||
extra_type != -1) {
|
||||
if (extra_vid == desc.idVendor &&
|
||||
extra_pid == desc.idProduct) {
|
||||
match = 1;
|
||||
if (printer_type == P_ANY ||
|
||||
printer_type == type)
|
||||
printer_type == extra_type)
|
||||
found = i;
|
||||
}
|
||||
}
|
||||
|
@ -439,10 +445,58 @@ static struct dyesub_backend *find_backend(char *uri_prefix)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Debug flag */
|
||||
int dyesub_debug = 0;
|
||||
|
||||
/* MAIN */
|
||||
static void print_help(char *argv0, struct dyesub_backend *backend)
|
||||
{
|
||||
struct libusb_context *ctx = NULL;
|
||||
struct libusb_device **list = NULL;
|
||||
int i;
|
||||
|
||||
char *ptr = strrchr(argv0, '/');
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = argv0;
|
||||
|
||||
if (!backend)
|
||||
backend = find_backend(ptr);
|
||||
|
||||
if (!backend) {
|
||||
DEBUG("CUPS Usage:\n");
|
||||
DEBUG("\tDEVICE_URI=someuri %s job user title num-copies options [ filename ]\n", URI_PREFIX);
|
||||
DEBUG("\n");
|
||||
DEBUG("Standalone Usage:\n");
|
||||
DEBUG("\t%s\n", URI_PREFIX);
|
||||
DEBUG(" [ -D ] [ -S serialnum ] [ -B backendname ] \n");
|
||||
DEBUG(" [ -V extra_vid ] [ -P extra_pid ] [ -T extra_type ] \n");
|
||||
DEBUG(" [ [ backend_specific_args ] | [ - | infile ] ]\n");
|
||||
for (i = 0; ; i++) {
|
||||
backend = backends[i];
|
||||
if (!backend)
|
||||
break;
|
||||
DEBUG(" -B %s\t# %s v%s\n",
|
||||
backend->uri_prefix, backend->name, backend->version);
|
||||
if (backend->cmdline_usage) {
|
||||
backend->cmdline_usage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DEBUG("Standalone %s backend v%s\n",
|
||||
backend->name, backend->version);
|
||||
DEBUG("\t%s\n", backend->uri_prefix);
|
||||
DEBUG("\t\t[ -D ] [ -S serialnum ] [ -B backendname ] \n");
|
||||
DEBUG("\t\t[ -V extra_vid ] [ -P extra_pid ] [ -T extra_type ] \n");
|
||||
DEBUG("\t\t[ infile | - ]\n");
|
||||
|
||||
if (backend->cmdline_usage) {
|
||||
backend->cmdline_usage();
|
||||
}
|
||||
}
|
||||
libusb_init(&ctx);
|
||||
find_and_enumerate(ctx, &list, backend, NULL, P_ANY, 1);
|
||||
libusb_free_device_list(list, 1);
|
||||
libusb_exit(ctx);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
|
@ -469,61 +523,70 @@ int main (int argc, char **argv)
|
|||
int jobid = 0;
|
||||
int pages = 0;
|
||||
|
||||
char *uri = getenv("DEVICE_URI");
|
||||
char *use_serno = NULL;
|
||||
char *uri;
|
||||
char *fname;
|
||||
int query_only = 0;
|
||||
int printer_type = P_ANY;
|
||||
|
||||
if (getenv("DYESUB_DEBUG"))
|
||||
dyesub_debug = 1;
|
||||
|
||||
DEBUG("Multi-Call Gutenprint DyeSub CUPS Backend version %s\n",
|
||||
BACKEND_VERSION);
|
||||
DEBUG("Copyright 2007-2014 Solomon Peachy\n");
|
||||
|
||||
/* Cmdline help */
|
||||
if (argc < 2) {
|
||||
char *ptr = strrchr(argv[0], '/');
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = argv[0];
|
||||
/* First pass at cmdline parsing */
|
||||
if (getenv("DYESUB_DEBUG"))
|
||||
dyesub_debug++;
|
||||
if (getenv("EXTRA_PID"))
|
||||
extra_pid = strtol(getenv("EXTRA_PID"), NULL, 16);
|
||||
if (getenv("EXTRA_VID"))
|
||||
extra_pid = strtol(getenv("EXTRA_VID"), NULL, 16);
|
||||
if (getenv("EXTRA_PID"))
|
||||
extra_type = atoi(getenv("EXTRA_TYPE"));
|
||||
if (getenv("BACKEND"))
|
||||
backend = find_backend(getenv("BACKEND"));
|
||||
if (!backend)
|
||||
backend = find_backend(ptr);
|
||||
use_serno = getenv("DEVICE");
|
||||
uri = getenv("DEVICE_URI"); /* For CUPS */
|
||||
|
||||
if (!backend) {
|
||||
DEBUG("CUPS Usage:\n\tDEVICE_URI=someuri %s job user title num-copies options [ filename ]\n\n",
|
||||
URI_PREFIX);
|
||||
DEBUG("Internal Backends: (prefix with DEVICE=serno for specific device)\n");
|
||||
for (i = 0; ; i++) {
|
||||
backend = backends[i];
|
||||
if (!backend)
|
||||
break;
|
||||
DEBUG(" %s backend version %s (BACKEND=%s)\n",
|
||||
backend->name, backend->version, backend->uri_prefix);
|
||||
DEBUG("\t\t%s [ infile | - ]\n",
|
||||
backend->uri_prefix);
|
||||
|
||||
if (backend->cmdline_usage) {
|
||||
backend->cmdline_usage(backend->uri_prefix);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DEBUG(" %s backend version %s (BACKEND=%s)\n",
|
||||
backend->name, backend->version, backend->uri_prefix);
|
||||
DEBUG(" Standalone Usage: (prefix with DEVICE=serno for specific device)\n");
|
||||
DEBUG("\t\t%s [ infile | - ]\n",
|
||||
backend->uri_prefix);
|
||||
|
||||
if (backend->cmdline_usage) {
|
||||
backend->cmdline_usage(backend->uri_prefix);
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "B:DhP:S:T:V:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'B':
|
||||
backend = find_backend(optarg);
|
||||
if (!backend) {
|
||||
fprintf(stderr, "ERROR: Unknown backend '%s'\n", optarg);
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
dyesub_debug++;
|
||||
break;
|
||||
case 'h':
|
||||
print_help(argv[0], backend);
|
||||
exit(0);
|
||||
// XXX display help!
|
||||
break;
|
||||
case 'P':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
case 'S':
|
||||
case 'T':
|
||||
extra_type = atoi(optarg);
|
||||
break;
|
||||
case 'V':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
case '?':
|
||||
/* We want to ignore unknown arguments */
|
||||
break;
|
||||
default:
|
||||
// XXX unhandled. do something else?
|
||||
break;
|
||||
}
|
||||
libusb_init(&ctx);
|
||||
find_and_enumerate(ctx, &list, backend, NULL, P_ANY, 1);
|
||||
libusb_free_device_list(list, 1);
|
||||
libusb_exit(ctx);
|
||||
}
|
||||
|
||||
/* Make sure a filename was specified */
|
||||
if (optind <= argc && !argv[optind]) {
|
||||
print_help(argv[0], backend);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -587,10 +650,10 @@ int main (int argc, char **argv)
|
|||
*ptr = 0;
|
||||
}
|
||||
} else {
|
||||
use_serno = getenv("DEVICE");
|
||||
/* Grab the filename */
|
||||
fname = argv[optind];
|
||||
|
||||
/* find backend */
|
||||
backend = find_backend(getenv("BACKEND"));
|
||||
/* Make sure we have a sane backend */
|
||||
if (!backend) {
|
||||
char *ptr = strrchr(argv[0], '/');
|
||||
if (ptr)
|
||||
|
@ -607,12 +670,14 @@ int main (int argc, char **argv)
|
|||
srand(getpid());
|
||||
jobid = rand();
|
||||
|
||||
if (backend->cmdline_arg && backend->cmdline_arg(NULL, 0, argv[1], argv[2])) {
|
||||
/* Check cmdline arguments */
|
||||
// XXX optind = 1;
|
||||
if (backend->cmdline_arg && backend->cmdline_arg(NULL, argc, argv)) {
|
||||
query_only = 1;
|
||||
} else {
|
||||
/* Open Input File */
|
||||
if (strcmp("-", argv[1])) {
|
||||
data_fd = open(argv[1], O_RDONLY);
|
||||
if (strcmp("-", fname)) {
|
||||
data_fd = open(fname, O_RDONLY);
|
||||
if (data_fd < 0) {
|
||||
perror("ERROR:Can't open input file");
|
||||
exit(1);
|
||||
|
@ -690,7 +755,7 @@ int main (int argc, char **argv)
|
|||
backend->attach(backend_ctx, dev, endp_up, endp_down, jobid);
|
||||
|
||||
if (query_only) {
|
||||
backend->cmdline_arg(backend_ctx, 1, argv[1], argv[2]);
|
||||
backend->cmdline_arg(backend_ctx, argc, argv);
|
||||
goto done_claimed;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,12 +117,12 @@ struct dyesub_backend {
|
|||
char *name;
|
||||
char *version;
|
||||
char *uri_prefix;
|
||||
void (*cmdline_usage)(char *caller);
|
||||
void (*cmdline_usage)(void);
|
||||
void *(*init)(void);
|
||||
void (*attach)(void *ctx, struct libusb_device_handle *dev,
|
||||
uint8_t endp_up, uint8_t endp_down, uint8_t jobid);
|
||||
void (*teardown)(void *ctx);
|
||||
int (*cmdline_arg)(void *ctx, int run, char *arg1, char *arg2);
|
||||
int (*cmdline_arg)(void *ctx, int argc, char **argv);
|
||||
int (*early_parse)(void *ctx, int data_fd);
|
||||
int (*read_parse)(void *ctx, int data_fd);
|
||||
int (*main_loop)(void *ctx, int copies);
|
||||
|
|
|
@ -919,48 +919,68 @@ static int dnpds40_set_counter_p(struct dnpds40_ctx *ctx, char *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void dnpds40_cmdline(char *caller)
|
||||
static void dnpds40_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qs | -qi | -qc ]\n", caller);
|
||||
DEBUG("\t\t%s [ -cca | -ccb | -ccm ]\n", caller);
|
||||
DEBUG("\t\t%s [ -scp num ]\n", caller);
|
||||
DEBUG("\t\t[ -i ] # Query printer info\n");
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
DEBUG("\t\t[ -n ] # Query counters\n");
|
||||
DEBUG("\t\t[ -N A|B|M ] # Clear counter A/B/M\n");
|
||||
DEBUG("\t\t[ -p num ] # Set counter P\n");
|
||||
|
||||
}
|
||||
|
||||
static int dnpds40_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct dnpds40_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-qs", arg1) ||
|
||||
!strcmp("-qi", arg1) ||
|
||||
!strcmp("-qc", arg1) ||
|
||||
!strcmp("-cca", arg1) ||
|
||||
!strcmp("-ccb", arg1) ||
|
||||
!strcmp("-ccm", arg1) ||
|
||||
!strcmp("-scp", arg1));
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "inN:ps")) >= 0) {
|
||||
switch(i) {
|
||||
case 'i':
|
||||
if (ctx)
|
||||
return dnpds40_get_info(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'n':
|
||||
if (ctx)
|
||||
return dnpds40_get_counters(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'N':
|
||||
if (ctx) {
|
||||
if (optarg[0] != 'A' &&
|
||||
optarg[0] != 'B' &&
|
||||
optarg[0] != 'M')
|
||||
return -1;
|
||||
else
|
||||
return dnpds40_clear_counter(ctx, optarg[0]);
|
||||
} else
|
||||
return 1;
|
||||
case 'p':
|
||||
if (ctx)
|
||||
return dnpds40_set_counter_p(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 's':
|
||||
if (ctx)
|
||||
return dnpds40_get_status(ctx);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp("-qs", arg1))
|
||||
return dnpds40_get_status(ctx);
|
||||
if (!strcmp("-qi", arg1))
|
||||
return dnpds40_get_info(ctx);
|
||||
if (!strcmp("-qc", arg1))
|
||||
return dnpds40_get_counters(ctx);
|
||||
if (!strcmp("-cca", arg1))
|
||||
return dnpds40_clear_counter(ctx, 'A');
|
||||
if (!strcmp("-ccb", arg1))
|
||||
return dnpds40_clear_counter(ctx, 'B');
|
||||
if (!strcmp("-ccm", arg1))
|
||||
return dnpds40_clear_counter(ctx, 'M');
|
||||
if (!strcmp("-scp", arg1))
|
||||
return dnpds40_set_counter_p(ctx, arg2);
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Exported */
|
||||
struct dyesub_backend dnpds40_backend = {
|
||||
.name = "DNP DS40/DS80/DSRX1",
|
||||
.version = "0.26",
|
||||
.version = "0.27",
|
||||
.uri_prefix = "dnpds40",
|
||||
.cmdline_usage = dnpds40_cmdline,
|
||||
.cmdline_arg = dnpds40_cmdline_arg,
|
||||
|
|
|
@ -234,22 +234,32 @@ static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void kodak1400_cmdline(char *caller)
|
||||
static void kodak1400_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -stc filename ]\n", caller);
|
||||
DEBUG("\t\t[ -C filename ] # Set tone curve\n");
|
||||
}
|
||||
|
||||
int kodak1400_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct kodak1400_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-stc", arg1));
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "C:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'C':
|
||||
if (ctx)
|
||||
return kodak1400_set_tonecurve(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp("-stc", arg1))
|
||||
return kodak1400_set_tonecurve(ctx, arg2);
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *kodak1400_init(void)
|
||||
|
@ -574,7 +584,7 @@ top:
|
|||
|
||||
struct dyesub_backend kodak1400_backend = {
|
||||
.name = "Kodak 1400/805",
|
||||
.version = "0.29",
|
||||
.version = "0.30",
|
||||
.uri_prefix = "kodak1400",
|
||||
.cmdline_usage = kodak1400_cmdline,
|
||||
.cmdline_arg = kodak1400_cmdline_arg,
|
||||
|
|
|
@ -467,35 +467,50 @@ static int kodak605_set_tonecurve(struct kodak605_ctx *ctx, char *fname)
|
|||
}
|
||||
|
||||
|
||||
static void kodak605_cmdline(char *caller)
|
||||
static void kodak605_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qs | -qm ]\n", caller);
|
||||
DEBUG("\t\t%s [ -stc filename ]\n", caller);
|
||||
DEBUG("\t\t[ -C filename ] # Set tone curve\n");
|
||||
DEBUG("\t\t[ -m ] # Query media\n");
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
}
|
||||
|
||||
static int kodak605_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct kodak605_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-qs", arg1) ||
|
||||
!strcmp("-qm", arg1) ||
|
||||
!strcmp("-stc", arg1) );
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "C:ms")) >= 0) {
|
||||
switch(i) {
|
||||
case 'C':
|
||||
if (ctx)
|
||||
return kodak605_set_tonecurve(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'm':
|
||||
if (ctx)
|
||||
return kodak605_get_media(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 's':
|
||||
if (ctx)
|
||||
return kodak605_get_status(ctx);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp("-qs", arg1))
|
||||
return kodak605_get_status(ctx);
|
||||
if (!strcmp("-qm", arg1))
|
||||
return kodak605_get_media(ctx);
|
||||
if (!strcmp("-stc", arg1))
|
||||
return kodak605_set_tonecurve(ctx, arg2);
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Exported */
|
||||
struct dyesub_backend kodak605_backend = {
|
||||
.name = "Kodak 605",
|
||||
.version = "0.16",
|
||||
.version = "0.17",
|
||||
.uri_prefix = "kodak605",
|
||||
.cmdline_usage = kodak605_cmdline,
|
||||
.cmdline_arg = kodak605_cmdline_arg,
|
||||
|
|
|
@ -274,25 +274,38 @@ static int kodak6800_set_tonecurve(struct kodak6800_ctx *ctx, char *fname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void kodak6800_cmdline(char *caller)
|
||||
static void kodak6800_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qtc filename | -stc filename ]\n", caller);
|
||||
DEBUG("\t\t[ -c filename ] # Get tone curve\n");
|
||||
DEBUG("\t\t[ -C filename ] # Set tone curve\n");
|
||||
}
|
||||
|
||||
static int kodak6800_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct kodak6800_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-qtc", arg1) ||
|
||||
!strcmp("-stc", arg1));
|
||||
|
||||
if (!strcmp("-qtc", arg1))
|
||||
return kodak6800_get_tonecurve(ctx, arg2);
|
||||
if (!strcmp("-stc", arg1))
|
||||
return kodak6800_set_tonecurve(ctx, arg2);
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "C:c:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'c':
|
||||
if (ctx)
|
||||
return kodak6800_get_tonecurve(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'C':
|
||||
if (ctx)
|
||||
return kodak6800_set_tonecurve(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -608,7 +621,7 @@ skip_query:
|
|||
/* Exported */
|
||||
struct dyesub_backend kodak6800_backend = {
|
||||
.name = "Kodak 6800/6850",
|
||||
.version = "0.30",
|
||||
.version = "0.31",
|
||||
.uri_prefix = "kodak6800",
|
||||
.cmdline_usage = kodak6800_cmdline,
|
||||
.cmdline_arg = kodak6800_cmdline_arg,
|
||||
|
|
|
@ -371,31 +371,39 @@ static int mitsu70x_get_status(struct mitsu70x_ctx *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void mitsu70x_cmdline(char *caller)
|
||||
static void mitsu70x_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qs ]\n", caller);
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
}
|
||||
|
||||
static int mitsu70x_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct mitsu70x_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
UNUSED(arg2);
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "s")) >= 0) {
|
||||
switch(i) {
|
||||
case 's':
|
||||
if (ctx)
|
||||
return mitsu70x_get_status(ctx);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-qs", arg1));
|
||||
|
||||
if (!strcmp("-qs", arg1))
|
||||
return mitsu70x_get_status(ctx);
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Exported */
|
||||
struct dyesub_backend mitsu70x_backend = {
|
||||
.name = "Mitsubishi CP-D70/D707",
|
||||
.version = "0.10",
|
||||
.version = "0.11",
|
||||
.uri_prefix = "mitsu70x",
|
||||
.cmdline_usage = mitsu70x_cmdline,
|
||||
.cmdline_arg = mitsu70x_cmdline_arg,
|
||||
|
|
|
@ -1292,75 +1292,127 @@ static int set_tonecurve(struct shinkos2145_ctx *ctx, int target, char *fname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void shinkos2145_cmdline(char *caller)
|
||||
static void shinkos2145_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t%s [ -qs | -qm | -qf | -qe | -qu ]\n", caller);
|
||||
DEBUG("\t\t%s [ -qtu filename | -qtc filename ]\n", caller);
|
||||
DEBUG("\t\t%s [ -su somestring | -stu filename | -stc filename ]\n", caller);
|
||||
DEBUG("\t\t%s [ -pc id | -fl | -ru | -rp | -b1 | -b0 ]\n", caller);
|
||||
DEBUG("\t\t%s [ -f ]\n", caller);
|
||||
DEBUG("\t\t[ -b 0|1 ] # Disable/Enable control panel\n");
|
||||
DEBUG("\t\t[ -c filename ] # Get user/NV tone curve\n");
|
||||
DEBUG("\t\t[ -C filename ] # Set user/NV tone curve\n");
|
||||
DEBUG("\t\t[ -e ] # Query error log\n");
|
||||
DEBUG("\t\t[ -f ] # Use fast return mode\n");
|
||||
DEBUG("\t\t[ -F ] # Flash Printer LED\n");
|
||||
DEBUG("\t\t[ -l filename ] # Get current tone curve\n");
|
||||
DEBUG("\t\t[ -L filename ] # Set current tone curve\n");
|
||||
DEBUG("\t\t[ -m ] # Query media\n");
|
||||
DEBUG("\t\t[ -i ] # Query printer info\n");
|
||||
DEBUG("\t\t[ -r ] # Reset user/NV tone curve\n");
|
||||
DEBUG("\t\t[ -R ] # Reset printer to factory defaults\n");
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
DEBUG("\t\t[ -u ] # Query user string\n");
|
||||
DEBUG("\t\t[ -U sometext ] # Set user string\n");
|
||||
DEBUG("\t\t[ -X jobid ] # Abort a printjob\n");
|
||||
}
|
||||
|
||||
int shinkos2145_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
|
||||
int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
{
|
||||
struct shinkos2145_ctx *ctx = vctx;
|
||||
int i;
|
||||
|
||||
if (!run || !ctx)
|
||||
return (!strcmp("-qs", arg1) ||
|
||||
!strcmp("-qf", arg1) ||
|
||||
!strcmp("-qe", arg1) ||
|
||||
!strcmp("-qm", arg1) ||
|
||||
!strcmp("-qu", arg1) ||
|
||||
!strcmp("-qtc", arg1) ||
|
||||
!strcmp("-qtu", arg1) ||
|
||||
!strcmp("-pc", arg1) ||
|
||||
!strcmp("-fl", arg1) ||
|
||||
!strcmp("-ru", arg1) ||
|
||||
!strcmp("-rp", arg1) ||
|
||||
!strcmp("-b1", arg1) ||
|
||||
!strcmp("-b0", arg1) ||
|
||||
!strcmp("-stc", arg1) ||
|
||||
!strcmp("-stu", arg1) ||
|
||||
!strcmp("-f", arg1) ||
|
||||
!strcmp("-su", arg1));
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "b:c:C:efFil:L:mr:R:suU:X:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'b':
|
||||
if (ctx) {
|
||||
if (optarg[0] == '1')
|
||||
button_set(ctx, BUTTON_ENABLED);
|
||||
else if (optarg[0] == '0')
|
||||
button_set(ctx, BUTTON_DISABLED);
|
||||
else
|
||||
return -1;
|
||||
} else
|
||||
return 1;
|
||||
case 'c':
|
||||
if (ctx)
|
||||
return get_tonecurve(ctx, TONECURVE_USER, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'C':
|
||||
if (ctx)
|
||||
return set_tonecurve(ctx, TONECURVE_USER, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'e':
|
||||
if (ctx)
|
||||
return get_errorlog(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'f':
|
||||
if (ctx)
|
||||
ctx->fast_return = 1;
|
||||
else
|
||||
return 1;
|
||||
case 'F':
|
||||
if (ctx)
|
||||
return flash_led(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'i':
|
||||
if (ctx)
|
||||
return get_fwinfo(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'l':
|
||||
if (ctx)
|
||||
return get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'L':
|
||||
if (ctx)
|
||||
return set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'm':
|
||||
if (ctx)
|
||||
return get_mediainfo(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'r':
|
||||
if (ctx)
|
||||
return reset_curve(ctx, RESET_USER_CURVE);
|
||||
else
|
||||
return 1;
|
||||
case 'R':
|
||||
if (ctx)
|
||||
return reset_curve(ctx, RESET_PRINTER);
|
||||
else
|
||||
return 1;
|
||||
case 's':
|
||||
if (ctx)
|
||||
return get_status(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'u':
|
||||
if (ctx)
|
||||
return get_user_string(ctx);
|
||||
else
|
||||
return 1;
|
||||
case 'U':
|
||||
if (ctx)
|
||||
return set_user_string(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
case 'X':
|
||||
if (ctx)
|
||||
return cancel_job(ctx, optarg);
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp("-f", arg1))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
if (!strcmp("-qs", arg1))
|
||||
get_status(ctx);
|
||||
else if (!strcmp("-qf", arg1))
|
||||
get_fwinfo(ctx);
|
||||
else if (!strcmp("-qe", arg1))
|
||||
get_errorlog(ctx);
|
||||
else if (!strcmp("-qm", arg1))
|
||||
get_mediainfo(ctx);
|
||||
else if (!strcmp("-qu", arg1))
|
||||
get_user_string(ctx);
|
||||
else if (!strcmp("-qtu", arg1))
|
||||
get_tonecurve(ctx, TONECURVE_USER, arg2);
|
||||
else if (!strcmp("-qtc", arg1))
|
||||
get_tonecurve(ctx, TONECURVE_CURRENT, arg2);
|
||||
else if (!strcmp("-su", arg1))
|
||||
set_user_string(ctx, arg2);
|
||||
else if (!strcmp("-stu", arg1))
|
||||
set_tonecurve(ctx, UPDATE_TARGET_USER, arg2);
|
||||
else if (!strcmp("-stc", arg1))
|
||||
set_tonecurve(ctx, UPDATE_TARGET_CURRENT, arg2);
|
||||
else if (!strcmp("-pc", arg1))
|
||||
cancel_job(ctx, arg2);
|
||||
else if (!strcmp("-fl", arg1))
|
||||
flash_led(ctx);
|
||||
else if (!strcmp("-ru", arg1))
|
||||
reset_curve(ctx, RESET_USER_CURVE);
|
||||
else if (!strcmp("-rp", arg1))
|
||||
reset_curve(ctx, RESET_PRINTER);
|
||||
else if (!strcmp("-b1", arg1))
|
||||
button_set(ctx, BUTTON_ENABLED);
|
||||
else if (!strcmp("-b0", arg1))
|
||||
button_set(ctx, BUTTON_DISABLED);
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *shinkos2145_init(void)
|
||||
|
@ -1370,7 +1422,8 @@ static void *shinkos2145_init(void)
|
|||
return NULL;
|
||||
memset(ctx, 0, sizeof(struct shinkos2145_ctx));
|
||||
|
||||
if (getenv("FAST_RETURN"))
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
|
@ -1665,7 +1718,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.29",
|
||||
.version = "0.30",
|
||||
.uri_prefix = "shinkos2145",
|
||||
.cmdline_usage = shinkos2145_cmdline,
|
||||
.cmdline_arg = shinkos2145_cmdline_arg,
|
||||
|
|
Loading…
Reference in a new issue