home *** CD-ROM | disk | FTP | other *** search
- From: magnus%thep.lu.se@Urd.lth.se (Magnus Olsson)
- Newsgroups: alt.sources
- Subject: autosign utility for Mail User's Shell (mush) part 01/01
- Message-ID: <1991Jul4.151009.12461@lth.se>
- Date: 4 Jul 91 15:10:09 GMT
-
- Submitted-by: magnus@thep.lu.se
- Archive-name: autosign/part01
-
- autosign
-
- A utility for use with the Mail User's Shell (mush)
-
- by Magnus Olsson (magnus@thep.lu.se)
-
-
- The Mail User's Shell (mush), by Dan Heller (argv@sun.com), has options for
- automatically appending your signature and/or a "fortune cookie" to all
- outgoing mail. The options are rather flexible; for example, you can use one
- signature for letters to certain domains and another one for other domains.
-
- However, you may wish for greater flexibility than that provided by mush.
- Version 7 (and later) of mush allows you to specify a program that is called
- to sign your mail. autosign.c is an example of such a program.
-
- Once you have installed it, every time you send a mail message you will be
- given a menu of signatures to choose from. You select one of these and it is
- appended to your message (you may of course also choose not to append any
- signature at all). autosign will then call your system's "fortune cookie"
- program to generate a fortune cookie. This will be shown to you beefore it is
- appended, and you'll be given the options to either append it to the message,
- or to generate a new fortune (this way, you can e.g. avoid appending rude
- jokes to letters to your boss - many of the quotes in fortune databases tend
- to be rather obscene), or not to append one at all.
-
- No modification to mush is needed, only a line in your .mushrc file.
-
- There is no Makefile (what use is that when the program consist of just one
- file?) and no manpage either - the instructions in the README file should
- suffice.
-
- Magnus Olsson | \e+ /_
- Dept. of Theoretical Physics | \ Z / q
- University of Lund, Sweden | >----<
- Internet: magnus@thep.lu.se | / \===== g
- Bitnet: THEPMO@SELDC52 | /e- \q
-
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # This is autosign, a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 07/04/1991 15:07 UTC by magnus@thep.lu.se
- # Source directory /usr/users/magnus/source/autosign
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 2655 -rw-r--r-- README
- # 2480 -rw-r--r-- autosign.c
- #
- # ============= README ==============
- if test -f 'README' -a X"$1" != X"-c"; then
- echo 'x - skipping README (File already exists)'
- else
- echo 'x - extracting README (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'README' &&
- autosign
- X
- A utility for use with the Mail User's Shell (mush)
- X
- by Magnus Olsson (magnus@thep.lu.se)
- July 4, 1991
- X
- This program is in the public domain.
- X
- ===========================================================================
- X
- The Mail User's Shell (mush), by Dan Heller (argv@sun.com), has options for
- automatically appending your signature and/or a "fortune cookie" to all
- outgoing mail. The options are rather flexible; for example, you can use one
- signature for letters to certain domains and another one for other domains.
- X
- However, you may wish for greater flexibility than that provided by mush.
- Version 7 (and later) of mush allows you to specify a program that is called
- to sign your mail. autosign.c is an example of such a program.
- X
- Once you have installed it, every time you send a mail message you will be
- given a menu of signatures to choose from. You select one of these and it is
- appended to your message (you may of course also choose not to append any
- signature at all). autosign will then call your system's "fortune cookie"
- program to generate a fortune cookie. This will be shown to you beefore it is
- appended, and you'll be given the options to either append it to the message,
- or to generate a new fortune (this way, you can e.g. avoid appending rude
- jokes to letters to your boss - many of the quotes in fortune databases tend
- to be rather obscene), or not to append one at all.
- X
- No modification to mush is needed, only a line in your .mushrc file.
- X
- X
- X
- Installation:
- X
- First edit the file autosign.c to suit your needs.
- As it is, it gives you a choice of two different signatures. These signatures
- should be kept in different files. The macros SIG1 and SIG2 should be defined
- as the full paths of these files.
- If you need another number of signatures than 2, you must define one macro for
- each file. The "switch (ans)" statement must also be changed, but the
- modifications are trivial.
- The macro FORTUNE should be defined as the full path of the program to
- generate fortune cookies on your system.
- X
- Then compile autosign with the following command:
- cc -o autosign autosign.c
- and move the resulting file autosign to somewhere in your path.
- On some systems, such as Ultrix, you'll have to do a 'rehash', too.
- X
- Then edit your .mushrc file to contain the line
- set autosign="| autosign"
- X
- That should be all!
- X
- X
- Note:
- X
- This program has been tested on a DECstation 3100 running RISC Ultrix 4.1. It
- has not been tried on any other system. It believe it should work on any
- system running BSD 4.x Unix.
- X
- Disclaimer:
- X
- The author will accept no responsibily whatsoever for any damage or unwanted
- effects caused by the use of this software.
- X
- X
- SHAR_EOF
- chmod 0644 README ||
- echo 'restore of README failed'
- Wc_c="`wc -c < 'README'`"
- test 2655 -eq "$Wc_c" ||
- echo 'README: original size 2655, current size' "$Wc_c"
- fi
- # ============= autosign.c ==============
- if test -f 'autosign.c' -a X"$1" != X"-c"; then
- echo 'x - skipping autosign.c (File already exists)'
- else
- echo 'x - extracting autosign.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'autosign.c' &&
- /**********************************
- X * autosign.c *
- X * A program to attach signatures *
- X * to outgoing mail *
- X * Designed to be called by mush *
- X * *
- X * Written by Magnus Olsson *
- X * (magnus@thep.lu.se) *
- X * July 4, 1991 *
- X * *
- X * This program is donated to *
- X * the public domain *
- X * *
- X * The author takes no *
- X * responsibily whatsoever for *
- X * any damage or unwanted effects *
- X * caused by the use of this *
- X * software. *
- X **********************************/
- X
- #include <stdio.h>
- #define READ 0
- #define WRITE 1
- #define MAX 9999
- /* MAX is the maximum number of characters allowed in a single fortune */
- X
- /* SIG1 and SIG2 are the full paths of the signature files */
- #define SIG1 "/usr/users/magnus/.signature"
- #define SIG2 "/usr/users/magnus/mail/sig2"
- /* FORTUNE is the full path to the fortune cookie program */
- #define FORTUNE "/usr/local/bin/cookie"
- X
- main ()
- X
- {
- X char ans,s [MAX+1];
- X int i;
- X FILE *sigfile;
- X int Pipe [2];
- X char *fname;
- X
- X fprintf (stderr,"1: Signature 1\n2: Signature 2\n3: No signature ");
- X scanf ("%c",&ans);
- X fprintf (stderr,"%c\n",ans);
- X
- X switch (ans) {
- X case '1': fname = SIG1; break;
- X case '2': fname = SIG2; break;
- X default: fname = NULL;
- X }
- X if (fname) {
- X if (sigfile = fopen (fname, "r")) {
- X do {
- X if (fgets (s,100,sigfile))
- X printf ("%s",s);
- X } while (! feof (sigfile));
- X fclose (sigfile);
- X }
- X else
- X fprintf (stderr,"Couldn't open signature file %s\n",fname);
- X }
- X
- X do {
- X if (pipe (Pipe)) {
- X fprintf (stderr,"Couldn't create pipe\n");
- X exit (1);
- X }
- X switch (fork ()) {
- X case -1: fprintf (stderr,"Couldn't spawn subprocess\n");
- X exit (1);
- X case 0: /* Child process */
- X dup2 (Pipe [WRITE],1); /* Redirect stdout to the pipe */
- X close (Pipe [WRITE]);
- X execl (FORTUNE,NULL); /* Print a fortune to the pipe and terminate process*/
- X default: /* Parent process */
- X i = read (Pipe [READ],s,MAX); /* Read the output of the fortune program */
- X s [i] = '\0'; /* End-if-string marker */
- X close (Pipe [READ]);
- X }
- X fprintf (stderr,"%s\nAdd the above fortune? (Yes/No/Another) ",s);
- X scanf ("%c",&ans);
- X fprintf (stderr,"%c\n",ans);
- X ans = toupper (ans);
- X } while (ans == 'A');
- X if (ans == 'Y')
- X puts (s);
- }
- X
- X
- X
- X
- SHAR_EOF
- chmod 0644 autosign.c ||
- echo 'restore of autosign.c failed'
- Wc_c="`wc -c < 'autosign.c'`"
- test 2480 -eq "$Wc_c" ||
- echo 'autosign.c: original size 2480, current size' "$Wc_c"
- fi
- exit 0
-