- st->words = get_words(st);
-}
-
-static char *
-get_words (struct state *st)
-{
- FILE *pp;
- register char *p = st->word_buf;
-
- st->word_buf[0] = '\0';
-
- if ((pp = popen(st->program, "r")))
- {
- while (fgets(p, sizeof(st->word_buf) - strlen(st->word_buf), pp))
- {
- if (strlen(st->word_buf) + 1 < sizeof(st->word_buf))
- p = st->word_buf + strlen(st->word_buf);
- else
- break;
- }
- (void) pclose(pp);
- if (! st->word_buf[0])
- sprintf (st->word_buf, "\"%s\" produced no output!", st->orig_program);
- else if (!st->first_time &&
- (strstr (st->word_buf, ": not found") ||
- strstr (st->word_buf, ": Not found") ||
- strstr (st->word_buf, ": command not found") ||
- strstr (st->word_buf, ": Command not found")))
- switch (random () % 20)
- {
- case 1: strcat (st->word_buf, "( Get with the st->program, bub. )\n");
- break;
- case 2: strcat (st->word_buf,
- "( I blow my nose at you, you silly person! ) \n"); break;
- case 3: strcat (st->word_buf,
- "\nThe resource you want to\nset is `noseguy.program'\n");
- break;
- case 4:
- strcat(st->word_buf,"\nHelp!! Help!!\nAAAAAAGGGGHHH!! \n\n"); break;
- case 5: strcpy (st->word_buf, "You have new mail.\n"); break;
- case 6:
- strcat(st->word_buf,"( Hello? Are you paying attention? )\n");break;
- case 7:
- strcat (st->word_buf, "sh: what kind of fool do you take me for? \n");
- break;
- }
- st->first_time = 0;
- p = st->word_buf;
- }
- else
- {
- perror(st->program);
- }
-
- return p;