From: Rasdan <rasdan@peak.org>
Subject: Changes to do_gen_vfile

Hey all,

Here's a change I put together earlier to do_gen_vfile (by Daniel Burke)
that lets you see things in your bug file while on-line).

It is a very nice little snippet, but it only let you see the last 20 
lines from the file.

I set it up so that you can see as many as you want.

Here's the entire thing:

In act.other.c, below do_gen_file, add:


ACMD(do_gen_vfile)
{
        char syscom[120];
        FILE *pfp;
        char *filename;
        int number = 0;

        one_argument(argument, arg);

        if (!*arg || !isdigit(*arg))
          number = 20;
        else
          number = atoi(arg);

        if (number > 100)
        {
          send_to_char("MAX LINES AT ONE TIME CAN NOT BE GREATER THAN 100!\r\n", ch);
          return;
        }

switch (subcmd) {
        case SCMD_V_BUGS:
                filename = BUG_FILE;
                break;
        case SCMD_V_IDEAS:
                filename = IDEA_FILE;
                break;
        case SCMD_V_TYPOS:
                filename = TYPO_FILE;
                break;
        default:
                send_to_char("Invalid command: do_gen_vfile\r\n", ch);
                return;
                break;
}

sprintf(syscom, "tail -%d %s", number, filename);
        if ((pfp = popen(syscom, "r")) == NULL) {
                send_to_char("No entries found\r\n", ch);
                return;
                }
sprintf(buf2, "Contents of file:\r\n");
send_to_char(buf2, ch);
while (fgets(syscom, 120, pfp) != NULL) {
        sprintf(buf2, "%s\r", syscom);
        send_to_char(buf2, ch);
        }
pclose(pfp);
}


In interpreter.h, add:
/* do_gen_vfile */
#define SCMD_V_BUGS     0
#define SCMD_V_IDEAS    1
#define SCMD_V_TYPOS    2

In interpreter.c, with the ACMD prototypes, prototype:
ACMD(do_gen_vfile);

and then in the command list, add:
  { "vbugs"    , POS_DEAD    , do_gen_vfile, LVL_CODER, SCMD_V_BUGS },
  { "videa"    , POS_DEAD    , do_gen_vfile, LVL_CODER, SCMD_V_IDEAS },
  { "vtypo"    , POS_DEAD    , do_gen_vfile, LVL_CODER, SCMD_V_TYPOS },


Keep in mind, I did not write this. All I did was make it so that you can 
see any number of lines you want, by doing:

videa <#> or vtypo <#> or vbugs <#>.

Hope you all enjoy this minor little improvement to this nifty bit of 
code.

Rasdan
