Changeset e160da4d in mainline for uspace/app/usbinfo/main.c


Ignore:
Timestamp:
2011-03-17T21:11:52Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da77278
Parents:
81ca204
Message:

Add printing of descriptor tree to usbinfo

File:
1 edited

Legend:

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

    r81ca204 re160da4d  
    4747#include "usbinfo.h"
    4848
    49 static void print_usage(char *app_name)
    50 {
    51 #define INDENT "      "
    52         printf(NAME ": query USB devices for descriptors\n\n");
    53         printf("Usage: %s [options] device [device [device [ ... ]]]\n",
    54             app_name);
    55         printf(INDENT "The device is a devman path to the device.\n");
    56         printf("\n");
    57 #undef INDENT
    58 }
    59 
    6049static bool resolve_hc_handle_and_dev_addr(const char *devpath,
    6150    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
     
    130119}
    131120
     121static void print_usage(char *app_name)
     122{
     123#define _INDENT "      "
     124#define _OPTION(opt, description) \
     125        printf(_INDENT opt "\n" _INDENT _INDENT description "\n")
     126
     127        printf(NAME ": query USB devices for descriptors\n\n");
     128        printf("Usage: %s [options] device [device [device [ ... ]]]\n",
     129            app_name);
     130        printf(_INDENT "The device is a devman path to the device.\n");
     131
     132        _OPTION("-h --help", "Print this help and exit.");
     133        _OPTION("-i --identification", "Brief device identification.");
     134        _OPTION("-m --match-ids", "Print match ids generated for the device.");
     135        _OPTION("-t --descriptor-tree", "Print descriptor tree.");
     136
     137        printf("\n");
     138        printf("If no option is specified, `-i' is considered default.\n");
     139        printf("\n");
     140
     141#undef _OPTION
     142#undef _INDENT
     143}
     144
    132145static struct option long_options[] = {
    133146        {"help", no_argument, NULL, 'h'},
    134147        {"identification", no_argument, NULL, 'i'},
    135148        {"match-ids", no_argument, NULL, 'm'},
     149        {"descriptor-tree", no_argument, NULL, 't'},
    136150        {0, 0, NULL, 0}
    137151};
    138 static const char *short_options = "him";
     152static const char *short_options = "himt";
    139153
    140154int main(int argc, char *argv[])
     
    147161        bool action_print_short_identification = false;
    148162        bool action_print_match_ids = false;
     163        bool action_print_descriptor_tree = false;
    149164
    150165        /*
     
    171186                                action_print_match_ids = true;
    172187                                break;
     188                        case 't':
     189                                action_print_descriptor_tree = true;
     190                                break;
    173191                        default:
     192                                assert(false && "unreachable code");
    174193                                break;
    175194                }
     
    177196
    178197        /* Set the default action. */
    179         if (!action_print_match_ids && !action_print_short_identification) {
     198        if (!action_print_match_ids
     199            && !action_print_short_identification
     200            && !action_print_descriptor_tree) {
    180201                action_print_short_identification = true;
    181202        }
     
    215236                        dump_device_match_ids(dev);
    216237                }
     238                if (action_print_descriptor_tree) {
     239                        dump_descriptor_tree_brief(dev);
     240                }
    217241
    218242                /* Destroy the control pipe (close the session etc.). */
Note: See TracChangeset for help on using the changeset viewer.