kopia lustrzana https://gitlab.com/sane-project/backends
2000-12-23 Henning Meier-Geinitz <hmg@gmx.de>
* NEWS: Added date of release. * TODO: Removed entries about PATH_MAX, sanei_scsi_find_devices, and shm.h. Added entry about the necessity to check HAVE_SYS_SHM_H. * configure configure.in include/sane/config.h.in: Default to --enable-warnings again. Don't set "-ansi" for OS/2. Test for sys/shm.h. * backend/GUIDE: Moved to doc/backend-writing.txt. * doc/backend-writing.txt: New file (moved from backend/GUIDE). Added comments about sanei-backend.h and PATH_MAX. * include/sane/sanei_backend.h: Added define for PATH_MAX (if necessary). * sanei/sanei_scsi.c: Implemented sanei_scsi_find_devices for FreeBSD (from ports@FreeBSD.org). * tools/Makefile.in: Use INSTALL_SCRIPT instead of INSTALL_PROGRAM for sane-config (from ports@FreeBSD.org).DEVEL_2_0_BRANCH-1
rodzic
db6266d362
commit
0268deab2e
|
@ -1,4 +1,4 @@
|
|||
Thu Mar 4 22:41:24 1999
|
||||
2000-12-23
|
||||
|
||||
Here are a few rules that should help writing a SANE-conformant
|
||||
backend:
|
||||
|
@ -92,6 +92,10 @@ backend:
|
|||
any other includes. If you use lalloca.h see above for the correct
|
||||
includes.
|
||||
|
||||
* Include sanei_backend.h after the other includes.
|
||||
|
||||
* It's no longer necessary to #define PATH_MAX (now in sanei_backend.h).
|
||||
|
||||
* Please use sanei functions whenever possible (e.g.
|
||||
sanei_config_read()). This makes porting to other os/platforms much
|
||||
easier.
|
||||
|
@ -108,10 +112,10 @@ backend:
|
|||
source code for your backend, you should include an update to the
|
||||
.desc file which reflects the new state of the backend.
|
||||
|
||||
"template.desc." is a template for new .desc files. If you'd like
|
||||
* "template.desc." is a template for new .desc files. If you'd like
|
||||
to try parsing your creation to recreate the sane-backends webpage,
|
||||
look at "sane-desc.el" in the tools/ directory.
|
||||
|
||||
* When your backend is included in the SANE distribution, add an entry
|
||||
to README and sane.lsm. The README entry should point to your
|
||||
to README and sane-backends.lsm. The README entry should point to your
|
||||
documentation (man-page, website, readme).
|
|
@ -245,6 +245,9 @@
|
|||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <sys/shm.h> header file. */
|
||||
#undef HAVE_SYS_SHM_H
|
||||
|
||||
/* Define if you have the <sys/io.h> header file. */
|
||||
#undef HAVE_SYS_IO_H
|
||||
|
||||
|
|
|
@ -2425,6 +2425,169 @@ SANE_Status sanei_scsi_cmd2(int fd,
|
|||
cam_freeccb(ccb);
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
#define WE_HAVE_FIND_DEVICES
|
||||
|
||||
int
|
||||
cam_compare_inquiry(int fd, path_id_t path_id,
|
||||
target_id_t target_id, lun_id_t target_lun,
|
||||
const char *vendor, const char *product, const char *type)
|
||||
{
|
||||
struct ccb_dev_match cdm;
|
||||
struct device_match_pattern *pattern;
|
||||
struct scsi_inquiry_data *inq;
|
||||
int retval = 0;
|
||||
|
||||
/* build ccb for device match */
|
||||
bzero(&cdm, sizeof(cdm));
|
||||
cdm.ccb_h.func_code = XPT_DEV_MATCH;
|
||||
|
||||
/* result buffer */
|
||||
cdm.match_buf_len = sizeof(struct dev_match_result);
|
||||
cdm.matches = (struct dev_match_result *)malloc(cdm.match_buf_len);
|
||||
cdm.num_matches = 0;
|
||||
|
||||
/* pattern buffer */
|
||||
cdm.num_patterns = 1;
|
||||
cdm.pattern_buf_len = sizeof(struct dev_match_pattern);
|
||||
cdm.patterns = (struct dev_match_pattern *)malloc(cdm.pattern_buf_len);
|
||||
|
||||
/* assemble conditions */
|
||||
cdm.patterns[0].type = DEV_MATCH_DEVICE;
|
||||
pattern = &cdm.patterns[0].pattern.device_pattern;
|
||||
pattern->flags = DEV_MATCH_PATH | DEV_MATCH_TARGET | DEV_MATCH_LUN;
|
||||
pattern->path_id = path_id;
|
||||
pattern->target_id = target_id;
|
||||
pattern->target_lun = target_lun;
|
||||
|
||||
if (ioctl(fd, CAMIOCOMMAND, &cdm) == -1) {
|
||||
DBG (1, "error sending CAMIOCOMMAND ioctl");
|
||||
retval = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if ((cdm.ccb_h.status != CAM_REQ_CMP)
|
||||
|| ((cdm.status != CAM_DEV_MATCH_LAST)
|
||||
&& (cdm.status != CAM_DEV_MATCH_MORE))) {
|
||||
DBG (1, "got CAM error %#x, CDM error %d\n",
|
||||
cdm.ccb_h.status, cdm.status);
|
||||
retval = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if (cdm.num_matches == 0) {
|
||||
DBG (1, "not found\n");
|
||||
retval = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if (cdm.matches[0].type != DEV_MATCH_DEVICE) {
|
||||
DBG (1, "no device match\n");
|
||||
retval = -1;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
inq = &cdm.matches[0].result.device_result.inq_data;
|
||||
if ((vendor && cam_strmatch(inq->vendor, vendor, SID_VENDOR_SIZE)) ||
|
||||
(product && cam_strmatch(inq->product, product, SID_PRODUCT_SIZE)))
|
||||
retval = 1;
|
||||
|
||||
ret:
|
||||
free(cdm.patterns);
|
||||
free(cdm.matches);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_scsi_find_devices (const char *findvendor, const char *findmodel,
|
||||
const char *findtype,
|
||||
int findbus, int findchannel, int findid, int findlun,
|
||||
SANE_Status (*attach) (const char *dev))
|
||||
{
|
||||
int fd;
|
||||
struct ccb_dev_match cdm;
|
||||
struct periph_match_pattern *pattern;
|
||||
struct periph_match_result *result;
|
||||
int i;
|
||||
char devname[16];
|
||||
|
||||
DBG_INIT();
|
||||
|
||||
if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) {
|
||||
DBG (1, "could not open %s\n", XPT_DEVICE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* build ccb for device match */
|
||||
bzero(&cdm, sizeof(cdm));
|
||||
cdm.ccb_h.func_code = XPT_DEV_MATCH;
|
||||
|
||||
/* result buffer */
|
||||
cdm.match_buf_len = sizeof(struct dev_match_result) * 100;
|
||||
cdm.matches = (struct dev_match_result *)malloc(cdm.match_buf_len);
|
||||
cdm.num_matches = 0;
|
||||
|
||||
/* pattern buffer */
|
||||
cdm.num_patterns = 1;
|
||||
cdm.pattern_buf_len = sizeof(struct dev_match_pattern);
|
||||
cdm.patterns = (struct dev_match_pattern *)malloc(cdm.pattern_buf_len);
|
||||
|
||||
/* assemble conditions ... findchannel is ignored */
|
||||
cdm.patterns[0].type = DEV_MATCH_PERIPH;
|
||||
pattern = &cdm.patterns[0].pattern.periph_pattern;
|
||||
pattern->flags = PERIPH_MATCH_NAME;
|
||||
strcpy(pattern->periph_name, "pass");
|
||||
if (findbus != -1) {
|
||||
pattern->path_id = findbus;
|
||||
pattern->flags |= PERIPH_MATCH_PATH;
|
||||
}
|
||||
if (findid != -1) {
|
||||
pattern->target_id = findid;
|
||||
pattern->flags |= PERIPH_MATCH_TARGET;
|
||||
}
|
||||
if (findlun != -1) {
|
||||
pattern->target_lun = findlun;
|
||||
pattern->flags |= PERIPH_MATCH_LUN;
|
||||
}
|
||||
|
||||
/* result loop */
|
||||
do {
|
||||
if (ioctl(fd, CAMIOCOMMAND, &cdm) == -1) {
|
||||
DBG (1, "error sending CAMIOCOMMAND ioctl");
|
||||
break;
|
||||
}
|
||||
|
||||
if ((cdm.ccb_h.status != CAM_REQ_CMP)
|
||||
|| ((cdm.status != CAM_DEV_MATCH_LAST)
|
||||
&& (cdm.status != CAM_DEV_MATCH_MORE))) {
|
||||
DBG (1, "got CAM error %#x, CDM error %d\n",
|
||||
cdm.ccb_h.status, cdm.status);
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < cdm.num_matches; i++) {
|
||||
if (cdm.matches[i].type != DEV_MATCH_PERIPH)
|
||||
continue;
|
||||
result = &cdm.matches[i].result.periph_result;
|
||||
DBG (4, "%s%d on scbus%d %d:%d\n",
|
||||
result->periph_name, result->unit_number,
|
||||
result->path_id, result->target_id, result->target_lun);
|
||||
if (cam_compare_inquiry(fd, result->path_id,
|
||||
result->target_id, result->target_lun,
|
||||
findvendor, findmodel, findtype) == 0) {
|
||||
sprintf(devname, "/dev/%s%d", result->periph_name, result->unit_number);
|
||||
(*attach) (devname);
|
||||
}
|
||||
}
|
||||
} while ((cdm.ccb_h.status == CAM_REQ_CMP)
|
||||
&& (cdm.status == CAM_DEV_MATCH_MORE));
|
||||
|
||||
free(cdm.patterns);
|
||||
free(cdm.matches);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ configdir = ${sysconfdir}/sane.d
|
|||
MKDIR = $(top_srcdir)/mkinstalldirs
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
|
@ -65,7 +66,7 @@ LIBLIB = ../lib/liblib.a
|
|||
all: $(DESTINATIONS)
|
||||
|
||||
install: sane-config
|
||||
$(INSTALL_PROGRAM) sane-config $(bindir)/sane-config
|
||||
$(INSTALL_SCRIPT) sane-config $(bindir)/sane-config
|
||||
|
||||
sane-config: sane-config.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
|
|
Ładowanie…
Reference in New Issue