Changeset 28129 for trunk/psModules/src/extras/pmVisual.c
- Timestamp:
- May 26, 2010, 4:53:35 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/extras/pmVisual.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/extras/pmVisual.c
r25754 r28129 86 86 87 87 88 // ask the user to continue or not. give up after 2 seconds. 89 // XXX add option to turn on/off timeouts? 88 90 bool pmVisualAskUser(bool *plotFlag) 89 91 { 92 struct timeval timeout; 93 fd_set fdSet; 94 int status; 95 90 96 char key[10]; 91 97 if (plotFlag) { 92 fprintf (std out, "[c]ontinue? [s]kip the rest of these plots? [a]bort all visual plots? (c) ");98 fprintf (stderr, "[p]ause? [c]ontinue? [s]kip the rest of these plots? [a]bort all visual plots? (c) "); 93 99 } else { 94 fprintf (stdout, "[c]ontinue? [a]bort all visual plots? (c) "); 95 } 96 if (!fgets(key, 8, stdin)) { 97 psWarning("Unable to read option"); 98 } 99 if (plotFlag && (key[0] == 's')) { 100 *plotFlag = false; 101 } 102 if (key[0] == 'a') { 103 isVisual = false; 100 fprintf (stderr, "[p]ause? [c]ontinue? [a]bort all visual plots? (c) "); 101 } 102 103 /* Wait up to 1.0 second for a response, then continue */ 104 timeout.tv_sec = 2; 105 timeout.tv_usec = 0; 106 107 FD_ZERO (&fdSet); 108 FD_SET (STDIN_FILENO, &fdSet); 109 110 status = select (1, &fdSet, NULL, NULL, &timeout); 111 if (status <= 0) { 112 fprintf (stderr, "\n"); 113 return true; // if no data, give up 114 } 115 116 while (true) { 117 if (!fgets(key, 8, stdin)) { 118 psWarning("Unable to read option"); 119 } 120 switch (key[0]) { 121 case 's': 122 if (plotFlag) *plotFlag = false; 123 *plotFlag = false; 124 return true; 125 case 'a': 126 isVisual = false; 127 return true; 128 case 'c': 129 case '\n': 130 return true; 131 default: 132 break; 133 } 134 135 if (plotFlag) { 136 fprintf (stderr, "[c]ontinue? [s]kip the rest of these plots? [a]bort all visual plots? (c) "); 137 } else { 138 fprintf (stderr, "[c]ontinue? [a]bort all visual plots? (c) "); 139 } 104 140 } 105 141 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
