HP-backend V0.96. Check device names to prevent USB-device to be

opened as SCSI-device
DEVEL_2_0_BRANCH-1
Peter Kirchgessner 2002-08-06 19:33:08 +00:00
rodzic 36a0e0d332
commit f60b851fa7
2 zmienionych plików z 62 dodań i 14 usunięć

Wyświetl plik

@ -598,23 +598,56 @@ HpConnect
sanei_hp_get_connect (const char *devname) sanei_hp_get_connect (const char *devname)
{const HpDeviceInfo *info; {const HpDeviceInfo *info;
HpConnect connect = HP_CONNECT_SCSI;
int got_connect_type = 0;
info = sanei_hp_device_info_get (devname); info = sanei_hp_device_info_get (devname);
if (!info) if (!info)
{ {
DBG(1, "sanei_hp_get_connect: Could not get info for %s. Assume SCSI\n", DBG(1, "sanei_hp_get_connect: Could not get info for %s. Assume SCSI\n",
devname); devname);
return HP_CONNECT_SCSI; connect = HP_CONNECT_SCSI;
} }
else
if ( !(info->config_is_up) ) if ( !(info->config_is_up) )
{ {
DBG(1, "sanei_hp_get_connect: Config not initialized for %s. Assume SCSI\n", DBG(1, "sanei_hp_get_connect: Config not initialized for %s. Assume SCSI\n",
devname); devname);
return HP_CONNECT_SCSI; connect = HP_CONNECT_SCSI;
}
else
{
connect = info->config.connect;
got_connect_type = info->config.got_connect_type;
} }
return info->config.connect; /* Beware of using a USB-device as a SCSI-device (not 100% perfect) */
if ((connect == HP_CONNECT_SCSI) && !got_connect_type)
{int maybe_usb;
maybe_usb = ( strstr (devname, "usb")
|| strstr (devname, "uscanner")
|| strstr (devname, "ugen"));
if (maybe_usb)
{static int print_warning = 1;
if (print_warning)
{
print_warning = 0;
DBG(1,"sanei_hp_get_connect: WARNING\n");
DBG(1," Device %s assumed to be SCSI, but device name\n",devname);
DBG(1," looks like USB. Will continue with USB.\n");
DBG(1," If you really want it as SCSI, add the following\n");
DBG(1," to your file .../etc/sane.d/hp.conf:\n");
DBG(1," %s\n", devname);
DBG(1," option connect-scsi\n");
DBG(1," The same warning applies to other device names containing\n");
DBG(1," \"usb\", \"uscanner\" or \"ugen\".\n");
}
connect = HP_CONNECT_DEVICE;
}
}
return connect;
} }
HpConnect HpConnect
@ -1262,6 +1295,7 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
hp_byte_t cmd[6]; hp_byte_t cmd[6];
hp_byte_t data[HP_PIPEBUF]; hp_byte_t data[HP_PIPEBUF];
} buf[2], *req = NULL; } buf[2], *req = NULL;
int reqs_completed = 0; int reqs_completed = 0;
int reqs_issued = 0; int reqs_issued = 0;
char *image_buf = 0; char *image_buf = 0;
@ -1271,12 +1305,13 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
int enable_requests = 1; int enable_requests = 1;
int enable_image_buffering = 0; int enable_image_buffering = 0;
const unsigned char *map = NULL; const unsigned char *map = NULL;
HpConnect connect = HP_CONNECT_SCSI; HpConnect connect;
PROCDATA_HANDLE *ph = NULL; PROCDATA_HANDLE *ph = NULL;
size_t count = procdata->lines * procdata->bytes_per_line; size_t count = procdata->lines * procdata->bytes_per_line;
RETURN_IF_FAIL( hp_scsi_flush(this) ); RETURN_IF_FAIL( hp_scsi_flush(this) );
connect = sanei_hp_get_connect (devname);
info = sanei_hp_device_info_get (devname); info = sanei_hp_device_info_get (devname);
assert (info); assert (info);
@ -1285,7 +1320,6 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
{ {
enable_requests = info->config.use_scsi_request; enable_requests = info->config.use_scsi_request;
enable_image_buffering = info->config.use_image_buffering; enable_image_buffering = info->config.use_image_buffering;
connect = info->config.connect;
} }
else else
{ {

Wyświetl plik

@ -43,9 +43,12 @@
HP Scanner Control Language (SCL). HP Scanner Control Language (SCL).
*/ */
static char *hp_backend_version = "0.95"; static char *hp_backend_version = "0.96";
/* Changes: /* Changes:
V 0.96, 05-Aug-2001, PK (peter@kirchgessner.net)
- check USB device names
V 0.95, 07-Jul-2001, PK (peter@kirchgessner.net) V 0.95, 07-Jul-2001, PK (peter@kirchgessner.net)
- add support for active XPA - add support for active XPA
- check if paper in ADF for ADF scan - check if paper in ADF for ADF scan
@ -324,6 +327,7 @@ hp_init_config (HpDeviceConfig *config)
config->connect = HP_CONNECT_SCSI; config->connect = HP_CONNECT_SCSI;
config->use_scsi_request = 1; config->use_scsi_request = 1;
config->use_image_buffering = 0; config->use_image_buffering = 0;
config->got_connect_type = 0;
} }
} }
@ -607,31 +611,37 @@ hp_read_config (void)
if (strcmp (arg2, "connect-scsi") == 0) if (strcmp (arg2, "connect-scsi") == 0)
{ {
config->connect = HP_CONNECT_SCSI; config->connect = HP_CONNECT_SCSI;
config->got_connect_type = 1;
} }
else if (strcmp (arg2, "connect-device") == 0) else if (strcmp (arg2, "connect-device") == 0)
{ {
config->connect = HP_CONNECT_DEVICE; config->connect = HP_CONNECT_DEVICE;
config->got_connect_type = 1;
config->use_scsi_request = 0; config->use_scsi_request = 0;
} }
else if (strcmp (arg2, "connect-pio") == 0) else if (strcmp (arg2, "connect-pio") == 0)
{ {
config->connect = HP_CONNECT_PIO; config->connect = HP_CONNECT_PIO;
config->got_connect_type = 1;
config->use_scsi_request = 0; config->use_scsi_request = 0;
} }
else if (strcmp (arg2, "connect-usb") == 0) else if (strcmp (arg2, "connect-usb") == 0)
{ {
config->connect = HP_CONNECT_USB; config->connect = HP_CONNECT_USB;
config->got_connect_type = 1;
config->use_scsi_request = 0; config->use_scsi_request = 0;
} }
else if (strcmp (arg2, "connect-reserve") == 0) else if (strcmp (arg2, "connect-reserve") == 0)
{ {
config->connect = HP_CONNECT_RESERVE; config->connect = HP_CONNECT_RESERVE;
config->got_connect_type = 1;
config->use_scsi_request = 0; config->use_scsi_request = 0;
} }
else if (strcmp (arg2, "connect-ptal") == 0) else if (strcmp (arg2, "connect-ptal") == 0)
{ {
#ifdef HAVE_PTAL #ifdef HAVE_PTAL
config->connect = HP_CONNECT_PTAL; config->connect = HP_CONNECT_PTAL;
config->got_connect_type = 1;
config->use_scsi_request = 0; config->use_scsi_request = 0;
#else #else
DBG(0,"hp_read_config: connect-ptal:\n"); DBG(0,"hp_read_config: connect-ptal:\n");
@ -655,12 +665,14 @@ hp_read_config (void)
{ {
if (is_df_config) /* Did we only read default configurations ? */ if (is_df_config) /* Did we only read default configurations ? */
{ {
is_df_config = 0; is_df_config = 0; /* Stop reading default config */
config = &dev_config; /* Initialize device config with default-config */
memcpy (&dev_config, &df_config, sizeof (dev_config));
config = &dev_config; /* Start reading a device config */
} }
if (cu_device[0] != '\0') /* Did we work on a device ? */ if (cu_device[0] != '\0') /* Did we work on a device ? */
{ {
memcpy (hp_global_config_get (), &dev_config, sizeof (dev_config)); memcpy (hp_global_config_get (), &dev_config,sizeof (dev_config));
DBG(1, "hp_read_config: attach %s\n", cu_device); DBG(1, "hp_read_config: attach %s\n", cu_device);
sanei_config_attach_matching_devices (cu_device, hp_attach); sanei_config_attach_matching_devices (cu_device, hp_attach);
cu_device[0] = '\0'; cu_device[0] = '\0';
@ -682,6 +694,8 @@ hp_read_config (void)
cu_device[0] = '\0'; cu_device[0] = '\0';
} }
fclose (fp); fclose (fp);
DBG(1, "hp_read_config: reset to default config\n");
memcpy (hp_global_config_get (), &df_config, sizeof (df_config));
} }
else else
{ {