FreeCalypso > hg > freecalypso-sw
annotate rvinterf/tmsh/main.c @ 839:5ab66dadefdd
gdi: power.c compiles
| author | Space Falcon <falcon@ivan.Harhan.ORG> | 
|---|---|
| date | Sat, 25 Apr 2015 19:29:38 +0000 | 
| parents | c146f38d2b5f | 
| children | 
| 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 | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 16 extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
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 { | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 21 extern int optind; | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 22 extern char *optarg; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 23 int c; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 24 fd_set fds; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 25 | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 26 while ((c = getopt(argc, argv, "B:dl:s:w:")) != EOF) | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 27 switch (c) { | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 28 case 'B': | 
| 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 29 rvinterf_Bopt = optarg; | 
| 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 30 continue; | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 31 case 'd': | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 32 dflag++; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 33 continue; | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 34 case 'l': | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 35 rvinterf_lopt = optarg; | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 36 continue; | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 37 case 's': | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 38 socket_pathname = optarg; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 39 continue; | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 40 case 'w': | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 41 rvinterf_wopt = optarg; | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 42 continue; | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 43 case '?': | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 44 default: | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 45 usage: fprintf(stderr, | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 46 "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 | 47 exit(1); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 48 } | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 49 switch (argc - optind) { | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 50 case 0: | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 51 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 52 fprintf(stderr, | 
| 200 
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
197diff
changeset | 53 "%s: -B, -l and -w options are meaningful only when launching rvinterf\n", | 
| 197 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 54 argv[0]); | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 55 exit(1); | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 56 } | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 57 break; | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 58 case 1: | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 59 launch_rvinterf(argv[optind]); | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 60 break; | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 61 default: | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 62 goto usage; | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 63 } | 
| 
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: 
182diff
changeset | 64 | 
| 182 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 65 ttyhacks = isatty(0) && !dflag; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 66 init(); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 67 tty_init(); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 68 for (;;) { | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 69 FD_ZERO(&fds); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 70 FD_SET(0, &fds); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 71 FD_SET(sock, &fds); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 72 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 | 73 if (c < 0) { | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 74 if (errno == EINTR) | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 75 continue; | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 76 tty_cleanup(); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 77 perror("select"); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 78 exit(1); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 79 } | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 80 if (FD_ISSET(0, &fds)) | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 81 handle_tty_input(); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 82 if (FD_ISSET(sock, &fds)) | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 83 handle_rvinterf_input(); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 84 fflush(stdout); | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 85 } | 
| 
13a0348ffce4
rvinterf/etm: checkpointing not-yet-compilable code
 Michael Spacefalcon <msokolov@ivan.Harhan.ORG> parents: diff
changeset | 86 } | 
