home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume30 / tin / part12 < prev    next >
Encoding:
Text File  |  1992-05-19  |  54.5 KB  |  1,866 lines

  1. Newsgroups: comp.sources.misc
  2. From: iain%anl433.uucp@germany.eu.net (Iain J. Lea)
  3. Subject:  v30i012:  tin - threaded full screen newsreader, Part12/14
  4. Message-ID: <1992May20.172901.29947@sparky.imd.sterling.com>
  5. X-Md4-Signature: ccb36227426acf8d6a4ad28c3a436482
  6. Date: Wed, 20 May 1992 17:29:01 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: iain%anl433.uucp@germany.eu.net (Iain J. Lea)
  10. Posting-number: Volume 30, Issue 12
  11. Archive-name: tin/part12
  12. Environment: BSD, SCO, ISC, SUNOS, SYSVR3, SYSVR4, ULTRIX, XENIX
  13. Supersedes: tin: Volume 29, Issue 19-30
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  MANIFEST CHANGES Makefile kill.c main.c
  22. # Wrapped by kent@sparky on Tue May 19 13:38:06 1992
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 12 (of 14)."'
  26. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  28. else
  29.   echo shar: Extracting \"'MANIFEST'\" \(939 characters\)
  30.   sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  31. XMANIFEST for tin newsreader (Thu May 14 00:26:48 MET DST 1992)
  32. X----------------------------------------------------------
  33. X   12658 Makefile
  34. X     122 MANIFEST
  35. X    3600 README
  36. X   12810 CHANGES
  37. X    8397 INSTALL
  38. X    4958 TODO
  39. X   14588 FAQ
  40. X    2568 FTP
  41. X   38440 tin.1
  42. X    2247 wildmat.3
  43. X   48215 tin.nrf
  44. X   13510 tin.h
  45. X   17525 extern.h
  46. X    4658 nntplib.h
  47. X   27832 proto.h
  48. X     585 patchlev.h
  49. X    8546 active.c
  50. X   22838 art.c
  51. X    7985 curses.c
  52. X    4195 debug.c
  53. X   14936 feed.c
  54. X   11458 getline.c
  55. X   24125 group.c
  56. X    2510 hashstr.c
  57. X    5603 help.c
  58. X    3615 inews.c
  59. X   14261 init.c
  60. X   11832 kill.c
  61. X   22813 lang.c
  62. X   12398 main.c
  63. X    7630 memory.c
  64. X   15398 misc.c
  65. X   20406 newsrc.c
  66. X   14882 nntplib.c
  67. X   13908 open.c
  68. X   22466 page.c
  69. X   26765 post.c
  70. X    3818 prompt.c
  71. X   23814 rcfile.c
  72. X   25838 save.c
  73. X    2916 screen.c
  74. X    7173 search.c
  75. X   24488 select.c
  76. X    8395 signal.c
  77. X   14239 spooldir.c
  78. X   17796 thread.c
  79. X    4798 wildmat.c
  80. X  634558 total
  81. END_OF_FILE
  82.   if test 939 -ne `wc -c <'MANIFEST'`; then
  83.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  84.   fi
  85.   # end of 'MANIFEST'
  86. fi
  87. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  88.   echo shar: Will not clobber existing file \"'CHANGES'\"
  89. else
  90.   echo shar: Extracting \"'CHANGES'\" \(12810 characters\)
  91.   sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  92. XCHANGES tin v1.1 PL2 -> tin 1.1 PL3
  93. X-----------------------------------
  94. X
  95. X1)  Iain Lea (iain%anl433.uucp@Germany.EU.net)
  96. X    BUG. STUPID error (I was the culprit) stopped group selection screen
  97. X         being redisplayed.
  98. X    FIX. select.c - changed 2 #ifdef's to #ifndef NO_RESYNC_ACTIVE_FILE.
  99. X
  100. X2)  Wolfgang Zenker (wolfgang@lyxys.ka.sub.org) 
  101. X    BUG. Replying through mail does not check Reply-To: mail header.
  102. X    FIX. post.c - added find_reply_to_addr() to find Reply-To: / From: address.
  103. X
  104. X3)  Hakan Lennestal (hakanl@lulea.telesoft.se)
  105. X    BUG. Makefile does not chown & chgrp for setuid version of tin.
  106. X    FIX. Makefile - applied supplied patch.
  107. X
  108. X4)  Michael Traub (traub@rtf.bt.co.uk)
  109. X    BUG. No support for PgUp PgDn Home End on vt200 terminals.
  110. X    FIX. misc.c - applied supplied patch.   
  111. X
  112. X5)  Chris Steinbroner (hesh@hpos102.cup.hp.com)
  113. X    BUG. Long groupnames (>40) will overwrite the screen[] array. 
  114. X    FIX. select.c - applied supplied patch.
  115. X
  116. X6)  Iain Lea (iain%anl433.uucp@Germany.EU.net)
  117. X    BUG. #include <sys/ioctl.h> is included twice and causes compile
  118. X         error on ISC Unix (#include files should be protected Sigh!).
  119. X    FIX. tin.h curses.c - removed #include from curses.c
  120. X
  121. X7)  Iain Lea (iain%anl433.uucp@Germany.EU.net)
  122. X    ADD. select.c - added default prompt to 'g' command.
  123. X
  124. X8)  Iain Lea (iain%anl433.uucp@Germany.EU.net)
  125. X    ADD. nntplib.c - added & intergrated NNTP clientlib.c
  126. X
  127. X9)  Iain Lea (iain%anl433.uucp@Germany.EU.net)
  128. X    ADD. group.c - 'd' command now toggles between Subject: & selected
  129. X         From: field combination. Save toggling through all four
  130. X         combinations to get back to original choice on slow terminals.
  131. X
  132. X10) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  133. X    BUG. Builtin inews is slow posting big articles because it uses
  134. X         put_server() routine with fflush() for every line.
  135. X    FIX. inews.c - replaced put_server() routine with fprintf() and
  136. X         single fflush() after loop.
  137. X
  138. X11) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  139. X    ADD. feed.c - added code to print num of arts mailed/printed.
  140. X
  141. X12) Kazushi Marukawa (kazushi@kocb.astem.or.jp)
  142. X    BUG. When reading news locally tin should use external inews and when 
  143. X         reading via nntp use builtin inews.
  144. X    FIX. inews.c - check to see if reading via nntp and use correct inews .
  145. X
  146. X13) Andy Jackson (arj@cam-orl.co.uk)
  147. X    BUG. 'o' command prints the same author for all articles within a thread.
  148. X    FIX. feed.c - pass correct artnum to print_file() routine.
  149. X
  150. X14) Andy Jackson (arj@cam-orl.co.uk)
  151. X    BUG. Unthreading groups specified in ~/.tin/unthread does not always work.
  152. X    FIX. misc.c - If group is beginning of hash chain it was not marked read.
  153. X         Check is made if active[].next == -1 and if so active[].threa is set
  154. X         to FALSE.
  155. X
  156. X15) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  157. X    ADD. thread.c - added 'd' command to toggle subject & author at thread level.
  158. X
  159. X16) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  160. X    ADD. init.c rcfile.c - added auto-saving of default prompt strings for next 
  161. X         session.
  162. X
  163. X18) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  164. X    ADD. post.c help.c - added action field to 'W' history of posted/followups
  165. X         so one can see if 'w' posted / 'f' followed up an article.
  166. X
  167. X19) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  168. X    BUG. SPOOLDIR is incorrectly used instead of spooldir.
  169. X    FIX. open.c init.c - replaced all SPOOLDIR's with spooldir.
  170. X
  171. X20) Jim Robinson (robinson@mdivax1.mdd.comm.mot.com)
  172. X    FIXES. rcfile.c - change_rcfile() when 'q' or 'ESC' are used to
  173. X           exist, SIGTSTP disposition is is not being reset to it's
  174. X           status upon enterring the routine, as is done when exiting
  175. X           routine otherwise.
  176. X           art.c - parse_header() stopped from being interrupted by
  177. X           SIGALRM signal.
  178. X           curses.c - ReadCh() code for READ_CHAR_HACK was wrong. On
  179. X           EOF or error getc() returns EOF, but code loop checks for 0.
  180. X    ENHANCEMENTS curses.c - InitScreen() if terminal has no inverse
  181. X           will now use underline.
  182. X           kill.c - kill_art_menu() implemented hot (auto select) of
  183. X           interesting arts.
  184. X           kill.c - kill menu has been enhanced to allow user to specify
  185. X           killing or auto-selection of articles.
  186. X           group.c - show_group_page() - modified to indicate 'hot' and
  187. X           'seen' articles.
  188. X    CHANGES rcfile.c - change_rcfile() when exiting by 'q' or 'ESC' we
  189. X           now do killing as is done when exiting otherwise.
  190. X           signal.c kill.c misc.c rcfile.c - Cleaned up files with use
  191. X           of sigaction() vs signal() which *greatly* enhances readability
  192. X           in places.
  193. X           signal.c - Changed handling of SIGTSP. Now when SIGTSTP is 
  194. X           caught we simply send ourself a SIGSTOP which is uncatchable.
  195. X           active.c -  notify_groups() now runs in raw mode.
  196. X           kill.c art.c - killing is now done by marking article as unread.
  197. X           This means that index files are now *not* modified on the basis
  198. X           of kills. 
  199. X           art.c - reload_index_file() is no longer needed and so has been
  200. X           deleted. 
  201. X           group.c - show_group_page() worked on to increase readability.
  202. X
  203. X21) Steve Starck (sstarck@nv6.uswnvg.com)
  204. X    ADD. Support for Sequent PTX. Applied supplied patch.
  205. X
  206. X22) Leila Burrell-Davis (lielabd@syma.sussex.ac.uk)
  207. X    BUG. Sequent Dynix is based on BSD4.2 so a few things are different
  208. X         for BSD configuration.
  209. X    FIX. Applied supplied patch.
  210. X
  211. X23) Preston Bannister (preston@felix.filenet.com)
  212. X    BUG. tin will hang if '|' piping command of articles is interrupted.
  213. X    FIX. misc.c - check if errno = EPIPE and if so return to calling function.
  214. X
  215. X24) Lloyd Wright (lloyd@hpcvaac.cv.hp.com)
  216. X    BUG. HPUX was using wrong mailer & should use gethostname() in inews.c
  217. X    FIX. applied supplied patch.
  218. X
  219. X25) G. Woodbury (news%wolves.cs.duke.edu)
  220. X    BUG. Good idea to put INDEXDIR on another filesystem then NEWSSPOOL to
  221. X         save space & inodes for news.
  222. X    FIX. main.c - added '-I dir' command line option.
  223. X
  224. X26) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  225. X    BUG. You have to explicity add *'s for regex killing/auto-selecting.
  226. X    FIX. kill.c - added *'s behind the scenes to make esier to use regexes.
  227. X
  228. X27) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  229. X    BUG. When having advanced through a thread at page level & returned to 
  230. X         thread level one is still positioned at start position in thread.
  231. X    FIX. thread.c - added code to move to current respnum when returning.
  232. X
  233. X28) Bill de Beaubien (wjb@moscom.com)
  234. X    BUG. Enviroment variable MAILER is not checked for mailer to use.
  235. X    FIX. init.c - added check for MAILER enviroment variable.
  236. X
  237. X29) Kuo-Chien Kai (kckai@cc.nthu.edu)
  238. X    BUG. A user can cancel any article.
  239. X    FIX. post.c - added check to make sure user has same address & name 
  240. X         as the From: header in article to cancel.
  241. X
  242. X30) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  243. X    BUG. SysV systems using uname() where not using utsname struct.
  244. X    FIX. inews.c - changed uname() to use utsname struct instead of array.
  245. X
  246. X31) Jean-Marc Bonnaudet (Jean.Marc.Bonnaudet@sniap.mchp.sni.de) 
  247. X    BUG. When viewing help pages 'j' & 'k' keys don't work.
  248. X    FIX. help.c - Added 'j' & 'k' keys for PgDn & PgUp operation.
  249. X
  250. X32) Leila Burrell-Davis (lielabd@syma.sussex.ac.uk)
  251. X    BUG. Line-editing produces $$ and does not auto-scroll horizontly if
  252. X         editing window <30 characters.
  253. X    FIX. feed.c - fixed so line prompt always leaves >=30 editing space.
  254. X
  255. X33) Stefan Rathmann (rathmann%anl433.uucp@Germany.EU.net)
  256. X    BUG. Only first 4 characters of mail address are given over to mailer.
  257. X    FIX. post.c - changed sizeof (pointer) to sizeof (buffer).
  258. X
  259. X34) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  260. X    BUG. Won't compile on Apollo DN4500 & DomainOS 10.3
  261. X    FIX. Added support to compile above configuration.
  262. X
  263. X35) Paul Halsema (phalsema@x102a.ess.harris.com)
  264. X    BUG. Won't compile on Harris HCX & CX/UX.
  265. X    FIX. Applied part of supplied patch. 
  266. X
  267. X36) Paul Halsema (phalsema@x102a.ess.harris.com)
  268. X    BUG. '^Y' command does not work because shell uses it as suspend signal.
  269. X    FIX. select.c - Changed '^Y' command to 'Y' command.
  270. X
  271. X37) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  272. X    ADD. Added basic support for per group configurable parameters.
  273. X
  274. X38) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  275. X    BUG. Built-in NNTP inews does not allow Gateway machines / Domain
  276. X         address to be specified for users posting address.
  277. X    FIX. tin.h inews.c - Added #define's NNTP_INEWS_GATEWAY and
  278. X         NNTP_INEWS_DOMAIN. For more info read the INSTALL document.
  279. X
  280. X39) Daemon Schaefer (damon@hpvcldm.vcd.hp.com)
  281. X    BUG. Make all of the confirmation prompts a confurable option. 
  282. X    FIX. init.c rcfile.c - added option to 'M' menu to allow prompts
  283. X         to be switched ON/OFF.
  284. X
  285. X40) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  286. X    BUG. Old versions of Unix(bsd42?) will not resize screen automatically
  287. X         because TIOCGWINSZ ioctl is not supported.
  288. X    FIX. signal.c - Added code to support TIOCGSIZE.
  289. X
  290. X41) Jonas Regmyr (dat91jre@ludat.lth.se)
  291. X    BUG. Should wrap around to first group when at last group at group
  292. X         selection level & vic versa when at first group.
  293. X    FIX. select.c group.c thread.c - Added #ifdef NO_WRAP_AROUND to allow
  294. X         old behaviour and also support for new.
  295. X
  296. X42) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  297. X    ADD. feed.c - Added same interface to 'x' crosspost command as used
  298. X         by mail,print,pipe & save commands.
  299. X
  300. X43) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  301. X    ADD. open.c - Added support for reading news from an INN NNTP server.
  302. X
  303. X44) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  304. X    BUG. Won't compile on SCO Unix 3.2.2
  305. X    FIX. Added support to compile above configuration.
  306. X
  307. X45) Adri Verhoef (a3@tintin.rivm.nl)
  308. X    BUG. Under BSD type systems builtin inews does not post with FQDN.
  309. X    FIX. inews.c - Call gethostbyname() to get fully qualified domain name. 
  310. X
  311. X46) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  312. X    BUG. Apollo DomainOS uses the ORGANIZATION environment variable. 
  313. X    FIX. init.c - Changed environment variable to NEWSORG when on apollo.
  314. X
  315. X47) Etienne Bido (ebido@bio.vu.nl)
  316. X    BUG. Should allow Distribution: field to be set from environment variable.
  317. X    FIX. init.c - Uses the value of the DISTRIBUTION env. variable for the
  318. X         Distribution: field when posting articles.
  319. X
  320. X48) Murray Laing (murray@uk.ac.ed.chemeng)
  321. X    BUG. Inconsistant commands for quitting and returning to upper levels.
  322. X    FIX. Standardised on 'Q' to quit tin & 'q' to quit to previous level.
  323. X
  324. X49) Murray Laing (murray@uk.ac.ed.chemeng)
  325. X    BUG. Should allow groups to be specified as regex on command line.
  326. X    FIX. main.c - changed code to do regex matching on specified groups.
  327. X
  328. X50) Jim Robinson (robinson@mdivax1.mdd.comm.mot.com)
  329. X    BUG. show_page() returns an index into base[] but was been used as an
  330. X         index into arts[].
  331. X    FIX. thread.c - applied supplied patch.
  332. X
  333. X51) Tom Theel (tom@imd.sterling.com)
  334. X    ADD. Applied supplied patch to allow reading news from CD-ROM.
  335. X52) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  336. X    BUG. Articles in spooldir can be recieved out of order (not nice).
  337. X    FIX. init.c - changed default sorting of articles to date ascending.
  338. X
  339. X    BUG. Usernames surrounded by "'s are shown like that on screen.
  340. X    FIX. misc.c - changed parse_from() to parse out "'s from ("name").
  341. X
  342. X54) John Schmitz (schmitz@hpscdc.hp.com)
  343. X    BUG. Manual page does not say that -u & -U options don't work if index
  344. X         are retieved via NNTP.
  345. X    FIX. tin.1 - added comment to clarify above.
  346. X
  347. X55) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  348. X    ADD. nntplib.h - added new #defines from NNTP 1.6 & CD-ROM SPOOLDIR.
  349. X56) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  350. X    BUG. SPOOLDIR defined from Makefile is not always used.
  351. X    FIX. rcfile.c - spooldir variable was used in a much earlier version
  352. X         of tin for something else (bitch cost 4 hours to find - sigh!)
  353. X57) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  354. X    BUG. With > 1000 arts viewing 1000 of 1000 overwrites part of displayed
  355. X         page header info.
  356. X    FIX. page.c signal.c - increased size of RIGHT_POS variable by 2.
  357. X
  358. X58) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  359. X    ADD. 'l' command to allow selection of different spooldir.
  360. X
  361. X59) Orest Zboroski (obz@sisd.Kodak.COM)
  362. X    BUG. The interface for quitting from prompts sometimes uses a)bort
  363. X         or e)xit. Its hard to remember & should always be the same.
  364. X    FIX. Changed all prompts to use 'q' to abort current action.
  365. X
  366. X60) Iain Lea (iain%anl433.uucp@Germany.EU.net)
  367. X    BUG. Unreal errors that killed stack traces when debugging with sdb.
  368. X    FIX. art.c - changed fread() in parse_header() to read buffer-1 chars.
  369. END_OF_FILE
  370.   if test 12810 -ne `wc -c <'CHANGES'`; then
  371.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  372.   fi
  373.   # end of 'CHANGES'
  374. fi
  375. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  376.   echo shar: Will not clobber existing file \"'Makefile'\"
  377. else
  378.   echo shar: Extracting \"'Makefile'\" \(12658 characters\)
  379.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  380. X# Makefile for tin - for tin compiler flag options read INSTALL and README.
  381. XEXE    = tin
  382. XEXED    = tind
  383. XBINDIR    = /usr/local/bin
  384. XMANDIR    = /usr/man/man1
  385. X
  386. X# Define if you want the multi SPOOLDIR extensions & library
  387. XCDROM    = -DCDROM_ABLE
  388. X# sun01
  389. X#CDLIB    = -ldbm -L/home/lea/.src/cllib/clientlib -lcllib 
  390. X# anl433
  391. XCDLIB    = /usr/local/src/cnews/dbz/dbz.o -L/usr/home/admin/iain/.src/cllib/clientlib -lcllib -lcposix
  392. X
  393. XCC    = cc
  394. XSTRIP    = strip
  395. XROFF    = + drf -F Helvetica -man3 
  396. XPRINT    = -Pps0
  397. XBASE_VER= ../112
  398. XPATCH_VER = 113
  399. XMAIL_ADDR = "iain%anl433.uucp@Germany.EU.net (Iain Lea)"
  400. X
  401. XHFILES    = tin.h extern.h nntplib.h proto.h
  402. X
  403. XCFILES    = active.c art.c curses.c debug.c feed.c getline.c group.c \
  404. X        hashstr.c help.c inews.c init.c kill.c lang.c main.c memory.c \
  405. X        misc.c newsrc.c nntplib.c open.c page.c post.c prompt.c \
  406. X        rcfile.c save.c screen.c search.c select.c signal.c spooldir.c \
  407. X        thread.c wildmat.c
  408. X
  409. XOFILES    = active.o art.o curses.o debug.o feed.o getline.o group.o \
  410. X        hashstr.o help.o inews.o init.o kill.o lang.o main.o memory.o \
  411. X        misc.o newsrc.o nntplib.o open.o page.o post.o prompt.o \
  412. X        rcfile.o save.o screen.o search.o select.o signal.o spooldir.o \
  413. X        thread.o wildmat.o 
  414. X
  415. XSUPPORT = Makefile MANIFEST README CHANGES INSTALL TODO FAQ FTP *.[13] $(EXE).nrf
  416. X
  417. XLINTFLAGS=-a -c -h -n -x 
  418. X
  419. X.c.o:
  420. X    $(CC) $(CFLAGS) $*.c
  421. X
  422. Xall: 
  423. X    @echo "There is no default. Specify one of the following targets."
  424. X    @echo "    make bsd       (BSD/Dec/DG/Next/Sun)"
  425. X    @echo "    make sysv      (SysV)"
  426. X    @echo "    make sysvr4    (SysV R4)"
  427. X    @echo "    make sco       (SCO Unix)"
  428. X    @echo "    make aix       (IBM AIX)"
  429. X    @echo "    make xenix     (Xenix 386)"
  430. X    @echo "    make sinix     (SNI SysV)"
  431. X    @echo "    make tower     (NCR Tower)"
  432. X    @echo "    make minix     (Minix 386)"
  433. X    @echo "    make ptx       (Sequent PTX)"
  434. X    @echo "    make apollo    (Apollo Domain)"
  435. X
  436. X# For BSD-derived systems
  437. Xbsd:
  438. X    @echo "Compiling for BSD/Dec/DG/Next/Sun..."
  439. X    @$(MAKE) CFLAGS='-c -O -DBSD -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  440. X             LIBS="-lcurses -ltermcap" \
  441. X             EXE=tin linkit
  442. X
  443. X# For System V
  444. X#             NETLIBS="-lnet -lnsl_s" \
  445. X#
  446. Xsysv:
  447. X    @echo "Compiling for System V..."
  448. X    @$(MAKE) CFLAGS='-c -O -DSYSV -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  449. X             LIBS="-lcurses -ltermcap" \
  450. X             EXE=tin linkit
  451. X
  452. X# For System V Release 4
  453. X#             NETLIBS="-lnsl -lsocket" \
  454. X#
  455. Xsysvr4:
  456. X    @echo "Compiling for System V Release 4..."
  457. X    @$(MAKE) CFLAGS='-c -O -DSVR4 -DPOSIX_JOB_CONTROL -DUSE_INVERSE_HACK -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  458. X             LIBS="-lcurses -ltermlib" \
  459. X             EXE=tin linkit
  460. X
  461. X# For SCO Unix
  462. X#             NETLIBS="-lnsl_s -lsocket" \
  463. X#
  464. Xsco:
  465. X    @echo "Compiling for SCO Unix..."
  466. X    @$(MAKE) CFLAGS='-c -O -DSYSV -DSCO_UNIX -UM_XENIX -DUSE_INVERSE_HACK -DLIBDIR="\"/usr/lib/news\"" -DSPOOLDIR="\"/usr/spool/news\""' \
  467. X             LIBS="-lcurses -lgen -lc_s" \
  468. X             EXE=tin linkit
  469. X
  470. X# For IBM AIX
  471. Xaix:
  472. X    @echo "Compiling for AIX..."
  473. X    @$(MAKE) CFLAGS='-c -O -DSYSV -DRS6000 -DREAD_CHAR_HACK -DUSE_LONG_FILENAMES -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  474. X             LIBS="-lcurses -ltermcap" \
  475. X             EXE=tin linkit
  476. X
  477. X# For Xenix 386
  478. X#             NETLIBS="-lsocket" \
  479. X#
  480. Xxenix:
  481. X    @echo "Compiling for Xenix 386..."
  482. X    @$(MAKE) CFLAGS='-c -Zi -DSYSV -DLIBDIR="\\"/usr/lib/news\\"" -DSPOOLDIR="\\"/usr/spool/news\\""' \
  483. X             LIBS="-lcurses -ltinfo -lx" \
  484. X             LFLAGS=-Zi EXE=tin linkit
  485. X
  486. X# For SNI Sinix
  487. Xsinix:
  488. X    @echo "Compiling for SNI Sinix..."
  489. X    @$(MAKE) CFLAGS='-c -O -DUSE_MKDIR -DLIBDIR=\\"/usr/lib/news\\" -DSPOOLDIR=\\"/usr/spool/news\\"' \
  490. X             LIBS="-lcurses" \
  491. X             EXE=tin linkit
  492. X
  493. X# For NCR Tower
  494. X#             NETLIBS="-lnet -lnsl_s" \
  495. X#
  496. Xtower:
  497. X    @echo "Compiling for NCR Tower..."
  498. X    @$(MAKE) CFLAGS='-c -O -DSYSV -DNCR -DISTRING -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  499. X             LIBS="-lcurses -ltermcap" \
  500. X             EXE=tin linkit
  501. X
  502. X# For Minix 386
  503. Xminix:
  504. X    @echo "Compiling for Minix 386..."
  505. X    @$(MAKE) CFLAGS='-c -O -DMINIX -D_POSIX_SOURCE -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  506. X             LIBS="-lcurses" \
  507. X             EXE=tin linkit
  508. X    chmem +131072 $(EXE) 
  509. X
  510. X# For Sequent PTX
  511. X#             NETLIBS="-lsocket -linet -lnsl_s" \
  512. X#
  513. Xptx:
  514. X    @echo "Compiling for Sequent PTX..."
  515. X    @$(MAKE) CFLAGS='-c -O -DPTX -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  516. X             LIBS="-lcurses -ltermcap" \
  517. X             EXE=tin linkit
  518. X
  519. X# For Apollo 
  520. Xapollo:
  521. X    @echo "Compiling for Apollo..."
  522. X    @$(MAKE) CFLAGS='-c -O -DLIBDIR=\"/usr/lib/news\" -DSPOOLDIR=\"/usr/spool/news\"' \
  523. X             LIBS="-lcurses -ltermcap" \
  524. X             EXE=tin linkit
  525. X
  526. X# !!!  THE FOLLOWING ARE SITE SPECIFIC - IGNORE  !!!
  527. Xanl432:
  528. X    @echo "Compiling for ANL432 with NNTP ONLY, NO POSTING, NO SHELL ESCAPE..."
  529. X    @$(MAKE) CC=gcc CFLAGS='-c -O2 -Wall -DSYSV -DNNTP_ONLY -DNNTP_EXTS -DNO_POSTING -DNO_SHELL_ESCAPE  -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  530. X             LIBS="-lcurses -ltermcap" \
  531. X             NETLIBS="-linet -lnsl_s" \
  532. X             EXE=tin linkit
  533. X
  534. Xlocal:
  535. X    @echo "Compiling for ANL433..."
  536. X    @$(MAKE) CC=cc CFLAGS='-c -g -DSYSV -DDEBUG -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\"' \
  537. X             LIBS="-lcurses -ltermcap" \
  538. X             EXE=tin linkit
  539. X
  540. Xanl433:
  541. X    @echo "Compiling for ANL433 with NNTP..."
  542. X    @$(MAKE) CC=gcc CFLAGS='-c -O2 -Wall -DSYSV -DNNTP_ABLE -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  543. X             LIBS="-lcurses -ltermcap" \
  544. X             NETLIBS="-linet -lnsl_s" \
  545. X             EXE=tin linkit
  546. X
  547. Xanl433cd:
  548. X    @echo "Compiling for ANL433 with CDROM..."
  549. X    @$(MAKE) CC=gcc CFLAGS='-c -O2 -Wall -DSYSV -DCDROM_ABLE -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  550. X             LIBS="-lcurses -ltermcap $(CDLIB)" \
  551. X             NETLIBS="-linet -lnsl_s" \
  552. X             EXE=tin linkit
  553. X
  554. Xapollo02:
  555. X    @echo "Compiling for APOLLO02 with NNTP ONLY..."
  556. X    @$(MAKE) CFLAGS='-c -O -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  557. X             LIBS="-lcurses -ltermcap" \
  558. X             EXE=tin linkit
  559. X
  560. Xos2unix:
  561. X    @echo "Compiling for OS2UNIX with NNTP ONLY..."
  562. X    @$(MAKE) CC=/usr2/gcc/bin/gcc CFLAGS='-c -O2 -Wall -DSYSV -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  563. X             LIBS="-lcurses -ltermcap" \
  564. X             NETLIBS="-linet -lnsl_s" \
  565. X             EXE=tin linkit
  566. X
  567. Xdaemon:
  568. X    @echo "Compiling for ANL433 with INDEX DAEMON..."
  569. X    @$(MAKE) CC=cc CFLAGS='-c -g -DSYSV -DINDEX_DAEMON -DDEBUG' \
  570. X             EXE=$(EXED) linkit
  571. X
  572. Xdec02:
  573. X    @echo "Compiling for DEC02 with NNTP ONLY..."
  574. X    @$(MAKE) CFLAGS='-c -O -DBSD -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  575. X             LIBS="-lcurses -ltermcap" \
  576. X             EXE=tin linkit
  577. X
  578. Xdg01:
  579. X    @echo "Compiling for DG01 with NNTP ONLY..."
  580. X    @$(MAKE) CFLAGS='-c -O -DBSD -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  581. X            LIBS="-lcurses -ltermcap" \
  582. X            EXE=tin linkit
  583. X
  584. Xhome:
  585. X    @echo "Compiling for (HOME) Xenix 386..."
  586. X    @$(MAKE) CFLAGS='-c -W2 -Zi -DSYSV -DDEBUG -DLIBDIR="\\"/usr/lib/news\\"" -DSPOOLDIR="\\"/usr/spool/news\\""' \
  587. X             LIBS="-lcurses -ltinfo -lx" \
  588. X             LFLAGS=-Zi EXE=tin linkit
  589. X
  590. Xmx331:
  591. X    @echo "Compiling for MX331 with NNTP ONLY..."
  592. X    @$(MAKE) CFLAGS='-c -O -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\\"anl433\\" -DNNTP_INEWS_DOMAIN=\\".uucp\\" -DUSE_MKDIR -DDEBUG' \
  593. X             LIBS="-lcurses" \
  594. X             EXE=tin linkit
  595. X
  596. Xmx351:
  597. X    @echo "Compiling for MX351 with NNTP ONLY..."
  598. X    @$(MAKE) CFLAGS='-c -O -DSVR4 -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DPOSIX_JOB_CONTROL -DUSE_INVERSE_HACK -DEBUG' \
  599. X             NETLIBS="-lnsl -lsocket" \
  600. X             LIBS="-lcurses -ltermlib" \
  601. X             EXE=tin linkit
  602. X
  603. Xsony01:
  604. X    @echo "Compiling for SONY01 with NNTP ONLY..."
  605. X    @$(MAKE) CC=gcc CFLAGS='-c -O2 -Wall -DBSD -DNNTP_ONLY -DLIBDIR=\"/a/usr/lib/news\" -DSPOOLDIR=\"/a/usr/spool/news\" -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  606. X            LIBS="-lcurses -ltermcap" \
  607. X            EXE=tin linkit
  608. X
  609. Xsun01:
  610. X    @echo "Compiling for SUN01 with NNTP ONLY..."
  611. X    @$(MAKE) CFLAGS='-c -O -DBSD -DNNTP_ONLY -DNNTP_INEWS_GATEWAY=\"anl433\" -DNNTP_INEWS_DOMAIN=\".uucp\" -DDEBUG' \
  612. X             LIBS="-lcurses -ltermcap" \
  613. X             EXE=tin linkit
  614. X
  615. Xsun01cd:
  616. X    @echo "Compiling for SUN01 with CDROM ABLE..."
  617. X    @$(MAKE) CFLAGS='-c -g -DBSD -DCDROM_ABLE -DLIBDIR=\"/home/sun02/iain/lib\" -DDEBUG' \
  618. X              NNTPLIB="$(CDLIB)" \
  619. X             LIBS="-lcurses -ltermcap" \
  620. X             EXE=tin linkit
  621. X
  622. Xlinkit: $(OFILES)
  623. X    @echo "Linking $(EXE)..."
  624. X    $(CC) $(LFLAGS) -o $(EXE) $(OFILES) $(NNTPLIB) $(NETLIBS) $(LIBS) 
  625. X    @ls -l $(EXE)
  626. X
  627. Xinstall:
  628. X    @echo "Installing $(EXE)..."
  629. X    @$(STRIP) $(EXE)
  630. X    @-mv $(EXE) $(BINDIR)
  631. X    @-rm $(BINDIR)/r$(EXE)
  632. X    @ln $(BINDIR)/$(EXE) $(BINDIR)/r$(EXE)
  633. X    @chmod 755 $(BINDIR)/$(EXE) $(BINDIR)/r$(EXE)  
  634. X    @ls -l $(BINDIR)/$(EXE) $(BINDIR)/r$(EXE)
  635. X    @cp $(EXE).1 $(MANDIR)
  636. X
  637. Xinstall_setuid:
  638. X    @echo "Installing SETUID $(EXE)..."
  639. X    @$(STRIP) $(EXE)
  640. X    @-mv $(EXE) $(BINDIR)
  641. X    @chown news $(BINDIR)/$(EXE) 
  642. X    @chown news $(BINDIR)/r$(EXE) 
  643. X    @chgrp news $(BINDIR)/$(EXE) 
  644. X    @chgrp news $(BINDIR)/r$(EXE) 
  645. X    @-rm $(BINDIR)/r$(EXE)
  646. X    @ln $(BINDIR)/$(EXE) $(BINDIR)/r$(EXE)
  647. X    @su news -c "chmod 6755 $(BINDIR)/$(EXE)"
  648. X    @su news -c "chmod 6755 $(BINDIR)/r$(EXE)"
  649. X    @ls -l $(BINDIR)/$(EXE) $(BINDIR)/r$(EXE)
  650. X    @cp $(EXE).1 $(MANDIR)
  651. X
  652. Xinstall_daemon:
  653. X    @echo "Installing index daemon $(EXED)..."
  654. X    @$(STRIP) $(EXED)
  655. X    @-mv $(EXED) $(BINDIR)
  656. X    @chown news $(BINDIR)/$(EXED) 
  657. X    @chmod 0755 $(BINDIR)/$(EXED)"
  658. X    @ls -l $(BINDIR)/$(EXED)
  659. X
  660. Xproto:
  661. X    @echo "Generating function prototypes for proto.h..."
  662. X    @echo "#if __STDC__" > PROTO.H
  663. X    @echo " " >> PROTO.H
  664. X    @cproto -e $(CFILES) >> PROTO.H
  665. X    @echo " " >> PROTO.H
  666. X    @echo "#else" >> PROTO.H
  667. X    @echo " " >> PROTO.H
  668. X    @cproto -e -f1 $(CFILES) >> PROTO.H
  669. X    @echo " " >> PROTO.H
  670. X    @echo "#endif" >> PROTO.H
  671. X    @-mv PROTO.H proto.h
  672. X
  673. Xnroff:
  674. X    @echo "Creating nroff man page..."
  675. X    @nroff -man $(EXE).1 > $(EXE).nrf
  676. X
  677. Xmanifest:
  678. X    @echo "Creating MANIFEST..."
  679. X    @echo "MANIFEST for tin newsreader (`date`)" > MANIFEST
  680. X    @echo "----------------------------------------------------------" >> MANIFEST
  681. X    @wc -c $(SUPPORT) $(HFILES) patchlev.h $(CFILES) >> MANIFEST
  682. X
  683. Xshar:
  684. X    @echo "Generating shell archive..."
  685. X    @make nroff
  686. X    @make manifest
  687. X    @shar -a -n $(EXE)1.1 -s $(MAIL_ADDR) -L50 -o ../$(EXE).shar $(SUPPORT) $(CFILES) $(HFILES) patchlev.h
  688. X
  689. Xuuencode:
  690. X    @make tar
  691. X    @echo "Uuencoding $(EXE).tar.Z..."
  692. X    @uuencode $(EXE).tar.Z $(EXE).tar.Z > $(EXE).tar.Z.uue
  693. X    @ls -l $(EXE).tar.Z.uue
  694. Xdiff:
  695. X    @echo "Generating diffs against $(BASE_VER)..."
  696. X    @make nroff
  697. X    @make manifest
  698. X    @-mv -f $(EXE).diff $(EXE).diff-
  699. X    @-diff -rcs $(BASE_VER) . > $(EXE).diff
  700. X    @ls -l $(EXE).diff
  701. X
  702. Xpatch:
  703. X    @make diff
  704. X    @echo "Generating patch against $(BASE_VER)..."
  705. X    @-mv $(EXE).diff $(EXE).patch$(PATCH_VER)
  706. X    @shar -a -n $(EXE) -s $(MAIL_ADDR) -L50 -o ../patch$(PATCH_VER).shar $(EXE).patch$(PATCH_VER)
  707. X    @ls -l ../patch$(PATCH_VER).shar*
  708. X
  709. Xtar:
  710. X    @echo "Generating compressed tar file..."
  711. X    @-rm $(EXE).tar $(EXE).tar.Z > /dev/null 2>&1
  712. X    @tar cvf $(EXE).tar $(SUPPORT) $(CFILES) $(HFILES) patchlev.h 
  713. X    @echo "Compressing $(EXE).tar..."
  714. X    @compress $(EXE).tar 
  715. X    @ls -l $(EXE).tar.Z
  716. X
  717. Xzoo:
  718. X    @echo "Generating zoo archive file..."
  719. X    @-rm $(EXE).zoo > /dev/null 2>&1
  720. X    @zoo ah $(EXE).zoo  $(SUPPORT) $(CFILES) $(HFILES) patchlev.h
  721. X    @ls -l $(EXE).zoo
  722. X
  723. Xtags:
  724. X    @echo "Generating tags (results in ./tags)..."
  725. X    @-rm tags
  726. X    @ctags $(HFILES) patchlev.h $(CFILES) 
  727. X
  728. Xlint:
  729. X    @echo "Linting source (results in ./LINT)..."
  730. X    @lint $(LINTFLAGS) -DNNTP_ABLE $(CFILES) > LINT
  731. X
  732. Xclean:
  733. X    @echo "Cleaning..."
  734. X    @-'rm' -rf $(OFILES) '#*' $(EXE).diff*
  735. X
  736. Xclobber:
  737. X    @echo "Clobbering..."
  738. X    @-'rm' -rf $(OFILES) '#*' tags $(EXE) $(EXE).diff* patch.shar*
  739. X
  740. Xcflow:
  741. X    @echo "Creating cflow for $(EXE)..."
  742. X    @cflow $(CFILES) > cflow.$(EXE) &
  743. X
  744. Xcscope:
  745. X    @echo "Creating cscope database $(EXE)..."
  746. X    @cscope $(SUPPORT) $(HFILES) patchlev.h $(CFILES)
  747. X
  748. Xman:
  749. X    @echo "Printing $(EXE) manual to $(PRINT)..."
  750. X    @$(ROFF) $(PRINT) $(EXE).1
  751. X
  752. Xprint:
  753. X    /bin/sh for FILE in $(HFILES) patchlev.h $(CFILES) $(SUPPORT); do \
  754. X    echo "Printing $$FILE to $(PRINT)..."; \
  755. X    a2ps -t4 $$FILE | lpr; \
  756. X    done
  757. X
  758. Xactive.o:    active.c $(HFILES)
  759. Xart.o:        art.c $(HFILES)
  760. Xcurses.o:    curses.c $(HFILES)
  761. Xdebug.o:    debug.c $(HFILES)
  762. Xfeed.o:        feed.c $(HFILES)
  763. Xgetline.o:    getline.c $(HFILES)
  764. Xgroup.o:    group.c $(HFILES)
  765. Xhashstr.o:    hashstr.c $(HFILES)
  766. Xhelp.o:        help.c $(HFILES)
  767. Xinews.o:    inews.c $(HFILES)
  768. Xinit.o:        init.c $(HFILES)
  769. Xkill.o:        kill.c $(HFILES)
  770. Xlang.o:        lang.c $(HFILES)
  771. Xmain.o:        main.c $(HFILES) patchlev.h
  772. Xmemory.o:    memory.c $(HFILES)
  773. Xmisc.o:        misc.c $(HFILES)
  774. Xnewsrc.o:    newsrc.c $(HFILES)
  775. Xnntplib.o:    nntplib.c $(HFILES)
  776. Xopen.o:        open.c nntplib.h
  777. Xpage.o:        page.c $(HFILES)
  778. Xpost.o:        post.c $(HFILES)
  779. Xprompt.o:    prompt.c $(HFILES)
  780. Xrcfile.o:    rcfile.c $(HFILES)
  781. Xsave.o:        save.c $(HFILES)
  782. Xscreen.o:    screen.c $(HFILES)
  783. Xsearch.o:    search.c $(HFILES)
  784. Xselect.o:    select.c $(HFILES)
  785. Xsignal.o:    signal.c $(HFILES)
  786. Xspooldir.o:    spooldir.c $(HFILES)
  787. Xthread.o:    thread.c $(HFILES)
  788. Xwildmat.o:    wildmat.c
  789. END_OF_FILE
  790.   if test 12658 -ne `wc -c <'Makefile'`; then
  791.     echo shar: \"'Makefile'\" unpacked with wrong size!
  792.   fi
  793.   # end of 'Makefile'
  794. fi
  795. if test -f 'kill.c' -a "${1}" != "-c" ; then 
  796.   echo shar: Will not clobber existing file \"'kill.c'\"
  797. else
  798.   echo shar: Extracting \"'kill.c'\" \(11832 characters\)
  799.   sed "s/^X//" >'kill.c' <<'END_OF_FILE'
  800. X/*
  801. X *  Project   : tin - a threaded Netnews reader
  802. X *  Module    : kill.c
  803. X *  Author    : I.Lea & J.Robinson
  804. X *  Created   : 01-04-91
  805. X *  Updated   : 10-05-92
  806. X *  Notes     : kill & auto select (hot) articles
  807. X *  Copyright : (c) Copyright 1991-92 by Iain Lea & Jim Robinson
  808. X *              You may  freely  copy or  redistribute  this software,
  809. X *              so  long as there is no profit made from its use, sale
  810. X *              trade or  reproduction.  You may not change this copy-
  811. X *              right notice, and it must be included in any copy made
  812. X */
  813. X
  814. X#include    "tin.h"
  815. X
  816. X#ifdef NO_REGEX 
  817. Xchar *stars = "";
  818. X#else        
  819. Xchar *stars = "*";
  820. X#endif
  821. X
  822. X#define SET_KILLED(i)        (arts[i].unread = ART_READ, arts[i].killed = 1, num_of_killed_arts++)
  823. X#define SET_HOT(i)        (arts[i].hot = 1, num_of_hot_arts++)
  824. X#define IS_READ(i)        (arts[i].unread == ART_READ)
  825. X#define IS_KILLED(i)        (arts[i].killed == 1)
  826. X
  827. X#define KILL_CHAR    'K'
  828. X#define HOT_CHAR    'H'
  829. X
  830. X#define K_KILL        0
  831. X#define K_HOT        1
  832. X
  833. Xint kill_level = 1;
  834. Xint kill_num = 0;
  835. Xint max_kill;
  836. Xstruct kill_t *killf;
  837. X
  838. X/*
  839. X *  read_kill_file - read ~/.tin/kill file contents into kill array
  840. X */
  841. X
  842. Xint read_kill_file ()
  843. X{
  844. X    char buf[LEN];
  845. X    FILE *fp;
  846. X    int n;
  847. X    char c;
  848. X    unsigned int type;
  849. X
  850. X    free_kill_array ();
  851. X    
  852. X    set_real_uid_gid ();
  853. X
  854. X    if ((fp = fopen (killfile, "r")) == NULL) {
  855. X        set_tin_uid_gid ();
  856. X        return FALSE;
  857. X    }
  858. X
  859. X    kill_num=0;
  860. X    while (fgets (buf, sizeof buf, fp) != NULL) {
  861. X        if (buf[0] == '#') {
  862. X            continue;
  863. X        }    
  864. X        if (kill_num == max_kill-1) {
  865. X            expand_kill ();
  866. X        }
  867. X        n = sscanf(buf, "%d %c", &type, &c);
  868. X        if (n == 0) {
  869. X            goto corrupt_killfile;
  870. X        }    
  871. X        if (n > 1 && c == HOT_CHAR) {    /* hot */
  872. X             killf[kill_num].kill_how = K_HOT;
  873. X        } else {
  874. X             killf[kill_num].kill_how = K_KILL;
  875. X        }     
  876. X        killf[kill_num].kill_type = type;
  877. X
  878. X        if (fgets (buf, sizeof buf, fp) == NULL)  {
  879. X            goto corrupt_killfile;
  880. X        }
  881. X        
  882. X        killf[kill_num].kill_group = (long) atol (buf);
  883. X
  884. X        switch (killf[kill_num].kill_type) {
  885. X        case KILL_SUBJ:
  886. X            if (fgets (buf, sizeof buf, fp) != NULL) {
  887. X                buf[strlen (buf)-1] = '\0';
  888. X                killf[kill_num].kill_subj = str_dup (buf);
  889. X            }
  890. X            break;
  891. X        case KILL_FROM:
  892. X            if (fgets (buf, sizeof buf, fp) != NULL) {
  893. X                buf[strlen (buf)-1] = '\0';
  894. X                killf[kill_num].kill_from = str_dup (buf);
  895. X            }
  896. X            break;
  897. X        case KILL_BOTH:
  898. X            if (fgets (buf, sizeof buf, fp) != NULL) {
  899. X                buf[strlen (buf)-1] = '\0';
  900. X                killf[kill_num].kill_subj = str_dup (buf);
  901. X            }
  902. X            if (fgets (buf, sizeof buf, fp) != NULL) {
  903. X                buf[strlen (buf)-1] = '\0';
  904. X                killf[kill_num].kill_from = str_dup (buf);
  905. X            }
  906. X            break;
  907. X        default:
  908. X            goto corrupt_killfile;
  909. X        }
  910. X        kill_num++;
  911. X    }
  912. X
  913. X    fclose (fp);
  914. X    set_tin_uid_gid ();
  915. X    return (kill_num);
  916. X
  917. Xcorrupt_killfile:
  918. X    fclose (fp);
  919. X    killf[kill_num].kill_type = 0;
  920. X    error_message (txt_corrupt_kill_file, killfile);
  921. X    set_tin_uid_gid ();
  922. X    return FALSE;
  923. X}
  924. X
  925. X/*
  926. X *  write_kill_file - write kill strings to ~/.tin/kill
  927. X */
  928. X
  929. Xvoid write_kill_file ()
  930. X{
  931. X    FILE *fp;
  932. X    int i;
  933. X    
  934. X    set_real_uid_gid ();
  935. X
  936. X    if (kill_num == 0 || (fp = fopen (killfile, "w")) == NULL) {
  937. X        set_tin_uid_gid ();
  938. X        return;
  939. X    }
  940. X
  941. X    wait_message (txt_saving);
  942. X    fprintf (fp, "# 1st line  1=(Subject: only)  2=(From: only)  3=(Subject: & From:)\n");
  943. X    fprintf (fp, "#           %c=(kill) %c=(auto-selection)\n", KILL_CHAR, HOT_CHAR);
  944. X    fprintf (fp, "# 2nd line  0=(kill on all newsgroups)  >0=(kill on specific newsgroup)\n");
  945. X    for (i=0 ; i < kill_num ; i++) {
  946. X        if (killf[i].kill_type == 0 || (killf[i].kill_subj == 0 
  947. X            &&  killf[i].kill_from == 0)) 
  948. X            continue;
  949. X
  950. X        if (killf[i].kill_how == K_KILL) {
  951. X            fprintf (fp, "#\n# %03d KILL\n", i+1);
  952. X            fprintf (fp, "%d\t%c\n", killf[i].kill_type, KILL_CHAR);
  953. X        } else {
  954. X            fprintf (fp, "#\n# %03d HOT\n", i+1);
  955. X            fprintf (fp, "%d\t%c\n", killf[i].kill_type, HOT_CHAR);
  956. X        }    
  957. X        fprintf (fp, "%ld\n", killf[i].kill_group);
  958. X
  959. X        switch (killf[i].kill_type) {
  960. X            case KILL_SUBJ:
  961. X                fprintf (fp, "%s\n", killf[i].kill_subj);
  962. X                break;
  963. X            case KILL_FROM:
  964. X                fprintf (fp, "%s\n", killf[i].kill_from);
  965. X                break;
  966. X            case KILL_BOTH:
  967. X                fprintf (fp, "%s\n", killf[i].kill_subj);
  968. X                fprintf (fp, "%s\n", killf[i].kill_from);
  969. X                break;
  970. X        }
  971. X    }
  972. X
  973. X    fclose (fp);
  974. X    chmod (killfile, 0600);
  975. X
  976. X    set_tin_uid_gid ();
  977. X}
  978. X
  979. Xstatic int get_choice (x, help, prompt, opt1, opt2, opt3, opt4)
  980. X    int x;
  981. X    char *help, *prompt, *opt1, *opt2, *opt3, *opt4;
  982. X{
  983. X    int ch, n = 0, i = 0;
  984. X    char *argv[4];
  985. X    
  986. X    if (opt1)
  987. X        argv[n++] = opt1;
  988. X    if (opt2)
  989. X        argv[n++] = opt2;
  990. X    if (opt3)
  991. X        argv[n++] = opt3;
  992. X    if (opt4)
  993. X        argv[n++] = opt4;
  994. X    assert(n > 0);
  995. X
  996. X    if (help)
  997. X        show_menu_help (help);
  998. X        
  999. X    do {
  1000. X        MoveCursor(x, (int) strlen (prompt));
  1001. X        fputs (argv[i], stdout);
  1002. X        fflush (stdout);
  1003. X        CleartoEOLN (); 
  1004. X        if ((ch = ReadCh ()) != ' ')
  1005. X            continue;
  1006. X        if (++i == n)
  1007. X            i = 0;
  1008. X    } while (ch != CR && ch != ESC);
  1009. X
  1010. X    if (ch == ESC)
  1011. X        return (-1);
  1012. X    return (i);
  1013. X}
  1014. X
  1015. X/*
  1016. X *  options menu so that the user can dynamically change parameters
  1017. X */
  1018. Xint kill_art_menu (group_name, index)
  1019. X    char *group_name;
  1020. X    int index;
  1021. X{
  1022. X    char buf[LEN];
  1023. X    char text[LEN];
  1024. X    char kill_from[LEN];
  1025. X    char kill_subj[LEN];
  1026. X    char kill_group[LEN];
  1027. X    char ch_default = 's';
  1028. X    int ch;
  1029. X    int counter = 0;
  1030. X    int killed = TRUE;
  1031. X    int kill_from_ok = FALSE;
  1032. X    int kill_subj_ok = FALSE;
  1033. X    int kill_every_group = FALSE;
  1034. X    int i;
  1035. X    int kill_how;
  1036. X
  1037. X#ifdef SIGTSTP
  1038. X    sigtype_t (*susp)() = (sigtype_t *) 0;
  1039. X
  1040. X    if (do_sigtstp) {
  1041. X        susp = sigdisp (SIGTSTP, SIG_DFL);
  1042. X        sigdisp (SIGTSTP, SIG_IGN);
  1043. X    }
  1044. X#endif
  1045. X    
  1046. X    sprintf (kill_group, "%s only", group_name);
  1047. X    sprintf (kill_subj, txt_kill_subject, COLS-35, COLS-35, arts[index].subject);
  1048. X    if (arts[index].name != (char *) 0) {
  1049. X        sprintf (text, "%s (%s)", arts[index].from, arts[index].name);
  1050. X    } else {
  1051. X        strcpy (text, arts[index].from);
  1052. X    }
  1053. X    sprintf (kill_from, txt_kill_from, COLS-35, COLS-35, text);
  1054. X    text[0] = '\0';
  1055. X    
  1056. X    ClearScreen ();
  1057. X
  1058. X    center_line (0, TRUE, txt_kill_menu);
  1059. X    
  1060. X    MoveCursor (INDEX_TOP, 0);
  1061. X    printf ("%s\r\n\r\n\r\n", txt_kill_how);
  1062. X    printf ("%s\r\n\r\n", txt_kill_text);
  1063. X    printf ("%s\r\n\r\n\r\n", txt_kill_text_type);
  1064. X    printf ("%s\r\n\r\n", kill_subj);
  1065. X    printf ("%s\r\n\r\n\r\n", kill_from);
  1066. X    printf ("%s%s", txt_kill_group, kill_group);
  1067. X    fflush (stdout);
  1068. X
  1069. X    i = get_choice (INDEX_TOP, txt_help_kill_how, txt_kill_how, 
  1070. X               "Kill       ", "Auto Select", NULL, NULL);
  1071. X    if (i == -1) {
  1072. X        return FALSE;
  1073. X    }    
  1074. X    kill_how = (i == 0 ? K_KILL : K_HOT);
  1075. X
  1076. X    show_menu_help (txt_help_kill_text);
  1077. X    
  1078. X    if (! prompt_menu_string (INDEX_TOP+3, (int) strlen (txt_kill_text), text)) {
  1079. X        return FALSE;
  1080. X    }
  1081. X
  1082. X    if (text[0]) {
  1083. X        i = get_choice(INDEX_TOP+5, txt_help_kill_text_type, 
  1084. X                   txt_kill_text_type, "Subject: line only    ", 
  1085. X                   "From: line only       ", "Subject: & From: lines", 
  1086. X                   NULL);
  1087. X        if (i == -1) {
  1088. X            return FALSE;
  1089. X        }    
  1090. X        counter = ((i == 0 ? KILL_SUBJ : (i == 1 ? KILL_FROM : KILL_BOTH)));
  1091. X    }
  1092. X
  1093. X    if (! text[0]) {
  1094. X        i = get_choice (INDEX_TOP+8, txt_help_kill_subject, 
  1095. X                    kill_subj, "Yes", "No ", NULL, NULL);
  1096. X        if (i == -1) {
  1097. X            return FALSE;
  1098. X        } else {
  1099. X            kill_subj_ok = (i ? FALSE : TRUE);
  1100. X        }
  1101. X        i = get_choice (INDEX_TOP+10, txt_help_kill_from, 
  1102. X                    kill_from, "No ", "Yes", NULL, NULL);
  1103. X        if (i == -1) {
  1104. X            return FALSE;
  1105. X        } else {
  1106. X            kill_from_ok = (i ? TRUE : FALSE);
  1107. X        }
  1108. X    }
  1109. X
  1110. X    if (text[0] || kill_subj_ok || kill_from_ok) {
  1111. X        i = get_choice (INDEX_TOP+13, txt_help_kill_group, 
  1112. X                   txt_kill_group, kill_group, "All groups", 
  1113. X                   NULL, NULL);
  1114. X        if (i == -1) {
  1115. X            return FALSE;
  1116. X        }    
  1117. X        kill_every_group = (i == 0 ? FALSE : TRUE);
  1118. X    }
  1119. X
  1120. X    while (1) {
  1121. X        do {
  1122. X            sprintf (msg, "%s%c", txt_quit_edit_save_killfile, ch_default);
  1123. X            wait_message (msg);
  1124. X            MoveCursor (LINES, (int) strlen (txt_quit_edit_save_killfile));
  1125. X            if ((ch = ReadCh ()) == CR)
  1126. X                ch = ch_default;
  1127. X        } while (ch != ESC && ch != 'q' && ch != 'e' && ch != 's');
  1128. X        switch (ch) {
  1129. X        case 'e':
  1130. X            start_line_offset = 2;
  1131. X            invoke_editor (killfile);
  1132. X            unkill_all_articles ();
  1133. X            killed_articles = read_kill_file ();
  1134. X            killed = TRUE;
  1135. X            goto kill_done;
  1136. X
  1137. X        case 'a':
  1138. X        case ESC:
  1139. X            killed = FALSE;
  1140. X            goto kill_done;
  1141. X            
  1142. X        case 's':
  1143. X            if (kill_num > max_kill-1) {
  1144. X                expand_kill ();
  1145. X            }
  1146. X
  1147. X            killf[kill_num].kill_how = kill_how;
  1148. X
  1149. X            if (text[0]) {
  1150. X                sprintf (buf, "%s%s%s", stars, text, stars);
  1151. X                switch (counter) {
  1152. X                case KILL_SUBJ:
  1153. X                    killf[kill_num].kill_subj = str_dup (buf);
  1154. X                    break;
  1155. X                case KILL_FROM:
  1156. X                    killf[kill_num].kill_from = str_dup (buf);
  1157. X                    break;
  1158. X                case KILL_BOTH:
  1159. X                    killf[kill_num].kill_subj = str_dup (buf);
  1160. X                    killf[kill_num].kill_from = killf[kill_num].kill_subj; 
  1161. X                    break;
  1162. X                }
  1163. X                killf[kill_num].kill_type = counter;
  1164. X                if (kill_every_group) {
  1165. X                    killf[kill_num].kill_group = 0L;
  1166. X                } else {
  1167. X                    killf[kill_num].kill_group = hash_s (group_name);
  1168. X                }
  1169. X                kill_num++;
  1170. X            } else {
  1171. X                if (kill_subj_ok) {
  1172. X                    killf[kill_num].kill_type = KILL_SUBJ;
  1173. X                    sprintf (buf, "%s%s%s", 
  1174. X                        stars, arts[index].subject, stars);
  1175. X                    killf[kill_num].kill_subj = str_dup (buf);
  1176. X                }
  1177. X                if (kill_from_ok) {
  1178. X                    killf[kill_num].kill_type |= KILL_FROM;
  1179. X                    if (arts[index].name != (char *) 0) {
  1180. X                        sprintf (buf, "%s%s (%s)%s", 
  1181. X                            stars, arts[index].from, arts[index].name, stars);
  1182. X                    } else {
  1183. X                        sprintf (buf, "%s%s%s", 
  1184. X                            stars, arts[index].from, stars);
  1185. X                    }
  1186. X                    killf[kill_num].kill_from = str_dup (buf);
  1187. X                }
  1188. X                if (killf[kill_num].kill_type) {        
  1189. X                    if (kill_every_group) {
  1190. X                        killf[kill_num].kill_group= 0L;
  1191. X                    } else {
  1192. X                        killf[kill_num].kill_group= hash_s (group_name);
  1193. X                    }
  1194. X                    kill_num++;
  1195. X                }
  1196. X            }
  1197. X            write_kill_file ();
  1198. X            
  1199. X        kill_done:
  1200. X            
  1201. X#ifdef SIGTSTP
  1202. X            if (do_sigtstp) {
  1203. X                sigdisp (SIGTSTP, susp);
  1204. X            }
  1205. X#endif
  1206. X            return (killed);
  1207. X        }    
  1208. X    }
  1209. X    /* NOTREACHED */
  1210. X}
  1211. X
  1212. X
  1213. X/*
  1214. X * We assume that any articles which are tagged as killed are also
  1215. X * tagged as being read BECAUSE they were killed. So, we retag
  1216. X * them as being unread.
  1217. X */
  1218. Xint unkill_all_articles ()
  1219. X{
  1220. X    int unkilled = FALSE;
  1221. X    register int i;
  1222. X
  1223. X    for (i=0 ; i < top ; i++) {
  1224. X        if (arts[i].killed) {
  1225. X            arts[i].killed = FALSE;
  1226. X            arts[i].unread = ART_UNREAD;
  1227. X            unkilled = TRUE;
  1228. X        }
  1229. X    }
  1230. X    num_of_killed_arts = 0;
  1231. X
  1232. X    return (unkilled);
  1233. X}
  1234. X
  1235. X
  1236. Xint kill_any_articles (group)
  1237. X    char *group;
  1238. X{
  1239. X    char buf[LEN];
  1240. X    int killed = FALSE;
  1241. X    int run_ok = FALSE;
  1242. X    int is_hot;
  1243. X    long newsgroup_hash;
  1244. X    register int i, j;
  1245. X
  1246. X    if (! kill_num) {
  1247. X        return (killed);
  1248. X    }
  1249. X
  1250. X    num_of_killed_arts = 0;
  1251. X    num_of_hot_arts = 0;
  1252. X
  1253. X    newsgroup_hash = hash_s (group);
  1254. X
  1255. X    for (i=0 ; i < kill_num ; i++) {
  1256. X        if (killf[i].kill_group == 0L ||
  1257. X            killf[i].kill_group == newsgroup_hash) {
  1258. X            run_ok = TRUE;    
  1259. X        }
  1260. X    }
  1261. X    if (! run_ok) {
  1262. X        return (killed);
  1263. X    }
  1264. X    if (debug && ! update) {
  1265. X        wait_message (txt_killing_arts);
  1266. X    }
  1267. X    for (i=0 ; i < top ; i++) {
  1268. X        if (IS_READ(i) && kill_level == 0) {
  1269. X            continue;
  1270. X        }    
  1271. X        for (j=0 ; j < kill_num ; j++) {
  1272. X            if (killf[j].kill_group != 0L &&
  1273. X                killf[j].kill_group != newsgroup_hash)
  1274. X                continue;
  1275. X
  1276. X            is_hot = (killf[j].kill_how == K_HOT ? TRUE : FALSE);
  1277. X            switch (killf[j].kill_type) {
  1278. X            case KILL_SUBJ:
  1279. X                if (STR_MATCH (arts[i].subject, killf[j].kill_subj)) {
  1280. X                    if (!is_hot)
  1281. X                        SET_KILLED(i);
  1282. X                    else
  1283. X                        SET_HOT(i);
  1284. X                }
  1285. X                break;
  1286. X            case KILL_FROM:
  1287. X                if (arts[i].name != (char *) 0) {
  1288. X                    sprintf (buf, "%s (%s)", arts[i].from, arts[i].name);
  1289. X                } else {
  1290. X                    strcpy (buf, arts[i].from);
  1291. X                }
  1292. X                if (STR_MATCH (buf, killf[j].kill_from)) {
  1293. X                    if (!is_hot)
  1294. X                        SET_KILLED(i);
  1295. X                    else
  1296. X                        SET_HOT(i);
  1297. X                }
  1298. X                break;
  1299. X            case KILL_BOTH:
  1300. X                if (STR_MATCH (arts[i].subject, killf[j].kill_subj)) {
  1301. X                    if (!is_hot)
  1302. X                        SET_KILLED(i);
  1303. X                    else
  1304. X                        SET_HOT(i);
  1305. X                    break;        /* XXX ? - JBR */
  1306. X                }
  1307. X                if (arts[i].name != (char *) 0) {
  1308. X                    sprintf (buf, "%s (%s)", arts[i].from, arts[i].name);
  1309. X                } else {
  1310. X                    strcpy (buf, arts[i].from);
  1311. X                }
  1312. X
  1313. X                if (STR_MATCH (buf, killf[j].kill_from)) {
  1314. X                    if (!is_hot)
  1315. X                        SET_KILLED(i);
  1316. X                    else
  1317. X                        SET_HOT(i);
  1318. X                }
  1319. X                break;
  1320. X            }
  1321. X            if (IS_KILLED(i) || ! killed)
  1322. X                killed = TRUE;
  1323. X        }
  1324. X    }
  1325. X    return (killed);
  1326. X}
  1327. END_OF_FILE
  1328.   if test 11832 -ne `wc -c <'kill.c'`; then
  1329.     echo shar: \"'kill.c'\" unpacked with wrong size!
  1330.   fi
  1331.   # end of 'kill.c'
  1332. fi
  1333. if test -f 'main.c' -a "${1}" != "-c" ; then 
  1334.   echo shar: Will not clobber existing file \"'main.c'\"
  1335. else
  1336.   echo shar: Extracting \"'main.c'\" \(12398 characters\)
  1337.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  1338. X/*
  1339. X *  Project   : tin - a threaded Netnews reader
  1340. X *  Module    : main.c
  1341. X *  Author    : I.Lea & R.Skrenta
  1342. X *  Created   : 01-04-91
  1343. X *  Updated   : 15-05-92
  1344. X *  Notes     :
  1345. X *  Copyright : (c) Copyright 1991-92 by Iain Lea & Rich Skrenta
  1346. X *              You may  freely  copy or  redistribute  this software,
  1347. X *              so  long as there is no profit made from its use, sale
  1348. X *              trade or  reproduction.  You may not change this copy-
  1349. X *              right notice, and it must be included in any copy made
  1350. X */
  1351. X
  1352. X#include    "tin.h"
  1353. X
  1354. X/*
  1355. X * OK lets start the ball rolling...
  1356. X */
  1357. Xvoid main (argc, argv)
  1358. X    int argc;    
  1359. X    char *argv[];
  1360. X{
  1361. X    int created, i;
  1362. X    int start_groupnum = 0;
  1363. X
  1364. X    cmd_line = TRUE;
  1365. X    debug = 0;    /* debug OFF */
  1366. X
  1367. X    set_signal_handlers ();
  1368. X
  1369. X    basename (argv[0], progname);
  1370. X
  1371. X    sprintf (page_header, "%s %s PL%d", progname, VERSION, PATCHLEVEL);     
  1372. X    sprintf (cvers, "%s (c) Copyright 1991-92 Iain Lea.", page_header);
  1373. X
  1374. X#if defined(NNTP_ONLY) || defined(CDROM_ONLY)
  1375. X    read_news_via_nntp = TRUE;
  1376. X#else
  1377. X    /* 
  1378. X     * rtin/cdtin so read news remotely via NNTP 
  1379. X     */
  1380. X    if (progname[0] == 'r' || (progname[0] == 'c' && progname[1] == 'd' )) {
  1381. X#        ifdef NNTP_ABLE            
  1382. X            read_news_via_nntp = TRUE;
  1383. X#        else
  1384. X            error_message (txt_option_not_enabled, "-DNNTP_ABLE");
  1385. X            exit (1);
  1386. X#        endif
  1387. X    }
  1388. X#endif
  1389. X
  1390. X    /*
  1391. X     * set up char *'s: homedir, newsrc, etc. 
  1392. X     */
  1393. X    init_selfinfo ();
  1394. X
  1395. X    /*
  1396. X     * process command line options
  1397. X     */
  1398. X    read_cmd_line_options (argc, argv);
  1399. X    if (update_fork || (update && verbose) || !update) {
  1400. X        error_message (cvers, "");
  1401. X    }
  1402. X
  1403. X    /*
  1404. X     *  if specified connect to (cdrom pseudo) nntp server
  1405. X     */
  1406. X    nntp_open ();
  1407. X
  1408. X    /*
  1409. X     *  allocate initial array sizes
  1410. X     */
  1411. X    init_alloc ();
  1412. X    hash_init ();
  1413. X
  1414. X    /*
  1415. X     *  load the active file into active[]
  1416. X     */
  1417. X    created = read_active_file ();
  1418. X
  1419. X    /*
  1420. X     *  log username info to local/central logfile (NNTP XUSER)
  1421. X     */
  1422. X    log_user ();
  1423. X
  1424. X    if (create_mail_save_dirs ()) {
  1425. X        write_rcfile ();
  1426. X    }    
  1427. X
  1428. X    if (optind < argc) {
  1429. X        while (optind < argc) {
  1430. X            for (i = 0 ; i < num_active ; i++) {
  1431. X                if (wildmat(active[i].name, argv[optind])) {        
  1432. X                    if (add_group (active[i].name, TRUE) < 0) {
  1433. X                        error_message (txt_not_in_active_file, active[i].name);
  1434. X                    }
  1435. X                }    
  1436. X            }    
  1437. X            optind++;
  1438. X        }
  1439. X    } else {
  1440. X        backup_newsrc ();
  1441. X        read_newsrc (TRUE);
  1442. X        mark_unthreaded_groups ();
  1443. X    }
  1444. X
  1445. X    /*
  1446. X     *  read in users kill/auto-select (hot) file
  1447. X     */
  1448. X    killed_articles = read_kill_file ();
  1449. X    
  1450. X    /*
  1451. X     *  check/start if any new/unread articles
  1452. X     */
  1453. X    start_groupnum = check_for_any_new_news (check_any_unread, start_any_unread);
  1454. X
  1455. X    /*
  1456. X     *  mail any new articles to specified user
  1457. X     *  or
  1458. X     *  save any new articles to savedir structure for later reading
  1459. X     */
  1460. X    save_or_mail_new_news ();
  1461. X    
  1462. X    /*
  1463. X     *  update index files
  1464. X     */
  1465. X    update_index_files ();
  1466. X    
  1467. X    if (! InitScreen ()) {
  1468. X        error_message (txt_screen_init_failed, progname);
  1469. X        exit (1);
  1470. X    }
  1471. X
  1472. X    /*
  1473. X     *   get screen size from termcap entry 
  1474. X     */
  1475. X    ScreenSize (&LINES, &COLS);
  1476. X    cmd_line = FALSE;
  1477. X    Raw (TRUE);
  1478. X
  1479. X    /* 
  1480. X     *  check & set actual screen size
  1481. X     */
  1482. X    set_win_size (&LINES, &COLS);
  1483. X
  1484. X    /*
  1485. X     *  check for any newly created newsgroups
  1486. X     */
  1487. X    if (notify_new_groups && ! created) {
  1488. X        notify_groups ();
  1489. X    }
  1490. X
  1491. X    /*
  1492. X     *  if first time print welcome screen
  1493. X      and auto-subscribe
  1494. X     *  to groups specified in /usr/lib/news/subscribe locally
  1495. X     *  or via NNTP if reading news remotely (LIST SUBSCRIBE)
  1496. X     */
  1497. X    if (created_rcdir && update == FALSE) {
  1498. X        show_intro_page ();
  1499. X    }
  1500. X    
  1501. X    selection_index (start_groupnum);
  1502. X
  1503. X    tin_done (0);
  1504. X}
  1505. X
  1506. X/*
  1507. X * process command line options
  1508. X */
  1509. X
  1510. Xvoid read_cmd_line_options (argc, argv)
  1511. X    int argc;
  1512. X    char *argv[];
  1513. X{
  1514. X    int ch;
  1515. X
  1516. X#ifdef INDEX_DAEMON
  1517. X    while ((ch = getopt (argc, argv, "D:f:hI:vV")) != EOF) {
  1518. X#else
  1519. X    while ((ch = getopt (argc, argv, "cD:f:hHI:m:M:np:rRs:SuUvVzZ")) != EOF) {
  1520. X#endif
  1521. X        switch (ch) {
  1522. X            case 'c':
  1523. X                catchup = TRUE;
  1524. X                update = TRUE;
  1525. X                break;
  1526. X                
  1527. X            case 'D':        /* debug mode 1=NNTP 2=ALL */
  1528. X#ifdef DEBUG            
  1529. X                redirect_output[0] = '\0';
  1530. X                debug = atoi (optarg);
  1531. X#else
  1532. X                error_message (txt_option_not_enabled, "-DDEBUG");
  1533. X                exit (1);
  1534. X#endif
  1535. X                break;
  1536. X
  1537. X            case 'f':
  1538. X                my_strncpy (newsrc, optarg, sizeof (newsrc));
  1539. X                break;
  1540. X
  1541. X            case 'H':
  1542. X                show_intro_page ();
  1543. X                exit (1);
  1544. X                break;
  1545. X
  1546. X#if !defined(NNTP_ONLY) || !defined(NNTP_XINDEX)
  1547. X            case 'I':
  1548. X                my_strncpy (indexdir, optarg, sizeof (indexdir));
  1549. X                mkdir (indexdir, 0777);
  1550. X                break;
  1551. X#endif
  1552. X            case 'm':
  1553. X                my_strncpy (default_maildir, optarg, sizeof (default_maildir));
  1554. X                break;
  1555. X
  1556. X            case 'M':    /* mail new news to specified user */
  1557. X                my_strncpy (mail_news_user, optarg, sizeof (mail_news_user));
  1558. X                mail_news = TRUE;
  1559. X                update = TRUE;
  1560. X                catchup = TRUE;
  1561. X                break;
  1562. X
  1563. X            case 'n':
  1564. X                notify_new_groups = TRUE;
  1565. X                break;
  1566. X
  1567. X            case 'p':
  1568. X                my_strncpy (cmd_line_printer, optarg, sizeof (cmd_line_printer));
  1569. X                default_printer = FALSE;
  1570. X                break;
  1571. X
  1572. X            case 'r':    /* read news remotely from default NNTP server */
  1573. X#ifdef NNTP_ABLE            
  1574. X                read_news_via_nntp = TRUE;
  1575. X#else
  1576. X                error_message (txt_option_not_enabled, "-DNNTP_ABLE");
  1577. X                exit (1);
  1578. X#endif
  1579. X                break;
  1580. X
  1581. X            case 'R':    /* read news saved by -S option */
  1582. X                error_message ("%s: Option -R not yet implemented.", progname);
  1583. X                exit (1);
  1584. X                break;
  1585. X
  1586. X            case 's':
  1587. X                my_strncpy (default_savedir, optarg, sizeof (default_savedir));
  1588. X                break;
  1589. X
  1590. X            case 'S':    /* save new news to dir structure */
  1591. X                save_news = TRUE;
  1592. X                update = TRUE;
  1593. X                break;
  1594. X
  1595. X            case 'u':    /* update index files */
  1596. X                update = TRUE;
  1597. X                break;
  1598. X
  1599. X            case 'U':    /* update index files in background */
  1600. X                update_fork = TRUE;
  1601. X                update = TRUE;
  1602. X                break;
  1603. X
  1604. X            case 'v':    /* verbose mode */
  1605. X                verbose = TRUE;
  1606. X                break;
  1607. X
  1608. X            case 'V':
  1609. X#if defined(__DATE__) && defined(__TIME__)            
  1610. X                sprintf (msg, "Version: %s PL%d  %s %s",
  1611. X                    VERSION, PATCHLEVEL, __DATE__, __TIME__);
  1612. X#else
  1613. X                sprintf (msg, "Version: %s PL%d",
  1614. X                    VERSION, PATCHLEVEL);
  1615. X#endif                    
  1616. X                error_message (msg, "");
  1617. X                exit (1);
  1618. X                break;
  1619. X
  1620. X            case 'z':
  1621. X                start_any_unread = TRUE;
  1622. X                update = TRUE;
  1623. X                break;
  1624. X
  1625. X            case 'Z':
  1626. X                check_any_unread = TRUE;
  1627. X                update = TRUE;
  1628. X                break;
  1629. X
  1630. X            case 'h':
  1631. X            case '?':
  1632. X            default:
  1633. X                usage (progname);
  1634. X                exit (1);
  1635. X        }
  1636. X    }
  1637. X}
  1638. X
  1639. X/*
  1640. X * usage
  1641. X */
  1642. X
  1643. Xvoid usage (progname)
  1644. X    char *progname;
  1645. X{
  1646. X#ifndef INDEX_DAEMON
  1647. X    error_message ("%s A threaded Netnews reader.\n", cvers);
  1648. X#else
  1649. X    error_message ("%s Tin index file daemon.\n", cvers);
  1650. X#endif
  1651. X    error_message ("Usage: %s [options] [newsgroups]", progname);
  1652. X#ifndef INDEX_DAEMON
  1653. X    error_message ("  -c       mark all news as read in subscribed newsgroups (batch mode)", "");
  1654. X#endif
  1655. X    error_message ("  -f file  subscribed to newsgroups file [default=%s]", newsrc);
  1656. X    error_message ("  -h       help", "");
  1657. X#ifndef INDEX_DAEMON
  1658. X    error_message ("  -H       help information about %s", progname);
  1659. X#endif
  1660. X    error_message ("  -I dir   index file directory [default=%s]", indexdir);
  1661. X#ifndef INDEX_DAEMON
  1662. X    error_message ("  -m dir   mailbox directory [default=%s]", default_maildir);
  1663. X    error_message ("  -M user  mail new news to specified user (batch mode)", "");
  1664. X    error_message ("  -n       notify user of any newly created newsgroups", "");
  1665. X    error_message ("  -p file  print program with options [default=%s]", DEFAULT_PRINTER);
  1666. X#  if defined(NNTP_ABLE) && !defined(NNTP_ONLY)
  1667. X    if (! read_news_via_nntp) {
  1668. X        error_message ("  -r       read news remotely from default NNTP server", "");
  1669. X    }
  1670. X#  endif /* NNTP_ABLE */    
  1671. X    error_message ("  -R       read news saved by -S option (not yet implemented)", "");
  1672. X    error_message ("  -s dir   save news directory [default=%s]", default_savedir);
  1673. X    error_message ("  -S       save new news for later reading (batch mode)", "");
  1674. X#  if !defined(NNTP_ONLY) || !defined(NNTP_XINDEX)
  1675. X    error_message ("  -u       update index files (batch mode)", "");
  1676. X    error_message ("  -U       update index files in the background while reading news", "");
  1677. X#  endif /* NNTP_XINDEX */
  1678. X#endif /* INDEX_DAEMON */
  1679. X    error_message ("  -v       verbose output for batch mode options", "");
  1680. X#ifndef INDEX_DAEMON
  1681. X    error_message ("  -z       start if any unread news", "");
  1682. X    error_message ("  -Z       return status indicating if any unread news (batch mode)", "");
  1683. X#endif
  1684. X    error_message ("\nMail bug reports/comments to %s", BUG_REPORT_ADDRESS);
  1685. X}
  1686. X
  1687. X/*
  1688. X *  check/start if any new/unread articles
  1689. X */
  1690. X
  1691. Xint check_for_any_new_news (check_any_unread, start_any_unread)
  1692. X    int check_any_unread;
  1693. X    int start_any_unread;
  1694. X{
  1695. X    int i = 0;
  1696. X    
  1697. X    if (check_any_unread) {
  1698. X        i = check_start_save_any_news (CHECK_ANY_NEWS);
  1699. X        exit (i);
  1700. X    }
  1701. X    
  1702. X    if (start_any_unread) {
  1703. X        i = check_start_save_any_news (START_ANY_NEWS);
  1704. X        if (i == -1) {        /* no new/unread news so exit */
  1705. X            exit (0);
  1706. X        }
  1707. X        update = FALSE;
  1708. X    }
  1709. X    return (i);
  1710. X}
  1711. X
  1712. X/*
  1713. X *  mail any new articles to specified user
  1714. X *  or
  1715. X *  save any new articles to savedir structure for later reading
  1716. X */
  1717. X
  1718. Xvoid save_or_mail_new_news ()
  1719. X{
  1720. X    int i;
  1721. X    
  1722. X    if (mail_news || save_news) {
  1723. X        i = catchup;            /* set catchup to FALSE */
  1724. X        catchup = FALSE;
  1725. X        do_update ();
  1726. X        catchup = i;            /* set catchup to previous value */
  1727. X        if (mail_news) {
  1728. X            check_start_save_any_news (MAIL_ANY_NEWS);
  1729. X        } else {
  1730. X            check_start_save_any_news (SAVE_ANY_NEWS);
  1731. X        }
  1732. X        tin_done (0);
  1733. X    }
  1734. X}
  1735. X
  1736. X/*
  1737. X *  update index files
  1738. X */
  1739. X
  1740. Xvoid update_index_files ()
  1741. X{
  1742. X    if (update || update_fork) {
  1743. X        if (read_news_via_nntp && xindex_supported) {
  1744. X            error_message ("%s: Updating of index files not supported", progname);
  1745. X            tin_done (1);
  1746. X        }
  1747. X
  1748. X        COLS = 132;                    /* set because curses has not started */ 
  1749. X        if (update_fork) {
  1750. X            catchup = FALSE;        /* turn off msgs when running forked */ 
  1751. X            verbose = FALSE;
  1752. X            switch (fork ()) {        /* fork child to update indexes in background */
  1753. X                case -1:    /* error forking */    
  1754. X                    perror_message ("Failed to start background indexing process", "");
  1755. X                    break;
  1756. X                case 0:        /* child process */    
  1757. X                    process_id = getpid ();
  1758. X#ifdef BSD
  1759. X                    setpgrp (0, process_id);    /* reset process group leader to this process */
  1760. X#    ifdef TIOCNOTTY
  1761. X                    {
  1762. X                        int fd;
  1763. X    
  1764. X                        if ((fd = open ("/dev/tty", O_RDWR)) >= 0) {
  1765. X                            ioctl (fd, TIOCNOTTY, (char *) NULL);
  1766. X                            close (fd);
  1767. X                        }    
  1768. X                    }    
  1769. X#    endif
  1770. X#else
  1771. X                    setpgrp ();
  1772. X                    signal (SIGHUP, SIG_IGN);    /* make immune from process group leader death */
  1773. X#endif
  1774. X                    signal (SIGQUIT, SIG_IGN);    /* stop indexing being interrupted */            
  1775. X                    signal (SIGALRM, SIG_IGN);    /* stop indexing resyning active file */            
  1776. X                    nntp_open ();            /* connect server if we are using nntp */
  1777. X                    thread_arts = FALSE;    /* stop threading to run faster */
  1778. X                    do_update ();
  1779. X                    nntp_close ();            /* connect server if we are using nntp */
  1780. X                    exit (0);
  1781. X                    break;
  1782. X                default:    /* parent process*/
  1783. X                    break;                    
  1784. X            }    
  1785. X            update = FALSE;
  1786. X        } else {
  1787. X            thread_arts = FALSE;    /* stop threading to run faster */
  1788. X            do_update ();
  1789. X            exit (0);
  1790. X        }
  1791. X    }
  1792. X}
  1793. X
  1794. X/*
  1795. X *  display page of general info. for first time user.
  1796. X */
  1797. X
  1798. Xvoid show_intro_page ()
  1799. X{
  1800. X    if (cmd_line) {
  1801. X        wait_message (cvers);     
  1802. X    } else {
  1803. X        ClearScreen ();
  1804. X        center_line (0, TRUE, cvers); 
  1805. X        Raw (FALSE);    
  1806. X    }
  1807. X
  1808. X    printf ("\n\nWelcome to tin, a full screen threaded Netnews reader. It can read news locally\n");
  1809. X    printf ("(ie. <spool>/news) or remotely (-r option) from a NNTP  (Network News Transport\n");
  1810. X    printf ("Protocol) server. tin -h lists the available command line options.\n\n");
  1811. X
  1812. X    printf ("Tin has four newsreading levels, the newsgroup selection page,  the group index\n");
  1813. X    printf ("page, the thread listing page and the article viewer. Help is available at each\n");
  1814. X    printf ("level by pressing the 'h' command.\n\n");
  1815. X
  1816. X    printf ("Move up/down by using the terminal arrow keys or 'j' and 'k'.  Use PgUp/PgDn or\n");
  1817. X    printf ("Ctrl-U and Ctrl-D to page up/down. Enter a newsgroup by pressing RETURN.\n\n");
  1818. X
  1819. X    printf ("Articles, threads, tagged articles or articles matching a pattern can be mailed\n");
  1820. X    printf ("('m' command), printed ('o' command), saved ('s' command), piped ('|' command).\n");
  1821. X    printf ("Use the 'w' command  to post  a news  article,  the 'f'/'F' commands to  post a\n");
  1822. X    printf ("follow-up  to  an existing  news article and the 'r'/'R' commands to  reply via\n");
  1823. X    printf ("mail to an existing news articles author.  The 'M' command allows the operation\n");
  1824. X    printf ("of tin to be configured via a menu.\n\n");
  1825. X
  1826. X    printf ("For more information read the manual page, README, INSTALL, TODO and FTP files.\n\n");
  1827. X    printf ("Please send bug reports/comments to the programs author with the 'B' command.\n");
  1828. X    fflush (stdout);
  1829. X
  1830. X    if (! cmd_line) {
  1831. X        Raw (TRUE);    
  1832. X        continue_prompt ();
  1833. X    }
  1834. X}
  1835. X
  1836. END_OF_FILE
  1837.   if test 12398 -ne `wc -c <'main.c'`; then
  1838.     echo shar: \"'main.c'\" unpacked with wrong size!
  1839.   fi
  1840.   # end of 'main.c'
  1841. fi
  1842. echo shar: End of archive 12 \(of 14\).
  1843. cp /dev/null ark12isdone
  1844. MISSING=""
  1845. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1846.     if test ! -f ark${I}isdone ; then
  1847.     MISSING="${MISSING} ${I}"
  1848.     fi
  1849. done
  1850. if test "${MISSING}" = "" ; then
  1851.     echo You have unpacked all 14 archives.
  1852.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1853. else
  1854.     echo You still must unpack the following archives:
  1855.     echo "        " ${MISSING}
  1856. fi
  1857. exit 0
  1858. exit 0 # Just in case...
  1859.