]> git.zerfleddert.de Git - usb-driver/blobdiff - config.c
update links for xc3sprog
[usb-driver] / config.c
index e09d5ca8989a96ffc50be23c7f5edb7ddb3f3658..2963129fbc95fc49d7bddf65f51605dd77a3ea53 100644 (file)
--- a/config.c
+++ b/config.c
@@ -17,11 +17,15 @@ static struct parport_config pp_config[4];
 
 static void read_config() {
        int i;
-       int line, len, num;
        static int config_read = 0;
        FILE *cfg;
-       char buf[LINELEN], *pbuf;
+       char buf[LINELEN];
+#ifdef JTAGKEY
+       char *pbuf;
        unsigned short vid, pid;
+       unsigned short iface;
+       int line, len, num;
+#endif
 
        if (config_read)
                return;
@@ -140,7 +144,7 @@ static void read_config() {
 
                                vid = 0;
                                vid = strtol(pbuf, NULL, 16);
-                               if (!num) {
+                               if (!vid) {
                                        PARSEERROR;
                                        continue;
                                }
@@ -149,20 +153,27 @@ static void read_config() {
                                pbuf = buf + i;
 
                                for (; i < len; i++) {
-                                       if (buf[i] == ' ' || buf[i] == '\t')
+                                       if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == ':')
                                                break;
                                }
 
                                pid = 0;
                                pid = strtol(pbuf, NULL, 16);
-                               if (!num) {
+                               if (!pid) {
                                        PARSEERROR;
                                        continue;
                                }
 
+                               iface = 0;
+                               pbuf = buf + i;
+                               if (pbuf[0] == ':') {
+                                       iface = atoi(pbuf + 1);
+                               }
+
                                pp_config[num].real = 0;
                                pp_config[num].usb_vid = vid;
                                pp_config[num].usb_pid = pid;
+                               pp_config[num].usb_iface = iface;
                                pp_config[num].open = jtagkey_open;
                                pp_config[num].close = jtagkey_close;
                                pp_config[num].transfer = jtagkey_transfer;
@@ -240,3 +251,20 @@ unsigned short config_usb_pid(int num) {
 
        return ret;
 }
+
+unsigned short config_usb_iface(int num) {
+       unsigned short ret = 0x00;
+       int i;
+       
+       read_config();
+       
+       for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
+               if (pp_config[i].num == num) {
+                       ret = pp_config[i].usb_iface;
+                       break;
+               }
+       }
+
+       return ret;
+}
+
Impressum, Datenschutz