-#ifdef DEBUG
- if (tr->cmdTrans == 13)
- DPRINTF("write byte: %d\n", val);
-#endif
-
- if (parportfd < 0)
- return ret;
-
- if (port == ppbase + PP_DATA) {
- DPRINTF("data port\n");
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = 0; /* We don't support reading of the data port */
- break;
-
- case PP_WRITE:
- ret = ioctl(parportfd, PPWDATA, &val);
- last_pp_write = val;
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
- }
- } else if (port == ppbase + PP_STATUS) {
- DPRINTF("status port (last write: %d)\n", last_pp_write);
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = ioctl(parportfd, PPRSTATUS, &val);
-#ifdef FORCE_PC3_IDENT
- val &= 0x5f;
- if (last_pp_write & 0x40)
- val |= 0x20;
- else
- val |= 0x80;
-#endif
- break;
-
- case PP_WRITE:
- ret = 0; /* Status Port is readonly */
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
- }
- } else if (port == ppbase + PP_CONTROL) {
- DPRINTF("control port\n");
- switch(tr->cmdTrans) {
- case PP_READ:
- ret = ioctl(parportfd, PPRCONTROL, &val);
- break;
-
- case PP_WRITE:
- ret = ioctl(parportfd, PPWCONTROL, &val);
- break;
-
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
+ if (claim) {
+ if (claimed)
+ return 0;
+
+ ret = usb_claim_interface(usb_devhandle, usbinterface);
+ if (!ret) {
+ claimed = 1;
+ ret = usb_set_altinterface(usb_devhandle, usbalternate);
+ if (ret)
+ fprintf(stderr, "usb_set_altinterface: %d\n", ret);
+ } else {
+ fprintf(stderr, "usb_claim_interface: %d -> %d (%s)\n",
+ usbinterface, ret, usb_strerror());