all: Simplify print_scan_output() a bit, eliminate the obsolete 'valid' argument.

This commit is contained in:
Solomon Peachy 2013-07-17 22:43:49 -04:00
parent 49f413543d
commit 937c687274
6 changed files with 13 additions and 22 deletions

View file

@ -28,7 +28,7 @@
#include <libusb-1.0/libusb.h>
#include <arpa/inet.h>
#define BACKEND_VERSION "0.4"
#define BACKEND_VERSION "0.5"
#define STR_LEN_MAX 64
#define DEBUG( ... ) fprintf(stderr, "DEBUG: " __VA_ARGS__ )
@ -162,7 +162,7 @@ static char *sanitize_string(char *str) {
static int print_scan_output(struct libusb_device *device,
struct libusb_device_descriptor *desc,
char *prefix, char *manuf2,
int found, int match, int valid,
int found, int match,
int scan_only, char *match_serno)
{
struct libusb_device_handle *dev;
@ -200,12 +200,11 @@ static int print_scan_output(struct libusb_device *device,
sprintf((char*)serial, "NONE_B%03d_D%03d", bus_num, port_num);
}
DEBUG("%s%sPID: %04X Manuf: '%s' Product: '%s' Serial: '%s'\n",
(!valid) ? "UNRECOGNIZED: " : "",
DEBUG("%sPID: %04X Manuf: '%s' Product: '%s' Serial: '%s'\n",
match ? "MATCH: " : "",
desc->idProduct, manuf, product, serial);
if (valid && scan_only) {
if (scan_only) {
/* URL-ify model. */
char buf[128]; // XXX ugly..
int j = 0, k = 0;

View file

@ -114,7 +114,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, "Kodak",
found, (found == i), 1,
found, (found == i),
scan_only, match_serno);
}

View file

@ -98,7 +98,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, "Kodak",
found, (found == i), 1,
found, (found == i),
scan_only, match_serno);
}

View file

@ -35,7 +35,7 @@
#include <fcntl.h>
#include <signal.h>
#define VERSION "0.55"
#define VERSION "0.56"
#define URI_PREFIX "canonselphy://"
#include "backend_common.c"
@ -368,7 +368,6 @@ static int find_and_enumerate(struct libusb_context *ctx,
for (i = 0 ; i < num ; i++) {
struct libusb_device_descriptor desc;
int valid = 0;
libusb_get_device_descriptor((*list)[i], &desc);
if (desc.idVendor != USB_VID_CANON)
@ -378,30 +377,25 @@ static int find_and_enumerate(struct libusb_context *ctx,
case USB_PID_CANON_ES1: // "Canon SELPHY ES1"
if (printer_type == P_ES1)
found = i;
valid = 1;
break;
case USB_PID_CANON_ES2: // "Canon SELPHY ES2"
case USB_PID_CANON_ES20: // "Canon SELPHY ES20"
if (printer_type == P_ES2_20)
found = i;
valid = 1;
break;
case USB_PID_CANON_ES3: // "Canon SELPHY ES3"
case USB_PID_CANON_ES30: // "Canon SELPHY ES30"
if (printer_type == P_ES3_30)
found = i;
valid = 1;
break;
case USB_PID_CANON_ES40: // "Canon SELPHY ES40"
case USB_PID_CANON_CP790:
if (printer_type == P_ES40_CP790)
found = i;
valid = 1;
break;
case USB_PID_CANON_CP10: // "Canon CP-10"
if (printer_type == P_CP10)
found = i;
valid = 1;
break;
case USB_PID_CANON_CP100: // "Canon CP-100"
case USB_PID_CANON_CP200: // "Canon CP-200"
@ -427,7 +421,6 @@ static int find_and_enumerate(struct libusb_context *ctx,
case USB_PID_CANON_CP900: // "Canon SELPHY CP900"
if (printer_type == P_CP_XXX)
found = i;
valid = 1;
break;
default:
/* Hook for testing unknown PIDs */
@ -435,18 +428,17 @@ static int find_and_enumerate(struct libusb_context *ctx,
int pid = strtol(getenv("SELPHY_PID"), NULL, 16);
int type = atoi(getenv("SELPHY_TYPE"));
if (pid == desc.idProduct) {
valid = 1;
if (printer_type == type) {
if (printer_type == type)
found = i;
}
break;
}
}
break;
continue;
}
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, "Canon",
found, (found == i), valid,
found, (found == i),
scan_only, match_serno);
}

View file

@ -620,7 +620,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, "",
found, (found == i), 1,
found, (found == i),
scan_only, match_serno);
}

View file

@ -77,7 +77,7 @@ static int find_and_enumerate(struct libusb_context *ctx,
found = print_scan_output((*list)[i], &desc,
URI_PREFIX, "",
found, (found == i), 1,
found, (found == i),
scan_only, match_serno);
}