A .signature changing program

Dave Gross dgross at polyslo.CalPoly.EDU
Tue Jul 10 10:50:47 AEST 1990



The following program allows the user to set up a file containing any number
of three-line .signatures and then to have these signatures to be read in
by number or at random into the .signature file.  It allows for a specific
and for a default collection of .signatures, and for a constant header to
the .signatures.

To use this program, first compile it and name the executable file (I named
mine "sigchange").  Then, set up a file called "clippings" in the same (home)
directory folder with the following format:

* An integer that represents the number of different signatures in the file
* A line which will be the header for each signature
* A three-line signature
* A blank line
* A three-line signature
* A blank line
* Repeat as often as desired (to the number in line #1)

A sample "clippings" file follows:

--------------------------------File Starts Here-------------------------------
3
<^><v><^><v><^><v><^><v>-  dgross at polyslo.CalPoly.EDU  -<v><^><v><^><v><^><v><^>
A monk asked Tozan when he was weighing some flax:  "What is Buddha?"
Tozan said:  "This flax weighs three pounds."


Two monks were arguing about a flag.  One said:  "The flag is moving."  The
other said:  "The wind is moving."  The sixth patriarch happened to be passing
by.  He told them:  "Not the wind, not the flag; mind is moving."

All mental states have mind as their forerunner, mind is their chief, and they
are mind-made.  If one speaks or acts, with a pure mind, happiness follows one
as one's shadow that does not leave 
--------------------------------File Ends Here---------------------------------

At this point, you should be able to run "sigchange" and get one of these
random signatures with the single header in your .signature file.

You can also set up another file with another name (say "politics") with
another set of signatures in it.  Select a signature from this file by
using "sigchange politics" (or any other filename).

You can select a specific signature by suffixing the command with a number.
To review:
 
sigchange		Selects a random signature from "clippings"
sigchange 12		Selects signature #12 from "clippings"
sigchange politics	Selects a random signature from "politics"
sigchange local 25  	Selects signature #25 from "local"

The C code for this sigchanger file follows.  It's pretty grungy, so bear with
it.  I'm an old BASIC programmer at heart...


#include <stdio.h>
main(num,vptr)
   int num;
   char *vptr[];
{
   char number[], line[], header[];
   FILE * file;
   FILE * sigfile;
   int no_of_clips, clip_no, i, a;

   clip_no = -1;
   if ((sigfile = fopen(".signature","w")) == NULL)
     printf("Unable to open .signature for write\n");
   if ((num<2) || ((file = fopen(*(vptr+1),"r")) == NULL))
   {
      printf("Reading from `clippings' file\n");
      if ((file=fopen("clippings","r")) == NULL)
         printf("ERROR: Unable to open `clippings' file");
      clip_no = atoi(*(vptr+1))-1; 
   }
   if (num>2)
   {
      clip_no = atoi(*(vptr+2))-1;
   }
   fgets(number,9,file);
   no_of_clips = atoi(number);
   if ((clip_no>=no_of_clips) || (clip_no<0))
   {
      srand(getpid(0)*time(0));
      a=rand(a);
      clip_no = a % no_of_clips;
   }
   fgets(header,82,file);
   fputs(header,sigfile);
   printf("Signature: Reading %d of %d.\n",clip_no+1,no_of_clips);
   for(i=0;i<clip_no;i++)
      {
        for(a=0;a<4;a++)
           {
              fgets(line,82,file);
           }
      }
   for(i=0;i<3;i++)
      {
         fgets(line,82,file);
         fputs(line,sigfile);
      }
   fclose(sigfile);
   fclose(file);
exit(0);
}
 

-- 
************************* dgross at polyslo.CalPoly.EDU ***************************
           "I never drive over 50 kmph in densely populated areas."
                             -- Adolph Hitler
-------------------------------------------------------------------------------



More information about the Alt.sources mailing list