annotate mot931c/ptydump.c @ 313:9b5079989681

frbl/reconst/inc/command.h: tab fixes
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 04 Mar 2020 23:10:48 +0000
parents 9082f3991fe5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
157
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <sys/file.h>
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <stdio.h>
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <stdlib.h>
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 main(argc, argv)
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 char **argv;
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 int fd;
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 u_char buf[1024];
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 int cc, i;
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 if (argc != 2) {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 fprintf(stderr, "usage: %s pty\n", argv[0]);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 exit(1);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 }
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 fd = open(argv[1], O_RDWR);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 if (fd < 0) {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 perror(argv[1]);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 exit(1);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 }
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 for (;;) {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 cc = read(fd, buf, sizeof buf);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (cc < 0) {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 perror("read error");
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 exit(1);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 }
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if (cc == 0) {
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 fprintf(stderr, "read EOF\n");
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 exit(1);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 }
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 printf("read %d bytes:", cc);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 for (i = 0; i < cc; i++)
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 printf(" %02X", buf[i]);
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 putchar('\n');
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
9082f3991fe5 mot931c break-in procedure cracked
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }