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

  1. Subject:  v19i081:  Cnews production release, Part04/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 81
  8. Archive-name: cnews2/part04
  9.  
  10. : ---CUT HERE---
  11. echo 'notebook/newslock':
  12. sed 's/^X//' >'notebook/newslock' <<'!'
  13. X.DA "22 April 1989"
  14. X.TL
  15. XLocking in C News
  16. X.AU
  17. XHenry Spencer
  18. X.AI
  19. XDept. of Zoology
  20. XUniversity of Toronto
  21. X.LP
  22. XSeveral parts of C News need some way of locking parts of the news
  23. Xsubsystem against concurrent execution.
  24. XVarious system-specific locking system calls exist, but none of them
  25. Xis truly portable, and most of them provide far more functionality than
  26. Xwe need.
  27. X.LP
  28. XC News locking uses the \fIlink\fR(2) system call and pre-agreed names.
  29. X\fILink\fR has the necessary characteristic for safe locking:
  30. Xit is an atomic test-and-set operation.
  31. XFurthermore, it exists in all Unixes.
  32. X.LP
  33. XAll locks are created in the NEWSCTL directory
  34. X(see \fIConfiguration Mechanisms in C News\fR for where this directory
  35. Xis to be found and how programs can determine this)
  36. Xand have names starting with `LOCK'.
  37. XTo acquire a lock, first create a temporary file in NEWSCTL with a name
  38. Xof the form `L.\fIn\fR', where \fIn\fR is your process id.
  39. XYou are urged to also write your process id, in decimal ASCII, into this
  40. Xfile.
  41. XThen attempt to link the
  42. Xtemporary
  43. Xfile to `LOCK\fIx\fR', where \fIx\fR is chosen based
  44. Xon what sort of locking you wish to do.
  45. XExisting lock names are:
  46. X.TS
  47. Xcenter;
  48. Xll.
  49. XLOCK    relaynews, modifications to control files
  50. XLOCKinput    input subsystem processing spooled input
  51. XLOCKbatch    batcher preparing batches
  52. XLOCKexpire    expire expiring articles
  53. X.TE
  54. XIf the link fails, sleep and try again.
  55. XIf it succeeds, proceed.
  56. XThe temporary file may be removed then or at the same time as the lock
  57. Xis removed.
  58. XPrograms are expected to make a determined effort to remove lock files
  59. Xwhen they terminate, normally or as a result of signals.
  60. X.LP
  61. XShell programs have an additional problem in that System V has broken
  62. X\fIln\fR(1) so that it removes a pre-existing destination file.
  63. XC News therefore provides a pure, simple locking program under
  64. Xthe name NEWSBIN/newslock (if the recommendations in
  65. X\fIDirectory Layout and PATH in C News\fR are followed, this will
  66. Xautomatically be in the search path of shell programs).
  67. XUsage is `newslock\ tempfile\ lockfile';
  68. Xexit status is 0 for success, 1 for failure, 2 for wrong number of arguments.
  69. XNo messages are printed for normal failure, so no redirection of output
  70. Xis needed.
  71. X.LP
  72. XA suitable locking procedure for a shell file using the standard
  73. Xconfiguration facilities is:
  74. X.DS
  75. Xlock="$NEWSCTL/LOCKxxx"        # modify name as appropriate
  76. Xltemp="$NEWSCTL/L.$$"
  77. Xecho $$ >$ltemp
  78. Xtrap "rm \-f $ltemp ; exit 0" 0 1 2 15
  79. Xwhile true
  80. Xdo
  81. X    if newslock $ltemp $lock
  82. X    then
  83. X        trap "rm \-f $ltemp $lock ; exit 0" 0 1 2 15
  84. X        break
  85. X    fi
  86. X    sleep 30
  87. Xdone
  88. X.DE
  89. XA template of this form can be found in the file \fInewslock.sh\fR.
  90. X.LP
  91. XAlthough there are various thorny questions associated with breaking
  92. Xlocks by dead programs, reboot is a time when surviving locks are
  93. Xdefinitely invalid.
  94. X(Although there are problems even here if a networked group of systems
  95. Xare not rebooted as a unit.)
  96. XFor this and other reasons, a system running C News should execute
  97. XNEWSCTL/bin/newsboot at reboot time (e.g. from \fI/etc/rc\fR).
  98. !
  99. echo 'notebook/config':
  100. sed 's/^X//' >'notebook/config' <<'!'
  101. X.DA "18 Feb 1989"
  102. X.TL
  103. XConfiguration Mechanisms in C News
  104. X.AU
  105. XHenry Spencer
  106. X.AI
  107. XDept. of Zoology
  108. XUniversity of Toronto
  109. X.SH
  110. XIntro
  111. X.LP
  112. XThere is an overall problem with news stuff in that some pathnames
  113. Xand such are site-specific.
  114. XIn C News this hits both shell files and C programs, the former a
  115. Xparticular inconvenience because they are not compiled and hence can't
  116. Xeasily pick it up from a library at compile time.
  117. XIt's easy to edit shell files, but there are too many of them for this
  118. Xto be very convenient.
  119. X.LP
  120. XSeveral mechanisms are needed to solve the entire problem..
  121. X.SH
  122. XConfiguration Parameters
  123. X.LP
  124. XAlthough there are many things that theoretically could be site-specific,
  125. Xthere are only a few that really crop up constantly,
  126. Xare highly likely to change,
  127. Xand have to be known to running code.
  128. XHere's a tentative list, with internal names and common defaults:
  129. X.TS
  130. Xlll.
  131. XNEWSARTS    pathname of the article database    /usr/spool/news
  132. XNEWSCTL    pathname of the control-file directory    /usr/lib/news
  133. XNEWSBIN    pathname of the program directory    /usr/lib/newsbin
  134. XNEWSPATH    shell PATH setting for news    /bin:/usr/bin
  135. XNEWSUMASK    default umask for file creation    002
  136. XNEWSMASTER    where to send mail about trouble    usenet
  137. XNEWSCONFIG    see "Subst" section    /usr/lib/news/bin/config
  138. X.TE
  139. X.SH
  140. XEnvironment Variables
  141. X.LP
  142. XAll C News programs
  143. Xthat care about configuration parameters are expected to look at
  144. Xenvironment variables with the same names as the parameters, and to
  145. Xuse the environment values to override internal defaults.
  146. XThis is primarily aimed at testing and special purposes rather than
  147. Xproduction use, as there is a fundamental problem:
  148. Xthe environment is insecure.
  149. XThe environment variables are nevertheless very useful.
  150. X.LP
  151. XThere is a need for a canned interface to the environment variables,
  152. Xto simplify their use.
  153. XThere is also a requirement for centrally-set defaults for normal
  154. Xproduction use.
  155. XThese requirements are addressed differently for C and shell programs.
  156. X.SH
  157. XC Interface
  158. X.LP
  159. X\fILibcnews\fR provides a set of inquiry functions:
  160. X.LP
  161. X.RS
  162. X.IP "char *fullartfile(char *name);"
  163. XReturns a full pathname for the NEWSARTS-relative file \fIname\fR;
  164. Xif \fIname\fR is NULL, returns the value of NEWSARTS.
  165. X.IP "char *ctlfile(char *name);"
  166. XReturns a full pathname for the NEWSCTL-relative file \fIname\fR;
  167. Xif \fIname\fR is NULL, returns the value of NEWSCTL.
  168. X.IP "char *binfile(char *name);"
  169. XReturns a full pathname for the NEWSBIN-relative file \fIname\fR;
  170. Xif \fIname\fR is NULL, returns the value of NEWSBIN.
  171. X.IP "char *newspath(void);"
  172. XReturns the value of the NEWSPATH parameter.
  173. X.IP "int newsumask(void);"
  174. XReturns the value of the NEWSUMASK parameter.
  175. X.IP "char *newsmaster(void);"
  176. XReturns the value of NEWSMASTER.
  177. X.RE
  178. X.LP
  179. XFunctions which return string values return pointers to areas which they
  180. Xmay later re-use, so the values should be copied if they are to persist
  181. Xpast later calls.
  182. XThere is also a function \fIartfile\fR which returns a relative pathname,
  183. Xas a special-purpose optimization,
  184. Xand a function \fIcd\fR which does a \fIchdir\fR and notes the location
  185. Xfor future use by \fIartfile\fR.
  186. X.LP
  187. XThe first inquiry function to be invoked automatically initializes
  188. Xtheir internal housekeeping.
  189. XAgainst the possibility of malicious setting of environment variables,
  190. Xif any environment variables are in fact present to override default
  191. Xvalues, and at least one value in fact differs from the default,
  192. Xthis initialization includes a call to a function the user must supply:
  193. X.LP
  194. X.RS
  195. X.IP "void unprivileged(void);"
  196. XDrop any special powers that should not be available to a normal user
  197. Xprogram,
  198. Xe.g. those obtained by set-uid bit.
  199. X.RE
  200. X.LP
  201. XPrograms that do not use the set-uid bit can normally have a null
  202. Ximplementation of \fIunprivileged\fR, but to encourage thought about
  203. Xthe matter this is \fInot\fR provided as a default.
  204. X.LP
  205. XSuitable external declarations for all these functions can be found
  206. Xin the include file \fIconfig.h\fR in the C News include directory.
  207. X.SH
  208. XShell interface
  209. X.LP
  210. XAll shell files that want to know configuration parameters should
  211. Xexecute NEWSCTL/bin/config using the `.' command;
  212. Xit sets shell variables with the same names as the parameters.
  213. XNote that it does not export these variables, so subordinate shell
  214. Xfiles need to pick up \fIconfig\fR themselves.
  215. XThis is to preserve the property that subordinate programs see environment
  216. Xvariables set only if the user set them.
  217. X.SH
  218. XSubst
  219. X.LP
  220. XThe alert mind will have noticed a circularity in the previous section:
  221. Xit's not possible to find NEWSCTL/bin/config until one knows where NEWSCTL is.
  222. XThere are also occasional annoyances in that documentation and such wants
  223. Xto know the local defaults, and can't get them from either the C or shell
  224. Xinterface.
  225. XHence the use of \fIsubst\fR.
  226. X.LP
  227. X\fISubst\fR does substitutions into source files (including shell files)
  228. Xin such a way that it is not necessary to maintain two versions of the file.
  229. XIn the top-level directory of the C News sources are four files:
  230. X\fIsubst\fR itself, the \fIsubstitutions\fR file defining the values of
  231. Xthe configuration parameters, and \fIsubst.hs\fR and \fIsubst.gc\fR,
  232. Xwhich are lists of files (relative to the top-level source directory)
  233. Xthat need substitutions done.
  234. X(The use of two `list' files reflects C News's dual authorship.)
  235. XSee the \fIsubst\fR(1) manual page for the gory details of the syntax.
  236. XThe only C program affected is the configuration-inquiry part of the
  237. Xlibrary, but all shell files that need any of the configuration parameters
  238. Xneed to be in one of the lists.
  239. X.SH
  240. XProgram startup
  241. X.LP
  242. XAs a result of all this, a C program which needs to know a configuration
  243. Xparameter simply calls the appropriate inquiry function,
  244. Xand is prepared for a return call to \fIunprivileged\fR.
  245. XA shell program has to do a bit more work; it should start with something
  246. Xon the order of:
  247. X.DS
  248. X#! /bin/sh
  249. X# foobar \- does foo, bar, and bletch
  250. X
  251. X# =()<. ${NEWSCONFIG\-@<NEWSCONFIG>@}>()=
  252. X. ${NEWSCONFIG\-/usr/lib/news/bin/config}
  253. X
  254. XPATH=$NEWSCTL/bin:$NEWSBIN/xxx:$NEWSBIN:$NEWSPATH ; export PATH
  255. Xumask $NEWSUMASK
  256. X.DE
  257. X(A prototype for this is in conf/proto.sh.)
  258. X(See an accompanying document for the logic of the PATH setting.)
  259. XThe NEWSCONFIG configuration parameter specifies the location of the
  260. Xconfigurer shell program, which is then executed to set up the rest
  261. Xof the parameters.
  262. XThe reason for doing it this way is to ensure that new parameters
  263. Xcan be added without having to change every shell file.
  264. !
  265. echo 'notebook/ihave.pic':
  266. sed 's/^X//' >'notebook/ihave.pic' <<'!'
  267. X.lf 1 ihave.pic.in
  268. X.LP
  269. X... 0 0 601 509
  270. X... 0.000i 5.082i 6.000i 0.000i
  271. X.nr 00 \n(.u
  272. X.nf
  273. X.PS 5.082i 6.000i  6
  274. X.lf 71
  275. X\h'1.737i'\v'4.872i'\D'l3.374i -0.030i'
  276. X.sp -1
  277. X\h'5.012i'\v'4.868i'\D'l0.100i -0.026i'
  278. X.sp -1
  279. X\h'5.011i'\v'4.818i'\D'l0.100i 0.024i'
  280. X.sp -1
  281. X\h'3.275i'\v'4.762i'\v'.2m'\h'-\w'\f1\s10\&articles\f1\s0'u/2u'\f1\s10\&articles\f1\s0\h'-\w'\f1\s10\&articles\f1\s0'u/2u'
  282. X.sp -1
  283. X\h'5.042i'\v'2.166i'\v'.2m'\h'-\w'\f1\s10\&\f1\s0'u/2u'\f1\s10\&\f1\s0\h'-\w'\f1\s10\&\f1\s0'u/2u'
  284. X.sp -1
  285. X\h'5.431i'\v'0.519i'\v'.2m'\h'-\w'\f1\s10\&\f1\s0'u/2u'\f1\s10\&\f1\s0\h'-\w'\f1\s10\&\f1\s0'u/2u'
  286. X.sp -1
  287. X\h'3.314i'\v'0.100i'\v'.2m'\h'-\w'\f3\s14\&ihave/sendme processing diagram\f1\s0'u/2u'\f3\s14\&ihave/sendme processing diagram\f1\s0\h'-\w'\f3\s14\&ihave/sendme processing diagram\f1\s0'u/2u'
  288. X.sp -1
  289. X\h'1.348i'\v'0.399i'\v'.2m'\h'-\w'\f3\s10\&utzoo\f1\s0'u/2u'\f3\s10\&utzoo\f1\s0\h'-\w'\f3\s10\&utzoo\f1\s0'u/2u'
  290. X.sp -1
  291. X\h'4.183i'\v'1.927i'\D'e1.817i 0.399i'
  292. X.sp -1
  293. X\h'5.092i'\v'0.399i'\v'.2m'\h'-\w'\f3\s10\&utstat\f1\s0'u/2u'\f3\s10\&utstat\f1\s0\h'-\w'\f3\s10\&utstat\f1\s0'u/2u'
  294. X.sp -1
  295. X\h'0.210i'\v'0.689i'\v'.2m'\h'-\w'\f1\s10\&article\f1\s0'u/2u'\f1\s10\&article\f1\s0\h'-\w'\f1\s10\&article\f1\s0'u/2u'
  296. X.sp -1
  297. X\h'0.369i'\v'0.689i'\D'l0.459i 0.000i'
  298. X.sp -1
  299. X\h'0.729i'\v'0.714i'\D'l0.100i -0.025i'
  300. X.sp -1
  301. X\h'0.729i'\v'0.664i'\D'l0.100i 0.025i'
  302. X.sp -1
  303. X\h'1.288i'\v'0.639i'\v'.2m'\h'-\w'\f1\s10\&match #1 I\f1\s0'u/2u'\f1\s10\&match #1 I\f1\s0\h'-\w'\f1\s10\&match #1 I\f1\s0'u/2u'
  304. X.sp -1
  305. X\h'0.759i'\v'1.448i'\D'l0.000i -0.349i'
  306. X.sp -1
  307. X\h'0.759i'\v'1.098i'\D'l0.958i 0.000i'
  308. X.sp -1
  309. X\h'1.717i'\v'1.098i'\D'l0.000i 0.349i'
  310. X.sp -1
  311. X\h'1.717i'\v'1.448i'\D'l-0.958i 0.000i'
  312. X.sp -1
  313. X\h'1.288i'\v'1.208i'\v'.2m'\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'\f1\s10\&batcher on\f1\s0\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'
  314. X.sp -1
  315. X\h'1.288i'\v'1.318i'\v'.2m'\h'-\w'\f1\s10\&msgid file\f1\s0'u/2u'\f1\s10\&msgid file\f1\s0\h'-\w'\f1\s10\&msgid file\f1\s0'u/2u'
  316. X.sp -1
  317. X\h'4.542i'\v'4.203i'\D'~ -0.230i 0.000i -0.240i -0.319i -0.160i -0.240i -0.080i -0.080i'
  318. X.sp -1
  319. X\h'3.922i'\v'3.617i'\D'l-0.088i -0.053i'
  320. X.sp -1
  321. X\h'3.887i'\v'3.652i'\D'l-0.053i -0.088i'
  322. X.sp -1
  323. X\h'5.101i'\v'3.814i'\D'l0.080i 0.150i'
  324. X.sp -1
  325. X\h'5.112i'\v'3.887i'\D'l0.069i 0.076i'
  326. X.sp -1
  327. X\h'5.156i'\v'3.864i'\D'l0.025i 0.100i'
  328. X.sp -1
  329. X\h'1.917i'\v'2.686i'\D'~ 0.160i 0.000i 0.080i -0.399i 0.160i -0.240i 0.080i -0.080i'
  330. X.sp -1
  331. X\h'2.343i'\v'2.055i'\D'l0.053i -0.088i'
  332. X.sp -1
  333. X\h'2.308i'\v'2.020i'\D'l0.088i -0.053i'
  334. X.sp -1
  335. X\h'1.288i'\v'2.186i'\D'l-0.010i 0.260i'
  336. X.sp -1
  337. X\h'1.257i'\v'2.345i'\D'l0.021i 0.101i'
  338. X.sp -1
  339. X\h'1.307i'\v'2.347i'\D'l-0.029i 0.099i'
  340. X.sp -1
  341. X\h'1.238i'\v'1.448i'\D'l0.050i 0.300i'
  342. X.sp -1
  343. X\h'1.247i'\v'1.653i'\D'l0.041i 0.094i'
  344. X.sp -1
  345. X\h'1.296i'\v'1.645i'\D'l-0.008i 0.103i'
  346. X.sp -1
  347. X\h'1.318i'\v'1.597i'\v'.2m'\h'-\w'\f1\s10\&(deadlock avoidance)\f1\s0'u/2u'\f1\s10\&(deadlock avoidance)\f1\s0\h'-\w'\f1\s10\&(deadlock avoidance)\f1\s0'u/2u'
  348. X.sp -1
  349. X\h'0.349i'\v'3.564i'\D'e2.017i 0.479i'
  350. X.sp -1
  351. X\h'5.092i'\v'2.955i'\D'l0.010i 0.379i'
  352. X.sp -1
  353. X\h'5.074i'\v'3.235i'\D'l0.028i 0.099i'
  354. X.sp -1
  355. X\h'5.124i'\v'3.234i'\D'l-0.022i 0.100i'
  356. X.sp -1
  357. X\h'5.111i'\v'3.165i'\v'.2m'\h'-\w'\f1\s10\&(deadlock avoidance)\f1\s0'u/2u'\f1\s10\&(deadlock avoidance)\f1\s0\h'-\w'\f1\s10\&(deadlock avoidance)\f1\s0'u/2u'
  358. X.sp -1
  359. X\h'5.092i'\v'3.524i'\v'.2m'\h'-\w'\f1\s10\&match #4 F or \(es\f1\s0'u/2u'\f1\s10\&match #4 F or \(es\f1\s0\h'-\w'\f1\s10\&match #4 F or \(es\f1\s0'u/2u'
  360. X.sp -1
  361. X\h'5.111i'\v'4.123i'\v'.2m'\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'\f1\s10\&batcher on\f1\s0\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'
  362. X.sp -1
  363. X\h'5.191i'\v'4.283i'\v'.2m'\h'-\w'\f1\s10\&filenames (opt.)\f1\s0'u/2u'\f1\s10\&filenames (opt.)\f1\s0\h'-\w'\f1\s10\&filenames (opt.)\f1\s0'u/2u'
  364. X.sp -1
  365. X\h'2.077i'\v'1.977i'\D'l2.106i -0.050i'
  366. X.sp -1
  367. X\h'4.084i'\v'1.954i'\D'l0.099i -0.027i'
  368. X.sp -1
  369. X\h'4.083i'\v'1.904i'\D'l0.100i 0.023i'
  370. X.sp -1
  371. X\h'5.092i'\v'2.126i'\D'l0.000i 0.499i'
  372. X.sp -1
  373. X\h'5.067i'\v'2.526i'\D'l0.025i 0.100i'
  374. X.sp -1
  375. X\h'5.116i'\v'2.526i'\D'l-0.025i 0.100i'
  376. X.sp -1
  377. X\h'3.215i'\v'1.867i'\v'.2m'\h'-\w'\f1\s10\&ihave control\f1\s0'u/2u'\f1\s10\&ihave control\f1\s0\h'-\w'\f1\s10\&ihave control\f1\s0'u/2u'
  378. X.sp -1
  379. X\h'3.195i'\v'3.484i'\v'.2m'\h'-\w'\f1\s10\&sendme control\f1\s0'u/2u'\f1\s10\&sendme control\f1\s0\h'-\w'\f1\s10\&sendme control\f1\s0'u/2u'
  380. X.sp -1
  381. X\h'5.101i'\v'3.654i'\v'.2m'\h'-\w'\f1\s10\&inews to.utzoo\f1\s0'u/2u'\f1\s10\&inews to.utzoo\f1\s0\h'-\w'\f1\s10\&inews to.utzoo\f1\s0'u/2u'
  382. X.sp -1
  383. X\h'1.288i'\v'1.937i'\v'.2m'\h'-\w'\f1\s10\&match #2 F or \(es\f1\s0'u/2u'\f1\s10\&match #2 F or \(es\f1\s0\h'-\w'\f1\s10\&match #2 F or \(es\f1\s0'u/2u'
  384. X.sp -1
  385. X\h'1.288i'\v'2.057i'\v'.2m'\h'-\w'\f1\s10\&inews to.utstat\f1\s0'u/2u'\f1\s10\&inews to.utstat\f1\s0\h'-\w'\f1\s10\&inews to.utstat\f1\s0'u/2u'
  386. X.sp -1
  387. X\h'3.215i'\v'1.078i'\v'.2m'\h'-\w'\f1\s10\&\f1\s0'u/2u'\f1\s10\&\f1\s0\h'-\w'\f1\s10\&\f1\s0'u/2u'
  388. X.sp -1
  389. X\h'1.242i'\v'0.975i'\D'l0.006i 0.103i'
  390. X.sp -1
  391. X\h'1.291i'\v'0.985i'\D'l-0.043i 0.093i'
  392. X.sp -1
  393. X\h'1.248i'\v'1.078i'\D'l0.050i -0.260i'
  394. X.sp -1
  395. X\h'0.809i'\v'5.082i'\D'l0.000i -0.399i'
  396. X.sp -1
  397. X\h'0.809i'\v'4.682i'\D'l0.908i 0.000i'
  398. X.sp -1
  399. X\h'1.717i'\v'4.682i'\D'l0.000i 0.399i'
  400. X.sp -1
  401. X\h'1.717i'\v'5.082i'\D'l-0.908i 0.000i'
  402. X.sp -1
  403. X\h'1.288i'\v'4.782i'\v'.2m'\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'\f1\s10\&batcher on\f1\s0\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'
  404. X.sp -1
  405. X\h'1.278i'\v'4.932i'\v'.2m'\h'-\w'\f1\s10\&filenames\f1\s0'u/2u'\f1\s10\&filenames\f1\s0\h'-\w'\f1\s10\&filenames\f1\s0'u/2u'
  406. X.sp -1
  407. X\h'1.278i'\v'3.804i'\D'l-0.020i 0.879i'
  408. X.sp -1
  409. X\h'1.235i'\v'4.582i'\D'l0.023i 0.100i'
  410. X.sp -1
  411. X\h'1.285i'\v'4.583i'\D'l-0.027i 0.099i'
  412. X.sp -1
  413. X\h'4.213i'\v'3.574i'\D'l-1.847i -0.010i'
  414. X.sp -1
  415. X\h'2.466i'\v'3.540i'\D'l-0.100i 0.024i'
  416. X.sp -1
  417. X\h'2.466i'\v'3.590i'\D'l-0.100i -0.026i'
  418. X.sp -1
  419. X\h'1.358i'\v'3.484i'\v'.2m'\h'-\w'\f1\s10\&match #5 F\f1\s0'u/2u'\f1\s10\&match #5 F\f1\s0\h'-\w'\f1\s10\&match #5 F\f1\s0'u/2u'
  420. X.sp -1
  421. X\h'4.213i'\v'3.574i'\D'e1.777i 0.479i'
  422. X.sp -1
  423. X\h'1.358i'\v'3.644i'\v'.2m'\h'-\w'\f1\s10\&rnews to.utstat/sendme\f1\s0'u/2u'\f1\s10\&rnews to.utstat/sendme\f1\s0\h'-\w'\f1\s10\&rnews to.utstat/sendme\f1\s0'u/2u'
  424. X.sp -1
  425. X\h'4.642i'\v'2.955i'\D'l0.000i -0.329i'
  426. X.sp -1
  427. X\h'4.642i'\v'2.626i'\D'l0.908i 0.000i'
  428. X.sp -1
  429. X\h'5.551i'\v'2.626i'\D'l0.000i 0.329i'
  430. X.sp -1
  431. X\h'5.551i'\v'2.955i'\D'l-0.908i 0.000i'
  432. X.sp -1
  433. X\h'5.042i'\v'2.735i'\v'.2m'\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'\f1\s10\&batcher on\f1\s0\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'
  434. X.sp -1
  435. X\h'5.042i'\v'2.845i'\v'.2m'\h'-\w'\f1\s10\&msgid file\f1\s0'u/2u'\f1\s10\&msgid file\f1\s0\h'-\w'\f1\s10\&msgid file\f1\s0'u/2u'
  436. X.sp -1
  437. X\h'1.228i'\v'2.626i'\v'.2m'\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'\f1\s10\&batcher on\f1\s0\h'-\w'\f1\s10\&batcher on\f1\s0'u/2u'
  438. X.sp -1
  439. X\h'1.288i'\v'2.735i'\v'.2m'\h'-\w'\f1\s10\&filenames (opt.)\f1\s0'u/2u'\f1\s10\&filenames (opt.)\f1\s0\h'-\w'\f1\s10\&filenames (opt.)\f1\s0'u/2u'
  440. X.sp -1
  441. X\h'4.542i'\v'4.443i'\D'l0.000i -0.479i'
  442. X.sp -1
  443. X\h'4.542i'\v'3.963i'\D'l1.278i 0.000i'
  444. X.sp -1
  445. X\h'5.820i'\v'3.963i'\D'l0.000i 0.479i'
  446. X.sp -1
  447. X\h'5.820i'\v'4.443i'\D'l-1.278i 0.000i'
  448. X.sp -1
  449. X\h'0.639i'\v'2.925i'\D'l0.000i -0.479i'
  450. X.sp -1
  451. X\h'0.639i'\v'2.446i'\D'l1.278i 0.000i'
  452. X.sp -1
  453. X\h'1.917i'\v'2.446i'\D'l0.000i 0.479i'
  454. X.sp -1
  455. X\h'1.917i'\v'2.925i'\D'l-1.278i 0.000i'
  456. X.sp -1
  457. X\h'1.298i'\v'0.729i'\v'.2m'\h'-\w'\f1\s10\&rnews\f1\s0'u/2u'\f1\s10\&rnews\f1\s0\h'-\w'\f1\s10\&rnews\f1\s0'u/2u'
  458. X.sp -1
  459. X\h'0.839i'\v'0.669i'\D'e0.918i 0.300i'
  460. X.sp -1
  461. X\h'0.499i'\v'1.977i'\D'e1.577i 0.419i'
  462. X.sp -1
  463. X\h'5.062i'\v'1.857i'\v'.2m'\h'-\w'\f1\s10\&match #3 I\f1\s0'u/2u'\f1\s10\&match #3 I\f1\s0\h'-\w'\f1\s10\&match #3 I\f1\s0'u/2u'
  464. X.sp -1
  465. X\h'5.181i'\v'1.977i'\v'.2m'\h'-\w'\f1\s10\&rnews to.utzoo/ihave\f1\s0'u/2u'\f1\s10\&rnews to.utzoo/ihave\f1\s0\h'-\w'\f1\s10\&rnews to.utzoo/ihave\f1\s0'u/2u'
  466. X.sp -1
  467. X\h'5.111i'\v'1.647i'\v'.2m'\h'-\w'\f1\s10\&ihave processing\f1\s0'u/2u'\f1\s10\&ihave processing\f1\s0\h'-\w'\f1\s10\&ihave processing\f1\s0'u/2u'
  468. X.sp -1
  469. X\h'1.438i'\v'3.245i'\v'.2m'\h'-\w'\f1\s10\&sendme processing\f1\s0'u/2u'\f1\s10\&sendme processing\f1\s0\h'-\w'\f1\s10\&sendme processing\f1\s0'u/2u'
  470. X.sp -1
  471. X.sp 1+5.082i
  472. X.PE
  473. X.if \n(00 .fi
  474. X.lf 71
  475. !
  476. echo 'notebook/ctlmsg':
  477. sed 's/^X//' >'notebook/ctlmsg' <<'!'
  478. X.TL
  479. XControl Message Implementation in C News
  480. X.AU
  481. XGeoff Collyer
  482. X.AI
  483. XDepartment of Statistics
  484. XUniversity of Toronto
  485. X.SH
  486. XIntroduction
  487. X.PP
  488. XNetnews
  489. X.I "control messages"
  490. Xare ordinary-looking netnews articles which contain the
  491. Xspecial header
  492. X.B "Control:" .
  493. XSuch articles are filed in the pseudo-newsgroup
  494. X.I control
  495. Xand cause related actions by the local news system,
  496. Xsuch as mailing a file to the poster of the control message.
  497. X.SH
  498. XBuilt-ins
  499. X.PP
  500. X.B ihave ,
  501. X.B sendme ,
  502. Xand
  503. X.B cancel
  504. Xare handled internally by
  505. X.I relaynews ,
  506. Xbecause processes cannot share open
  507. X.I dbm (3)
  508. Xdatabases,
  509. Xthere is no standard way to close them,
  510. Xand
  511. Xthese control messages read or write the
  512. X.I history
  513. Xfiles,
  514. Xincluding the
  515. X.I dbm
  516. Xfiles.
  517. X.I Ihave
  518. Xand
  519. X.I sendme
  520. Xare also permitted to have message-id arguments containing
  521. X.B <
  522. Xand
  523. X.B > ,
  524. Xboth of which are rejected by
  525. X.I relaynews
  526. Xin arguments to externally-implemented control messages,
  527. Xsince they are shell metacharacters
  528. X(\c
  529. X.B /
  530. Xand
  531. X.B ..
  532. Xare also bounced)
  533. Xand could be indicative of an attempt to
  534. Xdo something nasty.
  535. X.SH
  536. XNormal Control Messages
  537. X.PP
  538. XMost control messages are implemented by
  539. X.I relaynews
  540. Xby executing the command following
  541. X.B Control: ,
  542. Xwith a search path of
  543. X.I $NEWSCTL/bin:$NEWSBIN/ctl
  544. Xand with standard input set to
  545. Xthe control message article.
  546. XThe command inherits
  547. X.I relaynews 's
  548. Xuser and group ids,
  549. Xtypically
  550. X.I news ;
  551. Xthis can be important
  552. Xto gain access rights to control files.
  553. XThe news system will be locked
  554. X(by
  555. X.I $NEWSCTL /lock)
  556. Xwhile the command runs,
  557. Xbecause
  558. Xthis is often important
  559. Xfor manipulating control files
  560. Xfrom the command,
  561. Xand
  562. Xbecause
  563. Xthe news system is locked
  564. Xwhile
  565. X.I relaynews
  566. Xruns.
  567. XIf that command returns non-zero exit status,
  568. Xmail is sent to
  569. X.I $NEWSMASTER
  570. X(usually
  571. X.B usenet ).
  572. XStandard output and standard error
  573. Xoften are redirected to
  574. X.I $NEWSCTL /log
  575. Xand
  576. X.I $NEWSCTL /errlog
  577. Xrespectively;
  578. Xinvocations of
  579. X.I relaynews
  580. Xby
  581. X.I inews
  582. Xare exceptions.
  583. !
  584. echo 'notebook/ctlfiles':
  585. sed 's/^X//' >'notebook/ctlfiles' <<'!'
  586. X.DA "9 June 1989"
  587. X.TL
  588. XFiles in /usr/lib/news (aka NEWSCTL)
  589. X.AU
  590. XHenry Spencer
  591. X.AI
  592. XDept. of Zoology
  593. XUniversity of Toronto
  594. X.LP
  595. XThe following files can appear in \fI/usr/lib/news\fR (or wherever the
  596. Xsite's ``NEWSCTL''
  597. Xdirectory\(emsee \fIDirectory Layout and PATH in C News\fR\(emis).
  598. XThere may be others for the sake of local news readers, etc., but these
  599. Xare the ones C News knows about.
  600. X.IP "active" 15
  601. XMajor control file:
  602. Xlist of newsgroups recognized at this site, including current maximum
  603. Xand minimum article numbers and moderation status.
  604. XUpdated by \fIrelaynews\fR and \fIupact\fR.
  605. X.IP "active.old"
  606. XPrevious \fIactive\fR.
  607. XCreated by \fIupact\fR.
  608. X.IP "active.times"
  609. XList of created newsgroups and when they were created, aimed at making it
  610. Xpossible for news readers to be smarter about knowing when a group is new.
  611. XNot yet supported by standard news readers.
  612. X.IP "batchlog"
  613. XLatest batcher log, created by \fIsendbatches\fR,
  614. Xshowing backlogs.
  615. X.IP "batchlog.o*"
  616. XPrevious batcher logs.
  617. X.IP "batchparms"
  618. XControl file for \fIsendbatches\fR, specifying how to feed other sites.
  619. X.IP "bin"
  620. XMaster override directory for programs, searched before any other by
  621. Xall C News software.
  622. XNormally contains only the \fIconfig\fR shell file
  623. Xspecifying where to find everything else.
  624. X.IP "errlog"
  625. XError log from \fIrelaynews\fR.
  626. X.IP "errlog.o*"
  627. XPrevious \fIerrlog\fRs.
  628. X.IP "explist"
  629. XControl file for \fIexpire\fR, specifying what gets expired, and when,
  630. Xand what archiving is done.
  631. X.IP "history"
  632. XList of articles currently known at this site, with reception dates and
  633. Xpathnames.
  634. XUpdated by \fIrelaynews\fR and \fIexpire\fR.
  635. X.IP "history.dir"
  636. XPart of the \fIdbm\fR index for \fIhistory\fR.
  637. X.IP "history.pag"
  638. XOther part of the \fIdbm\fR index for \fIhistory\fR.
  639. X.IP "history.o"
  640. XPrevious \fIhistory\fR.
  641. XCreated by \fIexpire\fR.
  642. X.IP "localgroups"
  643. XList of local groups and descriptions, for use by \fIcheckgroups\fR
  644. Xcontrol-message handler (which uses it to decide what groups are
  645. Xlegitimate even though the \fIcheckgroups\fR message did not mention them).
  646. XEach line is a group name, a tab, and a terse description of the group.
  647. XThe descriptions are read only by humans.
  648. X.IP "log"
  649. XLog file from \fIrelaynews\fR, reporting what was received and when.
  650. X.IP "log.o*"
  651. XPrevious \fIlog\fRs.
  652. X.IP "mailname"
  653. XName of the site for purposes of mail, typically a domainized name.
  654. XUsed in building ``From:'' lines in newly-posted news.
  655. XIf not present,
  656. X``\fIhostname\fB.uucp\fR'' is assumed.
  657. X.IP "mailpaths"
  658. XMailing routes for submissions to moderated newsgroups.
  659. X.IP "newsgroups"
  660. XFile created by \fIcheckgroups\fR processing, with names and descriptions
  661. Xof newsgroups.
  662. XFor human reading only.
  663. XFormat identical to that of \fIlocalgroups\fR.
  664. X.IP "newsgroups.bac"
  665. XPrevious \fInewsgroups\fR file.
  666. XCreated by \fIcheckgroups\fR processing.
  667. X.IP "organization"
  668. XName of the organization,
  669. Xfor \fIinews\fR's use in creating the \fIOrganization:\fR header
  670. Xfor a posted article.
  671. X.IP "postdefltdist"
  672. XDefault distribution (if any; default ``world'') for \fIpostnews\fR.
  673. X.IP "postdefltgroup"
  674. XDefault newsgroup (if any; default is to insist on the user supplying one)
  675. Xfor \fIpostnews\fR.
  676. X.IP "replyusepath"
  677. XThis file should exist if and only if the local ``mail'' command is
  678. Xunable to handle `@' addresses,
  679. Xmeaning that replies to control messages (etc.) must use the ``Path:''
  680. Xline instead of ``From:''.
  681. XThe contents are ignored.
  682. X.IP "server"
  683. XHost name of the news server, where all operations (posting, etc.)
  684. Xshould be done.
  685. XIf file does not exist, current host is assumed.
  686. X.IP "setnewsids"
  687. XSet-uid-root program to get user and group ids correct for \fIrelaynews\fR.
  688. XNeeded only
  689. Xif the system is old enough to refuse to do \fIsetuid(geteuid())\fR.
  690. XIncluded in NEWSCTL rather than NEWSBIN because its presence is a significant
  691. Xpolicy issue for the administrator, i.e. it is, sort of, a control file.
  692. X.IP "sys"
  693. XMajor control file specifying what groups are legitimate here, and what groups
  694. Xare fed to other sites.
  695. X.IP "watchtime"
  696. XLast time \fInewswatch\fR was run.
  697. X.IP "whoami"
  698. XName of the system for news purposes, for \fInewshostname\fR.
  699. XIf file does not exist,
  700. Xother sources (\fIhostname\fR etc.) are consulted.
  701. !
  702. echo 'notebook/flow':
  703. sed 's/^X//' >'notebook/flow' <<'!'
  704. XThe flow of news articles through C news is as follows:
  705. Xa batch is received by some network service and passed to rnews,
  706. Xwhich invokes $NEWSBIN/input/newsspool to queue the batch in $NEWSARTS/in.coming;
  707. Xeventually $NEWSBIN/input/newsrun will be run by cron,
  708. Xit uncompresses any files in.coming and
  709. Xeither hands the article to $NEWBIN/relay/relaynews locally or invokes
  710. Xrelaynews over a network connection on its file server.
  711. X
  712. Xrelaynews writes the name of each spool file onto the ends of batch files
  713. Xfor neighbours.  Eventually cron runs $NEWSBIN/batch/sendbatches, which
  714. Xbatches up the outgoing articles and transmits them over some network.
  715. !
  716. echo 'notebook/vms':
  717. sed 's/^X//' >'notebook/vms' <<'!'
  718. X.DA "27 May 1989"
  719. X.TL
  720. XC News vs. VMS
  721. X.AU
  722. XHenry Spencer
  723. X.AI
  724. XDept. of Zoology
  725. XUniversity of Toronto
  726. X.PP
  727. XTo run C News at all, you need a fairly good emulation of Unix.
  728. XThere are several such for VMS.
  729. XThey have various minor imperfections.
  730. XThe only one we specifically \fIknow\fR of that is a real problem for
  731. XC News is the inability to make real links for cross-postings.
  732. XThere is some half-hearted code in various places that tries to deal
  733. Xwith this situation.
  734. XIt has \fInot\fR been tested too thoroughly.
  735. X.PP
  736. X\fIRelaynews\fR normally files an article under its first group and then
  737. Xmakes hard links into further groups.
  738. XIf \fIrelaynews\fR finds itself unable to make a hard link,
  739. Xit will try making a symbolic link instead.
  740. XThe one situation where this will fall down is if a news article's header
  741. Xis enormous, too big to fit in core.
  742. XIn this case, \fIrelaynews\fR stores the article in a temporary file,
  743. Xmakes links to it under all the appropriate names, and then unlinks the
  744. Xtemporary name.
  745. XThis obviously isn't going to work if the appropriate-name links are symbolic.
  746. XWe believe this case essentially never happens on large-address-space
  747. Xmachines, and is quite rare even for small address spaces.
  748. X.PP
  749. X\fIExpire\fR has a \fB\-l\fR option that tells it to consider the first
  750. Xname of an article as the ``leader'', not to be deleted until all others
  751. Xhave been deleted.
  752. X.PP
  753. XThe one place where extra work would be necessary would be \fImkhistory\fR,
  754. Xwhich has no notion that some links are different from others.
  755. X.PP
  756. XSo far as we know, we don't get into any of the other trouble areas of
  757. XUnix emulation on VMS, at least with the Eunice emulator.
  758. XWe don't have a VMS handy for testing,
  759. Xso we make no guarantees.
  760. !
  761. echo 'notebook/rfcerrata':
  762. sed 's/^X//' >'notebook/rfcerrata' <<'!'
  763. X.TL
  764. XErrors in RFC 1036
  765. X.AU
  766. XGeoff Collyer
  767. X.AI
  768. XDepartment of Statistics
  769. XUniversity of Toronto
  770. X.SH
  771. XIntroduction
  772. X.PP
  773. XRFC 1036,
  774. Xthe standard
  775. X.I "du jour"
  776. Xfor the format of Usenet (netnews) messages
  777. Xcontains significant errors,
  778. Xenumerated below.
  779. XReferences are made to
  780. XRFC 850,
  781. Xthe previous netnews message format standard.
  782. X.SH
  783. XHeader order insignificant
  784. X.PP
  785. XBetween
  786. XRFC 850
  787. Xand
  788. XRFC 1036,
  789. Xa sentence stating that the order of message headers is insignificant
  790. Xhas fallen out of the standard.
  791. XThis may be a reflection of the reality that
  792. XB 2.10
  793. Xnews did indeed care about the order
  794. Xof
  795. X.B From:
  796. Xand
  797. X.B Path: .
  798. X.SH
  799. X``Re:'' is only three characters
  800. X.PP
  801. XOne sees the contradiction
  802. X``the four characters "Re:"''
  803. Xrepeatedly;
  804. Xthere should be a space after the colon.
  805. X.SH
  806. Xcmsg incorrectly described
  807. X.PP
  808. XSimilary,
  809. XRFC 1036
  810. Xclaims that a
  811. X.B Subject:
  812. Xprefix of
  813. X``cmsg''
  814. Xwill be interpreted as denoting a control message;
  815. Xthe correct prefix is
  816. X``cmsg\ ''
  817. X(including a space).
  818. X.SH
  819. XXref is transmitted
  820. X.PP
  821. XRFC 1036
  822. Xsays that
  823. X.B Xref:
  824. Xheaders should not be transmitted,
  825. Xyet they are stored on disk as part of message headers,
  826. Xso they will be transmitted by both B and C news.
  827. XThe standard appears to be too strict.
  828. X.SH
  829. Xcancels should propagate always
  830. X.PP
  831. XRFC 1036
  832. Xclaims that
  833. X.I cancel
  834. Xcontrol messages should stop propagating when their target messages
  835. Xare not present;
  836. Xit would improve the efficacy of
  837. X.I cancel s
  838. Xto propagate them anyway.
  839. X.SH
  840. Xihave/sendme not documented
  841. X.PP
  842. XThe description of the ihave/sendme protocol is so vague
  843. Xas to be useless to an implementor.
  844. XSee the
  845. XC news
  846. Xdocumentation for an adequate description of the protocol.
  847. XThe description in
  848. XRFC 1036
  849. Xalso contains an error:
  850. X.I remotesys
  851. Xis not optional;
  852. Xgiven that there may be multiple message-ids preceding it,
  853. Xthere would be no way
  854. X(other than ad-hocery)
  855. Xto tell if the final argument were a message-id
  856. Xor a
  857. X.I remotesys .
  858. !
  859. echo 'notebook/README':
  860. sed 's/^X//' >'notebook/README' <<'!'
  861. XThis directory is the C News Implementor's Notebook, containing various
  862. Xinternal documents describing what goes on inside.  These should be read
  863. Xcautiously, as some of them may not be 100% up to date, although we've
  864. Xtried to keep them current.
  865. X
  866. XMost everything here is set up for the -ms macros, although very little
  867. Xfancy formatting is used in general.  The standard R, I, and B are the
  868. Xonly fonts used.  Conversion to another macro package should not be hard.
  869. X
  870. XIhave.pic.in is an illustration for ihave; ihave.pic is what you get after
  871. Xyou run ihave.pic.in through pic (in case you have a troff that knows about
  872. Xthe graphics commands but don't have pic); tmac.pic is extra macros for
  873. Xuse in troffing pic stuff.
  874. X
  875. XConfig and newslock need tbl.  Nothing here uses eqn.
  876. !
  877. echo 'notebook/ihave':
  878. sed 's/^X//' >'notebook/ihave' <<'!'
  879. X.TL
  880. XSetting Up Netnews Feeds Using the Ihave/sendme Protocol
  881. X.AU
  882. XGeoff Collyer
  883. X.AI
  884. XDepartment of Statistics
  885. XUniversity of Toronto
  886. X.SH
  887. XIntroduction
  888. X.PP
  889. XThe ihave/sendme protocol is a means of conserving network bandwidth
  890. Xat the expense of some real-time delays in getting netnews.
  891. XIt pre-dates the NetNews Transfer Protocol (NNTP)
  892. Xfor the TCP/IP protocol stack by several years and attempts much
  893. Xthe same optimisation,
  894. Xbut ihave/sendme is batched,
  895. Xunlike NNTP.
  896. X.PP
  897. XIhave/sendme
  898. Xis sketched in extremely vague terms in
  899. XARPA Internet RFC 1036 (nee 850),
  900. Xbut the description therein is so lofty as
  901. Xto be useless as a protocol specification.
  902. X.SH
  903. XInto the Breach
  904. X.PP
  905. XThe ihave/sendme strategy is for a site which has just received a new
  906. Xnetnews article to send an
  907. X.I ihave
  908. Xnetnews control message
  909. Xcontaining the Message-ID of the new article to each
  910. Xof its ihave/sendme
  911. Xneighbours;
  912. Xthe neighbour consults its netnews
  913. X.I history
  914. Xfile and if it has not seen the article,
  915. Xsends back a
  916. X.I sendme
  917. Xcontrol message containing the original Message-ID;
  918. Xupon receipt of the
  919. X.I sendme ,
  920. Xthe first site will transmit the article via normal channels
  921. Xto the requesting neighbour.
  922. X.PP
  923. XDue to the high volume of netnews,
  924. Xsending individual articles is always a performance disaster
  925. X(see B News,
  926. XNNTP and unbatched ihave/sendme),
  927. Xso the golden rule of netnews is
  928. X``Thou shalt batch thine articles.''.
  929. XThis makes the above sketch a little slower and more complicated:
  930. Xnow individual articles are not sent,
  931. Xbut batches of
  932. X.I ihave ,
  933. X.I sendme ,
  934. Xand
  935. Xnetnews messages are transmitted,
  936. Xincurring further delay since netnews batchers are usually
  937. Xrun only once per hour,
  938. Xsay.
  939. X.PP
  940. XTo permit
  941. X.I sys
  942. Xfile entries to distinguish
  943. X.I ihave s
  944. Xfrom
  945. X.I sendme s
  946. Xfrom
  947. Xordinary netnews traffic,
  948. Xtwo distributions have been usurped for use by ihave/sendme links:
  949. X.I ihave
  950. Xand
  951. X.I sendme .
  952. XWhen
  953. X.I relaynews
  954. Xis processing a control message of the form
  955. X.DS
  956. XControl: keyword system
  957. X.DE
  958. Xwhere
  959. X.I keyword
  960. Xmay be
  961. X.I ihave
  962. Xor
  963. X.I sendme ,
  964. X.I relaynews
  965. Xgenerates a reply
  966. Xby finding the
  967. X.I sys
  968. Xfile line that will match a newsgroup of
  969. X.B to. system
  970. Xand a distribution of
  971. X.B ihave
  972. X(or
  973. X.B sendme
  974. Xas appropriate),
  975. Xand sending its reply
  976. X(a
  977. X.I sendme
  978. Xcontrol in the case of
  979. X.I ihave,
  980. Xor ordinary articles in the case of
  981. X.I sendme )
  982. Xto the matched channel.
  983. X.PP
  984. XWe will now walk through an example ihave/sendme set up between
  985. Xtwo C news sites
  986. X(\c
  987. X.I utzoo
  988. Xand
  989. X.I utstat ),
  990. Xwith reference to the following
  991. X.I sys
  992. Xfile fragments and flow diagram.
  993. X.br
  994. X.ne 2i
  995. X.SH
  996. Xutzoo's sys file
  997. X.LP
  998. X.DS L
  999. X.ft B
  1000. X# for testing ihave/sendme control messages: an ihave/sendme link with utstat.
  1001. X# batcher turns batch file -> giant ihave control message & posts to to.utstat (#1)
  1002. Xutstat:rec.music.synth/all,!sendme,!ihave:I:utstat.ihave/togo
  1003. X# sends ihave & sendme messages via normal batching (or uux) (#2, #4)
  1004. Xutstat-ctl:to.utstat/all,!sendme,!ihave:f:utstat/togo
  1005. X# batcher turns batch file -> giant sendme control message & posts to to.utstat (#3)
  1006. Xutstat-send-ids:to.utstat/ihave:I:utstat.sendme/togo
  1007. X# final sending of the articles themselves (#5) (optional; can share with #2 & #4)
  1008. Xutstat-real:to.utstat/sendme:f:utstat/togo
  1009. X.ft R
  1010. X.DE
  1011. X.br
  1012. X.ne 2i
  1013. X.SH
  1014. Xutstat's sys file
  1015. X.LP
  1016. X.DS L
  1017. X.ft B
  1018. X# for testing ihave/sendme control messages: an ihave/sendme link with utzoo.
  1019. X# batcher turns batch file -> giant ihave control message & posts to to.utzoo (#1)
  1020. Xutzoo:rec.music.synth/all,!sendme,!ihave:I:utzoo.ihave/togo
  1021. X# sends ihave & sendme messages via normal batching (or uux) (#2, #4)
  1022. Xutzoo-ctl:to.utzoo/all,!sendme,!ihave:f:utzoo/togo
  1023. X# batcher turns batch file -> giant sendme control message & posts to to.utzoo (#3)
  1024. Xutzoo-send-ids:to.utzoo/ihave:I:utzoo.sendme/togo
  1025. X# final sending of the articles themselves (#5) (optional; can share with #2 & #4)
  1026. Xutzoo-real:to.utzoo/sendme:f:utzoo/togo
  1027. X.ft R
  1028. X.DE
  1029. X.so ihave.pic
  1030. X.SH
  1031. XAn Example
  1032. X.PP
  1033. XA new article arrives on
  1034. X.I utzoo
  1035. Xin newsgroup
  1036. X.I rec.music.synth
  1037. Xand is matched by
  1038. X.I sys
  1039. Xfile line
  1040. X.B "#1 on utzoo" ,
  1041. Xwhich writes the Message-ID of the article
  1042. Xonto a batch file
  1043. X(\c
  1044. X.I $NEWSARTS/out.going/utstat.ihave/togo ).
  1045. XThere are some subtleties here:
  1046. Xit would be essential to add
  1047. X.B ,!to
  1048. Xto #1's subscription list
  1049. Xif that list contained
  1050. X.B all
  1051. Xor
  1052. X.B to
  1053. Xto prevent leaking messages intended for the other
  1054. X.I sys
  1055. Xentries out #1;
  1056. Xand
  1057. Xit is always worthwhile to prevent leaking local
  1058. Xnewsgroups out one's full feeds,
  1059. Xso if #1's subscription list contained
  1060. X.B all
  1061. Xone would want to add something like
  1062. X.B ,!general
  1063. Xor
  1064. X.B ,!utstat .
  1065. XSome time later,
  1066. Xthe batcher runs on #1's batch file.
  1067. X.PP
  1068. XThe batcher on
  1069. X.I utzoo
  1070. Xprepares
  1071. Xa batch of Message-IDs as an
  1072. X.I ihave
  1073. Xcontrol message to
  1074. X.I utstat
  1075. Xand submits it to
  1076. X.I "inews -h" ,
  1077. Xwhich will match
  1078. X.I sys
  1079. Xfile line
  1080. X.B "#2 on utzoo" ,
  1081. Xwhich will typically write the file name of the
  1082. Xcontrol message
  1083. X(in the
  1084. X.I control
  1085. Xpseudo-newsgroup)
  1086. Xon the usual
  1087. X.I utstat
  1088. Xbatch file
  1089. X(\c
  1090. X.I $NEWSARTS/out.going/utstat/togo ).
  1091. X(For greater speed,
  1092. Xone can have the #2
  1093. X.I sys
  1094. Xfile line simply execute
  1095. X.I uux (1)
  1096. Xor
  1097. X.I mail (1)
  1098. Xbut this can result is a lot of short batches being sent,
  1099. Xwhich will increase
  1100. X.I rnews
  1101. Xprocessing overhead on
  1102. X.I utstat .)
  1103. X.PP
  1104. XSome time later,
  1105. Xthe batcher will run on
  1106. X.I utzoo
  1107. Xon the usual
  1108. X.I utstat
  1109. Xbatch file
  1110. Xand will produce batches,
  1111. Xincluding the
  1112. X.I ihave
  1113. Xcontrol message,
  1114. Xand transmit them to
  1115. X.I utstat
  1116. Xby means specified in
  1117. X.I $NEWSCTL/batchparms .
  1118. X.PP
  1119. XWhen the
  1120. X.I ihave
  1121. Xcontrol message arrives on
  1122. X.I utstat ,
  1123. Xit will match
  1124. X.I sys
  1125. Xfile line
  1126. X.B "#3 on utstat"
  1127. Xand have its Message-ID
  1128. Xwritten on the
  1129. X.I utzoo
  1130. X.I sendme
  1131. Xbatch file
  1132. X(\c
  1133. X.I $NEWSARTS/out.going/utzoo.sendme/togo ).
  1134. X.PP
  1135. XSome time later,
  1136. Xthe batcher will run on
  1137. X.I utstat
  1138. Xon that batch file,
  1139. Xwhich will produce a
  1140. X.I sendme
  1141. Xcontrol message
  1142. Xand submit it to
  1143. X.I "inews -h" ,
  1144. Xwhich will match
  1145. X.I sys
  1146. Xfile line
  1147. X.B "#4 on utstat" ,
  1148. Xwhich will write the name of the
  1149. X.I sendme
  1150. Xcontrol message in the
  1151. X.I control
  1152. Xpseudo-newsgroup on
  1153. Xthe usual
  1154. X.I utzoo
  1155. Xbatch file
  1156. X(\c
  1157. X.I $NEWSARTS/out.going/utzoo/togo)
  1158. X.PP
  1159. XSome time later,
  1160. Xthe batcher will run on
  1161. X.I utstat
  1162. Xon the usual
  1163. X.I utzoo
  1164. Xbatch file,
  1165. Xand will produce batches including
  1166. Xthe
  1167. X.I sendme
  1168. Xand send them to
  1169. X.I utzoo
  1170. Xby means specified in
  1171. X.I $NEWSCTL/batchparms .
  1172. X.PP
  1173. XWhen the
  1174. X.I sendme
  1175. Xcontrol message arrives on
  1176. X.I utzoo ,
  1177. Xit is matched by
  1178. X.I sys
  1179. Xfile line
  1180. X.B "#5 on utzoo" ,
  1181. Xwhich writes the file names of the articles
  1182. Xnamed by Message-ID in
  1183. Xthe
  1184. X.I sendme
  1185. Xcontrol message
  1186. Xon the usual
  1187. X.I utstat
  1188. Xbatch file.
  1189. X.PP
  1190. XSome time later,
  1191. Xthe batcher on
  1192. X.I utzoo
  1193. Xwill run and produce batches,
  1194. Xincluding the articles requested by the
  1195. X.I sendme ,
  1196. Xand will send them to
  1197. X.I utstat
  1198. Xby means specified in
  1199. X.I $NEWSCTL/batchparms .
  1200. X.SH
  1201. XComparison with B News
  1202. X.PP
  1203. XThere is a lot of activity involved in ihave/sendme,
  1204. Xand there are at least five distinct channels
  1205. Xand three transactions needed to send a batch of articles.
  1206. XB news ``simplifies'' the
  1207. X.I sys
  1208. Xfile by requiring certain
  1209. X.I sys
  1210. Xfile options (sic)
  1211. Xto be set to fixed values,
  1212. Xand
  1213. Xby overloading madly.
  1214. XThe resulting
  1215. X.I sys
  1216. Xfile
  1217. X.I is
  1218. Xshorter,
  1219. Xbut it is also much more difficult to decypher,
  1220. Xand if you should want to specify non-default options,
  1221. Xyou are out of luck.
  1222. !
  1223. echo 'notebook/ihave.pic.in':
  1224. sed 's/^X//' >'notebook/ihave.pic.in' <<'!'
  1225. X.LP
  1226. X.PS 6
  1227. Xscale=100
  1228. Xbox invis ht 509 wid 601 with .sw at 0,0
  1229. Xline -> from 174,21 to 512,24 
  1230. X"\f1\s10\&articles\f1\s0" at 328,32
  1231. X"\f1\s10\&\f1\s0" at 505,292
  1232. X"\f1\s10\&\f1\s0" at 544,457
  1233. X"\f3\s14\&ihave/sendme processing diagram\f1\s0" at 332,499
  1234. X"\f3\s10\&utzoo\f1\s0" at 135,469
  1235. Xellipse ht 40 wid 182 at 510,316
  1236. X"\f3\s10\&utstat\f1\s0" at 510,469
  1237. X"\f1\s10\&article\f1\s0" at 21,440
  1238. Xline -> from 37,440 to 83,440 
  1239. X"\f1\s10\&match #1 I\f1\s0" at 129,445
  1240. Xbox ht 35 wid 96 with .nw at 76,399 
  1241. X"\f1\s10\&batcher on\f1\s0" at 129,388
  1242. X"\f1\s10\&msgid file\f1\s0" at 129,377
  1243. Xspline -> from 455,88\
  1244. Xto 432,88\
  1245. Xto 408,120\
  1246. Xto 392,144\
  1247. Xto 384,152
  1248. Xline -> from 511,127 to 519,112 
  1249. Xspline -> from 192,240\
  1250. Xto 208,240\
  1251. Xto 216,280\
  1252. Xto 232,304\
  1253. Xto 240,312
  1254. Xline -> from 129,290 to 128,264 
  1255. Xline -> from 124,364 to 129,334 
  1256. X"\f1\s10\&(deadlock avoidance)\f1\s0" at 132,349
  1257. Xellipse ht 48 wid 202 at 136,152
  1258. Xline -> from 510,213 to 511,175 
  1259. X"\f1\s10\&(deadlock avoidance)\f1\s0" at 512,192
  1260. X"\f1\s10\&match #4 F or \(es\f1\s0" at 510,156
  1261. X"\f1\s10\&batcher on\f1\s0" at 512,96
  1262. X"\f1\s10\&filenames (opt.)\f1\s0" at 520,80
  1263. Xline -> from 208,311 to 419,316 
  1264. Xline -> from 510,296 to 510,246 
  1265. X"\f1\s10\&ihave control\f1\s0" at 322,322
  1266. X"\f1\s10\&sendme control\f1\s0" at 320,160
  1267. X"\f1\s10\&inews to.utzoo\f1\s0" at 511,143
  1268. X"\f1\s10\&match #2 F or \(es\f1\s0" at 129,315
  1269. X"\f1\s10\&inews to.utstat\f1\s0" at 129,303
  1270. X"\f1\s10\&\f1\s0" at 322,401
  1271. Xline <- from 125,401 to 130,427 
  1272. Xbox ht 40 wid 91 with .nw at 81,40 
  1273. X"\f1\s10\&batcher on\f1\s0" at 129,30
  1274. X"\f1\s10\&filenames\f1\s0" at 128,15
  1275. Xline -> from 128,128 to 126,40 
  1276. Xline -> from 422,151 to 237,152 
  1277. X"\f1\s10\&match #5 F\f1\s0" at 136,160
  1278. Xellipse ht 48 wid 178 at 511,151
  1279. X"\f1\s10\&rnews to.utstat/sendme\f1\s0" at 136,144
  1280. Xbox ht 33 wid 91 with .nw at 465,246 
  1281. X"\f1\s10\&batcher on\f1\s0" at 505,235
  1282. X"\f1\s10\&msgid file\f1\s0" at 505,224
  1283. X"\f1\s10\&batcher on\f1\s0" at 123,246
  1284. X"\f1\s10\&filenames (opt.)\f1\s0" at 129,235
  1285. Xbox ht 48 wid 128 with .nw at 455,112 
  1286. Xbox ht 48 wid 128 with .nw at 64,264 
  1287. X"\f1\s10\&rnews\f1\s0" at 130,436
  1288. Xellipse ht 30 wid 92 at 130,442
  1289. Xellipse ht 42 wid 158 at 129,311
  1290. X"\f1\s10\&match #3 I\f1\s0" at 507,323
  1291. X"\f1\s10\&rnews to.utzoo/ihave\f1\s0" at 519,311
  1292. X"\f1\s10\&ihave processing\f1\s0" at 512,344
  1293. X"\f1\s10\&sendme processing\f1\s0" at 144,184
  1294. X.PE
  1295. !
  1296. echo 'notebook/tmac.pic':
  1297. sed 's/^X//' >'notebook/tmac.pic' <<'!'
  1298. X.de PS    \" start picture (bwk)
  1299. X.    \" $1 is height, $2 is width in units
  1300. X.if t .sp .3
  1301. X.in (\\n(.lu-\\$2)/2u
  1302. X.ne \\$1
  1303. X..
  1304. X.de PE    \" end of picture
  1305. X.in
  1306. X.if t .sp .6
  1307. X..
  1308. !
  1309. echo 'batch/README':
  1310. sed 's/^X//' >'batch/README' <<'!'
  1311. XThis is C News output batching.
  1312. X
  1313. XThe bencode stuff (including bdecode.c, which is over in ../input) may be
  1314. Xworth installing as separate programs in a public directory.  crctab.c and
  1315. Xcoder.h are parts of it.
  1316. X
  1317. X"make r" runs a moderately thorough regression test.
  1318. !
  1319. echo 'batch/Makefile':
  1320. sed 's/^X//' >'batch/Makefile' <<'!'
  1321. X# Configuration stuff.
  1322. XCOPTS=-O
  1323. XCFLAGS=$(COPTS) -I../include
  1324. XLDFLAGS=
  1325. XLIBS=../libcnews.a
  1326. X# =()<NEWSARTS = @<NEWSARTS>@>()=
  1327. XNEWSARTS = /usr/spool/news
  1328. X# =()<NEWSBIN = @<NEWSBIN>@>()=
  1329. XNEWSBIN = /usr/lib/newsbin
  1330. X# =()<NEWSCTL = @<NEWSCTL>@>()=
  1331. XNEWSCTL = /usr/lib/news
  1332. X# workaround for System V make bug
  1333. XSHELL = /bin/sh
  1334. X
  1335. XOUTGOING = $(NEWSARTS)/out.going
  1336. XPGMDIR = $(NEWSBIN)/batch
  1337. X
  1338. XPGMS=batcher batchih batchsm batchsplit comp compcun nocomp viainews viauux \
  1339. X    sendbatches compc7 c7encode viamail viapmail bencode compb
  1340. XDTR=Makefile batcher.c batchih batchsplit c7encode.c comp compc7 compcun \
  1341. X    newsbatch.8 nocomp sendbatches viainews viauux viamail \
  1342. X    bencode.c coder.h crctab.c compb viapmail
  1343. XALL = $(PGMS) batchparms
  1344. X
  1345. Xall:    $(ALL)
  1346. X    chmod +x $(PGMS)
  1347. X
  1348. Xbatcher:    batcher.o $(LIBS)
  1349. X    $(CC) $(CFLAGS) $(LDFLAGS) batcher.o $(LIBS) -o $@
  1350. X
  1351. Xc7encode:    c7encode.o $(LIBS)
  1352. X    $(CC) $(CFLAGS) $(LDFLAGS) c7encode.o $(LIBS) -o $@
  1353. X
  1354. Xbencode:    bencode.o crctab.o $(LIBS)
  1355. X    $(CC) $(CFLAGS) bencode.o crctab.o $(LIBS) -o $@
  1356. X
  1357. Xbencode.o:    coder.h
  1358. X
  1359. Xbininstall:    all
  1360. X    -if test ! -d $(PGMDIR) ; then mkdir $(PGMDIR) ; fi
  1361. X    cp $(PGMS) $(PGMDIR)
  1362. X
  1363. Xnewsinstall:    batchparms
  1364. X    -if test ! -d $(OUTGOING) ; then mkdir $(OUTGOING) ; fi
  1365. X    -if test ! -r $(NEWSCTL)/batchparms ; then cp batchparms $(NEWSCTL) ; fi
  1366. X
  1367. Xbatchparms:    Makefile
  1368. X    echo '# 100KB, after compress, is 10 minutes at 1200 baud' >$@
  1369. X    echo '# 20 batches is somewhat arbitrary, about 1MB per site' >>$@
  1370. X    echo '# defaults:  2.11-compatible compression, transfer by uux' >>$@
  1371. X    echo '#' >>$@
  1372. X    echo '# site        size    queue    builder    muncher    sender' >>$@
  1373. X    echo '# ----        ----    -----    -------    -------    ------' >>$@
  1374. X    echo '/default/    100000    20    batcher    compcun    viauux' >>$@
  1375. X    echo '#' >>$@
  1376. X    echo '# sample ihave/sendme setup' >>$@
  1377. X    echo 'louie.ihave    100000    20    batchih    nocomp    viainews' >>$@
  1378. X    echo 'louie.sendme    100000    20    batchsm    nocomp    viainews' >>$@
  1379. X
  1380. Xbatchsm:    batchih
  1381. X    sed 's/ihave/sendme/g' batchih >$@
  1382. X
  1383. Xtest.1:
  1384. X    echo 'a test' >$@
  1385. X
  1386. Xtest.2:
  1387. X    echo 'another test' >$@
  1388. X
  1389. Xtest.3:
  1390. X    cat batcher.c batcher.c batcher.c batcher.c batcher.c >$@
  1391. X
  1392. Xr:    all test.1 test.2 test.3
  1393. X    echo a 1 >togo
  1394. X    echo b 1 >>togo
  1395. X    echo c 1 >>togo
  1396. X    echo d 1 >>togo
  1397. X    echo e 1 >>togo
  1398. X    echo f 1 >>togo
  1399. X    echo g 1 >>togo
  1400. X    echo h 3 >>togo
  1401. X    echo i 20 >>togo
  1402. X    echo j 999 >>togo
  1403. X    rm -rf bin
  1404. X    mkdir bin
  1405. X    echo 'ln $$* >/dev/null 2>/dev/null' >bin/newslock
  1406. X    echo 'cat' >bin/munch
  1407. X    echo '( echo --- ; cat ) >>output' >bin/xmit
  1408. X    echo 'echo 2 ; cat' >bin/munch2
  1409. X    echo '( echo +++ ; cat ) >>output' >bin/xmit2
  1410. X    echo 'echo 4' >bin/queuelen
  1411. X    echo 'echo 99' >bin/spacefor
  1412. X    ln batcher bin/batcher
  1413. X    ln batchsplit bin/batchsplit
  1414. X    chmod +x bin/*
  1415. X    NEWSCTL=`pwd` ./batchsplit 1
  1416. X    echo a 1 >test.good ; cmp test.good togo.1
  1417. X    echo b 1 >test.good ; cmp test.good togo.2
  1418. X    echo c 1 >test.good ; cmp test.good togo.3
  1419. X    echo d 1 >test.good ; cmp test.good togo.4
  1420. X    echo e 1 >test.good ; cmp test.good togo.5
  1421. X    echo f 1 >test.good ; cmp test.good togo.6
  1422. X    echo g 1 >test.good ; cmp test.good togo.7
  1423. X    echo h 3 >test.good ; echo i 20 >>test.good ; cmp test.good togo.next
  1424. X    echo j 999 >test.good ; cmp test.good togo
  1425. X    rm togo.*
  1426. X    echo `pwd`/test.1 >togo
  1427. X    echo ./test.2 >>togo
  1428. X    echo `pwd`/test.3 666 >>togo
  1429. X    ./batcher togo >test.out
  1430. X    echo "#! rnews `wc -c test.1 | awk '{print $$1}'`" >test.good
  1431. X    cat test.1 >>test.good
  1432. X    echo "#! rnews `wc -c test.2 | awk '{print $$1}'`" >>test.good
  1433. X    cat test.2 >>test.good
  1434. X    ( echo --- ; cat test.good ) >test.out1
  1435. X    ( echo +++ ; echo 2 ; cat test.good ) >test.out2
  1436. X    echo "#! rnews `wc -c test.3 | awk '{print $$1}'`" >test.temp
  1437. X    cat test.3 >>test.temp
  1438. X    cat test.temp >>test.good
  1439. X    ( echo --- ; cat test.temp ) >>test.out1
  1440. X    cmp test.good test.out
  1441. X    ./batcher -d `pwd` togo >test.out
  1442. X    cmp test.good test.out
  1443. X    rm test.out togo
  1444. X    rm -rf out.going batchparms test.out test.good
  1445. X    mkdir out.going out.going/foo out.going/bar
  1446. X    echo 'foo    500    10    batcher    munch    xmit' >batchparms
  1447. X    NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d >test.out
  1448. X    echo foo >test.good
  1449. X    cmp test.out test.good
  1450. X    echo '/default/    10000    5    batcher    munch2    xmit2' >>batchparms
  1451. X    NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d | sort >test.out
  1452. X    ( echo foo ; echo bar ) | sort >test.good
  1453. X    cmp test.out test.good
  1454. X    NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d bletch >test.out
  1455. X    echo bletch >test.good
  1456. X    cmp test.out test.good
  1457. X    >batchlog
  1458. X    >batchlog.o
  1459. X    NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches
  1460. X    test ! -s out.going/foo/output
  1461. X    test ! -s out.going/bar/output
  1462. X    echo `pwd`/test.1 200 >out.going/foo/togo
  1463. X    echo `pwd`/test.2 200 >>out.going/foo/togo
  1464. X    echo `pwd`/test.3 200 >>out.going/foo/togo
  1465. X    echo `pwd`/test.1 4000 >out.going/bar/togo
  1466. X    echo `pwd`/test.2 4000 >>out.going/bar/togo
  1467. X    echo `pwd`/test.3 4000 >>out.going/bar/togo
  1468. X    echo `pwd`/test.3 4000 >test.left
  1469. X    NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches
  1470. X    cmp out.going/foo/output test.out1
  1471. X    cmp out.going/bar/output test.out2
  1472. X    test ! -s out.going/foo/togo
  1473. X    test ! -s out.going/bar/togo
  1474. X    cmp test.left out.going/bar/togo.2
  1475. X    sed 1d batchlog.o >test.log
  1476. X    test ! -s test.log
  1477. X    sed 1d batchlog >test.log
  1478. X    echo 'bar    backlog 1 (batches flowing)' >test.good
  1479. X    cmp test.good test.log
  1480. X    rm -rf test.* togo out.going bin batchparms batchlog batchlog.*
  1481. X
  1482. Xdtr:    $(DTR)
  1483. X    makedtr $(DTR) >$@
  1484. X
  1485. Xclean:
  1486. X    rm -rf out.going bin
  1487. X    rm -f *.o test.* togo togo.* batchparms batcher batchsm 
  1488. X    rm -f batchlog batchlog.* c7encode bencode
  1489. !
  1490. echo 'batch/viauux':
  1491. sed 's/^X//' >'batch/viauux' <<'!'
  1492. X#! /bin/sh
  1493. X# Transmit batch to $1.  -r for no immediate call, -gd to specify grade
  1494. X# of traffic as fairly low.  You may want to add -z to suppress return of
  1495. X# exit-status-0 report, depending on what uucp you run.
  1496. X#
  1497. X# The 'exec' cuts down the number of processes active for this simple case.
  1498. X
  1499. Xexec uux - -r -gd $1!rnews
  1500. !
  1501. echo 'batch/comp':
  1502. sed 's/^X//' >'batch/comp' <<'!'
  1503. X#! /bin/sh
  1504. X# Invoke compress, without silly 2.11-compatible header.
  1505. X# 12-bit compression is the lowest common denominator among news sites,
  1506. X# and is often almost as good as the much-more-costly 16-bit compression.
  1507. X
  1508. Xcompress -b 12
  1509. Xstatus=$?
  1510. Xcase "$status"
  1511. Xin
  1512. X    2)
  1513. X    status=0        # compress stupidity
  1514. X    ;;
  1515. Xesac
  1516. Xexit $status
  1517. !
  1518. echo 'batch/batchsplit':
  1519. sed 's/^X//' >'batch/batchsplit' <<'!'
  1520. X#! /bin/sh
  1521. X# Prepare some batches of size $1 in files named togo.[0-9] .  We prepare a
  1522. X# total of 7 to stay within awk's limits on file descriptors (we need a
  1523. X# couple of other descriptors).  Source is file togo.next if it exists, or
  1524. X# togo if not.  If there is no togo.next and there is more in togo than will
  1525. X# fit in the numbered batches, put the next few lots in togo.next.  This
  1526. X# avoids the need to paw through the whole togo file every time when a large
  1527. X# backlog has built up.
  1528. X#
  1529. X# Buglet:  does not count the "#! rnews nnnnn" headers in sizes.
  1530. X#
  1531. X# If the togo file does not contain file sizes, we make an arbitrary guess
  1532. X# at an average size.
  1533. X
  1534. Xcase $#
  1535. Xin
  1536. X    0)
  1537. X    echo 'Usage: batchsplit size' >&2
  1538. X    exit 2
  1539. X    ;;
  1540. Xesac
  1541. X
  1542. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1543. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1544. X
  1545. XPATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH ; export PATH
  1546. Xumask $NEWSUMASK
  1547. X
  1548. X# Locking.
  1549. Xlock="$NEWSCTL/LOCK"
  1550. Xltemp="$NEWSCTL/L.$$"
  1551. Xecho $$ >$ltemp
  1552. Xtrap "rm -f $ltemp ; exit 0" 0 1 2 15
  1553. Xwhile true
  1554. Xdo
  1555. X    if newslock $ltemp $lock
  1556. X    then
  1557. X        trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  1558. X        break
  1559. X    fi
  1560. X    sleep 30
  1561. Xdone
  1562. X
  1563. Xrm -f togo.overflow togo.count
  1564. Xif test -s togo.next
  1565. Xthen
  1566. X    input=togo.next
  1567. Xelse
  1568. X    input=togo
  1569. Xfi
  1570. X
  1571. Xawk 'BEGIN { total = 0 ; ninbatch = 0 ; bno = 1 ; limit = '$1'
  1572. X        batch = "togo." bno ; nbatches = 7 }
  1573. X    {
  1574. X        if (NF == 1)
  1575. X            size = 3000    # Arbitrary guess.
  1576. X        else
  1577. X            size = $2
  1578. X        if (total + size > limit && ninbatch > 0) {
  1579. X            # Go to next batch.
  1580. X            bno++
  1581. X            if (bno <= nbatches) {
  1582. X                batch = "togo." bno
  1583. X                ninbatch = 0
  1584. X            } else if (bno == nbatches+1 && FILENAME == "togo") {
  1585. X                batch = "togo.next"
  1586. X                limit = 4 * nbatches * limit
  1587. X            } else {
  1588. X                print NR - 1 >"togo.count"
  1589. X                exit
  1590. X            }
  1591. X            total = 0
  1592. X        }
  1593. X        ninbatch++
  1594. X        total += size
  1595. X        print >batch
  1596. X    }' $input
  1597. X
  1598. Xif test -s togo.count
  1599. Xthen
  1600. X    sed "1,`cat togo.count`d" $input >togo.overflow
  1601. X    rm togo.count
  1602. Xfi
  1603. X
  1604. Xif test -r togo.overflow
  1605. Xthen
  1606. X    mv togo.overflow $input
  1607. Xelse
  1608. X    >$input
  1609. Xfi
  1610. !
  1611. echo 'batch/bencode.1':
  1612. sed 's/^X//' >'batch/bencode.1' <<'!'
  1613. X.TH BENCODE 1 "9 January 1988"
  1614. X.UC 4
  1615. X.SH NAME
  1616. Xbencode, bdecode \- encode a binary file into printable ASCII; decode it back
  1617. Xinto binary.
  1618. X.SH SYNOPSIS
  1619. X.B bencode [source]
  1620. X.br
  1621. X.B bdecode [source]
  1622. X.SH DESCRIPTION
  1623. X.I Bencode
  1624. Xis used to a encode a binary file into printable ASCII, and
  1625. X.I bdecode
  1626. Xis used to decode an encoded file back into binary.
  1627. XThese functions are typically used to package a binary file for mailing.
  1628. X.PP
  1629. X.I Bencode
  1630. Xtakes the named source file (the default is standard input) and
  1631. Xproduces an encoded version on the standard output.
  1632. XThe encoding uses only the ASCII characters ``A'' \- ``Z'', ``a'' \- ``z'', ``0''
  1633. X\- ``9'', ``+'', and ``-''.
  1634. XThe ASCII characters blank, newline, and ``/'' also appear in the
  1635. Xencoded file, but do not represent encoded bits.
  1636. XThe encoded file is terminated with
  1637. Xa byte count and cyclic redundancy check for detecting corrupted files.
  1638. X.PP
  1639. X.I Bdecode
  1640. Xreads a file encoded by bencode (the default is standard input), strips off
  1641. Xany leading and trailing lines added by mailers,
  1642. Xand writes the decoded version to standard output.
  1643. X.PP
  1644. XThese functions are similar to
  1645. X.I uuencode
  1646. Xand
  1647. X.I uudecode,
  1648. Xbut are more robust because of the CRC check and because
  1649. Xthey don't send characters like ``^'' and ``\\'', which are likely to get
  1650. Xmangled if the file should happen to pass through a
  1651. Xnon-ASCII machine.
  1652. X.PP
  1653. X.SH SEE\ ALSO
  1654. Xuuencode(1)
  1655. X.SH AUTHORS
  1656. XKen Lalonde and Reg Quinton
  1657. X.SH BUGS
  1658. XThe file is expanded by 35% (3 bytes become 4 plus control information)
  1659. Xcausing it to take longer to transmit.
  1660. !
  1661. echo 'batch/compc7':
  1662. sed 's/^X//' >'batch/compc7' <<'!'
  1663. X#! /bin/sh
  1664. X# like comp except use the bizarre c7unbatch format
  1665. X
  1666. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1667. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1668. X
  1669. XPATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH ; export PATH
  1670. Xumask $NEWSUMASK
  1671. X
  1672. Xecho '#! c7unbatch'
  1673. Xcompress -b 12 | c7encode
  1674. Xexit 0                # compress exit status sometimes stupid
  1675. !
  1676. echo done
  1677.  
  1678.  
  1679.