Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!caen!b-tech!ais.org!jph From: jph@ais.org (Joseph Hillenburg) Newsgroups: comp.lang.c Subject: Re: Help with rot13 code Message-ID: <=XZ+&8_@irie.ais.org> Date: 24 Jan 91 05:09:54 GMT References: Sender: jph@ais.org Organization: UMCC, Ann Arbor, MI Lines: 166 In article stanley@phoenix.com (John Stanley) writes: > > > Thank you to all those nice people who have been sending me >the fixes for the rot13 code that broke when ported to UNIX. > > However, I AM NOT THE ONE WHO MADE THE REQUEST FOR HELP! I replied >to the request by including the error output from my compiler and >telling the requestor to look at the errors and see if they ring any >bells. I was the one who posted. Thanks to all of you, I now have a working program which has been almost entirely redone, except for the rot13 core. > > You may all stop sending me the fixes. I have written my own, >perfectly functional rot13 filter. Though it is not as short as that >posted recently, is works just fine. > > Frr, vg jbexf svar. > ><><><><><>-------------------- Stanley@Phoenix.com >"When is it ever going to cease to suck around here?" - Leland McKenzie > of McKenzie, Brachman, Chaney, Cuzak, and Becker. > // Joseph Hillenburg, Secretary, Bloomington Amiga Users Group \X/ joseph@valnet.UUCP jph@irie.ais.org jph@ai.mit.edu "Only Apple could slow down a 68030 chip" --Computer Shopper /* remember to remove the .signature off the end of this */ /* ** ** rot13 ** rot13 is a program to convert text to rot13 format for UseNet, most ** generally for rec.humor, and the alt.sex.* groups. ** ** Feel free to make any mods, but please mail them to the people who have ** already worked on this. ** ** History: ** ** 11-21-90 ** Scott Berry (fxsdb@acad3.alaska.edu) ** Created. ** ** 11-23-90 ** Scott Berry (fxsdb@acad3.alaska.edu) ** Misc enhancements. ** ** 01-16-91 ** Joseph Hillenburg (jph@ais.org) ** Ported to UNIX, now dynamically knows it's name. ** ** 01-20-91 ** Joseph Hillenburg (jph@ais.org) ** Gradually trying to move towards proper C syntax. :) ** ** 01-21-91 ** Joseph Hillenburg (jph@ais.org) ** Cleaning up code, adding a real version number. ** ** 01-21-91 ** Earl Chew (cechew@bruce.cs.monash.oz.au) ** Misc enhancements. ** ** Thanks to: ** Scott Berry (fxsdb@acad3.alaska.edu) ** Joseph Hillenburg (jph@ais.org) ** Earl Chew (cechew@bruce.cs.monash.oz.au) ** Jayanth N. Anantharaman (jayanth@ee.eng.ohio-state.edu) ** All the dudes at comp.lang.c ** */ #include #include /* ** This is either "UNIX" or "VMS". "UNIX" should work for AmigaDOS and MS-DOS. ** Right now, this is only being used to hide ugly VMS full-length filenames. */ #define UNIX int main(argc,argv) char *argv[]; int argc; { int ch; FILE *infile,*outfile; /* ** Version goes here. */ char *version = "1.01j"; /* ** These #ifdefs are to handle ugly full VMS filenames. */ #ifndef VMS char *progname = "ROT13"; #else char *progname = argv[0]; #endif /* ** Kick out if there are more than 2 arguments or less than 1 */ if((argc < 2) || (argc >3)) { fprintf(stderr,"%s %s by Scott Berry and Joseph Hillenburg.\n",progname,version); fprintf(stderr,"Usage: %s [outfile]\n",progname); exit(1); } if(( infile = fopen(argv[1], "r")) == ( FILE * ) NULL ) { fprintf(stderr,"%s: Input file, %s, not found.\n",progname,argv[1]); exit(1); } /* ** if there is an output file, open it */ if((outfile = (argc == 3 ? fopen(argv[2],"w") : stdout)) == ( FILE * ) NULL ) { fprintf(stderr,"%s: Could not open output file, %s.\n",progname,argv[2]); exit(1); } /* ** get characters, while there still are characters to get, from the file and ** print them out (to file or screen) */ while ((ch=fgetc(infile)) != EOF) { /* ** since we're ROTing 13, we're moving up 13 if it's characters a-m, and down ** 13 if it's characters n-z. */ if (isupper(ch)) ch = (ch>'M'?ch-13:ch+13); if (islower(ch)) ch = (ch>'m'?ch-13:ch+13); fputc((ch), outfile); } fclose(infile); if (argc == 3) fclose (outfile); exit(0); } -- // Joseph Hillenburg, Secretary, Bloomington Amiga Users Group \X/ joseph@valnet.UUCP jph@irie.ais.org jph@ai.mit.edu "Only Apple could slow down a 68030 chip" --Computer Shopper