--- /dev/null
+/*
+ * (C) 2006 by Frank Zirkelbach <hackbard@hackdaworld.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <usb.h>
+#include "gemtag.h"
+
+/* variables */
+
+struct gemtag_handle {
+ struct usb_dev_handle *handle;
+};
+
+/* functions */
+
+struct usb_device *find_device(unsigned short vendor, unsigned short device) {
+
+ struct usb_bus *bus;
+ struct usb_device *dev;
+
+ bus=usb_get_busses();
+ while(bus) {
+ dev=bus->devices;
+ while(dev) {
+ if(dev->descriptor.idVendor==vendor &&
+ dev->descriptor.idProduct==device)
+ return dev;
+ dev=dev->next;
+ }
+ bus=bus->next;
+ }
+ return NULL;
+}
+
+struct gemtag_handle *gemtag_open(void) {
+ struct usb_device *gemtag;
+ unsigned char rbuf[16];
+ unsigned int rlen;
+ unsigned int i,numconf;
+ unsigned int j,numint;
+ struct gemtag_handle *gh;
+
+ rlen=sizeof(rbuf);
+
+ usb_init();
+ usb_find_busses();
+ usb_find_devices();
+
+ gemtag=find_device(USB_VENDOR_GEMTAG, USB_DEVICE_X501);
+ if(!gemtag) return NULL;
+
+ gh=malloc(sizeof(struct gemtag_handle));
+ if(!gh) return NULL;
+
+ memset(gh,0,sizeof(struct gemtag_handle));
+
+ numconf=gemtag->descriptor.bNumConfigurations;
+ printf("found gemtag, %u configurations\n",numconf);
+ for(i=0;i<numconf;i++) {
+ numint=gemtag->config[i].bNumInterfaces;
+ printf("config %u [nr %u] has %u interfaces\n",
+ i,gemtag->config[i].bConfigurationValue,
+ numint);
+ for(j=0;j<numint;j++) {
+ printf("config %u interface %u has %u altsettings\n",
+ i,j,gemtag->config[i].interface[j].num_altsetting);
+ }
+ }
+
+ gh->handle=usb_open(gemtag);
+ if(!gh->handle)
+ goto out_free;
+
+out_free:
+ free(gh);
+ return NULL;
+}
+
+int main(int argc, char **argv) {
+
+ struct gemtag_handle *gh;
+
+ gh=gemtag_open();
+
+ return 1;
+}
+
--- /dev/null
+/*
+ * (C) 2006 by Frank Zirkelbach <hackbard@hackdaworld.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _GEMTAG_H
+#define _GEMTAG_H
+
+#define USB_VENDOR_GEMTAG 0x1394
+#define USB_DEVICE_X501 0x0501
+
+#endif