static int usb_host_scan_sys(void *opaque, USBScanFunc *func)

{

    DIR *dir = 0;

    char line[1024];

    int bus_num, addr, speed, class_id, product_id, vendor_id;

    int ret = 0;

    char product_name[512];

    struct dirent *de;



    dir = opendir(USBSYSBUS_PATH "/devices");

    if (!dir) {

        perror("husb: cannot open devices directory");

        goto the_end;

    }



    while ((de = readdir(dir))) {

        if (de->d_name[0] != '.' && !strchr(de->d_name, ':')) {

            char *tmpstr = de->d_name;

            if (!strncmp(de->d_name, "usb", 3))

                tmpstr += 3;

            bus_num = atoi(tmpstr);



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/devnum", de->d_name))

                goto the_end;

            if (sscanf(line, "%d", &addr) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/bDeviceClass", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &class_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idVendor", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &vendor_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idProduct", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &product_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/product", de->d_name)) {

                *product_name = 0;

            } else {

                if (strlen(line) > 0)

                    line[strlen(line) - 1] = '\0';

                pstrcpy(product_name, sizeof(product_name), line);

            }



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/speed", de->d_name))

                goto the_end;

            if (!strcmp(line, "480\n"))

                speed = USB_SPEED_HIGH;

            else if (!strcmp(line, "1.5\n"))

                speed = USB_SPEED_LOW;

            else

                speed = USB_SPEED_FULL;



            ret = func(opaque, bus_num, addr, class_id, vendor_id,

                       product_id, product_name, speed);

            if (ret)

                goto the_end;

        }

    }

 the_end:

    if (dir)

        closedir(dir);

    return ret;

}

static int usb_host_scan_sys(void *opaque, USBScanFunc *func)

{

    DIR *dir = 0;

    char line[1024];

    int bus_num, addr, speed, class_id, product_id, vendor_id;

    int ret = 0;

    char product_name[512];

    struct dirent *de;



    dir = opendir(USBSYSBUS_PATH "/devices");

    if (!dir) {

        perror("husb: cannot open devices directory");

        goto the_end;

    }



    while ((de = readdir(dir))) {

        if (de->d_name[0] != '.' && !strchr(de->d_name, ':')) {

            char *tmpstr = de->d_name;

            if (!strncmp(de->d_name, "usb", 3))

                tmpstr += 3;

            bus_num = atoi(tmpstr);



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/devnum", de->d_name))

                goto the_end;

            if (sscanf(line, "%d", &addr) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/bDeviceClass", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &class_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idVendor", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &vendor_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/idProduct", de->d_name))

                goto the_end;

            if (sscanf(line, "%x", &product_id) != 1)

                goto the_end;



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/product", de->d_name)) {

                *product_name = 0;

            } else {

                if (strlen(line) > 0)

                    line[strlen(line) - 1] = '\0';

                pstrcpy(product_name, sizeof(product_name), line);

            }



            if (!usb_host_read_file(line, sizeof(line), USBSYSBUS_PATH "/devices/%s/speed", de->d_name))

                goto the_end;

            if (!strcmp(line, "480\n"))

                speed = USB_SPEED_HIGH;

            else if (!strcmp(line, "1.5\n"))

                speed = USB_SPEED_LOW;

            else

                speed = USB_SPEED_FULL;



            ret = func(opaque, bus_num, addr, class_id, vendor_id,

                       product_id, product_name, speed);

            if (ret)

                goto the_end;

        }

    }

 the_end:

    if (dir)

        closedir(dir);

    return ret;

}

static int FUNC_0(void *VAR_0, USBScanFunc *VAR_1)

{

    DIR *dir = 0;

    char VAR_2[1024];

    int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;

    int VAR_9 = 0;

    char VAR_10[512];

    struct dirent *VAR_11;



    dir = opendir(USBSYSBUS_PATH "/devices");

    if (!dir) {

        perror("husb: cannot open devices directory");

        goto the_end;

    }



    while ((VAR_11 = readdir(dir))) {

        if (VAR_11->d_name[0] != '.' && !strchr(VAR_11->d_name, ':')) {

            char *VAR_12 = VAR_11->d_name;

            if (!strncmp(VAR_11->d_name, "usb", 3))

                VAR_12 += 3;

            VAR_3 = atoi(VAR_12);



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/devnum", VAR_11->d_name))

                goto the_end;

            if (sscanf(VAR_2, "%d", &VAR_4) != 1)

                goto the_end;



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/bDeviceClass", VAR_11->d_name))

                goto the_end;

            if (sscanf(VAR_2, "%x", &VAR_6) != 1)

                goto the_end;



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/idVendor", VAR_11->d_name))

                goto the_end;

            if (sscanf(VAR_2, "%x", &VAR_8) != 1)

                goto the_end;



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/idProduct", VAR_11->d_name))

                goto the_end;

            if (sscanf(VAR_2, "%x", &VAR_7) != 1)

                goto the_end;



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/product", VAR_11->d_name)) {

                *VAR_10 = 0;

            } else {

                if (strlen(VAR_2) > 0)

                    VAR_2[strlen(VAR_2) - 1] = '\0';

                pstrcpy(VAR_10, sizeof(VAR_10), VAR_2);

            }



            if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/VAR_5", VAR_11->d_name))

                goto the_end;

            if (!strcmp(VAR_2, "480\n"))

                VAR_5 = USB_SPEED_HIGH;

            else if (!strcmp(VAR_2, "1.5\n"))

                VAR_5 = USB_SPEED_LOW;

            else

                VAR_5 = USB_SPEED_FULL;



            VAR_9 = VAR_1(VAR_0, VAR_3, VAR_4, VAR_6, VAR_8,

                       VAR_7, VAR_10, VAR_5);

            if (VAR_9)

                goto the_end;

        }

    }

 the_end:

    if (dir)

        closedir(dir);

    return VAR_9;

}

static int FUNC_0(void *VAR_0, USBScanFunc *VAR_1)
{ DIR *dir = 0; char VAR_2[1024]; int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; int VAR_9 = 0; char VAR_10[512]; struct dirent *VAR_11; dir = opendir(USBSYSBUS_PATH "/devices"); if (!dir) { perror("husb: cannot open devices directory"); goto the_end; } while ((VAR_11 = readdir(dir))) { if (VAR_11->d_name[0] != '.' && !strchr(VAR_11->d_name, ':')) { char *VAR_12 = VAR_11->d_name; if (!strncmp(VAR_11->d_name, "usb", 3))
VAR_12 += 3; VAR_3 = atoi(VAR_12); if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/devnum", VAR_11->d_name))
goto the_end; if (sscanf(VAR_2, "%d", &VAR_4) != 1)
goto the_end; if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/bDeviceClass", VAR_11->d_name))
goto the_end; if (sscanf(VAR_2, "%x", &VAR_6) != 1)
goto the_end; if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/idVendor", VAR_11->d_name))
goto the_end; if (sscanf(VAR_2, "%x", &VAR_8) != 1)
goto the_end; if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/idProduct", VAR_11->d_name))
goto the_end; if (sscanf(VAR_2, "%x", &VAR_7) != 1)
goto the_end; if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/product", VAR_11->d_name)) { *VAR_10 = 0; } else { if (strlen(VAR_2) > 0)
VAR_2[strlen(VAR_2) - 1] = '\0'; pstrcpy(VAR_10, sizeof(VAR_10), VAR_2); } if (!usb_host_read_file(VAR_2, sizeof(VAR_2), USBSYSBUS_PATH "/devices/%s/VAR_5", VAR_11->d_name))
goto the_end; if (!strcmp(VAR_2, "480\n"))
VAR_5 = USB_SPEED_HIGH; else if (!strcmp(VAR_2, "1.5\n"))
VAR_5 = USB_SPEED_LOW; else
VAR_5 = USB_SPEED_FULL; VAR_9 = VAR_1(VAR_0, VAR_3, VAR_4, VAR_6, VAR_8,
VAR_7, VAR_10, VAR_5); if (VAR_9)
goto the_end; } } the_end:
if (dir)
closedir(dir); return VAR_9; }