home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1569 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  4.0 KB

  1. From: dgross@polyslo.CalPoly.EDU (Dave Gross)
  2. Newsgroups: alt.sources
  3. Subject: A .signature changing program
  4. Message-ID: <26992667.88f@petunia.CalPoly.EDU>
  5. Date: 10 Jul 90 00:50:47 GMT
  6.  
  7.  
  8.  
  9. The following program allows the user to set up a file containing any number
  10. of three-line .signatures and then to have these signatures to be read in
  11. by number or at random into the .signature file.  It allows for a specific
  12. and for a default collection of .signatures, and for a constant header to
  13. the .signatures.
  14.  
  15. To use this program, first compile it and name the executable file (I named
  16. mine "sigchange").  Then, set up a file called "clippings" in the same (home)
  17. directory folder with the following format:
  18.  
  19. * An integer that represents the number of different signatures in the file
  20. * A line which will be the header for each signature
  21. * A three-line signature
  22. * A blank line
  23. * A three-line signature
  24. * A blank line
  25. * Repeat as often as desired (to the number in line #1)
  26.  
  27. A sample "clippings" file follows:
  28.  
  29. --------------------------------File Starts Here-------------------------------
  30. 3
  31. <^><v><^><v><^><v><^><v>-  dgross@polyslo.CalPoly.EDU  -<v><^><v><^><v><^><v><^>
  32. A monk asked Tozan when he was weighing some flax:  "What is Buddha?"
  33. Tozan said:  "This flax weighs three pounds."
  34.  
  35.  
  36. Two monks were arguing about a flag.  One said:  "The flag is moving."  The
  37. other said:  "The wind is moving."  The sixth patriarch happened to be passing
  38. by.  He told them:  "Not the wind, not the flag; mind is moving."
  39.  
  40. All mental states have mind as their forerunner, mind is their chief, and they
  41. are mind-made.  If one speaks or acts, with a pure mind, happiness follows one
  42. as one's shadow that does not leave 
  43. --------------------------------File Ends Here---------------------------------
  44.  
  45. At this point, you should be able to run "sigchange" and get one of these
  46. random signatures with the single header in your .signature file.
  47.  
  48. You can also set up another file with another name (say "politics") with
  49. another set of signatures in it.  Select a signature from this file by
  50. using "sigchange politics" (or any other filename).
  51.  
  52. You can select a specific signature by suffixing the command with a number.
  53. To review:
  54.  
  55. sigchange        Selects a random signature from "clippings"
  56. sigchange 12        Selects signature #12 from "clippings"
  57. sigchange politics    Selects a random signature from "politics"
  58. sigchange local 25      Selects signature #25 from "local"
  59.  
  60. The C code for this sigchanger file follows.  It's pretty grungy, so bear with
  61. it.  I'm an old BASIC programmer at heart...
  62.  
  63.  
  64. #include <stdio.h>
  65. main(num,vptr)
  66.    int num;
  67.    char *vptr[];
  68. {
  69.    char number[], line[], header[];
  70.    FILE * file;
  71.    FILE * sigfile;
  72.    int no_of_clips, clip_no, i, a;
  73.  
  74.    clip_no = -1;
  75.    if ((sigfile = fopen(".signature","w")) == NULL)
  76.      printf("Unable to open .signature for write\n");
  77.    if ((num<2) || ((file = fopen(*(vptr+1),"r")) == NULL))
  78.    {
  79.       printf("Reading from `clippings' file\n");
  80.       if ((file=fopen("clippings","r")) == NULL)
  81.          printf("ERROR: Unable to open `clippings' file");
  82.       clip_no = atoi(*(vptr+1))-1; 
  83.    }
  84.    if (num>2)
  85.    {
  86.       clip_no = atoi(*(vptr+2))-1;
  87.    }
  88.    fgets(number,9,file);
  89.    no_of_clips = atoi(number);
  90.    if ((clip_no>=no_of_clips) || (clip_no<0))
  91.    {
  92.       srand(getpid(0)*time(0));
  93.       a=rand(a);
  94.       clip_no = a % no_of_clips;
  95.    }
  96.    fgets(header,82,file);
  97.    fputs(header,sigfile);
  98.    printf("Signature: Reading %d of %d.\n",clip_no+1,no_of_clips);
  99.    for(i=0;i<clip_no;i++)
  100.       {
  101.         for(a=0;a<4;a++)
  102.            {
  103.               fgets(line,82,file);
  104.            }
  105.       }
  106.    for(i=0;i<3;i++)
  107.       {
  108.          fgets(line,82,file);
  109.          fputs(line,sigfile);
  110.       }
  111.    fclose(sigfile);
  112.    fclose(file);
  113. exit(0);
  114. }
  115.  
  116.  
  117. -- 
  118. ************************* dgross@polyslo.CalPoly.EDU ***************************
  119.            "I never drive over 50 kmph in densely populated areas."
  120.                              -- Adolph Hitler
  121. -------------------------------------------------------------------------------
  122.