- pp_config[3].real = 0;
- pp_config[3].usb_vid = 0x0403;
- pp_config[3].usb_pid = 0xcff8;
- pp_config[3].open = jtagkey_open;
- pp_config[3].close = jtagkey_close;
- pp_config[3].transfer = jtagkey_transfer;
+ line = 0;
+ do {
+ pbuf = fgets(buf, sizeof(buf), cfg);
+ if (!pbuf)
+ break;
+
+ line++;
+
+ len = strlen(buf);
+
+ if (len > 0 && buf[len-1] == '\n') {
+ buf[len-1] = '\0';
+ len--;
+ }
+ if (len > 0 && buf[len-1] == '\r') {
+ buf[len-1] = '\0';
+ len--;
+ }
+
+ for (i = 0; i < len; i++) {
+ if (buf[i] != ' ' && buf[i] != '\t')
+ break;
+ }
+
+ if (buf[i] == '#' || buf[i] == ';' || buf[i] == '\0')
+ continue;
+
+ if (!strncasecmp(buf+i, "LPT", 3)) {
+ unsigned char equal_seen = 0;
+
+ i += 3;
+ pbuf = buf+i;
+ for (; i < len; i++) {
+ if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == '=') {
+ if (buf[i] == '=')
+ equal_seen = 1;
+
+ buf[i] = '\0';
+ i++;
+ break;
+ }
+ }
+
+ if (*pbuf == '\0') {
+ PARSEERROR;
+ continue;
+ }
+
+ num = 0;
+ num = strtol(pbuf, NULL, 10);
+ if (num < 1) {
+ PARSEERROR;
+ continue;
+ }
+ num--;
+
+ for (; (i < len) && (!equal_seen) ; i++) {
+ if (buf[i] == '=') {
+ equal_seen = 1;
+ i++;
+ break;
+ } else if (buf[i] != ' ' && buf[i] != '\t') {
+ break;
+ }
+ }
+
+ if (!equal_seen) {
+ PARSEERROR;
+ continue;
+ }
+
+ for (; i < len; i++) {
+ if (buf[i] != ' ' && buf[i] != '\t')
+ break;
+ }
+
+ if (strncasecmp(buf+i, "FTDI:", 5)) {
+ PARSEERROR;
+ continue;
+ }
+
+ i += 5;
+ pbuf = buf + i;
+
+ for (; i < len; i++) {
+ if (buf[i] == ':')
+ break;
+ }
+
+ if (buf[i] != ':') {
+ PARSEERROR;
+ continue;
+ }
+
+ buf[i] = '\0';
+
+ vid = 0;
+ vid = strtol(pbuf, NULL, 16);
+ if (!num) {
+ PARSEERROR;
+ continue;
+ }
+
+ i++;
+ pbuf = buf + i;
+
+ for (; i < len; i++) {
+ if (buf[i] == ' ' || buf[i] == '\t')
+ break;
+ }
+
+ pid = 0;
+ pid = strtol(pbuf, NULL, 16);
+ if (!num) {
+ PARSEERROR;
+ continue;
+ }
+
+ pp_config[num].real = 0;
+ pp_config[num].usb_vid = vid;
+ pp_config[num].usb_pid = pid;
+ pp_config[num].open = jtagkey_open;
+ pp_config[num].close = jtagkey_close;
+ pp_config[num].transfer = jtagkey_transfer;
+ } else {
+ PARSEERROR;
+ }
+ } while (pbuf);
+#else
+ fprintf(stderr,"libusb-driver not compiled with FTDI2232-support, config file ignored!\n");