aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usbdump.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usbdump.c b/usbdump.c
index fd3358e..84ea108 100644
--- a/usbdump.c
+++ b/usbdump.c
@@ -40,6 +40,7 @@
#define LINEBUF_LEN 16383
int opt_unique_num = 0;
+int opt_data_limit = -1;
int opt_control_only = 0;
int64_t start_ts = 0;
@@ -62,7 +63,7 @@ void hexdump(char *linebuf, void *address, int length)
n = strlen(linebuf);
buf = address;
- for (i = 0; i < length; i++) {
+ for (i = 0; i < length && (opt_data_limit == -1 || i < opt_data_limit); i++) {
if (n > LINEBUF_LEN - 4)
continue;
if (i && !(i & 0x01)) {
@@ -309,7 +310,7 @@ void usage(void)
{
printf("usbdump Copyright (C) 2011 Bert Vermeulen <bert@biot.com>\n");
- printf("usage: usbdump -d <vid:pid> [-u <num lines>] [-c]\n");
+ printf("usage: usbdump -d <vid:pid> [-u <num lines>] [-l <data limit>] [-c]\n");
}
@@ -319,7 +320,7 @@ int main(int argc, char **argv)
char *device, *entry;
device = NULL;
- while ((opt = getopt(argc, argv, "d:u:c")) != -1) {
+ while ((opt = getopt(argc, argv, "d:u:l:c")) != -1) {
switch (opt) {
case 'd':
if (strlen(optarg) != 9 || strspn(optarg, "01234567890abcdef:") != 9)
@@ -330,6 +331,9 @@ int main(int argc, char **argv)
case 'u':
opt_unique_num = strtol(optarg, NULL, 10);
break;
+ case 'l':
+ opt_data_limit = strtol(optarg, NULL, 10);
+ break;
case 'c':
opt_control_only = 1;
break;