Changeset e160da4d in mainline for uspace/app/usbinfo/main.c
- Timestamp:
- 2011-03-17T21:11:52Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da77278
- Parents:
- 81ca204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/main.c
r81ca204 re160da4d 47 47 #include "usbinfo.h" 48 48 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 INDENT58 }59 60 49 static bool resolve_hc_handle_and_dev_addr(const char *devpath, 61 50 devman_handle_t *out_hc_handle, usb_address_t *out_device_address) … … 130 119 } 131 120 121 static 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 132 145 static struct option long_options[] = { 133 146 {"help", no_argument, NULL, 'h'}, 134 147 {"identification", no_argument, NULL, 'i'}, 135 148 {"match-ids", no_argument, NULL, 'm'}, 149 {"descriptor-tree", no_argument, NULL, 't'}, 136 150 {0, 0, NULL, 0} 137 151 }; 138 static const char *short_options = "him ";152 static const char *short_options = "himt"; 139 153 140 154 int main(int argc, char *argv[]) … … 147 161 bool action_print_short_identification = false; 148 162 bool action_print_match_ids = false; 163 bool action_print_descriptor_tree = false; 149 164 150 165 /* … … 171 186 action_print_match_ids = true; 172 187 break; 188 case 't': 189 action_print_descriptor_tree = true; 190 break; 173 191 default: 192 assert(false && "unreachable code"); 174 193 break; 175 194 } … … 177 196 178 197 /* 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) { 180 201 action_print_short_identification = true; 181 202 } … … 215 236 dump_device_match_ids(dev); 216 237 } 238 if (action_print_descriptor_tree) { 239 dump_descriptor_tree_brief(dev); 240 } 217 241 218 242 /* Destroy the control pipe (close the session etc.). */
Note:
See TracChangeset
for help on using the changeset viewer.