Hi,

We have some ugly code in openct that guesses whether
some device is serial or usb or ...

I think the code is not needed, most plattforms also don't
implement it. instead I modified all parts of the code to
not only pass a device name, but a device type as well
(i.e. "usb", "serial","pcmcia","pcmcia_block", ...).

Attached a patch to implement it. Feedback is very welcome.
I think it doesn't break anything (except that you need to update
your code and the hotplug scripts at the same time).

Regards, Andreas
diff -udrNPp --exclude=.svn openct.orig/etc/hotplug.openct.in openct/etc/hotplug.openct.in
--- openct.orig/etc/hotplug.openct.in	2006-04-21 08:38:04.000000000 +0200
+++ openct/etc/hotplug.openct.in	2006-06-09 15:06:54.000000000 +0200
@@ -12,7 +12,7 @@ if [ -n "$DEVICE" ]
 then
 	# if you see two ifdhandlers for one device, then you can
 	# either comment out the next line here ...
-	SBINDIR/openct-control attach $DEVICE usb:$PRODUCT
+	SBINDIR/openct-control attach usb $DEVICE $PRODUCT
 	exit 0
 fi
 
@@ -23,6 +23,6 @@ then
 	D="`cat /sys/$DEVPATH/device/bcdDevice |sed -e "s/^0*//"`"
 	PRODUCT="$V/$P/$D"
 	# or the following line. both should disable that effect.
-	SBINDIR/openct-control attach $DEVNAME usb:$PRODUCT
+	SBINDIR/openct-control attach usb $DEVNAME $PRODUCT
 	exit 0
 fi
diff -udrNPp --exclude=.svn openct.orig/etc/openct.hald.in openct/etc/openct.hald.in
--- openct.orig/etc/openct.hald.in	2006-04-21 08:38:04.000000000 +0200
+++ openct/etc/openct.hald.in	2006-06-09 15:07:09.000000000 +0200
@@ -8,10 +8,10 @@ DEVICE=`printf /dev/bus/usb/%03u/%03u \
 
 if test -e $DEVICE
 then
-	exec SBINDIR/openct-control attach $DEVICE usb:$PRODUCT
+	exec SBINDIR/openct-control attach usb $DEVICE $PRODUCT
 fi
 
 DEVICE=`printf /proc/bus/usb/%03u/%03u \
 	$HAL_PROP_USB_DEVICE_BUS_NUMBER \
 	$HAL_PROP_USB_DEVICE_LINUX_DEVICE_NUMBER`
-exec SBINDIR/openct-control attach $DEVICE usb:$PRODUCT
+exec SBINDIR/openct-control attach usb $DEVICE $PRODUCT
diff -udrNPp --exclude=.svn openct.orig/src/ifd/device.c openct/src/ifd/device.c
--- openct.orig/src/ifd/device.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/device.c	2006-06-09 15:19:00.000000000 +0200
@@ -11,33 +11,30 @@
 /*
  * Open a device given the name
  */
-ifd_device_t *ifd_device_open(const char *name)
+ifd_device_t *ifd_device_open(const char *type, const char *device)
 {
-	if (name == NULL) {
+	if (type == NULL) {
+		ct_error("Null type");
+		return NULL;
+	}
+
+	if (device == NULL) {
 		ct_error("Null device");
 		return NULL;
 	}
 
-	if (!strncmp(name, "serial:", 7))
-		return ifd_open_serial(name + 7);
-	if (!strncmp(name, "usb:", 4))
-		return ifd_open_usb(name + 4);
-	if (!strncmp(name, "remote:", 7))
-		return ifd_open_remote(name + 7);
-	if (!strncmp(name, "pcmcia:", 7))
-		return ifd_open_pcmcia(name + 7);
-	if (!strncmp(name, "pcmcia_block:", 13))
-		return ifd_open_pcmcia_block(name + 13);
+	if (!strcmp(type, "serial"))
+		return ifd_open_serial(device);
+	if (!strcmp(type, "usb"))
+		return ifd_open_usb(device);
+	if (!strcmp(type, "remote"))
+		return ifd_open_remote(device);
+	if (!strcmp(type, "pcmcia"))
+		return ifd_open_pcmcia(device);
+	if (!strcmp(type, "pcmcia_block"))
+		return ifd_open_pcmcia_block(device);
 
-	switch (ifd_sysdep_device_type(name)) {
-	case IFD_DEVICE_TYPE_SERIAL:
-		return ifd_open_serial(name);
-	case IFD_DEVICE_TYPE_USB:
-		return ifd_open_usb(name);
-		/* Other types to be added */
-	case -1:
-		ct_error("Unknown device type \"%s\"", name);
-	}
+	ct_error("Unknown device type \"%s\"", type);
 	return NULL;
 }
 
@@ -83,19 +80,6 @@ int ifd_device_type(ifd_device_t * dev)
 	return dev->type;
 }
 
-int ifd_device_identify(const char *name, char *ident, size_t len)
-{
-	ifd_device_t *dev;
-	int res = -1;
-
-	if (!(dev = ifd_device_open(name)))
-		return -1;
-	if (dev->ops && dev->ops->identify)
-		res = dev->ops->identify(dev, ident, len);
-	ifd_device_close(dev);
-	return res;
-}
-
 int ifd_device_reset(ifd_device_t * dev)
 {
 	if (!dev || !dev->ops || !dev->ops->reset)
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-acr30u.c openct/src/ifd/ifd-acr30u.c
--- openct.orig/src/ifd/ifd-acr30u.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-acr30u.c	2006-06-09 14:44:34.000000000 +0200
@@ -279,7 +279,7 @@ static int acr_reader_status(ifd_reader_
 /*
  * Initialize the device
  */
-static int acr_open(ifd_reader_t * reader, const char *device_name)
+static int acr_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 	acr_priv_t *priv;
@@ -287,7 +287,7 @@ static int acr_open(ifd_reader_t * reade
 	unsigned char status[ACR_STATUS_LENGTH];
 	int rc;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("acr30u: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-cardman.c openct/src/ifd/ifd-cardman.c
--- openct.orig/src/ifd/ifd-cardman.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-cardman.c	2006-06-09 14:44:55.000000000 +0200
@@ -35,7 +35,7 @@ static int cm_anyreply(const void *, siz
 /*
  * Initialize the device
  */
-static int cm_open(ifd_reader_t * reader, const char *device_name)
+static int cm_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 	cm_priv_t *priv;
@@ -43,7 +43,7 @@ static int cm_open(ifd_reader_t * reader
 
 	reader->name = "OMNIKEY CardMan 2020/6020/6120";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("cardman: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-ccid.c openct/src/ifd/ifd-ccid.c
--- openct.orig/src/ifd/ifd-ccid.c	2006-04-24 21:52:02.000000000 +0200
+++ openct/src/ifd/ifd-ccid.c	2006-06-09 14:45:33.000000000 +0200
@@ -773,11 +773,11 @@ static int ccid_open_pcmcia_block(ifd_de
 /*
  * Initialize the device
  */
-static int ccid_open(ifd_reader_t * reader, const char *device_name)
+static int ccid_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 	reader->name = "CCID Compatible";
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) == IFD_DEVICE_TYPE_USB)
 		return ccid_open_usb(dev, reader);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-cm4000.c openct/src/ifd/ifd-cm4000.c
--- openct.orig/src/ifd/ifd-cm4000.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-cm4000.c	2006-06-09 14:46:00.000000000 +0200
@@ -20,13 +20,13 @@
 /*
  * Initialize the device
  */
-static int cm_open(ifd_reader_t * reader, const char *device_name)
+static int cm_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "OMNIKEY CardMan 4000";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_PCMCIA) {
 		ct_error("cm4000: device %s is not a PCMCIA device",
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-egate.c openct/src/ifd/ifd-egate.c
--- openct.orig/src/ifd/ifd-egate.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-egate.c	2006-06-09 14:46:25.000000000 +0200
@@ -40,14 +40,14 @@
 /*
  * Initialize the device
  */
-static int eg_open(ifd_reader_t * reader, const char *device_name)
+static int eg_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	ifd_debug(1, "device=%s", device_name);
 	reader->name = "Schlumberger E-Gate";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("egate: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-etoken64.c openct/src/ifd/ifd-etoken64.c
--- openct.orig/src/ifd/ifd-etoken64.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-etoken64.c	2006-06-09 14:46:50.000000000 +0200
@@ -14,13 +14,13 @@
 /*
  * Initialize the device
  */
-static int et64_open(ifd_reader_t * reader, const char *device_name)
+static int et64_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "Aladdin eToken PRO 64k";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("etoken64: device %s is not a USB device",
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-etoken.c openct/src/ifd/ifd-etoken.c
--- openct.orig/src/ifd/ifd-etoken.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-etoken.c	2006-06-09 14:51:32.000000000 +0200
@@ -18,13 +18,13 @@ static int et_magic(ifd_device_t *);
 /*
  * Initialize the device
  */
-static int et_open(ifd_reader_t * reader, const char *device_name)
+static int et_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "Aladdin eToken PRO";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("etoken: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-eutron.c openct/src/ifd/ifd-eutron.c
--- openct.orig/src/ifd/ifd-eutron.c	2006-04-25 23:58:06.000000000 +0200
+++ openct/src/ifd/ifd-eutron.c	2006-06-09 14:52:09.000000000 +0200
@@ -30,14 +30,14 @@ typedef struct eut_priv {
 /*
  * Initialize the device
  */
-static int eutron_open(ifd_reader_t * reader, const char *device_name)
+static int eutron_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 	eut_priv_t *priv;
 
 	reader->name = "Eutron CryptoIdendity";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("eutron: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-gempc.c openct/src/ifd/ifd-gempc.c
--- openct.orig/src/ifd/ifd-gempc.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-gempc.c	2006-06-09 14:47:33.000000000 +0200
@@ -54,7 +54,7 @@ static const char *gpc_strerror(int stat
 /*
  * Initialize the reader
  */
-static int gpc_open(ifd_reader_t * reader, const char *device_name)
+static int gpc_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	char buffer[256];
 	gpc_status_t *st;
@@ -66,7 +66,7 @@ static int gpc_open(ifd_reader_t * reade
 	reader->name = "Gemplus Reader (pre-alpha, untested)";
 	reader->nslots = 1;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return IFD_ERROR_GENERIC;
 	reader->device = dev;
 
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifdhandler.c openct/src/ifd/ifdhandler.c
--- openct.orig/src/ifd/ifdhandler.c	2006-04-25 23:58:06.000000000 +0200
+++ openct/src/ifd/ifdhandler.c	2006-06-09 15:19:14.000000000 +0200
@@ -49,7 +49,7 @@ static void print_info(void);
 
 int main(int argc, char **argv)
 {
-	const char *device = NULL, *driver;
+	const char *device = NULL, *type = NULL, *driver;
 	ifd_reader_t *reader;
 	ct_info_t *status;
 	int c;
@@ -95,10 +95,11 @@ int main(int argc, char **argv)
 		return 0;
 	}
 
-	if (optind != argc - 2)
+	if (optind != argc - 3)
 		usage(1);
 
 	driver = argv[optind++];
+	type = argv[optind++];
 	device = argv[optind++];
 
 	ct_config.debug = opt_debug;
@@ -120,8 +121,8 @@ int main(int argc, char **argv)
 			ct_error("too many readers, no reader slot available");
 			return 1;
 		}
-		snprintf(path,PATH_MAX,"%d",r);
-		opt_reader=strdup(path);
+		snprintf(path, PATH_MAX, "%d", r);
+		opt_reader = strdup(path);
 	}
 
 	/* Become a daemon if needed - we do this after allocating the
@@ -152,8 +153,9 @@ int main(int argc, char **argv)
 	}
 
 	/* Create reader */
-	if (!(reader = ifd_open(driver, device))) {
-		ct_error("unable to open reader [EMAIL PROTECTED]", driver, device);
+	if (!(reader = ifd_open(driver, type, device))) {
+		ct_error("unable to open reader %s %s %s", driver, type,
+			 device);
 		return 1;
 	}
 
@@ -184,9 +186,9 @@ void ifdhandler_run(ifd_reader_t * reade
 	ct_socket_t *sock;
 	int rc;
 	struct sigaction act;
-        char path[PATH_MAX];
+	char path[PATH_MAX];
 
-        if (! ct_format_path(path, PATH_MAX, opt_reader)) {
+	if (!ct_format_path(path, PATH_MAX, opt_reader)) {
 		ct_error("ct_format_path failed!");
 		exit(1);
 	}
@@ -427,7 +429,7 @@ void version(void)
 void usage(int exval)
 {
 	fprintf(exval ? stderr : stdout,
-		"usage: ifdhandler [-Hds] [-r reader] driver device\n"
+		"usage: ifdhandler [-Hds] [-r reader] driver type device\n"
 		"  -r   specify index of reader\n"
 		"  -F   stay in foreground\n"
 		"  -H   hotplug device, monitor for detach\n"
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-ikey2k.c openct/src/ifd/ifd-ikey2k.c
--- openct.orig/src/ifd/ifd-ikey2k.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-ikey2k.c	2006-06-09 14:52:17.000000000 +0200
@@ -12,13 +12,13 @@
 /*
  * Initialize the device
  */
-static int ikey2k_open(ifd_reader_t * reader, const char *device_name)
+static int ikey2k_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "Rainbow iKey 2032";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("ikey2k: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-ikey3k.c openct/src/ifd/ifd-ikey3k.c
--- openct.orig/src/ifd/ifd-ikey3k.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-ikey3k.c	2006-06-09 14:52:23.000000000 +0200
@@ -12,13 +12,13 @@
 /*
  * Initialize the device
  */
-static int ikey3k_open(ifd_reader_t * reader, const char *device_name)
+static int ikey3k_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "Rainbow iKey 3000";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("ikey3k: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-kaan.c openct/src/ifd/ifd-kaan.c
--- openct.orig/src/ifd/ifd-kaan.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-kaan.c	2006-06-09 14:53:45.000000000 +0200
@@ -62,7 +62,7 @@ static int kaan_select_app(ifd_reader_t 
 /*
  * Initialize the device
  */
-static int kaan_open(ifd_reader_t * reader, const char *device_name)
+static int kaan_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	kaan_status_t *st;
 	ifd_device_t *dev;
@@ -72,7 +72,7 @@ static int kaan_open(ifd_reader_t * read
 	reader->name = "Kobil Kaan PRO";
 	reader->nslots = 1;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 
 	if (ifd_device_type(dev) == IFD_DEVICE_TYPE_SERIAL
@@ -125,7 +125,7 @@ static int kaan_open(ifd_reader_t * read
 /*
  * Initialize the device
  */
-static int b1_open(ifd_reader_t * reader, const char *device_name)
+static int b1_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	kaan_status_t *st;
 	ifd_device_t *dev;
@@ -136,7 +136,7 @@ static int b1_open(ifd_reader_t * reader
 	reader->name = "DTAG/T-TeleSec B1 standard";
 	reader->nslots = 1;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 
 	if (ifd_device_type(dev) == IFD_DEVICE_TYPE_SERIAL) {
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-pertosmart1030.c openct/src/ifd/ifd-pertosmart1030.c
--- openct.orig/src/ifd/ifd-pertosmart1030.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-pertosmart1030.c	2006-06-09 14:52:36.000000000 +0200
@@ -1431,7 +1431,7 @@ ps_apdu_recv(ifd_reader_t * reader, unsi
 /*
  * Initialize the device
  */
-static int ps_open(ifd_reader_t * reader, const char *device_name)
+static int ps_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	int rc;
 	ifd_device_t *dev;
@@ -1443,7 +1443,7 @@ static int ps_open(ifd_reader_t * reader
 	if (ct_config.debug >= 1)
 		ct_debug("ps_open: called: device name =%s", device_name);
 
-	dev = ifd_device_open(device_name);
+	dev = ifd_device_open(type_name, device_name);
 
 	if (dev == NULL) {
 		ct_error("ps_open: failed to open device: %", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-pertosmart1038.c openct/src/ifd/ifd-pertosmart1038.c
--- openct.orig/src/ifd/ifd-pertosmart1038.c	2006-04-25 23:58:06.000000000 +0200
+++ openct/src/ifd/ifd-pertosmart1038.c	2006-06-09 14:52:41.000000000 +0200
@@ -1220,7 +1220,7 @@ ps_apdu_recv(ifd_reader_t * reader, unsi
 /*
  * Initialize the device
  */
-static int ps_open(ifd_reader_t * reader, const char *device_name)
+static int ps_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	int rc = IFD_SUCCESS;
 	ifd_device_t *dev = NULL;
@@ -1232,7 +1232,7 @@ static int ps_open(ifd_reader_t * reader
 	if (ct_config.debug >= 1)
 		ct_debug("ps_open: called: device name =%s", device_name);
 
-	dev = ifd_device_open(device_name);
+	dev = ifd_device_open(type_name, device_name);
 
 	if (NULL == dev) {
 		ct_error("ps_open: failed to open device: %", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifdproxy.c openct/src/ifd/ifdproxy.c
--- openct.orig/src/ifd/ifdproxy.c	2006-04-25 23:58:06.000000000 +0200
+++ openct/src/ifd/ifdproxy.c	2006-06-09 15:19:22.000000000 +0200
@@ -176,11 +176,10 @@ int run_server(int argc, char **argv)
 	int rc;
 	char path[PATH_MAX];
 
-	if (! ct_format_path(path, PATH_MAX, opt_server_port)) {
+	if (!ct_format_path(path, PATH_MAX, opt_server_port)) {
 		return -1;
 	}
 
-
 	if (argc != 0)
 		usage(1);
 	if (ct_config.debug)
@@ -207,7 +206,7 @@ int run_server(int argc, char **argv)
 
 int run_client(int argc, char **argv)
 {
-	const char *name, *device, *address;
+	const char *name, *type, *device, *address;
 	ria_client_t *ria;
 	int rc;
 
@@ -215,13 +214,14 @@ int run_client(int argc, char **argv)
 	if (ifd_init())
 		return 1;
 
-	if (argc != 2 && argc != 3)
+	if (argc != 3 && argc != 4)
 		usage(1);
 	name = argv[0];
-	device = argv[1];
-	address = argc == 3 ? argv[2] : opt_device_port;
+	type = argv[1];
+	device = argv[2];
+	address = argc == 4 ? argv[3] : opt_device_port;
 
-	ria = ria_export_device(address, device);
+	ria = ria_export_device(address, type, device);
 
 	ifd_debug(1, "About to register device as \"%s\"", name);
 	if ((rc = ria_register_device(ria, name)) < 0) {
@@ -289,7 +289,7 @@ void usage(int exval)
 	fprintf(exval ? stderr : stdout,
 		"Usage:\n"
 		"ifdproxy server [-dF]\n"
-		"ifdproxy export [-dF] name device address\n"
+		"ifdproxy export [-dF] name type device address\n"
 		"ifdproxy list [-dF] address\n" "ifdproxy version\n");
 	exit(exval);
 }
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-smartboard.c openct/src/ifd/ifd-smartboard.c
--- openct.orig/src/ifd/ifd-smartboard.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-smartboard.c	2006-06-09 14:48:40.000000000 +0200
@@ -44,7 +44,7 @@ static int __smartboard_rsp(ifd_reader_t
 /*
  * Initialize the device
  */
-static int smartboard_open(ifd_reader_t * reader, const char *device_name)
+static int smartboard_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_params_t params;
 	ifd_device_t *dev;
@@ -54,7 +54,7 @@ static int smartboard_open(ifd_reader_t 
 	reader->nslots = 1;
 	reader->slot[0].dad = 0;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 
 	ifd_device_flush(dev);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-smph.c openct/src/ifd/ifd-smph.c
--- openct.orig/src/ifd/ifd-smph.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-smph.c	2006-06-09 14:54:47.000000000 +0200
@@ -93,14 +93,14 @@ static int smph_setctrl(ifd_device_t *de
 /*
  * Initialize the reader
  */
-static int _smph_open(ifd_reader_t *reader, const char *device_name,
+static int _smph_open(ifd_reader_t *reader, const char *type_name, const char *device_name,
 		      smph_priv_t *privd)
 {
   ifd_device_params_t params;
   ifd_device_t *dev;
 
   reader->nslots = 1;
-  if (!(dev = ifd_device_open(device_name)))
+  if (!(dev = ifd_device_open(type_name, device_name)))
     return -1;
   reader->device = dev;
 
@@ -124,7 +124,7 @@ static int _smph_open(ifd_reader_t *read
   return 0;
 }
 
-static int phx_open(ifd_reader_t * reader, const char *device_name)
+static int phx_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
   smph_priv_t *privd = NULL;
 
@@ -137,10 +137,10 @@ static int phx_open(ifd_reader_t * reade
     }
   privd->mode = PHS_CONV_DIRECT;
   privd->prot = prot_phoenix;
-  return _smph_open(reader, device_name, privd);
+  return _smph_open(reader, type_name, device_name, privd);
 }
 
-static int smtm_open(ifd_reader_t * reader, const char *device_name)
+static int smtm_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
   smph_priv_t *privd = NULL;
 
@@ -153,7 +153,7 @@ static int smtm_open(ifd_reader_t * read
     }
   privd->mode = PHS_CONV_DIRECT;
   privd->prot = prot_smartmouse;
-  return _smph_open(reader, device_name, privd);
+  return _smph_open(reader, type_name, device_name, privd);
 }
 
 /*
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-starkey.c openct/src/ifd/ifd-starkey.c
--- openct.orig/src/ifd/ifd-starkey.c	2006-04-24 21:52:02.000000000 +0200
+++ openct/src/ifd/ifd-starkey.c	2006-06-09 14:49:18.000000000 +0200
@@ -13,13 +13,13 @@
 /*
  * Initialize the device
  */
-static int starkey_open(ifd_reader_t * reader, const char *device_name)
+static int starkey_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_t *dev;
 
 	reader->name = "G&D Starkey 100";
 	reader->nslots = 1;
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	if (ifd_device_type(dev) != IFD_DEVICE_TYPE_USB) {
 		ct_error("starkey: device %s is not a USB device", device_name);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-towitoko.c openct/src/ifd/ifd-towitoko.c
--- openct.orig/src/ifd/ifd-towitoko.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ifd-towitoko.c	2006-06-09 14:49:38.000000000 +0200
@@ -27,7 +27,7 @@ enum {
 /*
  * Initialize the reader
  */
-static int twt_open(ifd_reader_t * reader, const char *device_name)
+static int twt_open(ifd_reader_t * reader, const char *type_name, const char *device_name)
 {
 	ifd_device_params_t params;
 	ifd_device_t *dev;
@@ -38,7 +38,7 @@ static int twt_open(ifd_reader_t * reade
 	reader->name = "Towitoko Reader";
 	reader->nslots = 1;
 
-	if (!(dev = ifd_device_open(device_name)))
+	if (!(dev = ifd_device_open(type_name, device_name)))
 		return -1;
 	reader->device = dev;
 
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ifd-wbeiuu.c openct/src/ifd/ifd-wbeiuu.c
--- openct.orig/src/ifd/ifd-wbeiuu.c	2006-05-23 21:37:39.000000000 +0200
+++ openct/src/ifd/ifd-wbeiuu.c	2006-06-09 14:56:07.000000000 +0200
@@ -115,7 +115,7 @@ static void wbeiuu_print_bytestring(unsi
 	free(str);
 }
 
-static int wbeiuu_open(ifd_reader_t * reader, const char *dev_name)
+static int wbeiuu_open(ifd_reader_t * reader, const char *type_name, const char *dev_name)
 {
 	int status;
 	ifd_device_t *dev;
@@ -125,12 +125,12 @@ static int wbeiuu_open(ifd_reader_t * re
 	reader->name = "WB Electronics Infinity USB Unlimited";
 	reader->nslots = 1;	// I has physically two, but electrically only one
 
-	dev = ifd_device_open(dev_name);
+	dev = ifd_device_open(type_name, dev_name);
 
 	//  if ((!dev = ifd_device_open(device_name)))
 	if (!dev) {
-		ifd_debug(1, "%s:%d Error when opening device %s.",
-			  __FILE__, __LINE__, dev_name);
+		ifd_debug(1, "%s:%d Error when opening type %s device %s.",
+			  __FILE__, __LINE__, type_name, dev_name);
 		return -1;
 	}
 
@@ -138,7 +138,7 @@ static int wbeiuu_open(ifd_reader_t * re
 		ifd_debug(1, "%s:%d device %s is not a USB device", __FILE__,
 			  __LINE__, dev_name);
 		ct_error("wbeiuu: device %s is not a USB device", dev_name);
-		//ifd_device_close(dev);
+		ifd_device_close(dev);
 		return -1;
 	}
 
diff -udrNPp --exclude=.svn openct.orig/src/ifd/internal.h openct/src/ifd/internal.h
--- openct.orig/src/ifd/internal.h	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/internal.h	2006-06-09 15:19:27.000000000 +0200
@@ -43,11 +43,6 @@ struct ifd_device {
 };
 
 struct ifd_device_ops {
-	/* Try to identify the attached device. In the case of
-	 * a serial device, perform serial PnP. For USB devices,
-	 * get the vendor/device ID */
-	int (*identify) (ifd_device_t *, char *, size_t);
-
 	/* Reset device */
 	int (*reset) (ifd_device_t *);
 
@@ -164,7 +159,6 @@ extern unsigned int csum_lrc_compute(con
 extern unsigned int csum_crc_compute(const uint8_t *, size_t, unsigned char *);
 
 /* Internal system dependent device functions */
-extern int ifd_sysdep_device_type(const char *);
 extern int ifd_sysdep_usb_poll_presence(ifd_device_t *, struct pollfd *);
 extern int ifd_sysdep_usb_control(ifd_device_t *,
 				  unsigned int,
diff -udrNPp --exclude=.svn openct.orig/src/ifd/reader.c openct/src/ifd/reader.c
--- openct.orig/src/ifd/reader.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/reader.c	2006-06-09 15:19:32.000000000 +0200
@@ -15,40 +15,18 @@ static int ifd_recv_atr(ifd_device_t *, 
 /*
  * Initialize a reader and open the device
  */
-ifd_reader_t *ifd_open(const char *driver_name, const char *device_name)
+ifd_reader_t *ifd_open(const char *driver_name, const char *type_name,
+		       const char *device_name)
 {
 	const ifd_driver_t *driver;
 	ifd_reader_t *reader;
 
-	ifd_debug(1, "trying to open [EMAIL PROTECTED]", driver_name, device_name);
+	ifd_debug(1, "trying to open %s %d %s", driver_name, type_name,
+		  device_name);
 	if (!driver_name || !strcmp(driver_name, "auto")) {
-		char pnp_id[64];
-
-		if (ifd_device_identify(device_name, pnp_id, sizeof(pnp_id)) <
-		    0) {
-			ct_error("%s: unable to identify device, "
-				 "please specify driver", device_name);
-			return NULL;
-		}
-#if 1
 		/* Currently not supported */
 		ct_error("%s: plug and play not supported", device_name);
 		return NULL;
-#else
-		if (!(driver_name = ifd_driver_for_id(pnp_id))) {
-			ct_error("%s: no driver for ID %s, "
-				 "please specify driver", device_name, pnp_id);
-			return NULL;
-		}
-
-		driver = ifd_driver_get(driver_name);
-		if (driver == NULL) {
-			ct_error("%s: driver \"%s\" not available "
-				 "(identified as %s)",
-				 device_name, driver_name, pnp_id);
-			return NULL;
-		}
-#endif
 	} else {
 		driver = ifd_driver_get(driver_name);
 		if (driver == NULL) {
@@ -64,8 +42,9 @@ ifd_reader_t *ifd_open(const char *drive
 	}
 	reader->driver = driver;
 
-	if (driver->ops->open && driver->ops->open(reader, device_name) < 0) {
-		ct_error("%s: initialization failed (driver %s)",
+	if (driver->ops->open
+	    && driver->ops->open(reader, type_name, device_name) < 0) {
+		ct_error("%s %s: initialization failed (driver %s)", type_name,
 			 device_name, driver->name);
 		free(reader);
 		return NULL;
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ria-device.c openct/src/ifd/ria-device.c
--- openct.orig/src/ifd/ria-device.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ria-device.c	2006-06-09 15:19:36.000000000 +0200
@@ -36,15 +36,16 @@ static void ria_close_device(ct_socket_t
 /*
  * Handle device side of things
  */
-ria_client_t *ria_export_device(const char *address, const char *device)
+ria_client_t *ria_export_device(const char *address, const char *type,
+				const char *device)
 {
 	ifd_device_t *dev;
 	ria_client_t *ria;
 	ct_socket_t *sock;
 
 	/* Open device */
-	if (!(dev = ifd_device_open(device))) {
-		ct_error("Unable to open device %s\n", device);
+	if (!(dev = ifd_device_open(type, device))) {
+		ct_error("Unable to open type %s device %s\n", type, device);
 		exit(1);
 	}
 
diff -udrNPp --exclude=.svn openct.orig/src/ifd/ria.h openct/src/ifd/ria.h
--- openct.orig/src/ifd/ria.h	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/ria.h	2006-06-09 15:19:40.000000000 +0200
@@ -61,7 +61,8 @@ extern int ria_command(ria_client_t *, u
 		       const void *, size_t, void *, size_t, long timeout);
 
 extern int ria_svc_listen(const char *, int);
-extern ria_client_t *ria_export_device(const char *, const char *);
+extern ria_client_t *ria_export_device(const char *, const char *,
+				       const char *);
 extern int ria_register_device(ria_client_t *, const char *);
 extern void ria_print_packet(ct_socket_t *, int,
 			     const char *, header_t *, ct_buf_t *);
diff -udrNPp --exclude=.svn openct.orig/src/ifd/serial.c openct/src/ifd/serial.c
--- openct.orig/src/ifd/serial.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/serial.c	2006-06-09 15:19:44.000000000 +0200
@@ -356,15 +356,6 @@ int ifd_serial_get_cts(ifd_device_t * de
 }
 
 /*
- * Identify attached device
- */
-static int ifd_serial_identify(ifd_device_t * dev, char *namebuf, size_t len)
-{
-	ct_error("Serial PNP not yet implemented");
-	return -1;
-}
-
-/*
  * Close the device
  */
 static void ifd_serial_close(ifd_device_t * dev)
@@ -393,7 +384,6 @@ ifd_device_t *ifd_open_serial(const char
 	/* Clear the NDELAY flag */
 	fcntl(fd, F_SETFL, 0);
 
-	ifd_serial_ops.identify = ifd_serial_identify;
 	ifd_serial_ops.reset = ifd_serial_reset;
 	ifd_serial_ops.set_params = ifd_serial_set_params;
 	ifd_serial_ops.get_params = ifd_serial_get_params;
@@ -428,65 +418,83 @@ static struct {
 	unsigned int bits, speed;
 } termios_speed[] = {
 #ifdef B0
-	{ B0, 0 },
+	{
+	B0, 0},
 #endif
 #ifdef B50
-	{ B50, 50 },
+	{
+	B50, 50},
 #endif
 #ifdef B75
-	{ B75, 75 },
+	{
+	B75, 75},
 #endif
 #ifdef B110
-	{ B110, 110 },
+	{
+	B110, 110},
 #endif
 #ifdef B134
-	{ B134, 134 },
+	{
+	B134, 134},
 #endif
 #ifdef B150
-	{ B150, 150 },
+	{
+	B150, 150},
 #endif
 #ifdef B200
-	{ B200, 200 },
+	{
+	B200, 200},
 #endif
 #ifdef B300
-	{ B300, 300 },
+	{
+	B300, 300},
 #endif
 #ifdef B600
-	{ B600, 600 },
+	{
+	B600, 600},
 #endif
 #ifdef B1200
-	{ B1200, 1200 },
+	{
+	B1200, 1200},
 #endif
 #ifdef B1800
-	{ B1800, 1800 },
+	{
+	B1800, 1800},
 #endif
 #ifdef B2400
-	{ B2400, 2400 },
+	{
+	B2400, 2400},
 #endif
 #ifdef B4800
-	{ B4800, 4800 },
+	{
+	B4800, 4800},
 #endif
 #ifdef B9600
-	{ B9600, 9600 },
+	{
+	B9600, 9600},
 #endif
 #ifdef B19200
 	{
-	B19200, 19200 },
+	B19200, 19200},
 #endif
 #ifdef B38400
 	{
-	B38400, 38400 },
+	B38400, 38400},
 #endif
 #ifdef B57600
-	{ B57600, 57600 },
+	{
+	B57600, 57600},
 #endif
 #ifdef B115200
-	{ B115200, 115200 },
+	{
+	B115200, 115200},
 #endif
 #ifdef B230400
-	{ B230400, 230400 },
+	{
+	B230400, 230400},
 #endif
-	{ -1, -1 }
+	{
+	-1, -1}
 };
 
 unsigned int speed_to_termios(unsigned int speed)
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-bsd.c openct/src/ifd/sys-bsd.c
--- openct.orig/src/ifd/sys-bsd.c	2006-06-13 09:17:49.000000000 +0200
+++ openct/src/ifd/sys-bsd.c	2006-06-13 09:17:50.000000000 +0200
@@ -28,24 +28,6 @@
 
 #include "usb-descriptors.h"
 
-int ifd_sysdep_device_type(const char *name)
-{
-	struct stat stb;
-
-	ifd_debug(1, "BSD: ifd_sysdep_device_type(%s)", name);
-	if (!name || name[0] != '/')
-		return -1;
-
-	if (!strncmp(name, "/dev/ugen", 9)) {
-		ifd_debug(1, "BSD: returning IFD_DEVICE_TYPE_USB");
-		if (stat(name, &stb) < 0)
-			return -1;
-		return IFD_DEVICE_TYPE_USB;
-	}
-
-	return -1;
-}
-
 /*
  * Poll for presence of USB device
  */
@@ -330,7 +312,7 @@ int ifd_sysdep_usb_release_interface(ifd
 
 int ifd_sysdep_usb_open(const char *device)
 {
-        return open(device, O_RDWR);
+	return open(device, O_RDWR);
 }
 
 /*
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-linux.c openct/src/ifd/sys-linux.c
--- openct.orig/src/ifd/sys-linux.c	2006-04-24 23:00:04.000000000 +0200
+++ openct/src/ifd/sys-linux.c	2006-06-09 15:19:48.000000000 +0200
@@ -42,14 +42,14 @@ struct usbdevfs_ctrltransfer {
 	uint16_t wValue;
 	uint16_t wIndex;
 	uint16_t wLength;
-	uint32_t timeout;  /* in milliseconds */
- 	void *data;
+	uint32_t timeout;	/* in milliseconds */
+	void *data;
 };
 
 struct usbdevfs_bulktransfer {
 	unsigned int ep;
 	unsigned int len;
-	unsigned int timeout; /* in milliseconds */
+	unsigned int timeout;	/* in milliseconds */
 	void *data;
 };
 
@@ -100,24 +100,24 @@ struct usbdevfs_urb {
 	int start_frame;
 	int number_of_packets;
 	int error_count;
-	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
+	unsigned int signr;	/* signal to be sent on error, -1 if none should be sent */
 	void *usercontext;
 	struct usbdevfs_iso_packet_desc iso_frame_desc[0];
 };
 
 /* ioctls for talking directly to drivers */
 struct usbdevfs_ioctl {
-	int	ifno;		/* interface 0..N ; negative numbers reserved */
-	int	ioctl_code;	/* MUST encode size + direction of data so the
+	int ifno;		/* interface 0..N ; negative numbers reserved */
+	int ioctl_code;		/* MUST encode size + direction of data so the
 				 * macros in <asm/ioctl.h> give correct values */
-	void *data;	/* param buffer (in, or out) */
+	void *data;		/* param buffer (in, or out) */
 };
 
 /* You can do most things with hubs just through control messages,
  * except find out what device connects to what port. */
 struct usbdevfs_hub_portinfo {
 	char nports;		/* number of downstream ports in this hub */
-	char port [127];	/* e.g. port 3 connects to device 27 */
+	char port[127];		/* e.g. port 3 connects to device 27 */
 };
 
 #define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
@@ -141,49 +141,8 @@ struct usbdevfs_hub_portinfo {
 #define USBDEVFS_DISCONNECT        _IO('U', 22)
 #define USBDEVFS_CONNECT           _IO('U', 23)
 
-/* other constants from kernel code */
-
-#define TTY_MAJOR            4
-#define PTY_SLAVE_MAJOR              3
-#define UNIX98_PTY_MASTER_MAJOR      128
-#define UNIX98_PTY_SLAVE_MAJOR       (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
-#define UNIX98_PTY_MAJOR_COUNT       8
-#define MISC_MAJOR           10
-
 /* end of import from usbdevice_fs.h */
 
-int ifd_sysdep_device_type(const char *name)
-{
-	struct stat stb;
-
-	if (!name || name[0] != '/')
-		return -1;
-
-	if (!strncmp(name, "/proc/bus/usb", 13) ||
-		!strncmp(name, "/dev/bus/usb", 12)) 
-		return IFD_DEVICE_TYPE_USB;
-
-	if (stat(name, &stb) < 0)
-		return -1;
-
-	if (S_ISCHR(stb.st_mode)) {
-		int major = major(stb.st_rdev);
-		int minor = minor(stb.st_rdev);
-
-		if (major == TTY_MAJOR
-		    || major == PTY_SLAVE_MAJOR
-		    || (UNIX98_PTY_SLAVE_MAJOR <= major
-			&& major <
-			UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_MAJOR_COUNT))
-			return IFD_DEVICE_TYPE_SERIAL;
-
-		if (major == MISC_MAJOR && minor == 1)
-			return IFD_DEVICE_TYPE_PS2;
-	}
-
-	return -1;
-}
-
 /*
  * Poll for presence of USB device
  */
@@ -408,7 +367,7 @@ int ifd_sysdep_usb_end_capture(ifd_devic
 
 int ifd_sysdep_usb_open(const char *device)
 {
-        return open(device, O_RDWR);
+	return open(device, O_RDWR);
 }
 
 /*
@@ -443,13 +402,13 @@ int ifd_scan_usb(void)
 				 "/dev/bus/usb/%s/%s",
 				 bus->dirname, dev->filename);
 			if (stat(device, &buf) == 0) {
-				ifd_spawn_handler(driver, device, -1);
+				ifd_spawn_handler(driver, "usb", device, -1);
 			} else {
 				snprintf(device, sizeof(device),
-				 	"/proc/bus/usb/%s/%s",
-				 	bus->dirname, dev->filename);
-			
-				ifd_spawn_handler(driver, device, -1);
+					 "/proc/bus/usb/%s/%s",
+					 bus->dirname, dev->filename);
+
+				ifd_spawn_handler(driver, "usb", device, -1);
 			}
 		}
 	}
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-null.c openct/src/ifd/sys-null.c
--- openct.orig/src/ifd/sys-null.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/sys-null.c	2006-06-09 15:19:48.000000000 +0200
@@ -13,11 +13,6 @@
 #include <stdio.h>
 #include <openct/driver.h>
 
-int ifd_sysdep_device_type(const char *name)
-{
-	return -1;
-}
-
 /*
  * USB handling
  */
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-osx.c openct/src/ifd/sys-osx.c
--- openct.orig/src/ifd/sys-osx.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/sys-osx.c	2006-06-09 15:19:48.000000000 +0200
@@ -11,11 +11,6 @@
 #include <stdio.h>
 #include <openct/driver.h>
 
-int ifd_sysdep_device_type(const char *name)
-{
-	return -1;
-}
-
 /*
  * USB handling
  */
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-solaris.c openct/src/ifd/sys-solaris.c
--- openct.orig/src/ifd/sys-solaris.c	2006-04-24 23:00:04.000000000 +0200
+++ openct/src/ifd/sys-solaris.c	2006-06-09 15:19:48.000000000 +0200
@@ -185,8 +185,7 @@ int open_ep(char *name, int interface, i
 	return 0;
 }
 
-void
-close_ep(int interface, int endpoint, int direction)
+void close_ep(int interface, int endpoint, int direction)
 {
 	if (interfaces[interface][endpoint].ep_fd[direction]) {
 		close(interfaces[interface][endpoint].ep_fd[direction]);
@@ -221,36 +220,6 @@ prepare_usb_control_req(usb_request_t * 
 #endif				/* _BIG_ENDIAN */
 }
 
-int ifd_sysdep_device_type(const char *name)
-{
-	char *cwd;
-
-	if ((cwd = getcwd(NULL, PATH_MAX)) == NULL) {
-		return -1;
-	}
-	/*
-	 * A USB device that is supported through the UGEN driver
-	 * is typically indicated by its control endpoint.
-	 * Eg /dev/usb/<vendor>.<product>/<instance>/cntrl0
-	 */
-	ifd_debug(6, "ifd_sysdep_device_type: cwd=\"%s\" name=\"%s\"", cwd,
-		  name);
-
-	if (!name || name[0] != '/') {
-		ifd_debug(6,
-			  "ifd_sysdep_device_type: device name does not start with \"/\"");
-		return -1;
-	}
-
-	if (strncmp(name, "/dev/usb/", 9) == 0) {
-		ifd_debug(6, "ifd_sysdep_device_type: detected USB device");
-		return IFD_DEVICE_TYPE_USB;
-	}
-
-	ifd_debug(6, "ifd_sysdep_device_type: No USB device detected");
-	return -1;
-}
-
 /*
  * Poll for presence of USB device
  */
@@ -531,7 +500,7 @@ int ifd_sysdep_usb_end_capture(ifd_devic
 
 int ifd_sysdep_usb_open(const char *device)
 {
-        return open(device, O_RDWR);
+	return open(device, O_RDWR);
 }
 
 /*
diff -udrNPp --exclude=.svn openct.orig/src/ifd/sys-sunray.c openct/src/ifd/sys-sunray.c
--- openct.orig/src/ifd/sys-sunray.c	2006-04-24 23:00:04.000000000 +0200
+++ openct/src/ifd/sys-sunray.c	2006-06-09 15:19:48.000000000 +0200
@@ -32,23 +32,6 @@
 
 struct usb_dev_handle *devices[128];
 
-int ifd_sysdep_device_type(const char *name)
-{
-	char prefix[PATH_MAX];
-	char *utdevroot;
-
-	ifd_debug(1, "SunRay: ifd_sysdep_device_type(%s)", name);
-	if (!name || name[0] != '/')
-		return -1;
-
-	utdevroot = getenv("UTDEVROOT");
-	snprintf(prefix, sizeof(prefix), "%s/usb/", utdevroot ? utdevroot : "");
-	if (!strncmp(name, prefix, strlen(prefix)))
-		return IFD_DEVICE_TYPE_USB;
-
-	return -1;
-}
-
 /*
  * Poll for presence of USB device
  */
diff -udrNPp --exclude=.svn openct.orig/src/ifd/utils.c openct/src/ifd/utils.c
--- openct.orig/src/ifd/utils.c	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/ifd/utils.c	2006-06-09 15:19:54.000000000 +0200
@@ -78,14 +78,16 @@ long ifd_time_elapsed(struct timeval *th
 /*
  * Spawn an ifdhandler
  */
-int ifd_spawn_handler(const char *driver, const char *device, int idx)
+int ifd_spawn_handler(const char *driver, const char *type, const char *device,
+		      int idx)
 {
 	const char *argv[16];
 	char reader[16], debug[10];
 	int argc, n;
 	pid_t pid;
 
-	ifd_debug(1, "driver=%s, device=%s, index=%d", driver, device, idx);
+	ifd_debug(1, "driver=%s, type=%s, device=%s, index=%d", driver, type,
+		  device, idx);
 
 	if ((pid = fork()) < 0) {
 		ct_error("fork failed: %m");
@@ -123,8 +125,8 @@ int ifd_spawn_handler(const char *driver
 	}
 
 	argv[argc++] = driver;
-	if (device)
-		argv[argc++] = device;
+	argv[argc++] = type;
+	argv[argc++] = device;
 	argv[argc] = NULL;
 
 	n = getdtablesize();
diff -udrNPp --exclude=.svn openct.orig/src/include/openct/device.h openct/src/include/openct/device.h
--- openct.orig/src/include/openct/device.h	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/include/openct/device.h	2006-06-09 14:50:30.000000000 +0200
@@ -72,7 +72,7 @@ enum {
 };
 typedef struct ifd_usb_capture ifd_usb_capture_t;
 
-extern ifd_device_t *	ifd_device_open(const char *);
+extern ifd_device_t *	ifd_device_open(const char*, const char *);
 extern void		ifd_device_close(ifd_device_t *);
 extern int		ifd_device_type(ifd_device_t *);
 extern int		ifd_device_reset(ifd_device_t *);
diff -udrNPp --exclude=.svn openct.orig/src/include/openct/driver.h openct/src/include/openct/driver.h
--- openct.orig/src/include/openct/driver.h	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/include/openct/driver.h	2006-06-09 14:38:20.000000000 +0200
@@ -31,7 +31,8 @@ struct ifd_driver_ops {
 	 * Called by: ifd_open.
 	 * @return Error code <0 if failure.
 	 */
-	int		(*open)(ifd_reader_t *reader, const char *name);
+	int		(*open)(ifd_reader_t *reader, const char *type,
+					const char *device);
 	/**
 	 * Close the reader.
 	 *
diff -udrNPp --exclude=.svn openct.orig/src/include/openct/ifd.h openct/src/include/openct/ifd.h
--- openct.orig/src/include/openct/ifd.h	2006-04-21 08:38:04.000000000 +0200
+++ openct/src/include/openct/ifd.h	2006-06-09 15:03:33.000000000 +0200
@@ -105,6 +105,7 @@ enum {
 extern int			ifd_init(void);
 
 extern ifd_reader_t *		ifd_open(const char *driver_name,
+					const char *type_name,
 					const char *device_name);
 extern void			ifd_close(ifd_reader_t *);
 extern int			ifd_reader_count(void);
@@ -113,7 +114,7 @@ extern void			ifd_detach(ifd_reader_t *)
 extern ifd_reader_t *		ifd_reader_by_handle(unsigned int handle);
 extern ifd_reader_t *		ifd_reader_by_index(unsigned int index);
 
-extern int			ifd_spawn_handler(const char *, const char *, int);
+extern int			ifd_spawn_handler(const char *, const char *, const char *, int);
 extern int			ifd_scan_usb(void);
 
 extern int			ifd_activate(ifd_reader_t *);
diff -udrNPp --exclude=.svn openct.orig/src/tools/openct-control.c openct/src/tools/openct-control.c
--- openct.orig/src/tools/openct-control.c	2006-04-21 08:38:02.000000000 +0200
+++ openct/src/tools/openct-control.c	2006-06-09 15:20:00.000000000 +0200
@@ -160,14 +160,15 @@ int mgr_shutdown(int argc, char **argv)
  */
 int mgr_attach(int argc, char **argv)
 {
-	const char *device, *driver, *idstring;
+	const char *driver, *type, *device, *idstring;
 	ifd_devid_t id;
 	pid_t pid;
 
-	if (argc != 3)
+	if (argc != 4)
 		usage(1);
-	device = argv[1];
-	idstring = argv[2];
+	type = argv[1];
+	device = argv[2];
+	idstring = argv[3];
 
 	/* Initialize IFD library */
 	ifd_init();
@@ -182,7 +183,7 @@ int mgr_attach(int argc, char **argv)
 		return 1;
 	}
 
-	pid = ifd_spawn_handler(driver, device, -1);
+	pid = ifd_spawn_handler(driver, type, device, -1);
 	return (pid > 0) ? 0 : 1;
 }
 
@@ -244,23 +245,37 @@ int mgr_status(int argc, char **argv)
 void configure_reader(ifd_conf_node_t * cf)
 {
 	static unsigned int nreaders = 0;
-	char *device, *driver;
+	char *driver, *type, *device;
 
-	if (ifd_conf_node_get_string(cf, "device", &device) < 0) {
+	if (ifd_conf_node_get_string(cf, "device", &type) < 0) {
 		ct_error("no device specified in reader configuration");
 		return;
 	}
 
-	if (ifd_conf_node_get_string(cf, "driver", &driver) < 0)
-		driver = "auto";
+	device = type;
+	while (*device && *device != ':')
+		device++;
+	if (*device == ':') {
+		*device = 0;
+		device++;
+	} else {
+		ct_error("cannot parse device string %s into type and device",
+			 type);
+		return;
+	}
 
-	if (device == NULL && driver == NULL) {
-		ct_error("neither device nor driver specified "
+	if (ifd_conf_node_get_string(cf, "driver", &driver) < 0) {
+		ct_error("no driver found");
+		return;
+	}
+
+	if (device == NULL || type == NULL || driver == NULL) {
+		ct_error("driver, type or device information not "
 			 "in reader configuration");
 		return;
 	}
 
-	ifd_spawn_handler(driver, device, nreaders++);
+	ifd_spawn_handler(driver, type, device, nreaders++);
 }
 
 /*
@@ -286,7 +301,7 @@ void usage(int exval)
 		"  -v   display version and exit\n"
 		"\nWhere command is one of:\n"
 		"init - initialize OpenCT\n"
-		"attach device ident - attach a hotplug device\n"
+		"attach type device ident - attach a hotplug device\n"
 		"status - display status of all readers present\n"
 		"shutdown - shutdown OpenCT\n", OPENCT_CONF_PATH);
 	exit(exval);
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to