common: Rework the early cmdline argument parsing code to improve robustness
Also move fast_return out of individual backends and into common code.master
parent
ba2f964c6a
commit
20f6d05b8a
133
README
133
README
|
@ -133,33 +133,56 @@
|
|||
Gutenprint (eg via its gimp plugin) or the Windows print-to-file
|
||||
output.
|
||||
|
||||
Extra debugging output can be enabled by setting the DYESUB_DEBUG
|
||||
environment variable or passing the '-D' argument on the command line.
|
||||
All global arguments:
|
||||
|
||||
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, these are equivalent:
|
||||
-D Increment debug level [1]
|
||||
-G Display GPL text
|
||||
-f Enable fast return mode if possible [2]
|
||||
-B name Use Backend 'name' [3]
|
||||
-S serno Use SerialNum 'serno' [4]
|
||||
-V extra_vid [5]
|
||||
-P extra_pid [5]
|
||||
-T extra_type [5]
|
||||
-d numcopies Print 'numcopies' of the supplied job
|
||||
|
||||
DEVICE=N782 backend filename [ arguments ]
|
||||
backend -S N782 filename [ arguments ]
|
||||
[1] This argument can be repeated to increase the debug level.
|
||||
Alternatively, the 'DYESUB_DEBUG' environment variable can be
|
||||
used.
|
||||
|
||||
All backends support an additional operational mode, to test out
|
||||
unknown models. To use this mode, specify the VID, PID and its
|
||||
internal device type as arguments or environment variables:
|
||||
[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. Not all backends support
|
||||
fast return.
|
||||
|
||||
EXTRA_VID=04a9 EXTRA_PID=3ab1 EXTRA_TYPE=7 backend filename
|
||||
backend -V 04a9 -P 3ab1 -T 7 filename
|
||||
[3] Alternatively, you can use the 'BACKEND' environment variable.
|
||||
|
||||
The VID and PID are specified in hexidecimal, and the TYPE is
|
||||
the P_XXX enumeration defined in backend_common.h. The '7' in this
|
||||
example corresponds to most Canon SELPHY CP models, and is what you
|
||||
would use if you were trying to get the backend to detect an
|
||||
otherwise unrecognized SELPHY CP model.
|
||||
[4] 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 with this switch, or using the 'SERIAL' environment
|
||||
variable. For example, these are equivalent:
|
||||
|
||||
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.
|
||||
SERIAL=N782 backend filename [ arguments ]
|
||||
backend -S N782 filename [ arguments ]
|
||||
|
||||
[5] All backends support an additional operational mode, to test out
|
||||
unknown models. To use this mode, specify the VID, PID and its
|
||||
internal device type as arguments or environment variables:
|
||||
|
||||
EXTRA_VID=04a9 EXTRA_PID=3ab1 EXTRA_TYPE=7 backend filename
|
||||
backend -V 04a9 -P 3ab1 -T 7 filename
|
||||
|
||||
The VID and PID are specified in hexidecimal, and the TYPE is
|
||||
the P_XXX enumeration defined in backend_common.h. The '7' in this
|
||||
example corresponds to most Canon SELPHY CP models, and is what you
|
||||
would use if you were trying to get the backend to detect an
|
||||
otherwise unrecognized SELPHY CP model.
|
||||
|
||||
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 support additional arguments; see below:
|
||||
|
||||
|
@ -271,7 +294,6 @@
|
|||
-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]
|
||||
|
@ -292,12 +314,6 @@
|
|||
Values are unsigned 16-bit big endian, between 0 and 2047
|
||||
(ie only 11 bits used)
|
||||
|
||||
[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
|
||||
|
@ -316,30 +332,23 @@
|
|||
|
||||
Valid commands:
|
||||
|
||||
-f Enable Fast return from prints [1]
|
||||
-s Query printer status
|
||||
-m Query media information
|
||||
-u Query user string
|
||||
-U somestring Set user string to 'somestring'
|
||||
-X id Cancel print job 'id' [2]
|
||||
-X id Cancel print job 'id' [1]
|
||||
-F Tone curve commands affect FINE table
|
||||
-c filename Query User tone curve from flash [3]
|
||||
-C filename Store User tone curve in flash [3]
|
||||
-l filename Query Current tone curve from RAM [3]
|
||||
-L filename Store Current tone curve in RAM [3]
|
||||
-c filename Query User tone curve from flash [2]
|
||||
-C filename Store User tone curve in flash [2]
|
||||
-l filename Query Current tone curve from RAM [2]
|
||||
-L filename Store Current tone curve in RAM [2]
|
||||
|
||||
[1] 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.
|
||||
|
||||
[2] Job ID is the Internal Job ID (reported via status)
|
||||
[1] 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
|
||||
'-s' command, specifically the 'Bank' output.
|
||||
|
||||
[3] Format of tone curve file:
|
||||
[2] Format of tone curve file:
|
||||
|
||||
256 entries each of Yellow, Magenta, Cyan mappings:
|
||||
Values are unsigned 16-bit big endian, between 0 and 16383
|
||||
|
@ -365,17 +374,16 @@
|
|||
-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
|
||||
-k num Specify standby delay (5-240 minutes)
|
||||
-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 User tone curve to default [3]
|
||||
-R Reset printer to factory defaults
|
||||
-s Query printer status
|
||||
-X id Cancel print job 'id' [3]
|
||||
-X id Cancel print job 'id' [2]
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -385,18 +393,12 @@
|
|||
Values are unsigned 16-bit big endian, between 0 and 2047
|
||||
(ie only 11 bits used)
|
||||
|
||||
[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)
|
||||
[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
|
||||
'-s' command, specifically the 'Bank' output.
|
||||
|
||||
[4] Default printer tone curve is a linear 'val << 3'
|
||||
[3] Default printer tone curve is a linear 'val << 3'
|
||||
|
||||
***************************************************************************
|
||||
BACKEND=shinkos6245
|
||||
|
@ -412,17 +414,16 @@
|
|||
-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
|
||||
-k num Specify standby delay (5-240 minutes)
|
||||
-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 User tone curve to default [3]
|
||||
-R Reset printer to factory defaults
|
||||
-s Query printer status
|
||||
-X id Cancel print job 'id' [3]
|
||||
-X id Cancel print job 'id' [2]
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -432,18 +433,12 @@
|
|||
Values are unsigned 16-bit big endian, between 0 and 2047
|
||||
(ie only 11 bits used)
|
||||
|
||||
[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)
|
||||
[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
|
||||
'-s' command, specifically the 'Bank' output.
|
||||
|
||||
[4] Default printer tone curve is a linear 'val << 3'
|
||||
[3] Default printer tone curve is a linear 'val << 3'
|
||||
|
||||
***************************************************************************
|
||||
BACKEND=sonyupdr150
|
||||
|
@ -494,14 +489,8 @@
|
|||
|
||||
Valid commands:
|
||||
|
||||
-m Query printer media status
|
||||
-f Enable Fast return from prints [1]
|
||||
|
||||
[1] 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.
|
||||
-s Query printer status
|
||||
-m Query printer media
|
||||
|
||||
***************************************************************************
|
||||
BACKEND=dnpds40
|
||||
|
|
263
backend_common.c
263
backend_common.c
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "backend_common.h"
|
||||
|
||||
#define BACKEND_VERSION "0.57"
|
||||
#define BACKEND_VERSION "0.58"
|
||||
#ifndef URI_PREFIX
|
||||
#error "Must Define URI_PREFIX"
|
||||
#endif
|
||||
|
@ -37,6 +37,7 @@
|
|||
/* Global Variables */
|
||||
int dyesub_debug = 0;
|
||||
int terminate = 0;
|
||||
int fast_return = 0;
|
||||
|
||||
/* Local Global Variables */
|
||||
static int extra_vid = -1;
|
||||
|
@ -682,16 +683,19 @@ static void print_help(char *argv0, struct dyesub_backend *backend)
|
|||
|
||||
if (!backend) {
|
||||
int i;
|
||||
DEBUG("Environment variables:\n");
|
||||
DEBUG(" DYESUB_DEBUG EXTRA_PID EXTRA_VID EXTRA_TYPE BACKEND SERIAL\n");
|
||||
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 ] [ -G ]\n");
|
||||
DEBUG(" [ -D ] [ -G ] [ -f ]\n");
|
||||
DEBUG(" [ -S serialnum ] [ -B backendname ] \n");
|
||||
DEBUG(" [ -V extra_vid ] [ -P extra_pid ] [ -T extra_type ] \n");
|
||||
DEBUG(" [ backend_specific_args ] \n");
|
||||
DEBUG(" [ -d copies ] [ - | infile ] \n");
|
||||
DEBUG(" [ -d copies ] \n");
|
||||
DEBUG(" [ - | infile ] \n");
|
||||
for (i = 0; ; i++) {
|
||||
backend = backends[i];
|
||||
if (!backend)
|
||||
|
@ -763,7 +767,7 @@ int main (int argc, char **argv)
|
|||
|
||||
/* First pass at cmdline parsing */
|
||||
if (getenv("DYESUB_DEBUG"))
|
||||
dyesub_debug++;
|
||||
dyesub_debug = atoi(getenv("DYESUB_DEBUG"));
|
||||
if (getenv("EXTRA_PID"))
|
||||
extra_pid = strtol(getenv("EXTRA_PID"), NULL, 16);
|
||||
if (getenv("EXTRA_VID"))
|
||||
|
@ -772,120 +776,24 @@ int main (int argc, char **argv)
|
|||
extra_type = atoi(getenv("EXTRA_TYPE"));
|
||||
if (getenv("BACKEND"))
|
||||
backend = find_backend(getenv("BACKEND"));
|
||||
use_serno = getenv("DEVICE");
|
||||
uri = getenv("DEVICE_URI"); /* For CUPS */
|
||||
if (getenv("FAST_RETURN"))
|
||||
fast_return++;
|
||||
use_serno = getenv("SERIAL");
|
||||
uri = getenv("DEVICE_URI"); /* CUPS backend mode? */
|
||||
|
||||
/* Try to ensure we have a sane backend for standalone mode.
|
||||
CUPS mode uses 'uri' later on. */
|
||||
if (!backend) {
|
||||
char *ptr = strrchr(argv[0], '/');
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = argv[0];
|
||||
backend = find_backend(ptr);
|
||||
}
|
||||
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "B:d:DGhP: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':
|
||||
copies = atoi(optarg);
|
||||
break;
|
||||
case 'D':
|
||||
dyesub_debug++;
|
||||
break;
|
||||
case 'G':
|
||||
print_license_blurb();
|
||||
exit(0);
|
||||
case 'h':
|
||||
print_help(argv[0], backend);
|
||||
exit(0);
|
||||
break;
|
||||
case 'P':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
case 'S':
|
||||
use_serno = optarg;
|
||||
break;
|
||||
case 'T':
|
||||
extra_type = atoi(optarg);
|
||||
break;
|
||||
case 'V':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
default: {
|
||||
/* Check to see if it is claimed by the backend */
|
||||
if (backend && backend->cmdline_arg) {
|
||||
int keep = optind;
|
||||
int boo;
|
||||
|
||||
boo = backend->cmdline_arg(NULL, argc, argv);
|
||||
backend_cmd += boo;
|
||||
|
||||
if (boo > 1)
|
||||
keep++;
|
||||
|
||||
optind = keep;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef LIBUSB_PRE_1_0_10
|
||||
if (dyesub_debug) {
|
||||
const struct libusb_version *ver;
|
||||
ver = libusb_get_version();
|
||||
DEBUG(" ** running with libusb %d.%d.%d%s (%d)\n",
|
||||
ver->major, ver->minor, ver->micro, (ver->rc? ver->rc : ""), ver->nano );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure a filename was specified */
|
||||
if (!backend_cmd && (optind == argc || !argv[optind])) {
|
||||
print_help(argv[0], backend);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Are we running as a CUPS backend? */
|
||||
if (uri) {
|
||||
int base = optind; // XXX aka 1.
|
||||
fname = argv[base + 5];
|
||||
/* CUPS backend mode */
|
||||
int base = optind; /* ie 1 */
|
||||
if (argc < 6) {
|
||||
ERROR("Insufficient arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argv[base])
|
||||
jobid = atoi(argv[base]);
|
||||
if (argv[base + 3])
|
||||
copies = atoi(argv[base + 3]);
|
||||
if (fname) { /* IOW, is it specified? */
|
||||
data_fd = open(fname, O_RDONLY);
|
||||
if (data_fd < 0) {
|
||||
perror("ERROR:Can't open input file");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fname = "-";
|
||||
}
|
||||
|
||||
/* Ensure we're using BLOCKING I/O */
|
||||
i = fcntl(data_fd, F_GETFL, 0);
|
||||
if (i < 0) {
|
||||
perror("ERROR:Can't open input");
|
||||
exit(1);
|
||||
}
|
||||
i &= ~O_NONBLOCK;
|
||||
i = fcntl(data_fd, F_SETFL, i);
|
||||
if (i < 0) {
|
||||
perror("ERROR:Can't open input");
|
||||
exit(1);
|
||||
}
|
||||
if (argc > 6)
|
||||
fname = argv[base + 5];
|
||||
|
||||
/* Figure out backend based on URI */
|
||||
{
|
||||
|
@ -919,9 +827,87 @@ int main (int argc, char **argv)
|
|||
if (ptr)
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
/* Always enable fast return in CUPS mode */
|
||||
fast_return++;
|
||||
} else {
|
||||
srand(getpid());
|
||||
jobid = rand();
|
||||
/* Standalone mode */
|
||||
|
||||
/* Try to guess backend from executable name */
|
||||
if (!backend) {
|
||||
char *ptr = strrchr(argv[0], '/');
|
||||
if (ptr)
|
||||
ptr++;
|
||||
else
|
||||
ptr = argv[0];
|
||||
backend = find_backend(ptr);
|
||||
}
|
||||
|
||||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "B:d:DfGhP:S:T:V:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'B':
|
||||
backend = find_backend(optarg);
|
||||
if (!backend) {
|
||||
fprintf(stderr, "ERROR: Unknown backend '%s'\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
copies = atoi(optarg);
|
||||
break;
|
||||
case 'D':
|
||||
dyesub_debug++;
|
||||
break;
|
||||
case 'f':
|
||||
fast_return++;
|
||||
break;
|
||||
case 'G':
|
||||
print_license_blurb();
|
||||
exit(0);
|
||||
case 'h':
|
||||
print_help(argv[0], backend);
|
||||
exit(0);
|
||||
case 'P':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
case 'S':
|
||||
use_serno = optarg;
|
||||
break;
|
||||
case 'T':
|
||||
extra_type = atoi(optarg);
|
||||
break;
|
||||
case 'V':
|
||||
extra_pid = strtol(optarg, NULL, 16);
|
||||
break;
|
||||
default: {
|
||||
/* Check to see if it is claimed by the backend */
|
||||
if (backend && backend->cmdline_arg) {
|
||||
int keep = optind;
|
||||
int boo;
|
||||
|
||||
boo = backend->cmdline_arg(NULL, argc, argv);
|
||||
backend_cmd += boo;
|
||||
|
||||
if (boo > 1)
|
||||
keep++;
|
||||
|
||||
optind = keep;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure a filename was specified */
|
||||
if (optind >= argc || !argv[optind]) {
|
||||
if (!backend_cmd)
|
||||
print_help(argv[0], backend);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Grab the filename */
|
||||
fname = argv[optind];
|
||||
|
@ -930,16 +916,47 @@ int main (int argc, char **argv)
|
|||
perror("ERROR:No input file");
|
||||
exit(1);
|
||||
}
|
||||
if (fname) {
|
||||
/* Open Input File */
|
||||
if (strcmp("-", fname)) {
|
||||
data_fd = open(fname, O_RDONLY);
|
||||
if (data_fd < 0) {
|
||||
perror("ERROR:Can't open input file");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
srand(getpid());
|
||||
jobid = rand();
|
||||
}
|
||||
|
||||
#ifndef LIBUSB_PRE_1_0_10
|
||||
if (dyesub_debug) {
|
||||
const struct libusb_version *ver;
|
||||
ver = libusb_get_version();
|
||||
DEBUG(" ** running with libusb %d.%d.%d%s (%d)\n",
|
||||
ver->major, ver->minor, ver->micro, (ver->rc? ver->rc : ""), ver->nano );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we have a sane backend */
|
||||
if (!backend) {
|
||||
fprintf(stderr, "ERROR: Unknown backend\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fname && strcmp("-", fname)) {
|
||||
data_fd = open(fname, O_RDONLY);
|
||||
if (data_fd < 0) {
|
||||
perror("ERROR:Can't open input file");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fname = "-";
|
||||
}
|
||||
|
||||
/* Ensure we're using BLOCKING I/O */
|
||||
i = fcntl(data_fd, F_GETFL, 0);
|
||||
if (i < 0) {
|
||||
perror("ERROR:Can't open input");
|
||||
exit(1);
|
||||
}
|
||||
i &= ~O_NONBLOCK;
|
||||
i = fcntl(data_fd, F_SETFL, i);
|
||||
if (i < 0) {
|
||||
perror("ERROR:Can't open input");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Ignore SIGPIPE */
|
||||
|
|
|
@ -150,6 +150,7 @@ int read_data(struct libusb_device_handle *dev, uint8_t endp,
|
|||
/* Exported data */
|
||||
extern int terminate;
|
||||
extern int dyesub_debug;
|
||||
extern int fast_return;
|
||||
|
||||
/* External data */
|
||||
extern struct dyesub_backend updr150_backend;
|
||||
|
|
|
@ -52,8 +52,6 @@ struct mitsu9550_ctx {
|
|||
|
||||
int is_s_variant;
|
||||
|
||||
int fast_return;
|
||||
|
||||
uint16_t rows;
|
||||
uint16_t cols;
|
||||
};
|
||||
|
@ -149,10 +147,6 @@ static void *mitsu9550_init(void)
|
|||
}
|
||||
memset(ctx, 0, sizeof(struct mitsu9550_ctx));
|
||||
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI") || getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -592,12 +586,12 @@ top:
|
|||
if (!sts->sts1) /* If printer transitions to idle */
|
||||
break;
|
||||
|
||||
if (ctx->fast_return && !be16_to_cpu(sts->copies)) { /* No remaining prints */
|
||||
if (fast_return && !be16_to_cpu(sts->copies)) { /* No remaining prints */
|
||||
INFO("Fast return mode enabled.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx->fast_return && !sts->sts5) { /* Ready for another job */
|
||||
if (fast_return && !sts->sts5) { /* Ready for another job */
|
||||
INFO("Fast return mode enabled.\n");
|
||||
break;
|
||||
}
|
||||
|
@ -744,7 +738,6 @@ static void mitsu9550_cmdline(void)
|
|||
{
|
||||
DEBUG("\t\t[ -m ] # Query media\n");
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
DEBUG("\t\t[ -f ] # Enable fast return mode\n");
|
||||
}
|
||||
|
||||
static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
|
||||
|
@ -755,7 +748,7 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "mfs")) >= 0) {
|
||||
while ((i = getopt(argc, argv, "ms")) >= 0) {
|
||||
switch(i) {
|
||||
case 'm':
|
||||
if (ctx) {
|
||||
|
@ -769,13 +762,6 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
return 1;
|
||||
|
||||
case 'f':
|
||||
if (ctx) {
|
||||
ctx->fast_return = 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
break; /* Ignore completely */
|
||||
}
|
||||
|
|
|
@ -403,7 +403,6 @@ struct shinkos1245_ctx {
|
|||
uint8_t endp_up;
|
||||
uint8_t endp_down;
|
||||
uint8_t jobid;
|
||||
uint8_t fast_return;
|
||||
|
||||
struct s1245_printjob_hdr hdr;
|
||||
|
||||
|
@ -1140,7 +1139,6 @@ done:
|
|||
|
||||
static void shinkos1245_cmdline(void)
|
||||
{
|
||||
DEBUG("\t\t[ -f ] # Use fast return mode\n");
|
||||
DEBUG("\t\t[ -m ] # Query media\n");
|
||||
DEBUG("\t\t[ -s ] # Query status\n");
|
||||
DEBUG("\t\t[ -u ] # Query user string\n");
|
||||
|
@ -1161,7 +1159,7 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "c:C:l:L:FfmsuU:X:")) >= 0) {
|
||||
while ((i = getopt(argc, argv, "c:C:l:L:FmsuU:X:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'F':
|
||||
if (ctx) {
|
||||
|
@ -1193,12 +1191,6 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
return 2;
|
||||
case 'f':
|
||||
if (ctx) {
|
||||
ctx->fast_return = 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'm':
|
||||
if (ctx) {
|
||||
j = shinkos1245_get_media(ctx);
|
||||
|
@ -1260,10 +1252,6 @@ static void *shinkos1245_init(void)
|
|||
}
|
||||
memset(ctx, 0, sizeof(struct shinkos1245_ctx));
|
||||
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI") || getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
ctx->tonecurve = PARAM_TABLE_STANDARD;
|
||||
|
||||
return ctx;
|
||||
|
@ -1554,7 +1542,7 @@ top:
|
|||
break;
|
||||
}
|
||||
case S_PRINTER_SENT_DATA:
|
||||
if (ctx->fast_return) {
|
||||
if (fast_return) {
|
||||
INFO("Fast return mode enabled.\n");
|
||||
state = S_FINISHED;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ struct shinkos2145_ctx {
|
|||
uint8_t endp_up;
|
||||
uint8_t endp_down;
|
||||
uint8_t jobid;
|
||||
uint8_t fast_return;
|
||||
|
||||
struct s2145_printjob_hdr hdr;
|
||||
|
||||
|
@ -1294,7 +1293,7 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "b:c:C:efFil:L:mr:R:suU:X:")) >= 0) {
|
||||
while ((i = getopt(argc, argv, "b:c:C:eFil:L:mr:R:suU:X:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'b':
|
||||
if (ctx) {
|
||||
|
@ -1325,12 +1324,6 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'f':
|
||||
if (ctx) {
|
||||
ctx->fast_return = 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'F':
|
||||
if (ctx) {
|
||||
j = flash_led(ctx);
|
||||
|
@ -1418,10 +1411,6 @@ static void *shinkos2145_init(void)
|
|||
}
|
||||
memset(ctx, 0, sizeof(struct shinkos2145_ctx));
|
||||
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI") || getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -1660,7 +1649,7 @@ static int shinkos2145_main_loop(void *vctx, int copies) {
|
|||
state = S_PRINTER_SENT_DATA;
|
||||
break;
|
||||
case S_PRINTER_SENT_DATA:
|
||||
if (ctx->fast_return) {
|
||||
if (fast_return) {
|
||||
INFO("Fast return mode enabled.\n");
|
||||
state = S_FINISHED;
|
||||
} else if (sts->hdr.status == STATUS_READY ||
|
||||
|
|
|
@ -99,7 +99,6 @@ struct shinkos6145_ctx {
|
|||
uint8_t endp_up;
|
||||
uint8_t endp_down;
|
||||
uint8_t jobid;
|
||||
uint8_t fast_return;
|
||||
|
||||
struct s6145_printjob_hdr hdr;
|
||||
|
||||
|
@ -1362,7 +1361,6 @@ static void shinkos6145_cmdline(void)
|
|||
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[ -i ] # Query printer info\n");
|
||||
DEBUG("\t\t[ -k num ] # Set sleep time (5-240 minutes)\n");
|
||||
|
@ -1383,7 +1381,7 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "c:C:efFik:l:L:mr:R:sX:")) >= 0) {
|
||||
while ((i = getopt(argc, argv, "c:C:eFik:l:L:mr:R:sX:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'c':
|
||||
if (ctx) {
|
||||
|
@ -1403,12 +1401,6 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'f':
|
||||
if (ctx) {
|
||||
ctx->fast_return = 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'F':
|
||||
if (ctx) {
|
||||
j = flash_led(ctx);
|
||||
|
@ -1503,10 +1495,6 @@ static void *shinkos6145_init(void)
|
|||
}
|
||||
memset(ctx, 0, sizeof(struct shinkos6145_ctx));
|
||||
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI") || getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -1786,7 +1774,7 @@ top:
|
|||
state = S_PRINTER_SENT_DATA;
|
||||
break;
|
||||
case S_PRINTER_SENT_DATA:
|
||||
if (ctx->fast_return) {
|
||||
if (fast_return) {
|
||||
INFO("Fast return mode enabled.\n");
|
||||
state = S_FINISHED;
|
||||
} else if (sts->hdr.status == STATUS_READY) {
|
||||
|
|
|
@ -94,7 +94,6 @@ struct shinkos6245_ctx {
|
|||
uint8_t endp_up;
|
||||
uint8_t endp_down;
|
||||
uint8_t jobid;
|
||||
uint8_t fast_return;
|
||||
|
||||
struct s6245_printjob_hdr hdr;
|
||||
|
||||
|
@ -1356,7 +1355,6 @@ static void shinkos6245_cmdline(void)
|
|||
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[ -i ] # Query printer info\n");
|
||||
DEBUG("\t\t[ -k num ] # Set sleep time (5-240 minutes)\n");
|
||||
|
@ -1377,7 +1375,7 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
/* Reset arg parsing */
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((i = getopt(argc, argv, "c:C:efFik:l:L:mr:R:sX:")) >= 0) {
|
||||
while ((i = getopt(argc, argv, "c:C:eFik:l:L:mr:R:sX:")) >= 0) {
|
||||
switch(i) {
|
||||
case 'c':
|
||||
if (ctx) {
|
||||
|
@ -1397,12 +1395,6 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'f':
|
||||
if (ctx) {
|
||||
ctx->fast_return = 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case 'F':
|
||||
if (ctx) {
|
||||
j = flash_led(ctx);
|
||||
|
@ -1497,10 +1489,6 @@ static void *shinkos6245_init(void)
|
|||
}
|
||||
memset(ctx, 0, sizeof(struct shinkos6245_ctx));
|
||||
|
||||
/* Use Fast return by default in CUPS mode */
|
||||
if (getenv("DEVICE_URI") || getenv("FAST_RETURN"))
|
||||
ctx->fast_return = 1;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -1771,7 +1759,7 @@ top:
|
|||
state = S_PRINTER_SENT_DATA;
|
||||
break;
|
||||
case S_PRINTER_SENT_DATA:
|
||||
if (ctx->fast_return) {
|
||||
if (fast_return) {
|
||||
INFO("Fast return mode enabled.\n");
|
||||
state = S_FINISHED;
|
||||
} else if (sts->hdr.status == STATUS_READY) {
|
||||
|
|
Loading…
Reference in New Issue