-static Byte readbuffer[BUFSIZ];
-
-#ifdef CONFIG_FEATURE_VI_CRASHME
-static int totalcmds = 0;
-static int Mp = 85; // Movement command Probability
-static int Np = 90; // Non-movement command Probability
-static int Dp = 96; // Delete command Probability
-static int Ip = 97; // Insert command Probability
-static int Yp = 98; // Yank command Probability
-static int Pp = 99; // Put command Probability
-static int M = 0, N = 0, I = 0, D = 0, Y = 0, P = 0, U = 0;
-char chars[20] = "\t012345 abcdABCD-=.$";
-char *words[20] = { "this", "is", "a", "test",
- "broadcast", "the", "emergency", "of",
- "system", "quick", "brown", "fox",
- "jumped", "over", "lazy", "dogs",
- "back", "January", "Febuary", "March"
-};
-char *lines[20] = {
- "You should have received a copy of the GNU General Public License\n",
- "char c, cm, *cmd, *cmd1;\n",
- "generate a command by percentages\n",
- "Numbers may be typed as a prefix to some commands.\n",
- "Quit, discarding changes!\n",
- "Forced write, if permission originally not valid.\n",
- "In general, any ex or ed command (such as substitute or delete).\n",
- "I have tickets available for the Blazers vs LA Clippers for Monday, Janurary 1 at 1:00pm.\n",
- "Please get w/ me and I will go over it with you.\n",
- "The following is a list of scheduled, committed changes.\n",
- "1. Launch Norton Antivirus (Start, Programs, Norton Antivirus)\n",
- "Reminder....Town Meeting in Central Perk cafe today at 3:00pm.\n",
- "Any question about transactions please contact Sterling Huxley.\n",
- "I will try to get back to you by Friday, December 31.\n",
- "This Change will be implemented on Friday.\n",
- "Let me know if you have problems accessing this;\n",
- "Sterling Huxley recently added you to the access list.\n",
- "Would you like to go to lunch?\n",
- "The last command will be automatically run.\n",
- "This is too much english for a computer geek.\n",
-};
-char *multilines[20] = {
- "You should have received a copy of the GNU General Public License\n",
- "char c, cm, *cmd, *cmd1;\n",
- "generate a command by percentages\n",
- "Numbers may be typed as a prefix to some commands.\n",
- "Quit, discarding changes!\n",
- "Forced write, if permission originally not valid.\n",
- "In general, any ex or ed command (such as substitute or delete).\n",
- "I have tickets available for the Blazers vs LA Clippers for Monday, Janurary 1 at 1:00pm.\n",
- "Please get w/ me and I will go over it with you.\n",
- "The following is a list of scheduled, committed changes.\n",
- "1. Launch Norton Antivirus (Start, Programs, Norton Antivirus)\n",
- "Reminder....Town Meeting in Central Perk cafe today at 3:00pm.\n",
- "Any question about transactions please contact Sterling Huxley.\n",
- "I will try to get back to you by Friday, December 31.\n",
- "This Change will be implemented on Friday.\n",
- "Let me know if you have problems accessing this;\n",
- "Sterling Huxley recently added you to the access list.\n",
- "Would you like to go to lunch?\n",
- "The last command will be automatically run.\n",
- "This is too much english for a computer geek.\n",
-};
-
-// create a random command to execute
-static void crash_dummy()
-{
- static int sleeptime; // how long to pause between commands
- char c, cm, *cmd, *cmd1;
- int i, cnt, thing, rbi, startrbi, percent;
-
- // "dot" movement commands
- cmd1 = " \n\r\002\004\005\006\025\0310^$-+wWeEbBhjklHL";
-
- // is there already a command running?
- if (strlen((char *) readbuffer) > 0)
- goto cd1;
- cd0:
- startrbi = rbi = 0;
- sleeptime = 0; // how long to pause between commands
- memset(readbuffer, '\0', BUFSIZ - 1); // clear the read buffer
- // generate a command by percentages
- percent = (int) lrand48() % 100; // get a number from 0-99
- if (percent < Mp) { // Movement commands
- // available commands
- cmd = cmd1;
- M++;
- } else if (percent < Np) { // non-movement commands
- cmd = "mz<>\'\""; // available commands
- N++;
- } else if (percent < Dp) { // Delete commands
- cmd = "dx"; // available commands
- D++;
- } else if (percent < Ip) { // Inset commands
- cmd = "iIaAsrJ"; // available commands
- I++;
- } else if (percent < Yp) { // Yank commands
- cmd = "yY"; // available commands
- Y++;
- } else if (percent < Pp) { // Put commands
- cmd = "pP"; // available commands
- P++;
- } else {
- // We do not know how to handle this command, try again
- U++;
- goto cd0;
- }
- // randomly pick one of the available cmds from "cmd[]"
- i = (int) lrand48() % strlen(cmd);
- cm = cmd[i];
- if (strchr(":\024", cm))
- goto cd0; // dont allow colon or ctrl-T commands
- readbuffer[rbi++] = cm; // put cmd into input buffer
-
- // now we have the command-
- // there are 1, 2, and multi char commands
- // find out which and generate the rest of command as necessary
- if (strchr("dmryz<>\'\"", cm)) { // 2-char commands
- cmd1 = " \n\r0$^-+wWeEbBhjklHL";
- if (cm == 'm' || cm == '\'' || cm == '\"') { // pick a reg[]
- cmd1 = "abcdefghijklmnopqrstuvwxyz";
- }
- thing = (int) lrand48() % strlen(cmd1); // pick a movement command
- c = cmd1[thing];
- readbuffer[rbi++] = c; // add movement to input buffer
- }
- if (strchr("iIaAsc", cm)) { // multi-char commands
- if (cm == 'c') {
- // change some thing
- thing = (int) lrand48() % strlen(cmd1); // pick a movement command
- c = cmd1[thing];
- readbuffer[rbi++] = c; // add movement to input buffer
- }
- thing = (int) lrand48() % 4; // what thing to insert
- cnt = (int) lrand48() % 10; // how many to insert
- for (i = 0; i < cnt; i++) {
- if (thing == 0) { // insert chars
- readbuffer[rbi++] = chars[((int) lrand48() % strlen(chars))];
- } else if (thing == 1) { // insert words
- strcat((char *) readbuffer, words[(int) lrand48() % 20]);
- strcat((char *) readbuffer, " ");
- sleeptime = 0; // how fast to type
- } else if (thing == 2) { // insert lines
- strcat((char *) readbuffer, lines[(int) lrand48() % 20]);
- sleeptime = 0; // how fast to type
- } else { // insert multi-lines
- strcat((char *) readbuffer, multilines[(int) lrand48() % 20]);
- sleeptime = 0; // how fast to type
- }
- }
- strcat((char *) readbuffer, "\033");
- }
- cd1:
- totalcmds++;
- if (sleeptime > 0)
- (void) mysleep(sleeptime); // sleep 1/100 sec
-}
-
-// test to see if there are any errors
-static void crash_test()
-{
- static time_t oldtim;
- time_t tim;
- char d[2], buf[BUFSIZ], msg[BUFSIZ];
-
- msg[0] = '\0';
- if (end < text) {
- strcat((char *) msg, "end<text ");
- }
- if (end > textend) {
- strcat((char *) msg, "end>textend ");
- }
- if (dot < text) {
- strcat((char *) msg, "dot<text ");
- }
- if (dot > end) {
- strcat((char *) msg, "dot>end ");
- }
- if (screenbegin < text) {
- strcat((char *) msg, "screenbegin<text ");
- }
- if (screenbegin > end - 1) {
- strcat((char *) msg, "screenbegin>end-1 ");
- }
-
- if (strlen(msg) > 0) {
- alarm(0);
- sprintf(buf, "\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
- totalcmds, last_input_char, msg, SOs, SOn);
- write(1, buf, strlen(buf));
- while (read(0, d, 1) > 0) {
- if (d[0] == '\n' || d[0] == '\r')
- break;
- }
- alarm(3);
- }
- tim = (time_t) time((time_t *) 0);
- if (tim >= (oldtim + 3)) {
- sprintf((char *) status_buffer,
- "Tot=%d: M=%d N=%d I=%d D=%d Y=%d P=%d U=%d size=%d",
- totalcmds, M, N, I, D, Y, P, U, end - text + 1);
- oldtim = tim;
- }
- return;
-}
-#endif /* CONFIG_FEATURE_VI_CRASHME */
-