From owner-freebsd-questions Wed Mar 21 13:36:20 2001 Delivered-To: freebsd-questions@freebsd.org Received: from itouch.co.nz (itouch.co.nz [203.99.66.188]) by hub.freebsd.org (Postfix) with ESMTP id B27F437B718 for ; Wed, 21 Mar 2001 13:36:12 -0800 (PST) (envelope-from jonc@itouch.co.nz) Received: (from jonc@localhost) by itouch.co.nz (8.11.2/8.11.1) id f2LLZof95453; Thu, 22 Mar 2001 09:35:50 +1200 (NZST) (envelope-from jonc) Date: Thu, 22 Mar 2001 09:35:49 +1200 From: Jonathan Chen To: Alfred Perlstein Cc: questions@FreeBSD.ORG Subject: Re: rotating .signatures? Message-ID: <20010322093549.A94461@itouchnz.itouch> References: <20010321103918.P12319@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010321103918.P12319@fw.wintelcom.net>; from bright@wintelcom.net on Wed, Mar 21, 2001 at 10:39:18AM -0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 21, 2001 at 10:39:18AM -0800, Alfred Perlstein wrote: > I've seen people that have rotating .signatures for email, > anyone know how to do this with mutt? I've got in my ~/.muttrc: set signature="~/bin/pick-sig|" which is a small C program which picks up a random signature from ~/.signatures. -- Jonathan Chen ---------------------------------------------------------------------- Opportunities are seldom labeled --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pick-sig.c" /* * Pick a signature from ~/.signatures directory * * jonathan.chen@itouch.co.nz */ #include #include #include #include #define SIGNATURE_DIR ".signatures" main () { int sigcount; DIR * sigdir; char path [1024]; int exit_val = EXIT_SUCCESS; sprintf (path, "%s/%s", getenv ("HOME"), SIGNATURE_DIR); /* * Open the directory, count the number of entries * */ if (!(sigdir = opendir (path))) return EXIT_FAILURE; for (sigcount = 0; readdir (sigdir); sigcount++); sigcount -= 2; /* don't count . and .. */ if (sigcount < 0) { fprintf (stderr, "Internal error on counting files\n"); exit_val = EXIT_FAILURE; goto end; } if (sigcount > 0) { int pick; int i; struct dirent * entry; FILE * sigfile; char line [1024]; srandomdev (); pick = random () % sigcount; rewinddir (sigdir); for (i = -2; i <= pick; i++) entry = readdir (sigdir); sprintf (path, "%s/%s/%s", getenv ("HOME"), SIGNATURE_DIR, entry -> d_name); if (!(sigfile = fopen (path, "r"))) { exit_val = EXIT_FAILURE; goto end; } while (fgets (line, sizeof (line), sigfile)) fputs (line, stdout); fclose (sigfile); } end: closedir (sigdir); return exit_val; } --uAKRQypu60I7Lcqm-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message