home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2622 < prev    next >
Internet Message Format  |  1991-01-28  |  11KB

  1. From: jph@ais.org (Joseph Hillenburg)
  2. Newsgroups: alt.sources
  3. Subject: Rot13 1.12j and Chat
  4. Message-ID: <8N4+N!?@irie.ais.org>
  5. Date: 29 Jan 91 03:12:22 GMT
  6.  
  7. Archive-Name: rot13/part01
  8.  
  9. Hello.
  10.  
  11. This is a dual posting of a rot13 program and a unix chat program. I felt
  12. bored, so I took some existing source both ways and modified it. The rot13
  13. program was originally by Scott Berry, and only ran under VMS. It only
  14. had the C source file. It now has a Makefile for UNIX, a Config.MMS file for
  15. VMS, and a .CLD file for VMS. It's only in beta at this point. I've still
  16. got to finish the part of the program that handles the .CLD.
  17.  
  18. The Chat program was originally from Citadel/UX, and intended for a BBS
  19. environment. While not the best chat in the world, it is simple and easy
  20. to maintain. If you are the chat maintainer, you MUST be the first one
  21. to run it after you delete the chat.tmp file every so often. The chat.tmp
  22. file that's created serves two purposes:
  23.  
  24.     1) to log the chat
  25.     2) to provide history capability
  26.  
  27.    //   Joseph Hillenburg, Secretary, Bloomington Amiga Users Group
  28.  \X/  joseph@valnet.UUCP     jph@irie.ais.org          jph@ai.mit.edu
  29.        "Only Apple could slow down a 68030 chip" --Computer Shopper
  30.  
  31. #! /bin/sh
  32. # This is a shell archive.  Remove anything before this line, then unpack
  33. # it by saving it into a file and typing "sh file".  To overwrite existing
  34. # files, type "sh file -c".  You can also feed this as standard input via
  35. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  36. # will see the following message at the end:
  37. #        "End of shell archive."
  38. # Contents:  README rot13.c Makefile descrip.mms rot13.cld chat
  39. # Wrapped by jph@irie.ais.org on Mon Jan 28 20:16:47 1991
  40. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  41. if test -f 'README' -a "${1}" != "-c" ; then 
  42.   echo shar: Will not clobber existing file \"'README'\"
  43. else
  44. echo shar: Extracting \"'README'\" \(1983 characters\)
  45. sed "s/^X//" >'README' <<'END_OF_FILE'
  46. X
  47. X1.12j                            Rot13                           01-28-91
  48. X
  49. XNote: Although this is version 1.12j, it's still in beta test. I've still
  50. Xgot a few things to do to it, but when I finish it, I'll release it in a
  51. Xset of programs.
  52. X
  53. XCredits:
  54. X    Scott Berry
  55. X    Joseph Hillenburg
  56. X    Earl Chew
  57. X    Jayanth N. Anantharaman
  58. X
  59. XWhat is Rot13?
  60. X
  61. X    Rot13 is a program to convert text files into rot13 format for
  62. Xusenet. This is often useful when you think you have some text that might
  63. Xbe offensive to some people.
  64. X
  65. XHow do I run Rot13?
  66. X
  67. X    Just use the syntax:
  68. X
  69. X        rot13 <infile> <outfile>
  70. X
  71. XWhere <infile> is the file to be processed, and <outfile> is the file to
  72. Xbe written to.
  73. X
  74. XWhat systems support Rot13?
  75. X
  76. X    I have sucessfully compiled it on an IBM RT running BSD 4.3, a
  77. XSPARCstation running GNU, and some HP-9000's running GNU, as well as a
  78. XVAX 6440 running VMS 5.3-1.
  79. X
  80. XHow do I build Rot13?
  81. X
  82. X    Under UNIX, just type 'make'. Under VMS, just type 'MMS' at the DCL
  83. Xprompt. It will automatically build itself.
  84. X
  85. XWhat about the compile time errors that my compiler _may_ give me?
  86. X
  87. X    You may have an error that looks like this:
  88. X
  89. Xmain: Function has no return statement.
  90. X
  91. XI'd appreciate help on eliminating this so I can completely clean out the
  92. Xsource.
  93. X
  94. XNOTE ABOUT rot13.cld:
  95. X
  96. X    It's not quite finished yet. I still have to finish that section.
  97. XFor now, under VMS, install ROT13 with a line in your login.com (or
  98. Xsylogin.com) that looks like:
  99. X
  100. X$ ROT13 :== <disk>:[DIR...]ROT13.EXE
  101. X
  102. XPretty soon, you'll only have to edit the .CLD file to point to the location
  103. Xof the executable and have a line in your login.com that resembles:
  104. X
  105. X$ SET COMMAND ROT13.CLD
  106. X
  107. XUsing CLDs is a much faster and efficient way to install it.
  108. X
  109. XPlease send bug fixes, etc to me in the form of context diffs.
  110. X
  111. X-joseph hillenburg
  112. X
  113. X   //   Joseph Hillenburg, Secretary, Bloomington Amiga Users Group
  114. X \X/  joseph@valnet.UUCP     jph@irie.ais.org          jph@ai.mit.edu
  115. X       "Only Apple could slow down a 68030 chip" --Computer Shopper
  116. X
  117. END_OF_FILE
  118. if test 1983 -ne `wc -c <'README'`; then
  119.     echo shar: \"'README'\" unpacked with wrong size!
  120. fi
  121. # end of 'README'
  122. fi
  123. if test -f 'rot13.c' -a "${1}" != "-c" ; then 
  124.   echo shar: Will not clobber existing file \"'rot13.c'\"
  125. else
  126. echo shar: Extracting \"'rot13.c'\" \(2330 characters\)
  127. sed "s/^X//" >'rot13.c' <<'END_OF_FILE'
  128. X/*
  129. X**
  130. X** rot13
  131. X**     rot13 is a program to convert text to rot13 format for UseNet, most
  132. X**     generally for rec.humor, and the alt.sex.* groups.
  133. X**
  134. X** Feel free to make any mods, but please mail them to the people who have
  135. X** already worked on this.
  136. X**
  137. X** History:
  138. X**
  139. X** 11-21-90
  140. X**   Scott Berry (fxsdb@acad3.alaska.edu)
  141. X**     Created.
  142. X**
  143. X** 11-23-90
  144. X**   Scott Berry (fxsdb@acad3.alaska.edu)
  145. X**     Bug fixes.
  146. X**
  147. X** 01-16-91
  148. X**   Joseph Hillenburg (jph@ais.org)
  149. X**     Ported to UNIX, now dynamically knows it's name.
  150. X**
  151. X** 01-20-91
  152. X**   Joseph Hillenburg (jph@ais.org)
  153. X**     Gradually trying to move towards proper C syntax. :)
  154. X**
  155. X** 01-21-91
  156. X**   Joseph Hillenburg (jph@ais.org)
  157. X**     Cleaning up code, adding a real version number.
  158. X**
  159. X** 01-21-91
  160. X**   Earl Chew (cechew@bruce.cs.monash.oz.au)
  161. X**     Bug fixes.
  162. X**
  163. X** 01-25-91
  164. X**   Joseph Hillenburg (jph@ais.org)
  165. X**     Bug fixes.
  166. X**
  167. X**  Thanks to:
  168. X**    Scott Berry                          (fxsdb@acad3.alaska.edu)
  169. X**    Joseph Hillenburg                    (jph@ais.org)
  170. X**    Earl Chew                            (cechew@bruce.cs.monash.oz.au)
  171. X**    Jayanth N. Anantharaman              (jayanth@ee.eng.ohio-state.edu)
  172. X**
  173. X*/
  174. X
  175. X#include <ctype.h>
  176. X#include <stdio.h>
  177. X
  178. Xint main(argc,argv)
  179. Xchar *argv[];
  180. Xint argc;
  181. X{
  182. X   int ch;
  183. X   FILE *infile,*outfile;
  184. X   char *version = "1.12j";
  185. X
  186. X#ifndef VMS
  187. X   char *progname = argv[0];
  188. X#else
  189. X   char *progname = "ROT13";
  190. X#endif
  191. X
  192. X     if((argc < 2) || (argc >3))
  193. X       {
  194. X          fprintf(stderr,"%s %s by Scott Berry and Joseph Hillenburg.\n",progname,version);
  195. X          fprintf(stderr,"Usage: %s <infile> [outfile]\n",progname);
  196. X          exit(1);
  197. X    }
  198. X     if(( infile = fopen(argv[1], "r")) == ( FILE * ) NULL )
  199. X       {
  200. X          fprintf(stderr,"%s: Input file, %s, not found.\n",progname,argv[1]);
  201. X          exit(1);
  202. X    }
  203. X     if((outfile = (argc == 3 ? fopen(argv[2],"w") : stdout))
  204. X         == ( FILE * ) NULL )
  205. X       {
  206. X          fprintf(stderr,"%s: Could not open output file, %s.\n",progname,argv[2]);
  207. X          exit(1);
  208. X    }
  209. X   while ((ch=fgetc(infile)) != EOF)
  210. X   {
  211. X          if (isupper(ch))
  212. X               ch = (ch>'M'?ch-13:ch+13);
  213. X          if (islower(ch))
  214. X               ch = (ch>'m'?ch-13:ch+13);
  215. X          fputc((ch), outfile);
  216. X    }
  217. X     fclose(infile);
  218. X     if (argc == 3)
  219. X          fclose (outfile);
  220. X     exit(0);
  221. X }
  222. END_OF_FILE
  223. if test 2330 -ne `wc -c <'rot13.c'`; then
  224.     echo shar: \"'rot13.c'\" unpacked with wrong size!
  225. fi
  226. # end of 'rot13.c'
  227. fi
  228. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  229.   echo shar: Will not clobber existing file \"'Makefile'\"
  230. else
  231. echo shar: Extracting \"'Makefile'\" \(335 characters\)
  232. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  233. X#
  234. X# Makefile for "rot13"
  235. X#
  236. X# Written by: Scott Berry and Joseph Hillenburg
  237. X# Last update: (01-28-91)
  238. X# This file is in the public domain.
  239. X#
  240. X
  241. XCC         = cc
  242. XEXE        = rot13
  243. XCFLAGS     = -O -DUNIX
  244. X
  245. XOBJECTS    = rot13.o
  246. X
  247. Xall: $(EXE) clean
  248. X
  249. X$(EXE): $(OBJECTS)
  250. X    $(CC) $(CFLAGS) -o $(EXE) $(OBJECTS)
  251. X
  252. Xclean:
  253. X    rm $(OBJECTS)
  254. X    strip $(EXE)
  255. END_OF_FILE
  256. if test 335 -ne `wc -c <'Makefile'`; then
  257.     echo shar: \"'Makefile'\" unpacked with wrong size!
  258. fi
  259. # end of 'Makefile'
  260. fi
  261. if test -f 'descrip.mms' -a "${1}" != "-c" ; then 
  262.   echo shar: Will not clobber existing file \"'descrip.mms'\"
  263. else
  264. echo shar: Extracting \"'descrip.mms'\" \(433 characters\)
  265. sed "s/^X//" >'descrip.mms' <<'END_OF_FILE'
  266. X!
  267. X! Descrip.MMS for "rot13"
  268. X!
  269. X! Written by: Scott Berry and Joseph Hillenburg
  270. X! Last update: (01-28-91)
  271. X! This file is in the public domain.
  272. X!
  273. X
  274. XEXE        = ROT13.EXE
  275. XCDEFS      = /DEFINE=(VMS)
  276. XSOURCES    = ROT13.C
  277. XOBJECTS    = ROT13.OBJ
  278. X
  279. X.SUFFIXES .C .OBJ
  280. X
  281. XROT13.EXE : $(OBJECTS)
  282. X        LINK /NODEBUG/EXEC=$(EXE) $(OBJECTS),sys$library:vaxcrtl.olb/libr
  283. X    DELETE $(OBJECTS);*
  284. X
  285. X.C.OBJ
  286. X        CC $(CDEFS) /NODEB/OPTIM/OBJ=$*.OBJ $*.C
  287. END_OF_FILE
  288. if test 433 -ne `wc -c <'descrip.mms'`; then
  289.     echo shar: \"'descrip.mms'\" unpacked with wrong size!
  290. fi
  291. # end of 'descrip.mms'
  292. fi
  293. if test -f 'rot13.cld' -a "${1}" != "-c" ; then 
  294.   echo shar: Will not clobber existing file \"'rot13.cld'\"
  295. else
  296. echo shar: Extracting \"'rot13.cld'\" \(155 characters\)
  297. sed "s/^X//" >'rot13.cld' <<'END_OF_FILE'
  298. XDEFINE VERB ROT13
  299. X
  300. XIMAGE CINDERELLA:[ANLHILLE.ROT13]ROT13.EXE
  301. X
  302. XQUALIFIER INPUT,VALUE(TYPE=$INFILE,REQUIRED)
  303. X
  304. XQUALIFIER OUTPUT,VALUE(TYPE=$INFILE,REQUIRED)
  305. END_OF_FILE
  306. if test 155 -ne `wc -c <'rot13.cld'`; then
  307.     echo shar: \"'rot13.cld'\" unpacked with wrong size!
  308. fi
  309. # end of 'rot13.cld'
  310. fi
  311. if test -f 'chat' -a "${1}" != "-c" ; then 
  312.   echo shar: Will not clobber existing file \"'chat'\"
  313. else
  314. echo shar: Extracting \"'chat'\" \(1333 characters\)
  315. sed "s/^X//" >'chat' <<'END_OF_FILE'
  316. X#!/bin/sh
  317. X# A kludge to yak at multiple people at once.  Turns out that sh is a lot
  318. X# better for this than csh...
  319. Xname="${1}"
  320. X# This was ripped straight out of Citadel/UX
  321. X# I have modified it to work better in a standalone environment.
  322. X# -jph
  323. Xif test "${name}"; then
  324. X  echo "Using ${name} as your nickname..."
  325. Xelse
  326. X  if test "$CHAT_NICK"; then
  327. X    name=$CHAT_NICK
  328. X    echo "Using $CHAT_NICK as your nickname..."
  329. X  else
  330. X    echo "Using $USER as your nickname..."
  331. X    name=$USER
  332. X    echo "Notice: You can use the syntax: chat <nickname>"
  333. X    echo "        or set the environment variable CHAT_NICK."
  334. X  fi
  335. Xfi
  336. Xexport name
  337. Xtime=`date`
  338. Xexport time 
  339. Xecho "Type ^D to leave chat."
  340. X
  341. Xecho "These people are in chat right now:"
  342. Xw | grep chat
  343. Xlfile=/tmp/chat.tmp
  344. Xif test -f $lfile ; then
  345. X  (umask 0 ; touch $lfile)
  346. Xfi
  347. XCHAT_MAINTAINER=jph ; export CHAT_MAINTAINER
  348. Xif test $name=$CHAT_MAINTAINER ; then
  349. X  chmod og+rw $lfile
  350. Xfi
  351. X
  352. Xecho "The chat maintainer is ${CHAT_MAINTAINER}"
  353. Xstty intr \^H
  354. Xstty lnext ""
  355. Xstty quit \^[
  356. X(tail -1f $lfile | egrep -v "^$name") &
  357. Xtjob=$!
  358. Xsleep 1
  359. Xecho "[${name} entering at ${time}]" >> $lfile
  360. Xtrap "" 2
  361. Xwhile read line; do
  362. X  echo "${name}: ${line}" >> $lfile
  363. Xdone
  364. X# Here the luser wanted to leave, so inform and clean up
  365. Xecho "[${name} leaving at ${time}]" >> $lfile
  366. Xkill -9 $tjob
  367. Xstty intr \^C
  368. Xstty quit \^\\
  369. Xexit 0
  370. X
  371. END_OF_FILE
  372. if test 1333 -ne `wc -c <'chat'`; then
  373.     echo shar: \"'chat'\" unpacked with wrong size!
  374. fi
  375. chmod +x 'chat'
  376. # end of 'chat'
  377. fi
  378. echo shar: End of shell archive.
  379. exit 0
  380.  
  381. -- 
  382.    //   Joseph Hillenburg, Secretary, Bloomington Amiga Users Group
  383.  \X/  joseph@valnet.UUCP     jph@irie.ais.org          jph@ai.mit.edu
  384.        "Only Apple could slow down a 68030 chip" --Computer Shopper
  385.