Commit ddbfe749 authored by Stefan Richter's avatar Stefan Richter

tools/firewire: nosy-dump: remove unused code

Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 83ef7c75
...@@ -903,11 +903,12 @@ set_input_mode(void) ...@@ -903,11 +903,12 @@ set_input_mode(void)
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
uint32_t buf[128 * 1024];
uint32_t filter;
int length, retval, view;
int fd = -1; int fd = -1;
FILE *output = NULL, *input = NULL; FILE *output = NULL, *input = NULL;
poptContext con; poptContext con;
int retval;
int view;
char c; char c;
struct pollfd pollfds[2]; struct pollfd pollfds[2];
...@@ -961,70 +962,62 @@ int main(int argc, const char *argv[]) ...@@ -961,70 +962,62 @@ int main(int argc, const char *argv[])
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
if (1) { filter = ~0;
uint32_t buf[128 * 1024]; if (!option_iso)
uint32_t filter; filter &= ~(1 << TCODE_STREAM_DATA);
int length; if (!option_cycle_start)
filter &= ~(1 << TCODE_CYCLE_START);
if (view == VIEW_STATS)
filter = ~(1 << TCODE_CYCLE_START);
filter = ~0; ioctl(fd, NOSY_IOC_FILTER, filter);
if (!option_iso)
filter &= ~(1 << TCODE_STREAM_DATA);
if (!option_cycle_start)
filter &= ~(1 << TCODE_CYCLE_START);
if (view == VIEW_STATS)
filter = ~(1 << TCODE_CYCLE_START);
ioctl(fd, NOSY_IOC_FILTER, filter); ioctl(fd, NOSY_IOC_START);
ioctl(fd, NOSY_IOC_START); pollfds[0].fd = fd;
pollfds[0].events = POLLIN;
pollfds[1].fd = STDIN_FILENO;
pollfds[1].events = POLLIN;
pollfds[0].fd = fd; while (run) {
pollfds[0].events = POLLIN; if (input != NULL) {
pollfds[1].fd = STDIN_FILENO; if (fread(&length, sizeof length, 1, input) != 1)
pollfds[1].events = POLLIN; return 0;
fread(buf, 1, length, input);
while (run) { } else {
if (input != NULL) { poll(pollfds, 2, -1);
if (fread(&length, sizeof length, 1, input) != 1) if (pollfds[1].revents) {
read(STDIN_FILENO, &c, sizeof c);
switch (c) {
case 'q':
if (output != NULL)
fclose(output);
return 0; return 0;
fread(buf, 1, length, input);
} else {
poll(pollfds, 2, -1);
if (pollfds[1].revents) {
read(STDIN_FILENO, &c, sizeof c);
switch (c) {
case 'q':
if (output != NULL)
fclose(output);
return 0;
}
} }
if (pollfds[0].revents)
length = read(fd, buf, sizeof buf);
else
continue;
} }
if (output != NULL) { if (pollfds[0].revents)
fwrite(&length, sizeof length, 1, output); length = read(fd, buf, sizeof buf);
fwrite(buf, 1, length, output); else
} continue;
}
switch (view) { if (output != NULL) {
case VIEW_TRANSACTION: fwrite(&length, sizeof length, 1, output);
handle_packet(buf, length); fwrite(buf, 1, length, output);
break; }
case VIEW_PACKET:
print_packet(buf, length); switch (view) {
break; case VIEW_TRANSACTION:
case VIEW_STATS: handle_packet(buf, length);
print_stats(buf, length); break;
break; case VIEW_PACKET:
} print_packet(buf, length);
break;
case VIEW_STATS:
print_stats(buf, length);
break;
} }
} else {
poptPrintUsage(con, stdout, 0);
} }
if (output != NULL) if (output != NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment