home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.folklore.computers,misc.misc,alt.sources
- From: peter@ficc.ferranti.com (Peter da Silva)
- Subject: Re: Jargon File Version is 2.7.1
- Message-ID: <=LY9CM3@xds13.ferranti.com>
- Date: Thu, 7 Mar 91 19:17:43 GMT
-
- What is this discussion doing in alt.sources?
-
- In article <19090@rpp386.cactus.org> jfh@rpp386.cactus.org (John F Haugh II) writes:
- > Could you please limit it to newsgroups that I don't carry? I am getting
- > a bit tired of Jargon File du jour. Is there anyone else that feels the
- > same way? Can I get an "Amen" brother?
-
- I'm glad he finally started sending it to newsgroups I *do* carry. I've
- been wondering why the file hasn't been showing up recently. Alt.sources
- is a fine place for it.
- --
- Peter da Silva. `-_-' peter@ferranti.com
- +1 713 274 5180. 'U` "Have you debugged your wolf today?"
- --
- Obligatory Source: a program to split mailbox files.
-
- #include <stdio.h>
- #include <ctype.h>
-
- #ifdef USG
- #define MAILBOX "/usr/mail/%s"
- #else
- #define MAILBOX "/usr/spool/mail/%s"
- #endif
-
- #define STRLEN 255
- char line[STRLEN];
-
- getline(fp, line)
- FILE *fp;
- char *line;
- {
- fgets(line, STRLEN, fp);
- line[strlen(line)-1] = 0;
- }
-
- main(ac, av)
- int ac;
- char **av;
- {
- FILE *fp = 0;
-
- while(--ac)
- if(fp = fopen(*++av, "r")) {
- fsplit(fp);
- fclose(fp);
- } else {
- perror(*av);
- exit(1);
- }
- if(!fp) {
- char buffer[255];
- char *p, *getenv(), *getlogin();
-
- if(!(p = getenv("MAIL"))) {
- if(!(p = getenv("LOGNAME"))) {
- if(!(p = getlogin())) {
- fprintf(stderr,
- "/etc/passwd: No login name.\n");
- exit(1);
- }
- sprintf(buffer, MAILBOX, p);
- }
- } else
- sprintf(buffer, "%s", p);
- if(!(fp = fopen(buffer, "r"))) {
- perror(buffer);
- exit(1);
- }
- fsplit(fp);
- fclose(fp);
- }
- }
-
- fsplit(fp)
- FILE *fp;
- {
- char outname[16];
- int outfile=0;
- FILE *outfp = 0;
-
- while(1) {
- getline(fp, line);
- if(feof(fp)) break;
- if(!strncmp(line, "From ", 5)) {
- if(outfp) fclose(outfp);
- sprintf(outname, "%d", ++outfile);
- if(!(outfp = fopen(outname, "w"))) {
- perror(outname);
- exit(1);
- }
- }
- if(outfp) fprintf(outfp, "%s\n", line);
- }
- if(outfp) fclose(outfp);
- }
-