tools/firewire: nosy-dump: remove unused code

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
Stefan Richter 2010-07-22 11:58:05 +02:00
parent 83ef7c7593
commit ddbfe74958
1 changed files with 50 additions and 57 deletions

View File

@ -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[])
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) {
case VIEW_TRANSACTION: if (output != NULL) {
handle_packet(buf, length); fwrite(&length, sizeof length, 1, output);
break; fwrite(buf, 1, length, output);
case VIEW_PACKET: }
print_packet(buf, length);
break; switch (view) {
case VIEW_STATS: case VIEW_TRANSACTION:
print_stats(buf, length); handle_packet(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)