kopia lustrzana https://gitlab.com/sane-project/backends
HP-backend V0.96. Check device names to prevent USB-device to be
opened as SCSI-deviceDEVEL_2_0_BRANCH-1
rodzic
36a0e0d332
commit
f60b851fa7
|
@ -598,23 +598,56 @@ HpConnect
|
|||
sanei_hp_get_connect (const char *devname)
|
||||
|
||||
{const HpDeviceInfo *info;
|
||||
HpConnect connect = HP_CONNECT_SCSI;
|
||||
int got_connect_type = 0;
|
||||
|
||||
info = sanei_hp_device_info_get (devname);
|
||||
if (!info)
|
||||
{
|
||||
DBG(1, "sanei_hp_get_connect: Could not get info for %s. Assume SCSI\n",
|
||||
devname);
|
||||
return HP_CONNECT_SCSI;
|
||||
connect = HP_CONNECT_SCSI;
|
||||
}
|
||||
|
||||
else
|
||||
if ( !(info->config_is_up) )
|
||||
{
|
||||
DBG(1, "sanei_hp_get_connect: Config not initialized for %s. Assume SCSI\n",
|
||||
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
|
||||
|
@ -1262,21 +1295,23 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
|
|||
hp_byte_t cmd[6];
|
||||
hp_byte_t data[HP_PIPEBUF];
|
||||
} buf[2], *req = NULL;
|
||||
|
||||
int reqs_completed = 0;
|
||||
int reqs_issued = 0;
|
||||
char *image_buf = 0;
|
||||
char *read_buf = 0;
|
||||
const HpDeviceInfo *info;
|
||||
const char *devname = sanei_hp_scsi_devicename (this);
|
||||
int enable_requests = 1;
|
||||
int enable_image_buffering = 0;
|
||||
int enable_requests = 1;
|
||||
int enable_image_buffering = 0;
|
||||
const unsigned char *map = NULL;
|
||||
HpConnect connect = HP_CONNECT_SCSI;
|
||||
HpConnect connect;
|
||||
PROCDATA_HANDLE *ph = NULL;
|
||||
size_t count = procdata->lines * procdata->bytes_per_line;
|
||||
|
||||
RETURN_IF_FAIL( hp_scsi_flush(this) );
|
||||
|
||||
connect = sanei_hp_get_connect (devname);
|
||||
info = sanei_hp_device_info_get (devname);
|
||||
|
||||
assert (info);
|
||||
|
@ -1285,7 +1320,6 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
|
|||
{
|
||||
enable_requests = info->config.use_scsi_request;
|
||||
enable_image_buffering = info->config.use_image_buffering;
|
||||
connect = info->config.connect;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1320,7 +1354,7 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
|
|||
{
|
||||
for (;;)
|
||||
{int val = 0;
|
||||
|
||||
|
||||
if (signal_caught) goto quit;
|
||||
sanei_hp_scl_inquire (this, SCL_FRONT_BUTTON, &val, 0, 0);
|
||||
if (val) break;
|
||||
|
@ -1332,7 +1366,7 @@ sanei_hp_scsi_pipeout (HpScsi this, int outfd, HpProcessData *procdata)
|
|||
DBG(1, "do_read: Error starting scan in reader process\n");
|
||||
goto quit;
|
||||
}
|
||||
}
|
||||
}
|
||||
ph = process_data_init (procdata, map, outfd, enable_image_buffering);
|
||||
|
||||
if ( ph == NULL )
|
||||
|
|
22
backend/hp.c
22
backend/hp.c
|
@ -43,9 +43,12 @@
|
|||
HP Scanner Control Language (SCL).
|
||||
*/
|
||||
|
||||
static char *hp_backend_version = "0.95";
|
||||
static char *hp_backend_version = "0.96";
|
||||
/* 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)
|
||||
- add support for active XPA
|
||||
- check if paper in ADF for ADF scan
|
||||
|
@ -324,6 +327,7 @@ hp_init_config (HpDeviceConfig *config)
|
|||
config->connect = HP_CONNECT_SCSI;
|
||||
config->use_scsi_request = 1;
|
||||
config->use_image_buffering = 0;
|
||||
config->got_connect_type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,31 +611,37 @@ hp_read_config (void)
|
|||
if (strcmp (arg2, "connect-scsi") == 0)
|
||||
{
|
||||
config->connect = HP_CONNECT_SCSI;
|
||||
config->got_connect_type = 1;
|
||||
}
|
||||
else if (strcmp (arg2, "connect-device") == 0)
|
||||
{
|
||||
config->connect = HP_CONNECT_DEVICE;
|
||||
config->got_connect_type = 1;
|
||||
config->use_scsi_request = 0;
|
||||
}
|
||||
else if (strcmp (arg2, "connect-pio") == 0)
|
||||
{
|
||||
config->connect = HP_CONNECT_PIO;
|
||||
config->got_connect_type = 1;
|
||||
config->use_scsi_request = 0;
|
||||
}
|
||||
else if (strcmp (arg2, "connect-usb") == 0)
|
||||
{
|
||||
config->connect = HP_CONNECT_USB;
|
||||
config->got_connect_type = 1;
|
||||
config->use_scsi_request = 0;
|
||||
}
|
||||
else if (strcmp (arg2, "connect-reserve") == 0)
|
||||
{
|
||||
config->connect = HP_CONNECT_RESERVE;
|
||||
config->got_connect_type = 1;
|
||||
config->use_scsi_request = 0;
|
||||
}
|
||||
else if (strcmp (arg2, "connect-ptal") == 0)
|
||||
{
|
||||
#ifdef HAVE_PTAL
|
||||
config->connect = HP_CONNECT_PTAL;
|
||||
config->got_connect_type = 1;
|
||||
config->use_scsi_request = 0;
|
||||
#else
|
||||
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 ? */
|
||||
{
|
||||
is_df_config = 0;
|
||||
config = &dev_config;
|
||||
is_df_config = 0; /* Stop reading default 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 ? */
|
||||
{
|
||||
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);
|
||||
sanei_config_attach_matching_devices (cu_device, hp_attach);
|
||||
cu_device[0] = '\0';
|
||||
|
@ -682,6 +694,8 @@ hp_read_config (void)
|
|||
cu_device[0] = '\0';
|
||||
}
|
||||
fclose (fp);
|
||||
DBG(1, "hp_read_config: reset to default config\n");
|
||||
memcpy (hp_global_config_get (), &df_config, sizeof (df_config));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue