all: Get rid of the remainder of the old two-stage cmdline parsing

All backend->cmdline_arg() invocations are done with intent to execute!
This commit is contained in:
Solomon Peachy 2015-08-24 17:28:10 -04:00
parent 3da69ee55b
commit b343d56f1e
13 changed files with 299 additions and 489 deletions

View File

@ -955,10 +955,11 @@ top:
static int canonselphy_cmdline_arg(void *vctx, int argc, char **argv)
{
// struct canonselphy_ctx *ctx = vctx;
struct canonselphy_ctx *ctx = vctx;
int i, j = 0;
UNUSED(vctx);
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
@ -976,7 +977,7 @@ static int canonselphy_cmdline_arg(void *vctx, int argc, char **argv)
struct dyesub_backend canonselphy_backend = {
.name = "Canon SELPHY CP/ES",
.version = "0.88",
.version = "0.89",
.uri_prefix = "canonselphy",
.cmdline_arg = canonselphy_cmdline_arg,
.init = canonselphy_init,

View File

@ -823,6 +823,9 @@ static int cw01_cmdline_arg(void *vctx, int argc, char **argv)
struct cw01_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -830,32 +833,20 @@ static int cw01_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'i':
if (ctx) {
j = cw01_get_info(ctx);
break;
}
return 1;
case 'n':
if (ctx) {
j = cw01_get_counters(ctx);
break;
}
return 1;
case 'N':
if (optarg[0] != 'A' &&
optarg[0] != 'B')
return CUPS_BACKEND_FAILED;
if (ctx) {
j = cw01_clear_counter(ctx, optarg[0]);
break;
}
return 2;
case 's':
if (ctx) {
j = cw01_get_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -869,7 +860,7 @@ static int cw01_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend cw01_backend = {
.name = "Citizen CW-01",
.version = "0.11",
.version = "0.12",
.uri_prefix = "citizencw01",
.cmdline_usage = cw01_cmdline,
.cmdline_arg = cw01_cmdline_arg,

View File

@ -1572,6 +1572,9 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
struct dnpds40_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -1579,51 +1582,32 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'i':
if (ctx) {
j = dnpds40_get_info(ctx);
break;
}
return 1;
case 'I':
if (ctx) {
j = dnpds40_get_sensors(ctx);
break;
}
return 1;
case 'n':
if (ctx) {
j = dnpds40_get_counters(ctx);
break;
}
return 1;
case 'N':
if (optarg[0] != 'A' &&
optarg[0] != 'B' &&
optarg[0] != 'M')
return CUPS_BACKEND_FAILED;
if (ctx) {
if (!ctx->supports_matte) {
ERROR("Printer FW does not support matte functions, please update!\n");
return CUPS_BACKEND_FAILED;
}
j = dnpds40_clear_counter(ctx, optarg[0]);
break;
}
return 2;
case 'p':
if (ctx) {
j = dnpds40_set_counter_p(ctx, optarg);
break;
}
return 2;
case 's':
if (ctx) {
j = dnpds40_get_status(ctx);
break;
}
return 1;
case 'k':
if (ctx) {
case 'k': {
int time = atoi(optarg);
if (!ctx->supports_standby) {
ERROR("Printer does not support standby\n");
@ -1638,9 +1622,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
j = dnpds620_standby_mode(ctx, time);
break;
}
return 2;
case 'K':
if (ctx) {
case 'K': {
int keep = atoi(optarg);
if (!ctx->supports_standby) {
ERROR("Printer does not support media keep mode\n");
@ -1655,9 +1637,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
j = dnpds620_media_keep_mode(ctx, keep);
break;
}
return 2;
case 'x':
if (ctx) {
case 'x': {
int enable = atoi(optarg);
if (!ctx->supports_iserial) {
ERROR("Printer does not support USB iSerialNumber reporting\n");
@ -1672,7 +1652,6 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
j = dnpds620_iserial_mode(ctx, enable);
break;
}
return 2;
default:
break; /* Ignore completely */
}
@ -1686,7 +1665,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend dnpds40_backend = {
.name = "DNP DS40/DS80/DSRX1/DS620",
.version = "0.60",
.version = "0.61",
.uri_prefix = "dnpds40",
.cmdline_usage = dnpds40_cmdline,
.cmdline_arg = dnpds40_cmdline_arg,

View File

@ -261,6 +261,9 @@ int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
struct kodak1400_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -268,11 +271,8 @@ int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'C':
if (ctx) {
j = kodak1400_set_tonecurve(ctx, optarg);
break;
}
return 2;
default:
break; /* Ignore completely */
}
@ -614,7 +614,7 @@ top:
struct dyesub_backend kodak1400_backend = {
.name = "Kodak 1400/805",
.version = "0.33",
.version = "0.34",
.uri_prefix = "kodak1400",
.cmdline_usage = kodak1400_cmdline,
.cmdline_arg = kodak1400_cmdline_arg,

View File

@ -491,6 +491,9 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
struct kodak605_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -498,23 +501,12 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'C':
if (ctx) {
j = kodak605_set_tonecurve(ctx, optarg);
break;
}
return 2;
case 'm':
if (ctx) {
uint8_t mediabuf[MAX_MEDIA_LEN];
struct kodak605_media_list *media = (struct kodak605_media_list *)mediabuf;
j = kodak605_get_media(ctx, media);
if (!j)
kodak605_dump_mediainfo(media);
kodak605_dump_mediainfo(ctx->media);
break;
}
return 1;
case 's':
if (ctx) {
case 's': {
struct kodak605_status sts;
j = kodak605_get_status(ctx, &sts);
@ -522,7 +514,6 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
kodak605_dump_status(&sts);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -536,7 +527,7 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend kodak605_backend = {
.name = "Kodak 605",
.version = "0.22",
.version = "0.23",
.uri_prefix = "kodak605",
.cmdline_usage = kodak605_cmdline,
.cmdline_arg = kodak605_cmdline_arg,

View File

@ -584,6 +584,9 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
struct kodak6800_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -591,39 +594,21 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'c':
if (ctx) {
j = kodak6800_get_tonecurve(ctx, optarg);
break;
}
return 2;
case 'C':
if (ctx) {
j = kodak6800_set_tonecurve(ctx, optarg);
break;
}
return 2;
case 'm':
if (ctx) {
j = kodak6800_get_mediainfo(ctx, ctx->media);
if (!j)
kodak68x0_dump_mediainfo(ctx->media);
break;
}
return 1;
case 's':
if (ctx) {
case 's': {
struct kodak68x0_status_readback status;
j = kodak6800_get_mediainfo(ctx, ctx->media);
if (!j)
j = kodak6800_get_status(ctx, &status);
if (!j)
kodak68x0_dump_status(ctx, &status);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -883,7 +868,7 @@ static int kodak6800_main_loop(void *vctx, int copies) {
/* Exported */
struct dyesub_backend kodak6800_backend = {
.name = "Kodak 6800/6850",
.version = "0.46",
.version = "0.47",
.uri_prefix = "kodak6800",
.cmdline_usage = kodak6800_cmdline,
.cmdline_arg = kodak6800_cmdline_arg,

View File

@ -568,6 +568,9 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
struct mitsu70x_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -575,11 +578,8 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 's':
if (ctx) {
j = mitsu70x_query_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -594,7 +594,7 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend mitsu70x_backend = {
.name = "Mitsubishi CP-D70/D707/K60",
.version = "0.31",
.version = "0.32",
.uri_prefix = "mitsu70x",
.cmdline_usage = mitsu70x_cmdline,
.cmdline_arg = mitsu70x_cmdline_arg,

View File

@ -737,6 +737,9 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
struct mitsu9550_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -744,17 +747,11 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'm':
if (ctx) {
j = mitsu9550_query_media(ctx);
break;
}
return 1;
case 's':
if (ctx) {
j = mitsu9550_query_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -768,7 +765,7 @@ static int mitsu9550_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend mitsu9550_backend = {
.name = "Mitsubishi CP-9550DW-S",
.version = "0.14",
.version = "0.15",
.uri_prefix = "mitsu9550",
.cmdline_usage = mitsu9550_cmdline,
.cmdline_arg = mitsu9550_cmdline_arg,

View File

@ -1165,6 +1165,9 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
struct shinkos1245_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -1172,54 +1175,33 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'F':
if (ctx) {
ctx->tonecurve = PARAM_TABLE_FINE;
break;
}
return 1;
case 'c':
if (ctx) {
j = get_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg);
break;
}
return 2;
case 'C':
if (ctx) {
j = set_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg);
break;
}
return 2;
case 'l':
if (ctx) {
j = get_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg);
break;
}
return 2;
case 'L':
if (ctx) {
j = set_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg);
break;
}
return 2;
case 'm':
if (ctx) {
j = shinkos1245_get_media(ctx);
if (!j)
shinkos1245_dump_media(ctx->medias, ctx->num_medias);
break;
}
return 1;
case 's':
if (ctx) {
case 's': {
struct shinkos1245_resp_status sts;
j = shinkos1245_get_status(ctx, &sts);
if (!j)
shinkos1245_dump_status(&sts);
break;
}
return 1;
case 'u':
if (ctx) {
case 'u': {
struct shinkos1245_resp_getid resp;
j = shinkos1245_get_printerid(ctx, &resp);
if (!j) {
@ -1227,22 +1209,15 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
memcpy(buffer, resp.data, sizeof(resp.data));
buffer[sizeof(resp.data)] = 0;
INFO("Printer ID: %02x '%s'\n", resp.id, buffer);
}
break;
}
}
return 1;
case 'U':
if (ctx) {
j = shinkos1245_set_printerid(ctx, optarg);
break;
}
return 1;
case 'X':
if (ctx) {
j = shinkos1245_canceljob(ctx, atoi(optarg));
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -1631,7 +1606,7 @@ static int shinkos1245_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos1245_backend = {
.name = "Shinko/Sinfonia CHC-S1245",
.version = "0.05WIP",
.version = "0.06WIP",
.uri_prefix = "shinkos1245",
.cmdline_usage = shinkos1245_cmdline,
.cmdline_arg = shinkos1245_cmdline_arg,

View File

@ -1293,6 +1293,9 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
struct shinkos2145_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -1300,7 +1303,6 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'b':
if (ctx) {
if (optarg[0] == '1')
j = button_set(ctx, BUTTON_ENABLED);
else if (optarg[0] == '0')
@ -1308,92 +1310,48 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
else
return -1;
break;
}
return 2;
case 'c':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 2;
case 'C':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 2;
case 'e':
if (ctx) {
j = get_errorlog(ctx);
break;
}
return 1;
case 'F':
if (ctx) {
j = flash_led(ctx);
break;
}
return 1;
case 'i':
if (ctx) {
j = get_fwinfo(ctx);
break;
}
return 1;
case 'l':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 2;
case 'L':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 2;
case 'm':
if (ctx) {
j = get_mediainfo(ctx);
break;
}
return 1;
case 'r':
if (ctx) {
j = reset_curve(ctx, RESET_USER_CURVE);
break;
}
return 1;
case 'R':
if (ctx) {
j = reset_curve(ctx, RESET_PRINTER);
break;
}
return 1;
case 's':
if (ctx) {
j = get_status(ctx);
break;
}
return 1;
case 'u':
if (ctx) {
j = get_user_string(ctx);
break;
}
return 1;
case 'U':
if (ctx) {
j = set_user_string(ctx, optarg);
break;
}
return 2;
case 'X':
if (ctx) {
j = cancel_job(ctx, optarg);
break;
}
return 2;
default:
break; /* Ignore completely */
}
@ -1734,7 +1692,7 @@ static int shinkos2145_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145",
.version = "0.45",
.version = "0.46",
.uri_prefix = "shinkos2145",
.cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg,

View File

@ -1457,6 +1457,9 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
struct shinkos6145_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -1464,37 +1467,21 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'c':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'C':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'e':
if (ctx) {
j = get_errorlog(ctx);
break;
}
return 1;
case 'F':
if (ctx) {
j = flash_led(ctx);
break;
}
return 1;
case 'i':
if (ctx) {
j = get_fwinfo(ctx);
break;
}
return 1;
case 'k':
if (ctx) {
case 'k': {
uint32_t i = atoi(optarg);
if (i < 5)
i = 0;
@ -1515,47 +1502,26 @@ int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv)
break;
}
case 'l':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'L':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'm':
if (ctx) {
j = get_mediainfo(ctx);
break;
}
return 1;
case 'r':
if (ctx) {
j = reset_curve(ctx, RESET_TONE_CURVE);
break;
}
return 1;
case 'R':
if (ctx) {
j = reset_curve(ctx, RESET_PRINTER);
break;
}
return 1;
case 's':
if (ctx) {
j = get_status(ctx);
break;
}
return 1;
case 'X':
if (ctx) {
j = cancel_job(ctx, optarg);
break;
}
return 1;
default:
break; /* Ignore completely */
}

View File

@ -1376,6 +1376,9 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
struct shinkos6245_ctx *ctx = vctx;
int i, j = 0;
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;
opterr = 0;
@ -1383,37 +1386,21 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'c':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'C':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'e':
if (ctx) {
j = get_errorlog(ctx);
break;
}
return 1;
case 'F':
if (ctx) {
j = flash_led(ctx);
break;
}
return 1;
case 'i':
if (ctx) {
j = get_fwinfo(ctx);
break;
}
return 1;
case 'k':
if (ctx) {
case 'k': {
uint32_t i = atoi(optarg);
if (i < 5)
i = 0;
@ -1434,47 +1421,26 @@ int shinkos6245_cmdline_arg(void *vctx, int argc, char **argv)
break;
}
case 'l':
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'L':
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'm':
if (ctx) {
j = get_mediainfo(ctx);
break;
}
return 1;
case 'r':
if (ctx) {
j = reset_curve(ctx, RESET_TONE_CURVE);
break;
}
return 1;
case 'R':
if (ctx) {
j = reset_curve(ctx, RESET_PRINTER);
break;
}
return 1;
case 's':
if (ctx) {
j = get_status(ctx);
break;
}
return 1;
case 'X':
if (ctx) {
j = cancel_job(ctx, optarg);
break;
}
return 1;
default:
break; /* Ignore completely */
}
@ -1843,7 +1809,7 @@ static int shinkos6245_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos6245_backend = {
.name = "Shinko/Sinfonia CHC-S6245",
.version = "0.02WIP",
.version = "0.03WIP",
.uri_prefix = "shinkos6245",
.cmdline_usage = shinkos6245_cmdline,
.cmdline_arg = shinkos6245_cmdline_arg,

View File

@ -257,10 +257,11 @@ top:
static int updr150_cmdline_arg(void *vctx, int argc, char **argv)
{
// struct updr150_ctx *ctx = vctx;
struct updr150_ctx *ctx = vctx;
int i, j = 0;
UNUSED(vctx);
if (!ctx)
return -1;
/* Reset arg parsing */
optind = 1;