home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / cnews2 / part12 < prev    next >
Text File  |  1989-06-29  |  49KB  |  1,973 lines

  1. Subject:  v19i089:  Cnews production release, Part12/19
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: utzoo!henry
  7. Posting-number: Volume 19, Issue 89
  8. Archive-name: cnews2/part12
  9.  
  10. : ---CUT HERE---
  11. echo 'man/rnews.8':
  12. sed 's/^X//' >'man/rnews.8' <<'!'
  13. X.\" =()<.ds a @<NEWSARTS>@>()=
  14. X.ds a /usr/spool/news
  15. X.\" =()<.ds b @<NEWSBIN>@>()=
  16. X.ds b /usr/lib/newsbin
  17. X.\" =()<.ds c @<NEWSCTL>@>()=
  18. X.ds c /usr/lib/news
  19. X.\" =()<.ds m @<NEWSMASTER>@>()=
  20. X.ds m usenet
  21. X.TH RNEWS 8 "22 June 1989" "C News"
  22. X.SH NAME
  23. Xrnews, cunbatch \- accept and spool news input
  24. X.br
  25. Xnewsspool, newsrun, c7decode \- news input spooler and processing
  26. X.br
  27. Xnewsrunning \- control news-processing daemon
  28. X.SH SYNOPSIS
  29. X.B rnews
  30. X[ file ... ]
  31. X.br
  32. X.B cunbatch
  33. X[ file ... ]
  34. X.br
  35. X.B \*b/input/newsspool
  36. X[
  37. X.B \-i
  38. X] [ file ... ]
  39. X.br
  40. X.B \*b/input/newsrun
  41. X.br
  42. X.B \*b/input/c7decode
  43. X.br
  44. X.B \*b/input/newsrunning
  45. X{\fBon\fR|\fBoff\fR}
  46. X.SH DESCRIPTION
  47. X.I Rnews
  48. Xaccepts the named \fIfile\fR(s) (standard input default)
  49. Xas news, and spools it up for processing, space permitting.
  50. X.I Cunbatch
  51. Xis a historical synonym for
  52. X.IR rnews ;
  53. Xthere is no difference in what they do.
  54. X.PP
  55. X.I Newsspool
  56. Xis the actual spooling program.
  57. XIt creates a spool file with a name based on the current time
  58. X(which avoids the need for locking) in the spooling directory
  59. X\fI\*a/in.coming\fR and copies the input \fIfile\fR(s) (standard input
  60. Xdefault) to it, stripping off any `\fB#!\ cunbatch\fR'
  61. Xor `\fB#!\ c7unbatch\fR' header as it does so.
  62. XIf invoked with the
  63. X.B \-i
  64. Xoption, when finished it attempts to start
  65. X.I newsrun
  66. Xto process the new news immediately.
  67. X.PP
  68. X.I Newsrun
  69. Xshould be run periodically (e.g. by \fIcron\fR(8)) to process spooled news.
  70. X.I Newsrunning
  71. Xcan be used to enable and disable \fInewsrun\fR's processing if it is desired
  72. Xto avoid major news processing during certain hours.
  73. X.PP
  74. X.I Newsrun
  75. Xchecks for the \fIstop\fR file that
  76. X\fInewsrunning\ off\fR creates,
  77. Xverifies that there is enough disk space for processing,
  78. Xand then starts processing spooled news.
  79. XEach batch is
  80. Xrun through \fIc7decode\fR (if necessary),
  81. Xde\fIcompress\fRed (if necessary), and then fed
  82. Xto
  83. X\fIrelaynews\fR
  84. X(on the server, if \fI\*c/server\fR exists and contains its name).
  85. XIf \fIrelaynews\fR fails,
  86. X\fInewsrun\fR reports this (by mail to \fB\*m\fR) and attempts to save
  87. Xthe spooled batch in the \fIbad\fR subdirectory for human inspection.
  88. XTo bound the accumulation in \fIbad\fR in the event of some systematic
  89. Xproblem, \fInewsrun\fR limits \fIbad\fR to 50 files;
  90. Xthis default can be changed by placing a \fIlimit\fR file in \fIbad\fR,
  91. Xcontaining one ASCII line with the desired numeric limit.
  92. XA limit of 0 will prevent saving of bad batches.
  93. X.PP
  94. X.I C7decode
  95. Xpasses standard input to standard output, decoding a complex and bizarre
  96. Xencoding of 8-bit data as printable ASCII characters.
  97. X.SH FILES
  98. X.nf
  99. X(All in \fI\*a/in.coming\fR)
  100. X.sp
  101. X.ta 2.5c
  102. X000000000    (etc.) spooled news
  103. Xstop    \fInewsrun\fR disable file
  104. Xbad    directory for failed news
  105. Xbad/limit    limit on number of files in \fIbad\fR
  106. X.SH SEE ALSO
  107. Xcompress(1),
  108. Xnewsbatch(8),
  109. Xnewsmail(8),
  110. Xrelaynews(8)
  111. X.SH DIAGNOSTICS
  112. XComplaints are mailed to \fB\*m\fR if something goes wrong.
  113. X.SH HISTORY
  114. XPart of C News.
  115. XWritten at University of Toronto by Henry Spencer.
  116. X.SH BUGS
  117. X\fIC7decode\fR should be part of the underlying transport mechanism.
  118. XIt hasn't been tested very well in the C News environment.
  119. X\fIBdecode\fR (see \fInewsmail\fR(8)) is probably better for most uses.
  120. !
  121. echo 'man/relaynews.8':
  122. sed 's/^X//' >'man/relaynews.8' <<'!'
  123. X.\" =()<.ds a @<NEWSARTS>@>()=
  124. X.ds a /usr/spool/news
  125. X.\" =()<.ds b @<NEWSBIN>@>()=
  126. X.ds b /usr/lib/newsbin
  127. X.\" =()<.ds c @<NEWSCTL>@>()=
  128. X.ds c /usr/lib/news
  129. X.\" =()<.ds m @<NEWSMASTER>@>()=
  130. X.ds m usenet
  131. X.TH RELAYNEWS 8 "28 May 1989" "C News"
  132. X.SH NAME
  133. Xrelaynews \- store and forward netnews articles
  134. X.SH SYNOPSIS
  135. X.B relaynews
  136. X[
  137. X.B \-inrs
  138. X]
  139. X[
  140. X.B \-d
  141. X.B fhlmt
  142. X]
  143. X[
  144. X.B \-x
  145. Xexcluded-site
  146. X]
  147. X.SH DESCRIPTION
  148. X.I Relaynews
  149. Xinstalls locally
  150. Xand
  151. Xbroadcasts (network) news articles
  152. Xread from its standard input.
  153. XTypically the articles will be in a batch
  154. X(see
  155. X.IR news (5)),
  156. Xwhich may
  157. X.I not
  158. Xbe compressed
  159. X(see
  160. X.IR compress (1)).
  161. XArticles are usually
  162. Xqueued for transmission to one's netnews neighbours via
  163. X.IR newsbatch (8)
  164. Xand thence via
  165. X.IR uux (1)
  166. Xor
  167. X.IR mail (1).
  168. X.PP
  169. X.B \-d
  170. Xturns on debugging of
  171. X.BR f iling,
  172. X.BR h eaders,
  173. X.BR l ocking,
  174. X.BR m atching,
  175. X.BR t ransmission.
  176. X.B \-r
  177. Xredirects stdout and stderr to
  178. X.B \*c/log
  179. Xand
  180. X.BR \*c/errlog .
  181. X.B \-i
  182. Xredirects stdout only to
  183. X.BR \*c/log .
  184. X.B \-n
  185. Xenables ``NNTP mode''
  186. Xin which history entries are generated as articles are rejected.
  187. X.B \-s
  188. Xmakes discarding an article a serious matter.
  189. X.B \-x
  190. Xexcludes
  191. X.I excluded-site
  192. Xfrom the list of netnews neighbours to receive article(s).
  193. X.PP
  194. X.IR "Control messages" ,
  195. Xrecognised by their
  196. X.B Control:
  197. Xheaders
  198. X(or
  199. X.B "for backward compatibility ONLY"
  200. Xa
  201. X.B Newsgroups:
  202. Xheader containing a single newsgroup ending in
  203. X.BR .ctl ),
  204. Xare filed under the
  205. X.B control
  206. Xpseudo-group only,
  207. Xbut are forwarded as usual,
  208. Xby examining their
  209. X.B Newsgroups:
  210. Xand
  211. X.B Distribution:
  212. Xheaders.
  213. XNote that posting to the
  214. X.B control
  215. Xpseudo-group
  216. Xwill not cause a message to be treated as a control message;
  217. X.B control
  218. Xis not a real newsgroup.
  219. X.PP
  220. XArticles which contain no locally-known
  221. X(to the
  222. X.I active
  223. Xfile)
  224. Xnewsgroups
  225. Xyet accepted by the local subscription list
  226. Xare filed exactly once,
  227. Xin the
  228. X.B junk
  229. Xpseudo-group,
  230. Xand forwarded as usual.
  231. XIn particular,
  232. Xif all newsgroups in the article are refused by
  233. Xthe local subscription list
  234. Xor
  235. Xare refused by an
  236. X.B x
  237. Xin
  238. X.I active
  239. Xfile entries,
  240. Xthen the article will be
  241. X.I discarded
  242. Xand not filed in
  243. X.BR junk .
  244. X.PP
  245. XLocally-generated articles
  246. Xneed not be permitted by the local subscription list
  247. Xbut are otherwise processed normally;
  248. Xthis is for backward compatibility
  249. Xand perhaps to keep the local subscription list short
  250. Xby not requiring
  251. X.B general
  252. Xand the like to be named.
  253. X.SH FILES
  254. X.PD 0
  255. X.TP 2i
  256. X.B \*a
  257. Xnetnews article tree
  258. X.TP
  259. X.B \*a/comp/unix/wizards
  260. Xexample newsgroup directory
  261. X(for
  262. X.BR comp.unix.wizards )
  263. X.TP
  264. X.BI \*a/out.going/ system /togo
  265. Xdefault
  266. X.B sys
  267. Xfile
  268. X.BR F ,
  269. X.B f
  270. Xand
  271. X.B I
  272. Xflags filename
  273. X.TP
  274. X.B \*c/sys
  275. Xdetermines who receives broadcast netnews articles,
  276. Xwhich ones,
  277. Xand
  278. Xhow they are to be sent articles
  279. X.TP
  280. X.B \*c/active
  281. Xcontains locally-legal newsgroups and (un)moderated flag
  282. X.TP
  283. X.B \*c/history
  284. Xrecord of articles received
  285. X.TP
  286. X.B \*c/history.{dir,pag}
  287. X.IR dbm (3)
  288. Xindex into
  289. X.B history
  290. X.TP
  291. X.B \*c/whoami
  292. Xif present,
  293. Xcontains news system's site name,
  294. Xoverriding any other host names
  295. X.TP
  296. X.B \*c/log
  297. Xlog of incoming articles
  298. X.TP
  299. X.B \*c/errlog
  300. Xlog of errors, should be empty
  301. X.TP
  302. X.B \*c/bin
  303. Xsystem-specific directory of programs to
  304. Xoverride
  305. X.B \*b
  306. Xand its subdirectories
  307. X.TP
  308. X.B \*b/ctl
  309. Xcommon directory of programs to implement control messages
  310. X.TP
  311. X.B \*b/relay/relaynews
  312. Xthe lean, mean news-relayin' machine
  313. X.TP
  314. X.B \*b/newsreply
  315. Xgenerates a return address from article headers
  316. X.PD
  317. X.SH "SEE ALSO"
  318. X.IR compress (1),
  319. X.IR mail (1),
  320. X.IR uux (1),
  321. X.IR dbm (3),
  322. X.IR news (5),
  323. X.IR newsbatch (8)
  324. X.br
  325. XARPA Internet RFCs 1036 and 850
  326. X.SH DIAGNOSTICS
  327. XUsually found in
  328. X.BR \*c/errlog .
  329. X.br
  330. X.IR Relaynews 's
  331. Xexit status is a bit vector of status bits;
  332. Xsee
  333. X.B news/include/news.h
  334. Xfor the bit definitions.
  335. X.SH HISTORY
  336. XWritten by Geoff Collyer
  337. Xat the University of Toronto
  338. Xas part of the C news project.
  339. X.SH BUGS
  340. XAn article with a header that does not fit entirely in a
  341. Xstatic buffer
  342. Xand on a machine without real links
  343. X(e.g. something like Eunice but on a PDP-11)
  344. Xwill be filed incorrectly:
  345. Xany symbolic links under \*a will point at a non-existent
  346. Xfilename.
  347. X.br
  348. XA control message which cannot be filed in the
  349. X.B control
  350. Xpseudo-group
  351. Xand
  352. Xwhich cannot be filed in the
  353. X.B junk
  354. Xpseudo-group because
  355. X.B junk
  356. Xis not in the
  357. X.I active
  358. Xfile will generate an error message
  359. Xwhich refers to the groups in its
  360. X.B Newsgroups:
  361. Xheader instead of referring to the
  362. X.B control
  363. Xpseudo-group.
  364. X.br
  365. X.I Relaynews
  366. Xcould run faster in some circumstances
  367. Xand would be simpler
  368. Xif
  369. X.I Control:
  370. Xwere required to be the first header,
  371. Xif present,
  372. Xand if
  373. X.I Newsgroups:
  374. Xwere required to be the next.
  375. !
  376. echo 'man/newsbatch.8':
  377. sed 's/^X//' >'man/newsbatch.8' <<'!'
  378. X.\" =()<.ds a @<NEWSARTS>@>()=
  379. X.ds a /usr/spool/news
  380. X.\" =()<.ds b @<NEWSBIN>@>()=
  381. X.ds b /usr/lib/newsbin
  382. X.\" =()<.ds c @<NEWSCTL>@>()=
  383. X.ds c /usr/lib/news
  384. X.\" =()<.ds m @<NEWSMASTER>@>()=
  385. X.ds m usenet
  386. X.TH NEWSBATCH 8 "28 May 1989" "C News"
  387. X.SH NAME
  388. Xsendbatches, batchsplit \- news batching to other sites
  389. X.br
  390. Xbatcher, batchih, batchsm \- news-batch preparation
  391. X.br
  392. Xcomp, nocomp, compcun, compc7, compb \- news-batch compression
  393. X.br
  394. Xc7encode, bencode \- compressed-news-batch encoding
  395. X.br
  396. Xviauux, viainews, viamail, viapmail \- news-batch transmission
  397. X.SH SYNOPSIS
  398. X.B \*b/batch/sendbatches
  399. X[ site ... ]
  400. X.PP
  401. X.B \&.../batchsplit
  402. Xbatchsize
  403. X.br
  404. X.B \&.../batcher
  405. X[
  406. X.B \-d
  407. Xdirectory
  408. X]
  409. Xlistfile
  410. X.br
  411. X.B \&.../batchih
  412. X[
  413. X.B \-d
  414. Xdirectory
  415. X]
  416. Xlistfile
  417. X.br
  418. X.B \&.../batchsm
  419. X[
  420. X.B \-d
  421. Xdirectory
  422. X]
  423. Xlistfile
  424. X.br
  425. X.B \&.../comp
  426. X.br
  427. X.B \&.../nocomp
  428. X.br
  429. X.B \&.../compcun
  430. X.br
  431. X.B \&.../compc7
  432. X.br
  433. X.B \&.../compb
  434. X.br
  435. X.B \&.../c7encode
  436. X.br
  437. X.B \&.../bencode
  438. X[ file ]
  439. X.br    
  440. X.B \&.../viauux
  441. Xsite
  442. X.br
  443. X.B \&.../viainews
  444. Xsite
  445. X.br
  446. X.B \&.../viamail
  447. Xsite
  448. X.br
  449. X.B \&.../viapmail
  450. Xsite
  451. X.SH DESCRIPTION
  452. X.I Sendbatches
  453. Xadministers batched transmission of news to other sites.
  454. XIt should be run periodically, under userid \fInews\fR,
  455. Xby \fIcron\fR(8) or similar means.
  456. XIt prepares and sends batches of news,
  457. Xsubject to restrictions on available space and length of outbound queues.
  458. X.PP
  459. XEach site that can have batches sent to it needs a \fIsite\fR directory
  460. Xunder \fI\*a/out.going\fR.
  461. XIf \fIsendbatches\fR is invoked with specific \fIsite\fRs given, it
  462. Xconsiders batching for those sites, only, in that order.
  463. XBy default, \fIsendbatches\fR consults the \fIbatchparms\fR file (see below)
  464. Xto determine what to do:
  465. XIf there is a \fB/default/\fR entry in \fIbatchparms\fR, \fIsendbatches\fR
  466. Xwill consider batching for all sites that have directories in
  467. X\fI\*a/out.going\fR, in oldest-first order by modification time of the
  468. Xdirectory.
  469. XIf there is no \fB/default/\fR entry, \fIsendbatches\fR
  470. Xconsiders batching for those sites named in \fIbatchparms\fR, in the
  471. Xorder named.
  472. X.PP
  473. XTo use the batcher, names of files to be sent to a specific site should
  474. Xbe appended to a \fItogo\fR file in its \fIsite\fR directory.
  475. XThe batcher expects the lines in \fItogo\fR to have two fields, a filename
  476. X(as a full pathname) of an article and its size in bytes.
  477. XA missing size field is arbitrarily assumed to be a default average.
  478. X.PP
  479. X\fISendbatches\fR uses a number of auxiliary programs to do the real work.
  480. XThe search path it uses to find them includes, in order,
  481. Xthe \fIsite\fR directory for the site in question,
  482. X\fI\*c/bin\fR, and \fI\*b/batch\fR.
  483. XThis permits per-site and per-news-database overrides of the default
  484. Xbehaviors.
  485. X\fISendbatches\fR provides all these programs with an environment
  486. Xvariable \fBNEWSSITE\fR, containing the name of the site that batches
  487. Xare being prepared for, in case this is useful in customization.
  488. X.PP
  489. XThe names of most of the auxiliary programs, and some other parameters,
  490. Xare taken from the file \fI\*c/batchparms\fR, an ASCII text file.
  491. XEmpty lines and lines starting with `#' are ignored.
  492. XOther lines specify the behavior for sites, one line per site.
  493. XA site line is six fields, separated by white space.
  494. XThe first field is the site name;
  495. Xa line whose site name is \fB/default/\fR specifies what parameters should
  496. Xbe used for sites not explicitly mentioned.
  497. X(The presence or absence of such a line also influences the behavior of
  498. X\fIsendbatches\fR when invoked without arguments; see above.)
  499. XThe second field is the size of batches to be prepared (before compression),
  500. Xin bytes.
  501. XThe third field is the maximum number of batches to be queued up for
  502. Xtransmission to that site.
  503. XThe fourth, fifth, and sixth fields are the names of the programs to
  504. Xbe used to build, compress, and transmit (respectively) batches to that site.
  505. X.PP
  506. XFor each site being considered for batches, \fIsendbatches\fR first
  507. Xdetermines whether there are in fact any articles to be batched.
  508. XAssuming there are, \fIsendbatches\fR then
  509. Xfinds the \fIbatchparms\fR line for that site
  510. Xand
  511. Xinvokes \fIqueuelen\fR (see \fInewsaux\fR(8))
  512. Xto find out how many batches are in the outbound queue for it already.
  513. X\fISendbatches\fR limits the number of batches prepared to the minimum of
  514. Xthe limits implied by queue lengths and available space.
  515. X.PP
  516. X\fISendbatches\fR uses \fIbatchsplit\fR
  517. Xas necessary
  518. Xto slice chunks out of the \fItogo\fR
  519. Xfile, each chunk containing the
  520. X\fItogo\fR lines for a batch limited to the specified size.
  521. XException:  a single article bigger than the specified size will still go out
  522. Xas one batch.
  523. X.PP
  524. XEach chunk is then processed through a batch preparer
  525. X(typically \fIbatcher\fR), which assembles the
  526. Xarticles into a batch,
  527. Xa batch compressor (typically \fIcompcun\fR),
  528. Xwhich performs compression and/or any other auxiliary processing
  529. Xneeded, and a batch transmitter (typically \fIviauux\fR),
  530. Xwhich sends the batch on its way (e.g. enqueues it for transmission).
  531. X.PP
  532. XBatch preparers in the standard distribution are:
  533. X.RS
  534. X.IP batcher 9
  535. Xnormal batching
  536. X.IP batchih
  537. X\fIihave\fR part of ihave/sendme
  538. X.IP batchsm
  539. X\fIsendme\fR part of ihave/sendme
  540. X.RE
  541. X.PP
  542. XIf \fIbatcher\fR is invoked with a \fB\-d\fR option, it \fIchdir\fRs to
  543. Xthe \fIdirectory\fR first, and strips it off the beginning of any article
  544. Xfilename that starts with it.
  545. XSince most articles will come from \fI\*a\fR, specifying
  546. X\fB\-d\ \*a\fR to \fIbatcher\fR will speed it up noticeably.
  547. XSince \fIsendbatches\fR does this, other preparers had better be ready
  548. Xto ignore an initial \fB\-d\fR option.
  549. X.PP
  550. XBatch compressors in the standard distribution are:
  551. X.RS
  552. X.IP comp 9
  553. Xordinary
  554. Xcompression
  555. X.IP compcun
  556. Xcompression plus the silly B-news-compatible
  557. X`#!\ cunbatch' header
  558. X.IP nocomp
  559. Xpass data straight through, no compression
  560. X.IP compc7
  561. Xcompression plus 7-bit encoding using
  562. X\fIc7encode\fR
  563. X.IP compb
  564. Xcompression plus very conservative 6-bit encoding
  565. Xusing \fIbencode\fR
  566. X.RE
  567. X.PP
  568. XBatch transmitters in the standard distribution are:
  569. X.RS
  570. X.IP viauux 9
  571. Xnormal transmission via UUCP
  572. X.IP viainews
  573. Xfeed the batch back to \fIinews\fR, ignoring the \fIsite\fR argument
  574. X(normally useful only for ihave/sendme)
  575. X.IP viamail
  576. Xmail the batch to \fIsite\fB!rnews\fR
  577. X.IP viapmail
  578. Xmail the batch to \fIsite\fB!rnews\fR, attempting to
  579. Xprotect an unencoded batch against the vagaries of mailers
  580. X.RE
  581. X.PP
  582. X.I C7encode
  583. Xencodes 8-bit data from standard input into a 7-bit form optimized for
  584. Xtransmission by uucp `f' protocol.
  585. XThe encoding is complex and bizarre.
  586. X.PP
  587. X.I Bencode
  588. Xtakes 8-bit data from
  589. Xthe named source file (the default is standard input)
  590. Xand encodes it
  591. Xusing only the ASCII characters ``A'' \- ``Z'', ``a'' \- ``z'', ``0''
  592. X\- ``9'', ``+'', and ``-''.
  593. XThe ASCII characters blank, newline, and ``/'' also appear in the
  594. Xencoded file, but do not represent encoded bits.
  595. XThe encoded file is terminated with
  596. Xa byte count and cyclic redundancy check for detecting corrupted files.
  597. XThis ought to suffice to get data through almost any network.
  598. X.PP
  599. X\fISendbatches\fR logs some information about sites with backlogs in
  600. X\fI\*c/batchlog\fR, keeping the previous \fIbatchlog\fR in
  601. X\fIbatchlog.o\fR and the one before that in \fIbatchlog.oo\fR.
  602. XThis is intended to help detection and diagnosis of flow problems.
  603. X.SH FILES
  604. X.ta \w'\*a/out.going/*'u+2n
  605. X.nf
  606. X\*c/LOCKbatch    lock for \fIsendbatches\fR
  607. X\*c/LOCK    overall news lock (used by \fIbatchsplit\fR)
  608. X\*c/L.*    lock temporaries
  609. X\*a/out.going/*    batch directories
  610. X\*c/batchparms    parameter file
  611. X
  612. Xalso see text
  613. X.SH SEE ALSO
  614. Xinews(1), compress(1), uux(1), relaynews(8), rnews(8)
  615. X.SH HISTORY
  616. XWritten at University of Toronto as part of the C News project.
  617. XA number of the ideas came from Chris Lewis, who was then with Motorola.
  618. X.I Bencode
  619. Xwritten at University of Waterloo
  620. Xby Reg Quinton and Ken Lalonde.
  621. X.SH BUGS
  622. X\fIBatchsplit\fR does not count the `#!\ rnews\ \fInnnn\fR' headers inside
  623. Xbatches when computing batch lengths.
  624. X.PP
  625. XIhave/sendme processing is a bit of a kludge;
  626. Xin particular, applying \fIbatchsplit\fR to a file full of article IDs
  627. Xjust happens to work okay.
  628. X.PP
  629. X\fISendbatches\fR estimates available space without considering the
  630. Xeffects of compression;
  631. Xthis is usually too conservative.
  632. X.PP
  633. X\fIViapmail\fR is obsolescent;
  634. X\fIviamail\fR with a batch encoded with \fIbencode\fR is vastly superior.
  635. !
  636. echo 'man/expire.8':
  637. sed 's/^X//' >'man/expire.8' <<'!'
  638. X.\" =()<.ds a @<NEWSARTS>@>()=
  639. X.ds a /usr/spool/news
  640. X.\" =()<.ds b @<NEWSBIN>@>()=
  641. X.ds b /usr/lib/newsbin
  642. X.\" =()<.ds c @<NEWSCTL>@>()=
  643. X.ds c /usr/lib/news
  644. X.\" =()<.ds m @<NEWSMASTER>@>()=
  645. X.ds m usenet
  646. X.TH EXPIRE 8 "5 June 1989" "C News"
  647. X.SH NAME
  648. Xexpire, doexpire \- expire old news
  649. X.br
  650. Xmkhistory \- rebuild news history file
  651. X.br
  652. Xupact \- update news active file
  653. X.br
  654. Xsuperkludge \- implement stupid Supersedes header in news
  655. X.SH SYNOPSIS
  656. X.B \*b/expire/expire
  657. X[
  658. X.B \-a
  659. Xarchdir
  660. X] [
  661. X.B \-p
  662. X] [
  663. X.B \-s
  664. X] [
  665. X.B \-F
  666. Xc
  667. X] [
  668. X.B \-c
  669. X] [
  670. X.B \-n
  671. Xnnnnn
  672. X] [
  673. X.B \-t
  674. X] [
  675. X.B \-l
  676. X] [
  677. X.B \-v
  678. X] [
  679. X.B \-d
  680. X]
  681. X[ controlfile ]
  682. X.br
  683. X.B \*b/expire/doexpire
  684. Xexpireoptions
  685. X.br
  686. X.B \*b/expire/mkhistory
  687. X.br
  688. X.B \*b/expire/upact
  689. X.br
  690. X.B \*b/expire/superkludge
  691. X[
  692. X.B \-v
  693. X]
  694. Xnewsgroup ...
  695. X.SH DESCRIPTION
  696. X.I Expire
  697. Xexpires old news, removing it from the current-news directories and
  698. X(if asked to) archiving it elsewhere.
  699. XIt updates news's
  700. X.I history
  701. Xfile to match.
  702. X.I Expire
  703. Xshould normally be run nightly, typically by using \fIdoexpire\fR (see below).
  704. X.PP
  705. X.IR Expire 's
  706. Xoperations are controlled by a control file
  707. X(which can be named or supplied on standard input),
  708. Xwhich is not optional\(emthere is no default behavior.
  709. XEach line of the control file should have four white-space-separated
  710. Xfields, as follows.
  711. X.PP
  712. XThe first field is one or more newsgroups,
  713. Xseparated by commas (no spaces!);
  714. Xpartial specifications are acceptable (e.g. `comp' specifies all groups
  715. Xwith that prefix).
  716. X.PP
  717. XThe second field is one letter, `m', `u', or `x', specifying that the line
  718. Xapplies only to moderated groups, only to unmoderated groups, or to both,
  719. Xrespectively.
  720. X.PP
  721. XThe third field specifies the expiry period in days.
  722. XThe most general form is three numbers separated by dashes.
  723. XThe units are days; decimal fractions are permitted.
  724. XThe first number gives the retention period:
  725. Xhow long must pass after an article's arrival before it is a candidate
  726. Xfor expiry.
  727. XThe third number gives the purge date:
  728. Xhow long must pass after arrival
  729. Xbefore the article will be expired unconditionally.
  730. XThe middle number gives the default expiry date:
  731. Xhow long after an article's arrival it is expired by default.
  732. XAn explicit expiry date in the article will override the default expiry
  733. Xdate but not the retention period or the purge date.
  734. XIf the field contains only two numbers with a dash separating them,
  735. Xthe retention period defaults to 0.
  736. XIf the field contains only a number, the retention period defaults to 0
  737. Xand the purge date defaults to `never'.
  738. X(But see below.)
  739. X.PP
  740. XThe fourth field is an archiving directory,
  741. Xor `@' which indicates that the default archiving directory (see \fB\-a\fR)
  742. Xshould be used,
  743. Xor `\-' which suppresses archiving.
  744. XAn explicit archiving directory (not `@') prefixed with `=' means
  745. Xthat articles should be archived into that directory itself;
  746. Xnormally they go into subdirectories under it by newsgroup name,
  747. Xas in the current-news directory tree.
  748. X(E.g., article 123 of comp.pc.drivel being archived into archive directory
  749. X\fI/exp\fR would normally become \fI/exp/comp/pc/drivel/123\fR,
  750. Xbut if the archiving
  751. Xdirectory was given as `=/exp' rather than `/exp', it would become
  752. X\fI/exp/123\fR.)
  753. X.I Expire
  754. Xcreates subdirectories under an archiving directory automatically,
  755. Xbut will not create the archiving directory itself.
  756. XArchiving directories must be given as full pathnames.
  757. X.PP
  758. XThe first line of the control file which applies to a given article is
  759. Xused to control its expiry.
  760. XIt is an error for no line to apply;
  761. Xthe last line should be something like `all\ x\ 7\ \-'
  762. Xto ensure that at least one line is always applicable.
  763. XCross-posted articles are treated as if they were independently posted
  764. Xto each group.
  765. X.PP
  766. XThe retention and purge defaults can be overridden by including a
  767. X\fIbounds\fR line,
  768. Xone with the special first field \fB/bounds/\fR;
  769. Xthe retention and purge defaults for following lines will be those of
  770. Xthe bounds line.
  771. XThe other fields of a bounds line are ignored but must be present.
  772. X.PP
  773. XEntries in the \fIhistory\fR file can be retained after article expiry,
  774. Xto stop a late-arriving copy of the article from being taken as a new article.
  775. XTo arrange this, include a line with the special first field \fB/expired/\fR;
  776. Xthis line then controls the expiry of \fIhistory\fR lines after the
  777. Xcorresponding articles expire.
  778. XDates are still measured from article arrival, not expiry.
  779. XThe other fields of such a line are ignored but must be present.
  780. XIt is strongly recommended that such a line be included, and that it
  781. Xspecify as long a time as practical.
  782. X.PP
  783. XCommand-line options are:
  784. X.TP 10
  785. X.BR \-a " dir"
  786. X\fIdir\fR is the default archiving directory;
  787. Xif no default is given, the control file may not contain
  788. Xany `@' archive-directory fields.
  789. X.TP
  790. X.B \-p
  791. Xprint an `index' line for each archived article,
  792. Xcontaining its pathname, message ID, date received, and `Subject:' line.
  793. X.TP
  794. X.B \-s
  795. Xspace is tight; optimize error recovery to minimize space consumed rather
  796. Xthan to leave as much evidence as possible.
  797. X.TP
  798. X.BR \-F " c"
  799. Xthe subfield separator character
  800. Xin the middle \fIhistory\fR field is \fIc\fR rather
  801. Xthan the normal `~'.
  802. X.TP
  803. X.B \-c
  804. Xcheck the format and consistency of the control file and the \fIactive\fR
  805. Xfile, but do not do any expiring.
  806. X.TP
  807. X.BR \-n " nnnnn"
  808. Xset \fIexpire\fR's idea of the time to \fInnnnn\fR (for testing).
  809. X.TP
  810. X.BR \-t
  811. Xprint (on standard error) a shell-script-like description of what would
  812. Xbe done, but don't do it.
  813. X.TP
  814. X.BR \-l
  815. Xconsider first filename in a \fIhistory\fR line to be the \fIleader\fR of
  816. Xits line, to be expired only after all others have expired.
  817. X(Meant for use on obnoxious systems like VMS which don't support real links.)
  818. X.TP
  819. X.BR \-v
  820. Xverbose:
  821. Xreport some statistics after termination.
  822. X.TP
  823. X.BR \-d
  824. Xturn on (voluminous and cryptic) debugging output.
  825. X.PP
  826. X.I Expire
  827. Xconsiders the middle field of a \fIhistory\fR line to consist of one or
  828. Xmore subfields separated by `~'.
  829. XThe first is the arrival date, which can be either a \fIgetdate\fR(3)-readable
  830. Xdate or a decimal seconds count;
  831. X\fIexpire\fR leaves this field unchanged.
  832. XThe second\(emif present, non-null, and not `\-'\(emis an explicit expiry
  833. Xdate for the file, again in either format, which \fIexpire\fR will convert
  834. Xto a decimal seconds count as it regenerates the \fIhistory\fR file.
  835. XSubsequent fields are preserved but ignored.
  836. X.PP
  837. X.I Doexpire
  838. Xchecks whether another \fIdoexpire\fR is running,
  839. Xchecks that there is enough disk space for expiry and archiving,
  840. Xinvokes \fIexpire\fR with any \fIexpireoptions\fR given and with
  841. X\fI\*c/explist\fR as the control file,
  842. Xand reports any difficulties by sending mail to \fI\*m\fR.
  843. XThis is usually better than just running \fIexpire\fR directly.
  844. X.PP
  845. X.I Mkhistory
  846. Xrebuilds the \fIhistory\fR file and its auxiliaries to match the articles
  847. Xin \fI\*a\fR.
  848. X.I Upact
  849. Xupdates the third fields of the \fIactive\fR file to match the articles
  850. Xin \fI\*a\fR (for historical reasons, \fIexpire\fR does not do this).
  851. XThese programs are both fairly slow and they both lock the whole news
  852. Xsystem for the duration of the run, so they should not be run casually.
  853. X.PP
  854. X.I Superkludge
  855. Xinspects the files in \fI\*a\fR for the \fInewsgroup\fR(s)
  856. Xgiven, and removes any that have been superseded, according to the
  857. X`Supersedes' header, by newer ones.
  858. XThe \fIhistory\fR file is not altered; it's not worth the trouble.
  859. XThe \fB\-v\fR option produces a report of how many articles have been
  860. Xsuperseded in each \fInewsgroup\fR.
  861. X.SH FILES
  862. X.ta 6c
  863. X.nf
  864. X\*c/history    history file
  865. X\*c/history.pag    \fIdbm\fR database for history file
  866. X\*c/history.dir    \fIdbm\fR database for history file
  867. X\*c/explist    expiry control file
  868. X\*c/history.o    history file as of last expiry
  869. X\*c/history.n*    new history file and \fIdbm\fR files abuilding
  870. X\*c/LOCKexpire    \fIdoexpire\fR's lock file
  871. X\*b/expire/*    various auxiliaries
  872. X.SH SEE ALSO
  873. Xinews(1), dbm(3), relaynews(8)
  874. X.SH HISTORY
  875. XWritten at U of Toronto by Henry Spencer, with contributions by Geoff Collyer.
  876. X.SH BUGS
  877. XArchiving is always done by copying, never by linking.
  878. XThis has the side effect that cross-posted articles are archived as
  879. Xseveral independent copies.
  880. X.PP
  881. XThe
  882. X.B \-p
  883. Xsubject-finder botches continued header lines,
  884. Xas does \fImkhistory\fR,
  885. Xalthough such lines are rare.
  886. X.PP
  887. X\fIUpact\fR and \fIsuperkludge\fR are distasteful kludges,
  888. Xbut then, so are the third field of the \fIactive\fR file and the
  889. X`Supersedes' header.
  890. X.PP
  891. XSome of the more obscure options of \fIexpire\fR have not been tested well.
  892. X.PP
  893. XOne cannot put more than one newsgroup into a single archiving directory
  894. Xwith the `=' feature, since the article numbers will collide with each
  895. Xother and expire doesn't do anything about this.
  896. !
  897. echo 'misc/gngp.c':
  898. sed 's/^X//' >'misc/gngp.c' <<'!'
  899. X/*
  900. X * gngp - globally find newsgroup and print
  901. X *    like grep, but for newsgroup patterns instead of regular expressions
  902. X */
  903. X
  904. X#include <stdio.h>
  905. X
  906. Xchar *progname;
  907. Xint debug = 0;
  908. X
  909. X/*
  910. X * if true, match only ng at start of line, followed by whitespace or newline.
  911. X */
  912. Xint anchored = 0;
  913. X
  914. XFILE *efopen();
  915. X
  916. X/*
  917. X * main - parse arguments and handle options
  918. X */
  919. Xmain(argc, argv)
  920. Xint argc;
  921. Xchar *argv[];
  922. X{
  923. X    int c, status = 0;
  924. X    int errflg = 0;
  925. X    FILE *in;
  926. X    extern int optind;
  927. X    extern char *optarg;
  928. X
  929. X    progname = argv[0];
  930. X    while ((c = getopt(argc, argv, "ad")) != EOF)
  931. X        switch (c) {
  932. X        case 'a':        /* anchored at start of line */
  933. X            anchored++;
  934. X            break;
  935. X        case 'd':
  936. X            matchdebug(1);    /* all debugging on */
  937. X            debug++;
  938. X            break;
  939. X        default:
  940. X            errflg++;
  941. X            break;
  942. X        }
  943. X    if (errflg || optind == argc) {
  944. X        (void) fprintf(stderr, "usage: %s [-ad] pattern [file...]\n",
  945. X            progname);
  946. X        exit(2);
  947. X    }
  948. X    if (optind == argc-1)
  949. X        status |= process(argv[optind], stdin, "stdin");
  950. X    else {
  951. X        int patind = optind;
  952. X
  953. X        for (optind++; optind < argc; optind++) {
  954. X            in = efopen(argv[optind], "r");
  955. X            status |= process(argv[patind], in, argv[optind]);
  956. X            (void) fclose(in);
  957. X        }
  958. X    }
  959. X    exit(status != 0? 0: 1);
  960. X}
  961. X
  962. X/*
  963. X * process - process input file
  964. X */
  965. Xprocess(pattern, in, inname)
  966. Xchar *pattern;
  967. XFILE *in;
  968. Xchar *inname;
  969. X{
  970. X    int status = 0;
  971. X    char line[BUFSIZ];
  972. X
  973. X    while (fgets(line, sizeof line, in) != NULL)
  974. X        if (anchored)
  975. X            status |= gngp(pattern, line);
  976. X        else {
  977. X            register char *start;
  978. X
  979. X            for (start = line; *start != '\0'; start++)
  980. X                status |= gngp(pattern, start);
  981. X        }
  982. X    return status;
  983. X}
  984. X
  985. Xint
  986. Xgngp(pattern, text)
  987. Xregister char *pattern, *text;
  988. X{
  989. X    int returned;
  990. X    char savewhite;
  991. X    char *whitesp;
  992. X
  993. X    if (anchored) {
  994. X        extern char *strpbrk();
  995. X
  996. X        whitesp = strpbrk(text, " \t\n");
  997. X        if (whitesp != NULL) {
  998. X            savewhite = *whitesp;
  999. X            *whitesp = '\0';
  1000. X        }
  1001. X    }
  1002. X    returned = ngmatch(pattern, text);
  1003. X    if (anchored) {
  1004. X        if (whitesp != NULL)
  1005. X            *whitesp = savewhite;
  1006. X    }
  1007. X    if (returned)
  1008. X        (void) fputs(text, stdout);
  1009. X    return returned;
  1010. X}
  1011. !
  1012. echo 'misc/newslock.c':
  1013. sed 's/^X//' >'misc/newslock.c' <<'!'
  1014. X/*
  1015. X * newslock - simple, unbroken version of ln(1) for shell-program locking
  1016. X *
  1017. X * (System V has broken ln(1) itself.)
  1018. X */
  1019. X#include <stdio.h>
  1020. X
  1021. Xmain(argc, argv)
  1022. Xint argc;
  1023. Xchar *argv[];
  1024. X{
  1025. X    if (argc != 3) {
  1026. X        fprintf(stderr, "Usage: %s tempname lockname\n", argv[0]);
  1027. X        exit(2);
  1028. X    }
  1029. X
  1030. X    if (link(argv[1], argv[2]) < 0)
  1031. X        exit(1);
  1032. X    else
  1033. X        exit(0);
  1034. X    /* NOTREACHED */
  1035. X}
  1036. !
  1037. echo 'misc/Makefile':
  1038. sed 's/^X//' >'misc/Makefile' <<'!'
  1039. XDEFS = # -Dvoid=int
  1040. XCOPTS = -O
  1041. XCFLAGS = $(DEFS) $(COPTS) -I../include
  1042. XLIBS = ../libcnews.a
  1043. XDBM = -ldbm
  1044. XLINTFLAGS = $(DEFS) -ha
  1045. XRN = ../relay
  1046. X# =()<NEWSBIN = @<NEWSBIN>@>()=
  1047. XNEWSBIN = /usr/lib/newsbin
  1048. X# workaround for System V make bug
  1049. XSHELL = /bin/sh
  1050. X
  1051. XMAINTBIN=newshist
  1052. XMAINT = $(MAINTBIN) newsdaily newswatch newsboot locknews addgroup delgroup
  1053. XUTILBIN = gngp newslock ctime getdate
  1054. XUTILS = $(UTILBIN) sizeof newshostname
  1055. XTHEM = $(MAINT) $(UTILS)
  1056. X
  1057. Xall:    $(THEM)
  1058. X
  1059. Xbins:    $(UTILBIN)
  1060. X
  1061. Xbininstall: $(THEM)
  1062. X    chmod +x $(THEM)
  1063. X    -if test ! -d $(NEWSBIN)/maint ; then mkdir $(NEWSBIN)/maint ; fi
  1064. X    cp $(MAINT) $(NEWSBIN)/maint
  1065. X    cp $(UTILS) $(NEWSBIN)
  1066. X
  1067. Xnewsinstall:
  1068. X    : nothing
  1069. X
  1070. Xgngp:    gngp.o $(LIBS)
  1071. X    $(CC) $(CFLAGS) gngp.o $(LIBS) -o $@
  1072. X
  1073. Xctime:    ctime.o $(LIBS)
  1074. X    $(CC) $(CFLAGS) ctime.o $(LIBS) -o $@
  1075. X
  1076. Xgetdate:    getdate.o $(LIBS)
  1077. X    $(CC) $(CFLAGS) getdate.o $(LIBS) -o $@
  1078. X
  1079. Xnewslock:    newslock.o $(LIBS)
  1080. X    $(CC) $(CFLAGS) newslock.o $(LIBS) -o $@
  1081. X
  1082. XNHCFLAGS = -I$(RN) $(CFLAGS)
  1083. XRNEWSOBJS = $(RN)/history.o $(RN)/article.o $(RN)/hdrcommon.o \
  1084. X $(RN)/io.o $(RN)/msgs.o
  1085. XNHLIBS = $(LIBS) $(DBM)
  1086. Xnewshist:    newshist.o $(RNEWSOBJS) $(LIBS)
  1087. X    $(CC) $(NHCFLAGS) newshist.o $(RNEWSOBJS) $(NHLIBS) -o $@
  1088. X
  1089. Xnewshist.o:    newshist.c
  1090. X    $(CC) $(NHCFLAGS) -c newshist.c
  1091. X
  1092. Xclean:
  1093. X    rm -f *.o $(MAINTBIN) $(UTILBIN)
  1094. !
  1095. echo 'misc/ctime.c':
  1096. sed 's/^X//' >'misc/ctime.c' <<'!'
  1097. X/*
  1098. X * ctime time_t ... - print the ascii time of time_t(s)
  1099. X */
  1100. X
  1101. X#include <stdio.h>
  1102. X#include <ctype.h>
  1103. X#include <time.h>
  1104. X#include <sys/types.h>
  1105. X#include <sys/timeb.h>
  1106. X
  1107. X#define    DAY    (24L*60L*60L)
  1108. X
  1109. Xstruct timeb ftnow;
  1110. X
  1111. Xchar *progname;
  1112. X
  1113. Xextern int errno;
  1114. Xextern char *strcpy();
  1115. Xextern char *strncpy();
  1116. Xextern char *strcat();
  1117. Xextern char *strchr();
  1118. Xextern char *strtok();
  1119. Xextern long atol();
  1120. Xextern char *malloc();
  1121. Xextern struct tm *gmtime();
  1122. Xextern time_t time();
  1123. X
  1124. X/* Forwards. */
  1125. Xextern void process();
  1126. X
  1127. X/*
  1128. X - main - parse arguments and handle options
  1129. X */
  1130. Xmain(argc, argv)
  1131. Xint argc;
  1132. Xchar *argv[];
  1133. X{
  1134. X    register int c;
  1135. X    register int errflg = 0;
  1136. X    extern int optind;
  1137. X    extern char *optarg;
  1138. X
  1139. X    progname = argv[0];
  1140. X    ftime(&ftnow);
  1141. X
  1142. X    while ((c = getopt(argc, argv, "")) != EOF)
  1143. X        switch (c) {
  1144. X        case '?':
  1145. X        default:
  1146. X            errflg++;
  1147. X            break;
  1148. X        }
  1149. X    if (errflg || optind == argc) {
  1150. X        (void) fprintf(stderr, "Usage: %s ascii_time ...\n", progname);
  1151. X        exit(2);
  1152. X    }
  1153. X
  1154. X    for (; optind < argc; optind++)
  1155. X        process(argv[optind]);
  1156. X    exit(0);
  1157. X}
  1158. X
  1159. X/*
  1160. X * process - print time_t of tm
  1161. X */
  1162. Xvoid
  1163. Xprocess(tms)
  1164. Xchar *tms;
  1165. X{
  1166. X    time_t tm;
  1167. X    char *ctime();
  1168. X    long atol();
  1169. X
  1170. X    tm = atol(tms);
  1171. X    (void) fputs(ctime(&tm), stdout);
  1172. X}
  1173. !
  1174. echo 'misc/newshist.c':
  1175. sed 's/^X//' >'misc/newshist.c' <<'!'
  1176. X/*
  1177. X * newshist msgids - print history lines corresponding to msgids
  1178. X */
  1179. X
  1180. X#include <stdio.h>
  1181. X#include "news.h"
  1182. X#include "history.h"
  1183. X
  1184. Xchar *progname;
  1185. Xint debug;
  1186. Xstatic char *histfile;        /* unused */
  1187. Xint remote;            /* to satisfy rnews code */
  1188. Xint headdebug = 0;        /* no debugging */
  1189. X
  1190. X/*
  1191. X * main - parse arguments and handle options
  1192. X */
  1193. Xmain(argc, argv)
  1194. Xint argc;
  1195. Xchar *argv[];
  1196. X{
  1197. X    int c;
  1198. X    int errflg = 0;
  1199. X    extern int optind;
  1200. X    extern char *optarg;
  1201. X
  1202. X    progname = argv[0];
  1203. X    while ((c = getopt(argc, argv, "df:")) != EOF)
  1204. X        switch (c) {
  1205. X        case 'd':
  1206. X            ++debug;
  1207. X            break;
  1208. X        case 'f':
  1209. X            histfile = optarg;
  1210. X            break;
  1211. X        default:
  1212. X            errflg++;
  1213. X            break;
  1214. X        }
  1215. X    if (optind == argc || errflg) {
  1216. X        fprintf(stderr, "usage: %s [-df file] msgid ...\n", progname);
  1217. X        exit(2);
  1218. X    }
  1219. X
  1220. X    for (; optind < argc; optind++)
  1221. X        process(argv[optind]);
  1222. X    exit(0);
  1223. X}
  1224. X
  1225. X/*
  1226. X * process - message-id argument
  1227. X */
  1228. Xprocess(msgid)
  1229. Xchar *msgid;
  1230. X{
  1231. X    char *histent;
  1232. X
  1233. X    if (msgid == NULL)
  1234. X        return;        
  1235. X    histent = gethistory(msgid);
  1236. X    if (histent == NULL) {
  1237. X        char newmsgid[1000];
  1238. X        extern char *strcpy(), *strcat();
  1239. X
  1240. X        (void) strcpy(newmsgid, "<");
  1241. X        (void) strcat(newmsgid, msgid);
  1242. X        (void) strcat(newmsgid, ">");
  1243. X        histent = gethistory(newmsgid);
  1244. X    }
  1245. X    if (histent == NULL)
  1246. X        fprintf(stderr, "%s: no history entry for %s nor <%s>\n",
  1247. X            progname, msgid, msgid);
  1248. X    else
  1249. X        fputs(histent, stdout);
  1250. X    (void) fflush(stdout);
  1251. X}
  1252. X
  1253. Xunprivileged()
  1254. X{
  1255. X}
  1256. !
  1257. echo 'misc/getdate.c':
  1258. sed 's/^X//' >'misc/getdate.c' <<'!'
  1259. X/*
  1260. X * getdate ascii_time ... - print the time_t of ascii_time(s)
  1261. X */
  1262. X
  1263. X#include <stdio.h>
  1264. X#include <ctype.h>
  1265. X#include <time.h>
  1266. X#include <sys/types.h>
  1267. X#include <sys/timeb.h>
  1268. X
  1269. X#define    DAY    (24L*60L*60L)
  1270. X
  1271. Xstruct timeb ftnow;
  1272. X
  1273. Xchar *progname;
  1274. X
  1275. Xextern int errno;
  1276. Xextern char *strcpy();
  1277. Xextern char *strncpy();
  1278. Xextern char *strcat();
  1279. Xextern char *strchr();
  1280. Xextern char *strtok();
  1281. Xextern long atol();
  1282. Xextern char *malloc();
  1283. Xextern struct tm *gmtime();
  1284. Xextern time_t time();
  1285. X
  1286. Xextern time_t getdate();
  1287. X
  1288. X/* Forwards. */
  1289. Xextern void process();
  1290. X
  1291. X/*
  1292. X - main - parse arguments and handle options
  1293. X */
  1294. Xmain(argc, argv)
  1295. Xint argc;
  1296. Xchar *argv[];
  1297. X{
  1298. X    register int c;
  1299. X    register int errflg = 0;
  1300. X    extern int optind;
  1301. X    extern char *optarg;
  1302. X
  1303. X    progname = argv[0];
  1304. X    ftime(&ftnow);
  1305. X
  1306. X    while ((c = getopt(argc, argv, "")) != EOF)
  1307. X        switch (c) {
  1308. X        case '?':
  1309. X        default:
  1310. X            errflg++;
  1311. X            break;
  1312. X        }
  1313. X    if (errflg || optind == argc) {
  1314. X        (void) fprintf(stderr, "Usage: %s ascii_time ...\n", progname);
  1315. X        exit(2);
  1316. X    }
  1317. X
  1318. X    for (; optind < argc; optind++)
  1319. X        process(argv[optind]);
  1320. X    exit(0);
  1321. X}
  1322. X
  1323. X/*
  1324. X * process - print time_t of tm
  1325. X */
  1326. Xvoid
  1327. Xprocess(tm)
  1328. Xchar *tm;
  1329. X{
  1330. X    time_t it;
  1331. X
  1332. X    it = getdate(tm, &ftnow);
  1333. X    if (it < 0)
  1334. X        error("`%s' not valid date", tm);
  1335. X    else
  1336. X        (void) printf("%ld\n", it);
  1337. X}
  1338. !
  1339. echo 'misc/ctime.1':
  1340. sed 's/^X//' >'misc/ctime.1' <<'!'
  1341. X.TH CTIME 1 local
  1342. X.DA 23 April 1986
  1343. X.SH NAME
  1344. Xctime, getdate \- date conversions to and from numeric form
  1345. X.SH SYNOPSIS
  1346. X.B ctime
  1347. Xseconds ...
  1348. X.br
  1349. X.B getdate
  1350. Xdate ...
  1351. X.SH DESCRIPTION
  1352. X.I Ctime
  1353. Xconverts one or more Unix-internal (number of seconds since 1 Jan 1970)
  1354. Xdates into a human-readable form, as supplied by
  1355. X.IR ctime (3).
  1356. X.I Getdate
  1357. Xdoes the inverse, as done by
  1358. X.IR getdate (3).
  1359. X.PP
  1360. X.I Getdate
  1361. Xactually accepts a somewhat wider range of input than just output from
  1362. X.I ctime
  1363. Xor
  1364. X.IR date (1);
  1365. Xsee
  1366. X.IR getdate (3)
  1367. Xfor details.
  1368. XNote that each
  1369. X.I date
  1370. Xfed to
  1371. X.I getdate
  1372. Xmust be \fIone\fR argument;
  1373. Xit may be necessary to enclose it in quotes.
  1374. X.SH SEE ALSO
  1375. Xctime(3), getdate(3), date(1)
  1376. X.SH DIAGNOSTICS
  1377. X.I Getdate
  1378. Xwill object and exit with a status of 1 if it cannot make sense of a
  1379. X.IR date .
  1380. X.SH HISTORY
  1381. XSlightly-modified versions of programs written by Geoff Collyer at UTCS.
  1382. !
  1383. echo 'misc/README':
  1384. sed 's/^X//' >'misc/README' <<'!'
  1385. XThese are miscellaneous C News utilities which are used by more than one
  1386. Xsubsystem or aren't large enough to deserve their own directory.  newsaux(8)
  1387. Xdescribes most of them.
  1388. X
  1389. XCtime and getdate are, in our opinion, useful enough to deserve installing
  1390. Xin their own right, so we supply a manpage.
  1391. !
  1392. echo 'misc/newshostname':
  1393. sed 's/^X//' >'misc/newshostname' <<'!'
  1394. X#! /bin/sh
  1395. X# newshostname - print the hostname known to the news system
  1396. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1397. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1398. X# export NEWSCTL NEWSBIN NEWSARTS
  1399. X
  1400. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1401. Xumask $NEWSUMASK
  1402. X
  1403. X# "test -r && cat" is used here instead of just "cat" because pre-v8
  1404. X# cat's are broken and return good status when they can't read their files.
  1405. X( (test -r $NEWSCTL/whoami && cat $NEWSCTL/whoami) || hostname ||
  1406. X    (test -r /etc/whoami && cat /etc/whoami) ||
  1407. X    uuname -l || uname -n || echo the_unknown_host) 2>/dev/null
  1408. !
  1409. echo 'misc/locknews':
  1410. sed 's/^X//' >'misc/locknews' <<'!'
  1411. X#! /bin/sh
  1412. X# lock the news system & arrange to unlock later
  1413. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1414. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1415. X
  1416. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH    # don't export it
  1417. Xumask $NEWSUMASK
  1418. X
  1419. Xcd $NEWSCTL
  1420. Xtrap : 1 2 3 15            # kids can be killed, but not me
  1421. Xif newslock sys LOCK; then
  1422. X    echo 'news system locked by you'
  1423. X    PS1="newslocked$PS1 " ${SHELL-/bin/sh}
  1424. X    rm -f LOCK
  1425. X    echo 'news system unlocked now'
  1426. Xelse
  1427. X    echo 'inadequate permissions, or news system already locked'
  1428. Xfi
  1429. !
  1430. echo 'misc/addgroup':
  1431. sed 's/^X//' >'misc/addgroup' <<'!'
  1432. X#! /bin/sh
  1433. X# addgroup - add a newsgroup, locally only
  1434. X
  1435. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1436. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1437. X
  1438. XPATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH
  1439. Xumask $NEWSUMASK
  1440. X
  1441. Xusage="Usage: $0 groupname {y|n|m|x|=realgroup}"
  1442. X
  1443. Xcase $# in
  1444. X2)    ;;
  1445. X*)    echo "$usage" >&2 ; exit 2    ;;
  1446. Xesac
  1447. X
  1448. Xcase "$1" in
  1449. X*/*)    echo "$usage" >&2 ; exit 2    ;;
  1450. Xesac
  1451. X
  1452. Xcase "$2" in
  1453. X[ynmx])    ;;
  1454. X=*/*)    echo "$usage" >&2 ; exit 2    ;;
  1455. X=*)    ;;
  1456. X*)    echo "$usage" >&2 ; exit 2    ;;
  1457. Xesac
  1458. X
  1459. Xalready="`sed 's/[     ].*//' $NEWSCTL/active | fgrep -x \"$1\"`"
  1460. Xif test " $already" != " "
  1461. Xthen
  1462. X    echo "$0: $1 appears to exist already: \`$already'" >&2
  1463. X    exit 1
  1464. Xfi
  1465. X
  1466. Xlock="$NEWSCTL/LOCK"
  1467. Xltemp="$NEWSCTL/L.$$"
  1468. Xecho $$ >$ltemp
  1469. Xtrap "rm -f $ltemp ; exit 0" 0 1 2 15
  1470. Xwhile true
  1471. Xdo
  1472. X    if newslock $ltemp $lock
  1473. X    then
  1474. X        trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  1475. X        break
  1476. X    fi
  1477. X    echo 'news system locked, waiting...'
  1478. X    sleep 5
  1479. Xdone
  1480. X
  1481. Xecho "$1 0000000000 0000000000 $2" >>$NEWSCTL/active
  1482. Xmkpdir $NEWSARTS/`echo $1 | tr . /`
  1483. X
  1484. XSENDER=${USER-unknown}@`hostname`
  1485. Xecho "$1 `getdate now` $SENDER" >>$NEWSCTL/active.times  # rn hook
  1486. Xecho "newsgroup $1 was created locally by $SENDER." | mail $NEWSMASTER
  1487. !
  1488. echo 'misc/delgroup':
  1489. sed 's/^X//' >'misc/delgroup' <<'!'
  1490. X#! /bin/sh
  1491. X# delgroup - delete a newsgroup, locally only
  1492. X
  1493. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1494. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1495. X
  1496. XPATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN:$NEWSPATH ; export PATH
  1497. Xumask $NEWSUMASK
  1498. X
  1499. Xusage="Usage: $0 groupname"
  1500. X
  1501. Xcase $# in
  1502. X1)    ;;
  1503. X*)    echo "$usage" >&2 ; exit 2    ;;
  1504. Xesac
  1505. X
  1506. Xcase "$1" in
  1507. X*/*)    echo "$usage" >&2 ; exit 2    ;;
  1508. Xesac
  1509. X
  1510. Xalready="`sed 's/[     ].*//' $NEWSCTL/active | fgrep -x \"$1\"`"
  1511. Xif test " $already" = " "
  1512. Xthen
  1513. X    echo "$0: $1 appears not to exist" >&2
  1514. X    exit 1
  1515. Xfi
  1516. X
  1517. Xlock="$NEWSCTL/LOCK"
  1518. Xltemp="$NEWSCTL/L.$$"
  1519. Xecho $$ >$ltemp
  1520. Xtrap "rm -f $ltemp ; exit 0" 0 1 2 15
  1521. Xwhile true
  1522. Xdo
  1523. X    if newslock $ltemp $lock
  1524. X    then
  1525. X        trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  1526. X        break
  1527. X    fi
  1528. X    echo 'news system locked, waiting...'
  1529. X    sleep 5
  1530. Xdone
  1531. X
  1532. Xcd $NEWSCTL
  1533. X
  1534. Xawk "\$1 != \"$1\"" active >active.tmp
  1535. Xmv active active.old && mv active.tmp active
  1536. X
  1537. Xecho "You may wish to rm -rf $NEWSARTS/`echo "$1" | sed 's;\.;/;g'` at some point."
  1538. !
  1539. echo 'misc/sizeof':
  1540. sed 's/^X//' >'misc/sizeof' <<'!'
  1541. X#!/bin/sh
  1542. X# sizeof - report size of files, totalled
  1543. X
  1544. Xcase $# in
  1545. X0)    echo "Usage: sizeof file ..." >&2 ; exit 2 ;;
  1546. Xesac
  1547. X
  1548. Xls -ld $* 2>/dev/null | awk 'BEGIN { tot = 0 }
  1549. X    {
  1550. X        if (NF == 8)
  1551. X            tot += $4
  1552. X        else if (NF == 9)    # stupid clowns in AT&T changed format
  1553. X            tot += $5
  1554. X    }
  1555. X    END { print tot }'
  1556. !
  1557. echo 'misc/newswatch':
  1558. sed 's/^X//' >'misc/newswatch' <<'!'
  1559. X#! /bin/sh
  1560. X# newswatch - look for anomalies, notably locks present a long time
  1561. X
  1562. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1563. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1564. X
  1565. XPATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN:$NEWSPATH ; export PATH
  1566. Xumask $NEWSUMASK
  1567. X
  1568. Xif test $# -gt 0
  1569. Xthen
  1570. X    gurus="$*"
  1571. Xelse
  1572. X    gurus="$NEWSMASTER"
  1573. Xfi
  1574. X
  1575. Xcd $NEWSCTL
  1576. X
  1577. Xlocks="`echo LOCK*`"
  1578. Xif test -r watchtime -a " $locks" != " LOCK*"
  1579. Xthen
  1580. X    trouble="`find $locks ! -newer watchtime -print`"
  1581. X    if test " $trouble" != " "
  1582. X    then
  1583. X        ls -ldtr $trouble | mail $gurus
  1584. X    fi
  1585. Xfi
  1586. Xtouch watchtime
  1587. !
  1588. echo 'misc/newsdaily':
  1589. sed 's/^X//' >'misc/newsdaily' <<'!'
  1590. X#! /bin/sh
  1591. X# newsdaily - daily housekeeping chores
  1592. X
  1593. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1594. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1595. X
  1596. XPATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN:$NEWSPATH ; export PATH
  1597. Xumask $NEWSUMASK
  1598. X
  1599. Xgripes="/tmp/ngrip$$"
  1600. Xtmp="/tmp/ndai$$"
  1601. Xtrap "rm -f $gripes $tmp ; exit 0" 0 1 2 15
  1602. X>$gripes
  1603. X
  1604. Xif test $# -gt 0
  1605. Xthen
  1606. X    gurus="$*"
  1607. Xelse
  1608. X    gurus="$NEWSMASTER"
  1609. Xfi
  1610. X
  1611. Xcd $NEWSCTL
  1612. X
  1613. X# keep several generations of errlog for problem tracking
  1614. Xrm -f errlog.ooo
  1615. Xmv errlog.oo errlog.ooo
  1616. Xmv errlog.o errlog.oo
  1617. Xmv errlog errlog.o && >errlog
  1618. X
  1619. X# keep one generation of log -- it's big
  1620. Xrm log.o
  1621. Xmv log log.o && >log
  1622. X
  1623. X# report any errors
  1624. Xsleep 500            # hope that log.o is quiescent after this
  1625. Xif test -s errlog.o
  1626. Xthen
  1627. X    (
  1628. X        echo "errlog.o"
  1629. X        echo ---------
  1630. X        cat errlog.o
  1631. X        echo ---------
  1632. X        echo
  1633. X    ) >>$gripes
  1634. Xfi
  1635. X
  1636. X# look for input anomalies
  1637. Xcd $NEWSARTS/in.coming
  1638. Xthem="`ls | egrep -v '^bad$'`"
  1639. Xif test " $them" != " "
  1640. Xthen
  1641. X    find $them -mtime +1 -print >$tmp    # old non-bad files lying about
  1642. X    if test -s $tmp
  1643. X    then
  1644. X        (
  1645. X            echo 'old input files:'
  1646. X            cat $tmp
  1647. X            echo
  1648. X        ) >>$gripes
  1649. X    fi
  1650. Xfi
  1651. Xfind bad -type f -mtime -2 -print >$tmp        # recent bad batches
  1652. Xif test -s $tmp
  1653. Xthen
  1654. X    (
  1655. X        echo 'recent bad input batches:'
  1656. X        cat $tmp
  1657. X        echo
  1658. X    ) >>$gripes
  1659. Xfi
  1660. Xfind bad -type f -mtime +7 -exec rm -f '{}' ';'
  1661. X
  1662. X# look for output anomalies
  1663. Xcd $NEWSARTS/out.going
  1664. Xfind * -type f -name 'togo*' -size +0 -mtime +1 -print >$tmp
  1665. Xif test -s $tmp
  1666. Xthen
  1667. X    (
  1668. X        echo 'batching possibly stalled for sites:'
  1669. X        sed 's;/.*;;' $tmp | sort -u
  1670. X        echo
  1671. X    ) >>$gripes
  1672. Xfi
  1673. X
  1674. X# and send it
  1675. Xif test -s $gripes
  1676. Xthen
  1677. X    mail $gurus <$gripes
  1678. Xfi
  1679. !
  1680. echo 'misc/newsboot':
  1681. sed 's/^X//' >'misc/newsboot' <<'!'
  1682. X#! /bin/sh
  1683. X# newsboot - clean up on reboot
  1684. X
  1685. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1686. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1687. X
  1688. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1689. Xumask $NEWSUMASK
  1690. X
  1691. Xcd $NEWSCTL
  1692. Xrm -f L.* LOCK*                # leftover locks
  1693. Xrm -f history.n*            # leftover expire work files
  1694. X
  1695. Xcd $NEWSARTS/in.coming
  1696. Xrm -f nspool.* nruntmp.*        # leftover temporaries
  1697. Xfor f in nntp.*                # find partial batches
  1698. Xdo
  1699. X    while test -f $f        # still there?
  1700. X    do
  1701. X        name=`getdate now`
  1702. X        if test ! -f $name
  1703. X        then
  1704. X            mv $f $name
  1705. X        else
  1706. X            sleep 2
  1707. X        fi
  1708. X    done
  1709. Xdone
  1710. !
  1711. echo 'nntpdiffs/README':
  1712. sed 's/^X//' >'nntpdiffs/README' <<'!'
  1713. XC news diffs for NNTP 1.5 server directory.  Geoff Collyer, 8 June 1989
  1714. X
  1715. Xdiff contains normal diffs against 1.5.
  1716. Xcdiff.1.5.0 is equivalent context diffs against 1.5;
  1717. Xcdiff.1.5.5 is context diffs against 1.5.5.
  1718. XContext diffs are courtesy Jean-Francois Lamy.
  1719. X
  1720. Xsrc contains the resultant changed 1.5 source.
  1721. Xsrc.allnew contains entirely new source files.
  1722. X
  1723. XThe changes to misc.c and newnews.c have not been tested.
  1724. XThe other changes have been tested and make a large difference to
  1725. Xperformance.
  1726. !
  1727. echo 'nntpdiffs/diff/ihave.c':
  1728. sed 's/^X//' >'nntpdiffs/diff/ihave.c' <<'!'
  1729. X46c46,52
  1730. X<     retcode = spawn(rnews, "rnews", (char *) 0, CONT_XFER, ERR_XFERFAIL, errbuf);
  1731. X---
  1732. X> #ifdef UNBATCHED_INPUT
  1733. X>     retcode = spawn(rnews, "rnews", (char *) 0, CONT_XFER,
  1734. X>         ERR_XFERFAIL, errbuf);
  1735. X> #else
  1736. X>     /* C news input hook */
  1737. X>     retcode = batch_input_article(CONT_XFER, ERR_XFERFAIL, errbuf);
  1738. X> #endif
  1739. !
  1740. echo 'nntpdiffs/diff/misc.c':
  1741. sed 's/^X//' >'nntpdiffs/diff/misc.c' <<'!'
  1742. X85d84
  1743. X<  *            Converts "msg_id" to lower case.
  1744. X118,121d116
  1745. X< 
  1746. X<     for (cp = msg_id; *cp != '\0'; ++cp)
  1747. X<         if (isupper(*cp))
  1748. X<             *cp = tolower(*cp);
  1749. !
  1750. echo 'nntpdiffs/diff/newnews.c':
  1751. sed 's/^X//' >'nntpdiffs/diff/newnews.c' <<'!'
  1752. X258c258
  1753. X< seekuntil(fp, key, line, linesize)
  1754. X---
  1755. X> seekuntil(fp, akey, line, linesize)
  1756. X260c260
  1757. X<     char        *key;
  1758. X---
  1759. X>     char        *akey;
  1760. X266a267,268
  1761. X>     extern long dtol();
  1762. X>     char key[30];
  1763. X267a270
  1764. X>     (void) sprintf(key, "%ld", dtol(akey));    /* akey -> time_t in ascii */
  1765. X329a333,335
  1766. X> /*
  1767. X>  * C news version of getword.
  1768. X>  */
  1769. X336a343
  1770. X>     extern char *index();
  1771. X340,366c347,359
  1772. X<     if (cp = index(line, '\t')) {
  1773. X< /*
  1774. X<  * The following gross hack is present because the history file date
  1775. X<  * format is braindamaged.  They like "mm/dd/yy hh:mm", which is useless
  1776. X<  * for relative comparisons of dates using something like atoi() or
  1777. X<  * strcmp.  So, this changes their format into yymmddhhmm.  Sigh.
  1778. X<  *
  1779. X<  * 12345678901234    ("x" for cp[x])
  1780. X<  * mm/dd/yy hh:mm     (their lousy representation)
  1781. X<  * yymmddhhmm        (our good one)
  1782. X<  * 0123456789        ("x" for w[x])
  1783. X<  */
  1784. X<         *cp = '\0';
  1785. X<         (void) strncpy(w, cp+1, 15);
  1786. X<         w[0] = cp[7];        /* Years */
  1787. X<         w[1] = cp[8];
  1788. X<         w[2] = cp[1];        /* Months */
  1789. X<         w[3] = cp[2];
  1790. X<         w[4] = cp[4];        /* Days */
  1791. X<         w[5] = cp[5];
  1792. X<         w[6] = cp[10];        /* Hours */
  1793. X<         w[7] = cp[11];
  1794. X<         w[8] = cp[13];        /* Minutes */
  1795. X<         w[9] = cp[14];
  1796. X<         w[10] = '\0';
  1797. X<     } else
  1798. X<         w[0] = '\0';
  1799. X---
  1800. X>     w[0] = '\0';                /* in case of bad format */
  1801. X>     if (cp = index(line, '\t')) {        /* find 2nd field */
  1802. X>         register char *endp;
  1803. X> 
  1804. X>         *cp++ = '\0';
  1805. X>         endp = index(cp, '~');        /* end of date-received */
  1806. X>         if (endp == NULL)
  1807. X>             endp = index(cp, '\t');    /* end of expiry */
  1808. X>         if (endp != NULL) {
  1809. X>             (void) strncpy(w, cp, endp - cp);
  1810. X>             w[endp - cp] = '\0';
  1811. X>         }
  1812. X>     }
  1813. !
  1814. echo 'nntpdiffs/diff/serve.c':
  1815. sed 's/^X//' >'nntpdiffs/diff/serve.c' <<'!'
  1816. X239a240,242
  1817. X> #ifndef UNBATCHED_INPUT
  1818. X>     {
  1819. X>         char errbuf[2 * NNTP_STRLEN];
  1820. X240a244,246
  1821. X>         enqpartbatch(CONT_XFER, ERR_XFERFAIL, errbuf);
  1822. X>     }
  1823. X> #endif
  1824. X241a248
  1825. X> 
  1826. X290d296
  1827. X< 
  1828. !
  1829. echo 'nntpdiffs/src/Makefile':
  1830. sed 's/^X//' >'nntpdiffs/src/Makefile' <<'!'
  1831. X#
  1832. X# Makefile for NNTP server
  1833. X#
  1834. X
  1835. XSRVROBJ = main.o serve.o access.o access_inet.o access_dnet.o active.o \
  1836. X    batch.o \
  1837. X    ahbs.o globals.o group.o help.o ihave.o list.o misc.o netaux.o \
  1838. X    newgroups.o newnews.o nextlast.o ngmatch.o post.o parsit.o scandir.o \
  1839. X    slave.o spawn.o strcasecmp.o subnet.o time.o xhdr.o fakesyslog.o \
  1840. X    ../common/version.o
  1841. X
  1842. XSRVRSRC = main.c serve.c access.c access_inet.c access_dnet.c active.c \
  1843. X    batch.c \
  1844. X    ahbs.c globals.c group.c help.c ihave.c list.c misc.c netaux.c \
  1845. X    newgroups.c newnews.c nextlast.c ngmatch.c post.c parsit.c scandir.c \
  1846. X    slave.c spawn.c strcasecmp.c subnet.c time.c xhdr.c fakesyslog.c \
  1847. X    ../common/version.c
  1848. X
  1849. XSRVRINC = common.h ../common/conf.h ../common/nntp.h
  1850. X
  1851. XSRCS    = ${SRVRSRC}
  1852. X
  1853. X# -ldbm here if you've #define'ed DBM in ../common/conf.h
  1854. XLIBS    = -ldbm
  1855. X
  1856. XCFLAGS    = -O
  1857. X
  1858. X# Where nntpd is going to live
  1859. X
  1860. XDESTDIR    = /etc
  1861. X
  1862. Xall:    nntpd
  1863. X
  1864. Xnntpd: ${SRVROBJ} ${SRVRINC}
  1865. X    ${CC} ${CFLAGS} -o nntpd ${SRVROBJ} ${LIBS}
  1866. X
  1867. X${SRVROBJ}: ${SRVRINC}
  1868. X
  1869. Xinstall: nntpd
  1870. X    cp nntpd ${DESTDIR}/nntpd
  1871. X    chmod 711 ${DESTDIR}/nntpd
  1872. X
  1873. Xlint:
  1874. X    lint ${SRVRSRC}
  1875. X
  1876. Xclean:
  1877. X    -rm -f *.o nntpd make*.out a.out
  1878. X
  1879. Xdistrib: clean
  1880. X    rm -rf SCCS save tags
  1881. X
  1882. Xcheck:
  1883. X    sccs check
  1884. X    sccs prt -y *.[ch] > /dev/null
  1885. X
  1886. Xtags:    ${SRVRSRC} ${SRVRINC}
  1887. X    ctags ${SRVRSRC} ${SRVRINC}
  1888. X
  1889. X# Dependencies
  1890. X
  1891. X../common/version.o:
  1892. X    ${CC} ${CFLAGS} -c ../common/version.c
  1893. X    mv version.o ../common/version.o
  1894. !
  1895. echo 'nntpdiffs/src/ihave.c':
  1896. sed 's/^X//' >'nntpdiffs/src/ihave.c' <<'!'
  1897. X#ifndef lint
  1898. Xstatic char    *sccsid = "@(#)ihave.c    1.11    (Berkeley) 1/11/88";
  1899. X#endif
  1900. X
  1901. X#include "common.h"
  1902. X
  1903. X#ifdef LOG
  1904. Xint    ih_accepted;
  1905. Xint    ih_rejected;
  1906. Xint    ih_failed;
  1907. X#endif LOG
  1908. X
  1909. X/*
  1910. X * IHAVE <messageid>
  1911. X *
  1912. X * Accept an article for transferral if we haven't seen it before.
  1913. X */
  1914. X
  1915. Xihave(argc, argv)
  1916. X    int        argc;
  1917. X    char        *argv[];
  1918. X{
  1919. X    char        errbuf[2 * NNTP_STRLEN];
  1920. X    int        retcode;
  1921. X    register char    *cp;
  1922. X
  1923. X    if (argc != 2) {
  1924. X        printf("%d Usage: IHAVE <message-id>.\r\n", ERR_CMDSYN);
  1925. X        (void) fflush(stdout);
  1926. X        return;
  1927. X    }
  1928. X
  1929. X    cp = gethistent(argv[1]);
  1930. X    if (cp != NULL) {
  1931. X        printf("%d Got it.\r\n", ERR_GOTIT);
  1932. X        (void) fflush(stdout);
  1933. X#ifdef LOG
  1934. X        ih_rejected++;
  1935. X#ifdef IHAVE_DEBUG
  1936. X        syslog(LOG_DEBUG, "%s ihave %s rejected", hostname, argv[1]);
  1937. X#endif IHAVE_DEBUG
  1938. X#endif LOG
  1939. X        return;
  1940. X    }
  1941. X        
  1942. X#ifdef UNBATCHED_INPUT
  1943. X    retcode = spawn(rnews, "rnews", (char *) 0, CONT_XFER,
  1944. X        ERR_XFERFAIL, errbuf);
  1945. X#else
  1946. X    /* C news input hook */
  1947. X    retcode = batch_input_article(CONT_XFER, ERR_XFERFAIL, errbuf);
  1948. X#endif
  1949. X    if (retcode <= 0)
  1950. X        printf("%d %s\r\n", ERR_XFERFAIL, errbuf);
  1951. X    else if (retcode > 0)
  1952. X        printf("%d Thanks.\r\n",
  1953. X            OK_XFERED);
  1954. X    (void) fflush(stdout);
  1955. X
  1956. X#ifdef LOG
  1957. X    if (retcode == 1)
  1958. X        ih_accepted++;
  1959. X    else
  1960. X        ih_failed++;
  1961. X        
  1962. X#ifdef IHAVE_DEBUG
  1963. X    syslog(LOG_DEBUG, "%s ihave %s accepted %s",
  1964. X        hostname, argv[1], retcode == 1 ? "succeeded" : "failed");
  1965. X#endif IHAVE_DEBUG
  1966. X#endif LOG
  1967. X
  1968. X}
  1969. !
  1970. echo done
  1971.  
  1972.  
  1973.