Changeset ca56afa in mainline for uspace/app/usbinfo/info.c


Ignore:
Timestamp:
2011-02-25T09:46:23Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d493ac17
Parents:
15b0432 (diff), a80849c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with /usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/info.c

    r15b0432 rca56afa  
    129129            config_descriptor.total_length);
    130130
     131        /*
     132         * Get supported languages of STRING descriptors.
     133         */
     134        l18_win_locales_t *langs;
     135        size_t langs_count;
     136        rc = usb_request_get_supported_languages(&ctrl_pipe,
     137            &langs, &langs_count);
     138        if (rc != EOK) {
     139                fprintf(stderr,
     140                    NAME ": failed to get list of supported languages: %s.\n",
     141                    str_error(rc));
     142                goto skip_strings;
     143        }
     144
     145        printf("String languages (%zu):", langs_count);
     146        size_t i;
     147        for (i = 0; i < langs_count; i++) {
     148                printf(" 0x%04x", (int) langs[i]);
     149        }
     150        printf(".\n");
     151
     152        /*
     153         * Dump all strings in all available langages;
     154         */
     155        for (i = 0; i < langs_count; i++) {
     156                l18_win_locales_t lang = langs[i];
     157
     158                printf("%sStrings for language 0x%04x:\n", get_indent(0),
     159                    (int) lang);
     160
     161                /*
     162                 * Try all indexes - we will see what pops-up ;-).
     163                 * However, to speed things up, we will stop after
     164                 * encountering several broken (or nonexistent ones)
     165                 * descriptors in line.
     166                 */
     167                size_t idx;
     168                size_t failed_count = 0;
     169                for (idx = 1; idx < 0xFF; idx++) {
     170                        char *string;
     171                        rc = usb_request_get_string(&ctrl_pipe, idx, lang,
     172                            &string);
     173                        if (rc != EOK) {
     174                                failed_count++;
     175                                if (failed_count > 3) {
     176                                        break;
     177                                }
     178                                continue;
     179                        }
     180                        printf("%sString #%zu: \"%s\"\n", get_indent(1),
     181                            idx, string);
     182                        free(string);
     183                        failed_count = 0; /* Reset failed counter. */
     184                }
     185        }
     186
     187
     188skip_strings:
     189
    131190        rc = EOK;
     191
    132192leave:
    133193        /* Ignoring errors here. */
Note: See TracChangeset for help on using the changeset viewer.