FreeCalypso > hg > freecalypso-reveng
comparison mot931c/ptydump.c @ 157:9082f3991fe5
mot931c break-in procedure cracked
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Wed, 14 May 2014 05:34:37 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 156:275d0f71a014 | 157:9082f3991fe5 |
|---|---|
| 1 #include <sys/types.h> | |
| 2 #include <sys/file.h> | |
| 3 #include <stdio.h> | |
| 4 #include <stdlib.h> | |
| 5 | |
| 6 main(argc, argv) | |
| 7 char **argv; | |
| 8 { | |
| 9 int fd; | |
| 10 u_char buf[1024]; | |
| 11 int cc, i; | |
| 12 | |
| 13 if (argc != 2) { | |
| 14 fprintf(stderr, "usage: %s pty\n", argv[0]); | |
| 15 exit(1); | |
| 16 } | |
| 17 fd = open(argv[1], O_RDWR); | |
| 18 if (fd < 0) { | |
| 19 perror(argv[1]); | |
| 20 exit(1); | |
| 21 } | |
| 22 for (;;) { | |
| 23 cc = read(fd, buf, sizeof buf); | |
| 24 if (cc < 0) { | |
| 25 perror("read error"); | |
| 26 exit(1); | |
| 27 } | |
| 28 if (cc == 0) { | |
| 29 fprintf(stderr, "read EOF\n"); | |
| 30 exit(1); | |
| 31 } | |
| 32 printf("read %d bytes:", cc); | |
| 33 for (i = 0; i < cc; i++) | |
| 34 printf(" %02X", buf[i]); | |
| 35 putchar('\n'); | |
| 36 } | |
| 37 } |
