backends: Revamp cmdline args so you can specify multiple backend args at once.

This commit is contained in:
Solomon Peachy 2014-02-11 22:45:14 -05:00
parent b8242fe847
commit 1faa032ea6
6 changed files with 167 additions and 129 deletions

View File

@ -939,7 +939,7 @@ static void dnpds40_cmdline(void)
static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
{
struct dnpds40_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -947,38 +947,44 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv)
while ((i = getopt(argc, argv, "inN:p:s")) >= 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;
j = dnpds40_get_info(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 -1;
if (ctx) {
j = dnpds40_clear_counter(ctx, optarg[0]);
break;
}
return 1;
case 'p':
if (ctx)
return dnpds40_set_counter_p(ctx, optarg);
else
return 1;
if (ctx) {
j = dnpds40_set_counter_p(ctx, optarg);
break;
}
return 1;
case 's':
if (ctx)
return dnpds40_get_status(ctx);
else
return 1;
if (ctx) {
j = dnpds40_get_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -987,7 +993,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.28",
.version = "0.29",
.uri_prefix = "dnpds40",
.cmdline_usage = dnpds40_cmdline,
.cmdline_arg = dnpds40_cmdline_arg,

View File

@ -251,7 +251,7 @@ static void kodak1400_cmdline(void)
int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
{
struct kodak1400_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -259,13 +259,16 @@ int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
while ((i = getopt(argc, argv, "C:")) >= 0) {
switch(i) {
case 'C':
if (ctx)
return kodak1400_set_tonecurve(ctx, optarg);
else
return 1;
if (ctx) {
j = kodak1400_set_tonecurve(ctx, optarg);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -593,7 +596,7 @@ top:
struct dyesub_backend kodak1400_backend = {
.name = "Kodak 1400/805",
.version = "0.30",
.version = "0.31",
.uri_prefix = "kodak1400",
.cmdline_usage = kodak1400_cmdline,
.cmdline_arg = kodak1400_cmdline_arg,

View File

@ -483,7 +483,7 @@ static void kodak605_cmdline(void)
static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
{
struct kodak605_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -491,23 +491,28 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
while ((i = getopt(argc, argv, "C:ms")) >= 0) {
switch(i) {
case 'C':
if (ctx)
return kodak605_set_tonecurve(ctx, optarg);
else
return 1;
if (ctx) {
j = kodak605_set_tonecurve(ctx, optarg);
break;
}
return 1;
case 'm':
if (ctx)
return kodak605_get_media(ctx);
else
return 1;
if (ctx) {
j = kodak605_get_media(ctx);
break;
}
return 1;
case 's':
if (ctx)
return kodak605_get_status(ctx);
else
return 1;
if (ctx) {
j = kodak605_get_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -516,7 +521,7 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend kodak605_backend = {
.name = "Kodak 605",
.version = "0.17",
.version = "0.18",
.uri_prefix = "kodak605",
.cmdline_usage = kodak605_cmdline,
.cmdline_arg = kodak605_cmdline_arg,

View File

@ -294,7 +294,7 @@ static void kodak6800_cmdline(void)
static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
{
struct kodak6800_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -302,18 +302,22 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
while ((i = getopt(argc, argv, "C:c:")) >= 0) {
switch(i) {
case 'c':
if (ctx)
return kodak6800_get_tonecurve(ctx, optarg);
else
return 1;
if (ctx) {
j = kodak6800_get_tonecurve(ctx, optarg);
break;
}
return 1;
case 'C':
if (ctx)
return kodak6800_set_tonecurve(ctx, optarg);
else
return 1;
if (ctx) {
j = kodak6800_set_tonecurve(ctx, optarg);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -632,7 +636,7 @@ skip_query:
/* Exported */
struct dyesub_backend kodak6800_backend = {
.name = "Kodak 6800/6850",
.version = "0.31",
.version = "0.32",
.uri_prefix = "kodak6800",
.cmdline_usage = kodak6800_cmdline,
.cmdline_arg = kodak6800_cmdline_arg,

View File

@ -380,7 +380,7 @@ static void mitsu70x_cmdline(void)
static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
{
struct mitsu70x_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -388,13 +388,16 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
while ((i = getopt(argc, argv, "s")) >= 0) {
switch(i) {
case 's':
if (ctx)
return mitsu70x_get_status(ctx);
else
return 1;
if (ctx) {
j = mitsu70x_get_status(ctx);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -404,7 +407,7 @@ static int mitsu70x_cmdline_arg(void *vctx, int argc, char **argv)
/* Exported */
struct dyesub_backend mitsu70x_backend = {
.name = "Mitsubishi CP-D70/D707",
.version = "0.11",
.version = "0.12",
.uri_prefix = "mitsu70x",
.cmdline_usage = mitsu70x_cmdline,
.cmdline_arg = mitsu70x_cmdline_arg,

View File

@ -1324,7 +1324,7 @@ static void shinkos2145_cmdline(void)
int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
{
struct shinkos2145_ctx *ctx = vctx;
int i;
int i, j = 0;
/* Reset arg parsing */
optind = 1;
@ -1334,92 +1334,109 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv)
case 'b':
if (ctx) {
if (optarg[0] == '1')
return button_set(ctx, BUTTON_ENABLED);
j = button_set(ctx, BUTTON_ENABLED);
else if (optarg[0] == '0')
return button_set(ctx, BUTTON_DISABLED);
j = button_set(ctx, BUTTON_DISABLED);
else
return -1;
} else
return 1;
break;
}
return 1;
case 'c':
if (ctx)
return get_tonecurve(ctx, TONECURVE_USER, optarg);
else
return 1;
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'C':
if (ctx)
return set_tonecurve(ctx, TONECURVE_USER, optarg);
else
return 1;
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_USER, optarg);
break;
}
return 1;
case 'e':
if (ctx)
return get_errorlog(ctx);
else
return 1;
if (ctx) {
j = get_errorlog(ctx);
break;
}
return 1;
case 'f':
if (ctx) {
ctx->fast_return = 1;
return 0;
} else
return 1;
break;
}
return 1;
case 'F':
if (ctx)
return flash_led(ctx);
else
return 1;
if (ctx) {
j = flash_led(ctx);
break;
}
return 1;
case 'i':
if (ctx)
return get_fwinfo(ctx);
else
return 1;
if (ctx) {
j = get_fwinfo(ctx);
break;
}
return 1;
case 'l':
if (ctx)
return get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
else
return 1;
if (ctx) {
j = get_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'L':
if (ctx)
return set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
else
return 1;
if (ctx) {
j = set_tonecurve(ctx, TONECURVE_CURRENT, optarg);
break;
}
return 1;
case 'm':
if (ctx)
return get_mediainfo(ctx);
else
return 1;
if (ctx) {
j = get_mediainfo(ctx);
break;
}
return 1;
case 'r':
if (ctx)
return reset_curve(ctx, RESET_USER_CURVE);
else
return 1;
if (ctx) {
j = reset_curve(ctx, RESET_USER_CURVE);
break;
}
return 1;
case 'R':
if (ctx)
return reset_curve(ctx, RESET_PRINTER);
else
return 1;
if (ctx) {
j = reset_curve(ctx, RESET_PRINTER);
break;
}
return 1;
case 's':
if (ctx)
return get_status(ctx);
else
return 1;
if (ctx) {
j = get_status(ctx);
break;
}
return 1;
case 'u':
if (ctx)
return get_user_string(ctx);
else
return 1;
if (ctx) {
j = get_user_string(ctx);
break;
}
return 1;
case 'U':
if (ctx)
return set_user_string(ctx, optarg);
else
return 1;
if (ctx) {
j = set_user_string(ctx, optarg);
break;
}
return 1;
case 'X':
if (ctx)
return cancel_job(ctx, optarg);
else
return 1;
if (ctx) {
j = cancel_job(ctx, optarg);
break;
}
return 1;
default:
break; /* Ignore completely */
}
if (j) return j;
}
return 0;
@ -1727,7 +1744,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.30",
.version = "0.31",
.uri_prefix = "shinkos2145",
.cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg,