annotate rvinterf/etm/main.c @ 197:fa7174faa9aa

fc-tmsh: option to invoke rvinterf "behind the scenes"
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Dec 2013 07:31:52 +0000
parents 13a0348ffce4
children 2847b6cbd915
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the main() function for fc-tmsh.
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/errno.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <unistd.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 char *socket_pathname = "/tmp/rvinterf_socket";
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 int ttyhacks, dflag;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 int sock;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
16 extern char *rvinterf_lopt, *rvinterf_wopt;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
17
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 main(argc, argv)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 char **argv;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 extern char *optarg;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 int c;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 fd_set fds;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
25 while ((c = getopt(argc, argv, "dl:s:w:")) != EOF)
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 switch (c) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 case 'd':
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 dflag++;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 continue;
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
30 case 'l':
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
31 rvinterf_lopt = optarg;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
32 continue;
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 case 's':
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 socket_pathname = optarg;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 continue;
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
36 case 'w':
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
37 rvinterf_wopt = optarg;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
38 continue;
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 case '?':
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 default:
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
41 usage: fprintf(stderr,
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
42 "usage: %s [options] [ttyport]\n", argv[0]);
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 exit(1);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 }
197
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
45 switch (argc - optind) {
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
46 case 0:
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
47 if (rvinterf_lopt || rvinterf_wopt) {
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
48 fprintf(stderr,
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
49 "%s: -l and -w options are meaningful only when launching rvinterf\n",
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
50 argv[0]);
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
51 exit(1);
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
52 }
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
53 break;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
54 case 1:
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
55 launch_rvinterf(argv[optind]);
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
56 break;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
57 default:
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
58 goto usage;
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
59 }
fa7174faa9aa fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 182
diff changeset
60
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 ttyhacks = isatty(0) && !dflag;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 init();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 tty_init();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 for (;;) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 FD_ZERO(&fds);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 FD_SET(0, &fds);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 FD_SET(sock, &fds);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 c = select(sock+1, &fds, 0, 0, 0);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 if (c < 0) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 if (errno == EINTR)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 continue;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 tty_cleanup();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 perror("select");
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 exit(1);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 if (FD_ISSET(0, &fds))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 handle_tty_input();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 if (FD_ISSET(sock, &fds))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 handle_rvinterf_input();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 fflush(stdout);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 }