home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / tapeops / part03 < prev    next >
Encoding:
Internet Message Format  |  1993-03-08  |  45.1 KB

  1. Path: comp-sources-3b1
  2. From: vern@zebra.alphacdc.com (vern)
  3. Subject:  v02i037:  3B1 Tape processing utilities, Part03/04
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 28d66468 38ad147c 9eb05bd6 579a633a
  7.  
  8. Submitted-by: vern@zebra.alphacdc.com (vern)
  9. Posting-number: Volume 2, Issue 37
  10. Archive-name: tapeops/part03
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 3 (of 4)."
  19. # Contents:  header.sh mk.index.sh params prep.sh rd.tape.sh
  20. #   src/group.c src/read.vtoc.c utils/convert.sh utils/set_up.sh
  21. #   utils/trim.sh utils/util.hdr.sh utils/util.prep.sh
  22. #   utils/util.rd.sh utils/util.sq.sh
  23. # Wrapped by vern@zebra on Mon Mar  8 08:57:41 1993
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f header.sh -a "${1}" != "-c" ; then 
  26.   echo shar: Will not over-write existing file \"header.sh\"
  27. else
  28. echo shar: Extracting \"header.sh\" \(2031 characters\)
  29. sed "s/^X//" >header.sh <<'END_OF_header.sh'
  30. X
  31. X# The purpose of this script is to prepare the 'squirrel'ed files
  32. X# for transfer to tape.  This consists of building a 'contents'
  33. X# file from the "Subject" line in the posted articles.  The 'contents'
  34. X# is sorted and similar titles are moved together for easier reference.
  35. X# The articles are then compressed and moved to the 'savdir' where
  36. X# they can copied to tape.
  37. X
  38. Xexport NEWSDEV=/dev/fp002
  39. Xexport CMDDIR=/news/.tape.ops        # Where scripts are stored
  40. Xexport WRKDIR=/news/.tape.ops        # Where collected files are stored
  41. Xexport SRCDIR=$WRKDIR/src        # Where 'C' code programs are stored
  42. Xexport ARCDIR=$WRKDIR/arcdir        # Where linkde articles are stored
  43. Xexport PARAMS=$CMDDIR/params        # Control information
  44. Xexport LIST=$CMDDIR/save.list        # Directory list to be saved
  45. Xexport LINKS=$CMDDIR/link.list        # List of saved 'Message ID's
  46. Xexport KLINKS=$CMDDIR/old.links        # Working file in case of crash
  47. Xexport GOOFS=$CMDDIR/goofs        # Error log
  48. Xexport SAVDIR=$WRKDIR/savdir        # Compressed files for taping
  49. Xexport CONDIR=$WRKDIR/condir        # Another working directory
  50. Xexport CONFILE=$WRKDIR/contents        # The 'Subject:' lines
  51. Xexport PNTRS=$WRKDIR/pntrs        # References articles
  52. Xexport CPNTRS=$WRKDIR/c.pntrs        # Cross reference to articles
  53. Xexport RPNTRS=$WRKDIR/r.pntrs        # Another cross reference
  54. Xexport GRP=news                # Group name for permisions
  55. Xexport OWN=netnews            # News owner for permisions
  56. Xexport COPY=0                # A flag used when copying tapes
  57. Xexport TMP=$WRKDIR/tmps            # A temporrary file
  58. Xexport TMP1=$WRKDIR/tmpp1        # Another temporary file
  59. Xexport TMP2=$WRKDIR/tmpp2        # And another
  60. X
  61. X# These values are more guess work than knowledge.  I have had trouble
  62. X# resolving the 254 blocks and 6 streams used during tap formatting and
  63. X# the actual number of blocks I can put on a tape.
  64. Xexport PERCENT=6200    # This is the last five percent of disk space
  65. Xexport MAXOFFSET=45384  # or B1FE 512 byte blocks = 23329792 bytes
  66. X# was 45566
  67. X# If we add 2 blocks for header, B200 512 byte blocks
  68. X# or 1DAA blocks per stream???
  69. X# The MAXOFFSET revised 9-29-92 by experimentation.
  70. END_OF_header.sh
  71. if test 2031 -ne `wc -c <header.sh`; then
  72.     echo shar: \"header.sh\" unpacked with wrong size!
  73. fi
  74. chmod +x header.sh
  75. # end of overwriting check
  76. fi
  77. if test -f mk.index.sh -a "${1}" != "-c" ; then 
  78.   echo shar: Will not over-write existing file \"mk.index.sh\"
  79. else
  80. echo shar: Extracting \"mk.index.sh\" \(2628 characters\)
  81. sed "s/^X//" >mk.index.sh <<'END_OF_mk.index.sh'
  82. X# This is the sequence of operations to read articles from a tape
  83. X# prepared using 'prep' and 'wr.tape'.
  84. X
  85. Xif [ ! "$WRKDIR" ]
  86. Xthen
  87. X    . /news/.tape.ops/header.sh
  88. Xfi
  89. X
  90. XINDDIR="$WRKDIR/Indexes"
  91. X
  92. X# This should be the start of the program
  93. X
  94. Xecho `date +%T`" Starting read operations. "
  95. X
  96. Xwhile [ "$ret" != 0 ]
  97. Xdo
  98. X    Tgetname -t 2/dev/null
  99. X    ret=$?
  100. X    if [ "$ret" != 0 ]
  101. X    then
  102. X        echo "Please insert a tape. Q)uit or C)ontinue. \c"
  103. X        read -r ch
  104. X        if [ "$ch" = "q" -o "$ch" = "Q" ]
  105. X        then
  106. X            exit
  107. X        fi
  108. X        ret=1
  109. X    else
  110. X        Tgetname -v > /dev/null 2>/dev/null
  111. X#        Tgetname -r > /dev/null 2>/dev/null
  112. X#        ret=$?
  113. X        set `Tgetname -r | tr -d "'"`
  114. X        name=$1
  115. X        offset=$2
  116. X        if [ $offset = 0 ]
  117. X        then
  118. X            echo "\nYou may have inserted the wrong tape.
  119. XThis tape has no data written to it.  Enter \"g\" when you have
  120. Xanother tape inserted.  Enter \"q\" to quit."
  121. X            read -r ch
  122. X            if [ "$ch" = "q" -o "$ch" = "Q" ]
  123. X            then
  124. X                exit
  125. X            else
  126. Xecho "\nWaiting for another tape to be inserted.
  127. XPress any key to continue. Q)uit \c"
  128. X                read -r ch
  129. X                if [ "ch" = "q" -o "$ch" = "Q" ]
  130. X                then
  131. X                    exit
  132. X                fi
  133. X            fi
  134. X            ret=1
  135. X        fi
  136. X    fi
  137. Xdone
  138. X
  139. X# 'read.vtoc -w9' will write all used chapters to standard out in column
  140. X# format. 
  141. X
  142. Xif [ ! -d $INDDIR ]
  143. Xthen
  144. X    mkdir $INDDIR
  145. X    chown netnews $INDDIR
  146. X    chgrp news $INDDIR
  147. Xfi
  148. X
  149. Xecho \
  150. X"# The format of entries is <Article Name> <File Number> <Chapter Number>" \
  151. X> $INDDIR/$name
  152. Xchown netnews $INDDIR/$name
  153. Xchgrp news $INDDIR/$name
  154. Xchmod 0644 $INDDIR/$name
  155. Xecho `date +%T`" The contents of tape \""$name"\" are:"
  156. X$SRCDIR/read.vtoc -w9
  157. Xbase=$PWD
  158. Xif [ ! -d $name ]
  159. Xthen
  160. X    mkdir $name
  161. Xfi
  162. X
  163. XTgetname +l
  164. Xfor chap in 1 2 3 4 5 6 7 8 9
  165. Xdo
  166. X    cd $base/$name
  167. X    set -u `$SRCDIR/read.vtoc -r$chap`
  168. X    if [ "$1" != "$chap" ]
  169. X    then
  170. X        continue
  171. X    fi
  172. X    offset=$2
  173. X    blocks=$3
  174. X    echo `date +%T`" Reading chapter $chap"
  175. X    if [ $offset -lt 0 -o $blocks -lt 0 ]
  176. X    then
  177. X        continue
  178. X    fi
  179. X    if [ ! -d $chap ]
  180. X    then
  181. X        mkdir $chap
  182. X    fi
  183. X    cd $chap
  184. X
  185. X    tapecpio -icuxRT32O$offset contents < /dev/rft3 2>/dev/null
  186. X    ret=$?
  187. X
  188. X    if [ $ret != 0 ]
  189. X    then
  190. Xecho "\tUnable to read a 'contents' entry in chapter $chap.
  191. X\tPushing on. Return was $ret"
  192. X    else
  193. X        sed -e 's/$/    '$chap'/' contents >> $INDDIR/$name.$$
  194. X    fi
  195. Xdone
  196. X
  197. Xcd $base
  198. Xecho `date +%T`" Rewinding tape in background."
  199. XTgetname -v &        # to rewind the tape
  200. XTgetname -l
  201. X
  202. Xecho `date +%T`" Changing arrangement of the '$name' Index file. "
  203. Xsort -fd -o $INDDIR/$name.$$ $INDDIR/$name.$$
  204. X$SRCDIR/group $INDDIR/$name.$$
  205. X
  206. Xecho "" >> $INDDIR/$name
  207. Xcat $INDDIR/$name.$$ >> $INDDIR/$name
  208. X
  209. Xecho `date +%T`" Your Index is: $INDDIR/$name."
  210. X
  211. Xrm -f $INDDIR/$name.$$
  212. Xrm -f /tmp/tape.vtoc
  213. Xrm -f /tmp/ss.osets
  214. Xrm -f ss.filelist
  215. Xrm -f c.pntrs
  216. Xrm -rf $name
  217. Xexit
  218. END_OF_mk.index.sh
  219. if test 2628 -ne `wc -c <mk.index.sh`; then
  220.     echo shar: \"mk.index.sh\" unpacked with wrong size!
  221. fi
  222. chmod +x mk.index.sh
  223. # end of overwriting check
  224. fi
  225. if test -f params -a "${1}" != "-c" ; then 
  226.   echo shar: Will not over-write existing file \"params\"
  227. else
  228. echo shar: Extracting \"params\" \(235 characters\)
  229. sed "s/^X//" >params <<'END_OF_params'
  230. XNext fnum to link:    159
  231. XNumber of bytes held:    2,261,378
  232. XDate last squirreled:    93-03-08
  233. XName of work tape:    Data-002
  234. XBlocks of offset:    31000
  235. XDate last taped:    93-03-05
  236. XBlocks available:    14384
  237. XNext chapter number:    6
  238. XCompression factor:    929
  239. END_OF_params
  240. if test 235 -ne `wc -c <params`; then
  241.     echo shar: \"params\" unpacked with wrong size!
  242. fi
  243. # end of overwriting check
  244. fi
  245. if test -f prep.sh -a "${1}" != "-c" ; then 
  246.   echo shar: Will not over-write existing file \"prep.sh\"
  247. else
  248. echo shar: Extracting \"prep.sh\" \(2522 characters\)
  249. sed "s/^X//" >prep.sh <<'END_OF_prep.sh'
  250. Xif [ ! "$WRKDIR" ]
  251. Xthen
  252. X    . /news/.tape.ops/header.sh
  253. Xfi
  254. X
  255. Xecho `date +%T`" Starting prep routines for transfer to tape."
  256. X
  257. Xcurrdir=$PWD
  258. Xcd $WRKDIR
  259. X
  260. X# Clean out any previous effort to generate a 'savdir' etc.  Then
  261. X# create new ones.
  262. X
  263. Xif [ -d $SAVDIR ]
  264. Xthen
  265. X    rm -r $SAVDIR
  266. Xfi
  267. Xmkdir $SAVDIR
  268. X
  269. Xif [ -f $TMP1 ]
  270. Xthen
  271. X    rm $TMP1
  272. Xfi
  273. Xif [ -f $TMP2 ]
  274. Xthen
  275. X    rm $TMP2
  276. Xfi
  277. X
  278. Xif [ -s $PARAMS ]
  279. Xthen
  280. X    fnum=`awk - '{ if ( $0 ~ /Last fnum:/ ) print $3 }' $PARAMS`
  281. Xelse
  282. X    echo "\t\tWe are in trouble!"
  283. X    echo "\tThere is no $PARAMS file so the 'squirrel'ed data is"
  284. X    echo "\tdefective.  Clean it up before proceeding."
  285. X    read
  286. X    exit 1
  287. Xfi
  288. X
  289. X> $CONFILE
  290. Xls -1 $ARCDIR > $PNTRS
  291. X
  292. Xecho `date +%T`" Reading 'Subject:' lines from 'arcdir'. "
  293. X
  294. X# Go through all the files in 'arcdir' and read the 'Subject: ' line.
  295. X# Add a tab and the file number to the line and put it in 'contents'.
  296. Xwhile
  297. X    read pntr
  298. Xdo
  299. X    sed -n '/^Subject:/ {
  300. X            s/Subject: //
  301. X            s/$/    '$pntr'/p; q
  302. X            }' $ARCDIR/$pntr >> $CONFILE
  303. Xdone <$PNTRS
  304. X
  305. Xecho `date +%T`" Changing arrangement of the 'contents' file. "
  306. X
  307. X# Sort the 'contents' then run 'group' to place followup articles
  308. X# following the original.  'Group' also produces 'c.pntrs' which is
  309. X# a listing of the files in the same order that they appear
  310. X# in the 'contents'.
  311. X
  312. Xsort -fd -o $CONFILE $CONFILE
  313. X$SRCDIR/group $CONFILE
  314. X
  315. Xecho "\nYou should have a destination tape installed in the drive at
  316. Xthis point.  It will then have completed the retension phase
  317. Xbefore you need it.\n"
  318. X
  319. Xecho `date +%T`" Moving and compressing files to be taped. "
  320. X# Get the 'arcdir' file names from 'contents' and transfer to 'savdir'
  321. X# while compressing.  Be careful not to use up the last 5 percent of
  322. X# disk.
  323. Xwhile
  324. X    read pntr
  325. Xdo
  326. X    sed '/^Path:/d' $ARCDIR/$pntr | compress > $SAVDIR/$pntr.Z
  327. X    chgrp $GRP $SAVDIR/$pntr.Z
  328. X    chown $OWN $SAVDIR/$pntr.Z
  329. X    set `df $NEWSDEV`
  330. X    if [ $3 -lt $PERCENT ]
  331. X    then
  332. X        total=`cat $PNTRS | wc -l`
  333. X        lnum=`fgrep -nx $pntr $PNTRS | cut -f1 -d":"`
  334. X        let needed="$total-$lnum"
  335. Xecho "You are running low on disk space.  There are only $3 blocks
  336. Xremaining.  So far, $lnum of $total files have been compressed.
  337. X    A. Single step through the rest of the list.
  338. X    B. Open another window and transfer data to floppy disks.
  339. X    C. Go ahead and put what we have on tape, save the rest.
  340. X    D. Quit for now.
  341. XEnter A, B, C, or D. <cr>"
  342. X        read ans
  343. X        if [ "$ans" = "d" -o "$ans" = "D" ]
  344. X        then
  345. X            cd $currdir
  346. X            exit 1
  347. X        elif [ "$ans" = "c" -o "$ans" = "C" ]
  348. X        then
  349. X            break
  350. X        fi
  351. X    fi
  352. Xdone < $PNTRS
  353. X
  354. Xcp $PNTRS $CPNTRS
  355. X
  356. X# Now do the tape operations.
  357. Xwr.tape.sh
  358. END_OF_prep.sh
  359. if test 2522 -ne `wc -c <prep.sh`; then
  360.     echo shar: \"prep.sh\" unpacked with wrong size!
  361. fi
  362. chmod +x prep.sh
  363. # end of overwriting check
  364. fi
  365. if test -f rd.tape.sh -a "${1}" != "-c" ; then 
  366.   echo shar: Will not over-write existing file \"rd.tape.sh\"
  367. else
  368. echo shar: Extracting \"rd.tape.sh\" \(2364 characters\)
  369. sed "s/^X//" >rd.tape.sh <<'END_OF_rd.tape.sh'
  370. X# This is the sequence of operations to read articles from a tape
  371. X# prepared using 'prep' and 'wr.tape'.
  372. X
  373. Xif [ ! "$WRKDIR" ]
  374. Xthen
  375. X    . /news/.tape.ops/header.sh
  376. Xfi
  377. X
  378. X
  379. X# This should be the start of the program
  380. X
  381. Xecho `date +%T`" Starting read operations. "
  382. X
  383. Xwhile [ "$ret" != "0" ]
  384. Xdo
  385. X    Tgetname -t 2/dev/null
  386. X    ret=$?
  387. X    if [ "$ret" != "0" ]
  388. X    then
  389. X        echo "$ret, Please insert a tape. Q)uit or C)ontinue. \c"
  390. X        read -r ch
  391. X        if [ "$ch" = "q" -o "$ch" = "Q" ]
  392. X        then
  393. X            exit
  394. X        fi
  395. X        ret=1
  396. X    else
  397. X# From here on, the tape drive is locked, any 'exit' must perform
  398. X# 'Tgetname -l' to unlock the drive before leaving.
  399. X        Tgetname +l
  400. X        Tgetname -v > /dev/null 2>/dev/null
  401. X        Tgetname -r > /dev/null 2>/dev/null
  402. X        ret=$?
  403. X        set `Tgetname -r | tr -d "'"`
  404. X        name=$1
  405. X        offset=$2
  406. X        if [ $offset = 0 ]
  407. X        then
  408. X            echo "\nYou may have inserted the wrong tape.
  409. XThis tape has no data written to it.  Enter \"g\" when you have
  410. Xanother tape inserted.  Enter \"q\" to quit."
  411. X            read -r ch
  412. X            if [ "$ch" = "q" -o "$ch" = "Q" ]
  413. X            then
  414. X                Tgetname -l
  415. X                exit
  416. X            else
  417. Xecho "\nWaiting for another tape to be inserted.
  418. XPress any key to continue. Q)uit \c"
  419. X                read -r ch
  420. X                if [ "ch" = "q" -o "$ch" = "Q" ]
  421. X                then
  422. X                    Tgetname -l
  423. X                    exit
  424. X                fi
  425. X            fi
  426. X            ret=1
  427. X        fi
  428. X    fi
  429. Xdone
  430. X
  431. X# 'read.vtoc -w9' will write all used chapters to standard out in column
  432. X# format. 
  433. X
  434. Xecho `date +%T`" The contents of tape \""$name"\" are:"
  435. X        $SRCDIR/read.vtoc -w9
  436. Xecho "Which chapter do you wish to access? \c"
  437. Xread chap
  438. X
  439. Xif [ "$chap" = "" ]
  440. Xthen
  441. X    Tgetname -l
  442. X    exit
  443. Xfi
  444. X
  445. Xset `$SRCDIR/read.vtoc -r$chap`
  446. Xoffset=$2
  447. Xblocks=$3
  448. X
  449. Xbase=$PWD
  450. Xif [ ! -d $name ]
  451. Xthen
  452. X    mkdir $name
  453. Xfi
  454. Xcd $name
  455. Xif [ ! -d $chap ]
  456. Xthen
  457. X    mkdir $chap
  458. Xfi
  459. Xcd $chap
  460. X
  461. Xtapecpio -icuxRT32O$offset contents < /dev/rft3 2>/dev/null
  462. Xret=$?
  463. Xif [ $ret != 0 ]
  464. Xthen
  465. X    echo "ret = "$ret
  466. X    echo "\tThere was an error during the reading of the source tape.
  467. X\tBailing out!  Please rerun this program."
  468. X    Tgetname -l
  469. X    exit 1
  470. Xfi
  471. X$SRCDIR/pick.files
  472. Xrslt=$?
  473. Xif [ "$rslt" != 0 ]
  474. Xthen
  475. X    echo `date +%T`" Searching for files."
  476. X    list=`cat r.pntrs`
  477. X    dbuf -iT124O$offset /dev/rft3 | \
  478. X       execStrip tapecpio -icvR"T124" $list 1> /dev/null 2>$WRKDIR/errs
  479. X
  480. X    echo `date +%T`" Rewinding tape."
  481. Xfi
  482. X
  483. XTgetname -l
  484. XTgetname -v &        # to rewind the tape
  485. Xecho `date +%T`" Your recovered files are in:\n"$PWD
  486. X
  487. Xrm -f /tmp/tape.vtoc
  488. Xrm -f r.pntrs
  489. Xrm -f ss.filelist
  490. Xrm -f $PWD/contents
  491. X
  492. Xcd $base
  493. Xexit
  494. END_OF_rd.tape.sh
  495. if test 2364 -ne `wc -c <rd.tape.sh`; then
  496.     echo shar: \"rd.tape.sh\" unpacked with wrong size!
  497. fi
  498. chmod +x rd.tape.sh
  499. # end of overwriting check
  500. fi
  501. if test -f src/group.c -a "${1}" != "-c" ; then 
  502.   echo shar: Will not over-write existing file \"src/group.c\"
  503. else
  504. echo shar: Extracting \"src/group.c\" \(4119 characters\)
  505. sed "s/^X//" >src/group.c <<'END_OF_src/group.c'
  506. X/* This is a 'c' version of a 'sed/awk' script I first used to group
  507. X * similar titles together in the contents.  It isn't as fast as some
  508. X * other algorithm might be but it beats the devil out of the script.
  509. X * That script took 20 minutes to process 800 titles!!!
  510. X *
  511. X * The 'contents' is first read into the memory space allocated to
  512. X * 'r1'.  'r1' is then scanned to count the number of lines.  Next
  513. X * 'r2' is allocated of sufficient size to hold 'lncnt' entries  of
  514. X * 'item' and 'r3' is allocated to hold 'lncnt' pointers to 'item'.
  515. X * The 'items' in 'r2' are filled in by a second scan of 'r1'.
  516. X * 'line' contains a pointer into 'r1' to the start of each entry in
  517. X * the 'contents' listing and 'leng' is the number of characters in
  518. X * the title.
  519. X * The top 'item' is then used as pattern for scanning the remainder
  520. X * of 'r1' for entries which contain the pattern or which are contained
  521. X * in the pattern.  When a match is found, the '*line' is written to
  522. X * 'r4' and the 'leng' value in 'r2' is set to zero to indicate to
  523. X * subsequent searchs that that entry has been "found".  After each
  524. X * pass, the 'r4' array is sorted to length and the **char's are
  525. X * added to 'r3'.
  526. X * After the scan sequence is completed, the data is read out from 'r1'
  527. X * to the reopened 'contents' in the newly ordered sequence.
  528. X */
  529. X
  530. X#include <fcntl.h>
  531. X#include <malloc.h>
  532. X#include <stdio.h>
  533. X
  534. X#define CFILE "contents"
  535. X#define PFILE "c.pntrs"
  536. X
  537. Xtypedef struct {
  538. X    char *line;
  539. X    int leng;
  540. X    } item;
  541. X
  542. XFILE    *fds1, *fds2;
  543. Xmain( argc, argv )
  544. Xint argc;
  545. Xchar *argv[];
  546. X{
  547. X    int i, k, fd, lcnt, done;
  548. X    int size;
  549. X    char fname[120];
  550. X    char *c1, *c2, *c3, *c4;
  551. X    item *i1, *i2, *i3;
  552. X    char **l1;
  553. X    char *r1, *lim_r1;
  554. X    item *r2, *lim_r2;
  555. X    char **r3, **lim_r3;
  556. X    item *r4[200];
  557. X    char errbuf[80];
  558. X    
  559. X    if ( argc == 0 ) strcpy( fname, CFILE );
  560. X    else strncpy( fname, argv[1], sizeof( fname ) -1 );
  561. X    if ( access( fname, 04 ))
  562. X    {
  563. X        sprintf( errbuf, "No \"%s\" file.", fname );
  564. X        perror( errbuf );
  565. X        exit( 1);
  566. X    }
  567. X    fd = open( fname, O_RDONLY );
  568. X    size = lseek( fd, 0, 2 );
  569. X    lseek( fd, 0, 0 );
  570. X    r1 = malloc( size );
  571. X    lim_r1 = r1 + size;
  572. X    read( fd, r1, size );
  573. X    close( fd );
  574. X    for( c1 = r1, lcnt = 0; c1 <= r1 + size ; c1++ )
  575. X        if ( *c1 == '\n' ) lcnt++;
  576. X    r2 = (item *)calloc( lcnt, sizeof( item ));
  577. X    lim_r2 = r2 + lcnt;
  578. X    r3 = (char **)calloc( lcnt, sizeof( char * ));
  579. X    lim_r3 = r3 + lcnt;
  580. X     for( c1 = r1, i1 = r2; c1 < lim_r1 && i1 < lim_r2; i1++ )
  581. X    {
  582. X        i1->line = c1;
  583. X        c2 = c1;
  584. X        while( *c1 != '\n' && *c1 != '\t' ) c1++;
  585. X        if ( *c1 == '\t' ) i1->leng = c1 - c2;
  586. X        while( *c1 != '\n' ) c1++;
  587. X        *c1++ = '\0';
  588. X    }
  589. X    l1 = r3;
  590. X    for ( i1 = r2; i1 < lim_r2; i1++ )
  591. X    {
  592. X        if ( ! i1->leng ) continue;
  593. X        i = 0;
  594. X        r4[i++] = i1;
  595. X            /* Watch out for jerks who post with only '?' or '.' */
  596. X        if ( i1->leng > 2 ) for ( i2 = i1+1; i2 < lim_r2; i2++ )
  597. X        {
  598. X            if ( i2->leng == 0 ) continue;
  599. X            if ( i2->leng >= i1->leng )
  600. X            {
  601. X                k = i2->leng - i1->leng;
  602. X                c1 = i1->line;
  603. X                c2 = i2->line;
  604. X            }
  605. X            else
  606. X            {
  607. X                k = i1->leng - i2->leng;
  608. X                c1 = i2->line;
  609. X                c2 = i1->line;
  610. X            }
  611. X                    /* Look for shorter string in the longer one. */
  612. X            while ( k-- >= 0 )
  613. X            {
  614. X                c3 = c1;            /* The shorter line */
  615. X                c4 = c2++;
  616. X                while ( *c3 == *c4 && *c3 != '\t' ) c3++, c4++;
  617. X                if ( *c3 == '\t' )
  618. X                {
  619. X                    r4[i++] = i2;
  620. X                    break;
  621. X                }
  622. X            }
  623. X        }
  624. X        done = 0;
  625. X    /* Now reorder the strings to put the shortest first. */
  626. X        while ( ! done )
  627. X        {
  628. X            done = 1;
  629. X            for ( k = 0; k < i - 1; k++ )
  630. X            {
  631. X                if ( r4[k]->leng > r4[k+1]->leng )
  632. X                {
  633. X                    i3 = r4[k];
  634. X                    r4[k] = r4[k+1];
  635. X                    r4[k+1] = i3;
  636. X                    done = 0;
  637. X                }
  638. X            }
  639. X        }
  640. X    /* Now move the pointers to the output array */
  641. X        for ( k = 0; k < i; k++ )
  642. X        {
  643. X            *l1++ = r4[k]->line;
  644. X            r4[k]->leng = 0;
  645. X    /* leng = 0 says this item already queued for output */
  646. X        }
  647. X     }
  648. X    if (( fds1 = fopen( fname, "w" )) == 0 )
  649. X    {
  650. X        perror( "Opening contents file" );
  651. X        exit( -1 );
  652. X    }
  653. X
  654. X    if (( fds2 = fopen( PFILE, "w" )) == 0 )
  655. X    {
  656. X        perror( "Opening pointers file" );
  657. X        exit( -1 );
  658. X    }
  659. X     for ( l1 = r3; l1 < lim_r3; l1++ )
  660. X    {
  661. X        fprintf( fds1, "%s\n", *l1 );
  662. X        c1 = *l1;
  663. X        while ( *c1++ != '\t' );
  664. X        fprintf( fds2, "%s\n", c1 );
  665. X    }
  666. X    fclose( fds1 );
  667. X    fclose( fds2 );
  668. X}
  669. END_OF_src/group.c
  670. if test 4119 -ne `wc -c <src/group.c`; then
  671.     echo shar: \"src/group.c\" unpacked with wrong size!
  672. fi
  673. # end of overwriting check
  674. fi
  675. if test -f src/read.vtoc.c -a "${1}" != "-c" ; then 
  676.   echo shar: Will not over-write existing file \"src/read.vtoc.c\"
  677. else
  678. echo shar: Extracting \"src/read.vtoc.c\" \(3713 characters\)
  679. sed "s/^X//" >src/read.vtoc.c <<'END_OF_src/read.vtoc.c'
  680. X/* This is one way of getting around that damned 'TdspSSss' program
  681. X * makes a window that you can't kill. */
  682. X
  683. X/* Flags:
  684. X *     c    print [num] chapter number and offset, for writing
  685. X *     d    debug, prints data about all 9 chapters
  686. X *     g    return the size of the larget chapter
  687. X *     w    write, print data about all used chapters
  688. X *     r    read, print chapter offset and size, only one
  689. X *         entry if a number is included.
  690. X *     -    ignored
  691. X *     [0-9]    select specific chapter data
  692. X *         if a chapter number is present with either 'c' or 'w'
  693. X *         data relevant to that entry number is written to
  694. X *         '/tmp/ss.osets'.
  695. X *    The return value is the chapter number of the next blank
  696. X *     chapter unless [num] is used.  Then it is [num].
  697. X */
  698. X
  699. X#include <stdio.h>
  700. X#include <fcntl.h>
  701. X#include <string.h>
  702. X
  703. X#define VTOC "/tmp/tape.vtoc"
  704. Xstruct names {
  705. X    char text[46];
  706. X    short files;
  707. X    int start;
  708. X    int bytes;
  709. X};
  710. Xint fd, cflag, dflag, gflag, wflag, rflag;
  711. Xstruct names entry;
  712. X
  713. Xmain(argc, argv)
  714. Xint argc;
  715. Xchar *argv[];
  716. X{
  717. X    int i, num;
  718. X    char *p, ch;
  719. X    i = 1;
  720. X    cflag = 0;
  721. X    dflag = 0;
  722. X    gflag = 0;
  723. X    rflag = 0;
  724. X    wflag = 0;
  725. X    num = -1;
  726. X    while ( i < argc )
  727. X    {
  728. X        p = argv[i];
  729. X        while ( ch = *p++ ) switch( ch )
  730. X        {
  731. X            case '0':
  732. X            case '1':
  733. X            case '2':
  734. X            case '3':
  735. X            case '4':
  736. X            case '5':
  737. X            case '6':
  738. X            case '7':
  739. X            case '8':
  740. X            case '9':num = ch & 0x0f; break;
  741. X            case 'c':cflag = 1; break;
  742. X            case 'd':dflag = 1; break;
  743. X            case 'g':gflag = 1; break;
  744. X            case 'r':rflag = 1; break;
  745. X            case 'w':wflag = 1; break;
  746. X            case '-':
  747. X            default: break;
  748. X        }
  749. X        i++;
  750. X    }
  751. X    if (( fd = open( VTOC, O_RDONLY)) == -1 )
  752. X    {
  753. X        perror("Can't open /tmp/tape.vtoc");
  754. X        exit( -1 );
  755. X    }
  756. X    lseek( fd, 520, 0 );
  757. X    if ( wflag | cflag ) i = w_info( num );
  758. X    else if ( rflag ) i = r_info( num );
  759. X    else if ( gflag ) i = greatest(fd);
  760. X    close( fd );
  761. X    exit( i );
  762. X}
  763. X
  764. Xint w_info( num )
  765. Xint num;
  766. X{
  767. X    int fd2, i, j, k, m, n;
  768. X    char *p;
  769. X    char buf1[20];
  770. X    char name[10];
  771. X    char id[16];
  772. X    char comment[26];
  773. X    if ( num != '\0' ) j = num;
  774. X    else j = -1;
  775. X    k = 0;
  776. X    if ( wflag ) printf(
  777. X"Chap   Name      Comment                  Files  Offset  Size\n");
  778. X    for (i=1; i <= 9; i++)
  779. X    {
  780. X        read( fd, &entry, sizeof(entry) );
  781. X         if ( entry.text[0] < '\0' )
  782. X        {
  783. X            if ( dflag ){
  784. X                entry.text[0] = '\0';
  785. X                entry.text[8] = '\0';
  786. X                entry.text[21] = '\0';
  787. X            }
  788. X            else
  789. X            {
  790. X                if ( cflag ) {
  791. X                    printf( "%d %d", i, k );
  792. X                    return( i++ );
  793. X                }
  794. X                j = i;
  795. X            }
  796. X        }
  797. X        if ( wflag && entry.text[0] > '\0' )
  798. X        {
  799. X            m = 0;
  800. X            for ( n=0; n < 8; n++ ) name[n]=entry.text[m++];
  801. X            name[n]='\0';
  802. X            for ( n=0; n < 13; n++ ) id[n]=entry.text[m++];
  803. X            id[n]='\0';
  804. X            for ( n=0; n < 24; n++ ) comment[n]=entry.text[m++]; 
  805. X            comment[n]='\0';
  806. X            printf(
  807. X                    "%3d  %-8s   %-24s   %4d %6d %6d\n", i,
  808. X                    name, comment, entry.files, entry.start,
  809. X                    entry.bytes );
  810. X        }
  811. X        if ( i == j )
  812. X        {
  813. X             sprintf( buf1,"%d:%d",
  814. X                entry.start, entry.bytes );
  815. X            for ( m = 0, p = buf1; *p; m++, p++ );
  816. X            *p++=m;
  817. X            *p = '\0';
  818. X            fd2 = open( "/tmp/ss.osets",
  819. X                    O_WRONLY | O_CREAT | O_TRUNC, 0666 );
  820. X            write( fd2, buf1, strlen( buf1 ) );
  821. X            close( fd2 );
  822. X            if ( cflag )
  823. X            {
  824. X                printf( "%d %d", i, k );
  825. X                return( i++ );
  826. X            }
  827. X            return( i );
  828. X        }
  829. X        k = entry.start + entry.bytes;
  830. X    }
  831. X    return( i );
  832. X} 
  833. X
  834. Xint r_info( num )
  835. Xint num;
  836. X
  837. X{
  838. X    int i, k;
  839. X    k = num;
  840. X    for ( i = 1; i <= 9 ; i++ )
  841. X    {
  842. X        read( fd, &entry, sizeof(entry) );
  843. X        if ( entry.text[0] < '\0' ) {
  844. X            printf( "0 0 0" );
  845. X            break;
  846. X        }
  847. X        if ( num == -1 ) k = i;
  848. X        if ( i == k ) printf( "%d %d %d", i,
  849. X                entry.start, entry.bytes );
  850. X    }
  851. X    return( i );
  852. X}
  853. X
  854. Xint greatest(fd)
  855. Xint fd;
  856. X{
  857. X    int i, j, k;
  858. X    k = 0;
  859. X    for ( i = 1; i <= 9 ; i++ )
  860. X    {
  861. X        read( fd, &entry, sizeof(entry) );
  862. X        if ( entry.text[0] < '\0' ) break;
  863. X        j = entry.bytes;
  864. X        if ( j > k ) k = j;
  865. X    }
  866. X    printf( "%d", k );
  867. X    return( 0 );
  868. X}
  869. END_OF_src/read.vtoc.c
  870. if test 3713 -ne `wc -c <src/read.vtoc.c`; then
  871.     echo shar: \"src/read.vtoc.c\" unpacked with wrong size!
  872. fi
  873. # end of overwriting check
  874. fi
  875. if test -f utils/convert.sh -a "${1}" != "-c" ; then 
  876.   echo shar: Will not over-write existing file \"utils/convert.sh\"
  877. else
  878. echo shar: Extracting \"utils/convert.sh\" \(1514 characters\)
  879. sed "s/^X//" >utils/convert.sh <<'END_OF_utils/convert.sh'
  880. X# This is the sequence of operations to read articles from a tape
  881. X# prepared using 'prep' and 'wr.tape'.
  882. X
  883. Xif [ ! "$WRKDIR" ]
  884. Xthen
  885. X    . /news/.tape.ops/utils/util.hdr.sh
  886. Xfi
  887. X
  888. X# This is the start of the program
  889. X
  890. Xawk -F"    " - '{ if ( $0 ~ /State of operations:/ ) ok1 = 1
  891. X        }
  892. X        END{
  893. X        if ( ok1 != 1 )    print "State of operations:    1"
  894. X    }' $RDPARMS >> $RDPARMS
  895. X
  896. Xif [ ! -s $PARAMS ]
  897. Xthen
  898. X    echo "Next fnum to link:    1" > $PARAMS
  899. X    echo "Number of bytes held:    0" >> $PARAMS
  900. X    echo "Date last squirreled:    0" >> $PARAMS
  901. X    echo "Next chapter number:    1" >> $PARAMS
  902. X    echo "Blocks of offset:    0" >> $PARAMS
  903. X    chgrp $GRP $PARAMS
  904. X    chown $OWN $PARAMS
  905. Xfi
  906. X
  907. Xstate=1
  908. X
  909. Xwhile [ 1 ]
  910. Xdo
  911. X    state=`sed -n 's/State of operations:\    //p' $RDPARMS`
  912. X    case $state in
  913. X        1) util.rd.sh
  914. X            ret=$?
  915. X            if [ "$ret" = "0" ]
  916. X            then
  917. X                state=2
  918. X            else
  919. X                Tgetname -l
  920. X                exit
  921. X            fi;;
  922. X        2) util.sq.sh
  923. X            ret=$?
  924. X            case $ret in
  925. X                0) state=1;;
  926. X                1) tgetname -l
  927. X                    exit;;
  928. X                2) state=3;;
  929. X            esac;;
  930. X        3) Tgetname -l
  931. X            util.prep.sh
  932. X            ret=$?
  933. X            if [ "$ret" = 0 ]
  934. X            then
  935. X                state=4
  936. X            else
  937. X                exit
  938. X            fi;;
  939. X        4) util.wr.sh
  940. X            ret=$?
  941. X            if [ "$ret" = 0 ]
  942. X            then
  943. X                state=1
  944. Xecho `date +%T`" Finished writing to new tape.  Reinsert the source tape.
  945. X<cr> to continue. Q)uit."
  946. X                read ch
  947. X                if [ "$ch" = "q" -o "$ch" = "Q" ]
  948. X                then
  949. X                    exit
  950. X                fi
  951. X            else
  952. X                exit
  953. X            fi;;
  954. X    esac
  955. Xawk -F"    " - '{ if ( $0 ~ /State of operations:/ ) $2 = "'"$state"'"
  956. X        print $1"    "$2 >> "'$TMP1'"
  957. X        }' $RDPARMS
  958. X    mv $TMP1 $RDPARMS
  959. X    chgrp $GRP $RDPARMS
  960. X    chown $OWN $RDPARMS
  961. X
  962. Xdone
  963. Xexit
  964. END_OF_utils/convert.sh
  965. if test 1514 -ne `wc -c <utils/convert.sh`; then
  966.     echo shar: \"utils/convert.sh\" unpacked with wrong size!
  967. fi
  968. chmod +x utils/convert.sh
  969. # end of overwriting check
  970. fi
  971. if test -f utils/set_up.sh -a "${1}" != "-c" ; then 
  972.   echo shar: Will not over-write existing file \"utils/set_up.sh\"
  973. else
  974. echo shar: Extracting \"utils/set_up.sh\" \(3149 characters\)
  975. sed "s/^X//" >utils/set_up.sh <<'END_OF_utils/set_up.sh'
  976. X# This is the sequence of operations to read articles from a tape
  977. X# prepared using 'prep' and 'wr.tape'.
  978. X
  979. Xif [ ! "$WRKDIR" ]
  980. Xthen
  981. X    . /news/.tape.ops/utils/util.hdr.sh
  982. Xfi
  983. X
  984. X
  985. X# This should be the start of the program
  986. Xecho "This script allows you to select the partially filled chapter and read
  987. Xit to the 'cache' directory.  It can then be appended to and rewritten
  988. Xto the same chapter. <cr> \c"
  989. Xread ch
  990. X
  991. Xret=1
  992. Xwhile [ $ret != 0 ]
  993. Xdo
  994. X    Tgetname -t
  995. X    ret=$?
  996. X    if [ $ret != 0 ]
  997. X    then
  998. Xecho "Please a target tape. <cr> to continue, Q)uit. \c"
  999. X        read  ch
  1000. X        if [ "$ch" = "q" -o "$ch" = "Q" ]
  1001. X        then
  1002. X            exit 1
  1003. X        fi
  1004. X        ret=1
  1005. X    fi
  1006. Xdone
  1007. X
  1008. XTgetname -v > /dev/null
  1009. Xset `Tgetname -r | tr -d "'"`
  1010. Xname=$1
  1011. Xfoffset=$2
  1012. X
  1013. Xwhile [ 1 ]
  1014. Xdo
  1015. X    echo "\tThe contents of tape '$name' are:"
  1016. X    $SRCDIR/read.vtoc -w9
  1017. X    echo "Select which chapter to move to 'cache'. \c"
  1018. X    read chap
  1019. X    if [ $cHap -eq 0 -o $chap -gt 9 ]
  1020. X    then
  1021. X        echo "\nTry again, '$chap" is not a legal number."
  1022. X    fi
  1023. X    set `$SRCDIR/read.vtoc -r$chap`
  1024. X    offset=$2
  1025. X    blocks=$3
  1026. X    echo "\tYou have selected to read '$blocks' blocks from chapter '$chap'
  1027. X    starting at offset '$offset'. <y/n> \c"
  1028. X    read ch
  1029. X    if [ "$ch" = "y" -o "$ch" = "Y" ]
  1030. X    then
  1031. X        break
  1032. X    fi
  1033. Xdone
  1034. Xecho `date +%T`" Reading chapter $chap from tape '$name' starting \
  1035. Xat $offset offset."
  1036. Xif [ ! -d $CACHE ]
  1037. Xthen
  1038. X    mkdir $CACHE
  1039. Xfi
  1040. Xcd $CACHE
  1041. Xdbuf -iT248O$offset /dev/rft3 2>/dev/null | \
  1042. X    execStrip tapecpio -icdR"T248" >/dev/null 2>$WRKDIR/errs
  1043. Xret=$?
  1044. Xif [ $ret != 0 ]
  1045. Xthen
  1046. X    echo "ret = "$ret
  1047. X    echo "Whoops.  There was an error during the updating '$name'.
  1048. XBailing out!  Please rerun this program."
  1049. X    exit 1
  1050. Xfi
  1051. Xcd $WRKDIR
  1052. X
  1053. Xif [ ! -s $RDPARMS ]
  1054. Xthen
  1055. X    > $RDPARMS
  1056. Xfi
  1057. Xawk -F"    " - '{    if ( $0 ~ /Number of bytes held:/ ) ok1 = 1
  1058. X        if ( $0 ~ /Next fnum to link:/ ) ok2 = 1
  1059. X        if ( $0 ~ /Name of work tape:/ ) ok3 = 1
  1060. X        if ( $0 ~ /Blocks of offset:/ ) ok4 = 1
  1061. X        if ( $0 ~ /Date last taped:/ ) ok5 = 1
  1062. X        if ( $0 ~ /Blocks available:/ ) ok6 = 1
  1063. X        if ( $0 ~ /Next chapter number:/ ) ok7 = 1
  1064. X        if ( $0 ~ /Compression factor:/ ) ok8 = 1
  1065. X        if ( $0 ~ /Name of source tape:/ ) ok11 = 1
  1066. X        if ( $0 ~ /Next source chapter:/ ) ok9 = 1
  1067. X        if ( $0 ~ /Comment:/ ) ok10 = 1
  1068. X    }
  1069. X    END{    if ( ok1 != 1 ) print "Number of bytes held:    0"
  1070. X        if ( ok2 != 1 ) print "Next fnum to link:    0"
  1071. X        if ( ok3 != 1 ) print "Name of work tape:    blank"
  1072. X        if ( ok4 != 1 ) print "Blocks of offset:    0"
  1073. X        if ( ok5 != 1 ) print "Date last taped:    1-1-1"
  1074. X        if ( ok6 != 1 ) print "Blocks available:    45384"
  1075. X        if ( ok7 != 1 ) print "Next chapter number:    1"
  1076. X        if ( ok8 != 1 ) print "Compression factor:    1024"
  1077. X        if ( ok11 != 1 ) print "Name of source tape:    blank"
  1078. X        if ( ok9 != 1 ) print "Next source chapter:    1"
  1079. X        if ( ok10 != 1 ) print "Comment:    "
  1080. X    }' $RDPARMS >> $RDPARMS
  1081. X(( avail = $MAXOFFSET - $offset ))
  1082. Xawk -F"    " - '{ if ( $0 ~ /Name of work tape:/ ) $2 = "'"$name"'"
  1083. X        if ( $0 ~ /Next chapter number:/ ) $2 = "'"$chap"'"
  1084. X        if ( $0 ~ /Blocks of offset:/ ) $2 = "'"$offset"'"
  1085. X        if ( $0 ~ /Blocks available:/ ) $2 = "'"$avail"'"
  1086. X        print $1"    "$2 >> "'$TMP1'"
  1087. X        }' $RDPARMS
  1088. Xmv $TMP1 $RDPARMS
  1089. X
  1090. XTgetname -b
  1091. Xsafe=$?
  1092. Xif [ $safe = 30 ]
  1093. Xthen
  1094. X    echo "\n\tThis tape has the \"SAFE\" key set.
  1095. X\tYou will need to reset it before trying to write."
  1096. Xfi
  1097. END_OF_utils/set_up.sh
  1098. if test 3149 -ne `wc -c <utils/set_up.sh`; then
  1099.     echo shar: \"utils/set_up.sh\" unpacked with wrong size!
  1100. fi
  1101. chmod +x utils/set_up.sh
  1102. # end of overwriting check
  1103. fi
  1104. if test -f utils/trim.sh -a "${1}" != "-c" ; then 
  1105.   echo shar: Will not over-write existing file \"utils/trim.sh\"
  1106. else
  1107. echo shar: Extracting \"utils/trim.sh\" \(3621 characters\)
  1108. sed "s/^X//" >utils/trim.sh <<'END_OF_utils/trim.sh'
  1109. Xif [ ! "$WRKDIR" ]
  1110. Xthen
  1111. X    . /news/.tape.ops/utils/util.hdr.sh    # Use this for start up
  1112. Xfi
  1113. X
  1114. Xcheck=$1
  1115. Xbad_blocks=0
  1116. X
  1117. Xfunction move_em
  1118. X{
  1119. X    source=$1
  1120. X    target=$2
  1121. X    rm -f $source/contents $source/ss.filelist
  1122. X    ls -l $source | cut -c27-37,51- | sort -nr > $TMP1
  1123. X
  1124. X# Add in 200 bytes for each file, 85 for the cpio header,
  1125. X# 59 for the 'contents' file
  1126. X# size of ss.filelist entry handled by "length $2 + 2", '-' & '\n'
  1127. X    set `awk - 'BEGIN{ source = "'"$source"'"
  1128. X        target = "'"$target"'"
  1129. X        sum = "'"$sum"'" + 0
  1130. X        lim = "'"$hi_lim"'" + 0
  1131. X        fnum = "'"$fnum"'" + 0
  1132. X        max = lim * 512 }
  1133. X        {
  1134. X            if ( $2 == "" ) next
  1135. X            tsum = $1 + sum + 134 + length ( $2 ) + 2
  1136. X            if ( tsum <= max ) {
  1137. X            print source"/"$2" "target"/"fnum".Z" > "'"$TMP2"'"
  1138. X                sum = tsum
  1139. X                fnum++
  1140. X            }
  1141. X        }
  1142. X        END { print sum"    "fnum }' $TMP1`
  1143. X    sum=$1
  1144. X    fnum=$2
  1145. X    
  1146. X    while
  1147. X        read line
  1148. X        [ "$line" != "" ]
  1149. X    do
  1150. X        mv $line
  1151. X    done < $TMP2
  1152. X    rm -f $TMP1 $TMP2
  1153. X    return 0
  1154. X}
  1155. X
  1156. Xif [ "$check" = "test" ]
  1157. Xthen
  1158. X    echo "\tChecking for amount of residual data. \c"
  1159. Xelse
  1160. X    echo `date +%T`" Preparing chapter size. \c"
  1161. Xfi
  1162. X
  1163. Xpoffset=`sed -n 's/Blocks of offset:\    //p' $PARAMS`
  1164. Xpchap=`sed -n 's/Next chapter number:\    //p' $PARAMS`
  1165. X
  1166. X(( hi_lim =  ( MAXOFFSET - poffset ) / ( 10 - pchap ) ))
  1167. X
  1168. X# The '248' value is associated with the size of buffer used to
  1169. X# write to tape.
  1170. X#if [ $pchap -lt 9 ]
  1171. X#then
  1172. X    while
  1173. X        (( hi_lim % 248 ))
  1174. X    do
  1175. X        (( hi_lim = hi_lim + 1 ))
  1176. X    done
  1177. X#fi
  1178. X
  1179. X# Start with 255 bytes. 85 for the cpio header for
  1180. X# 'contents', 'ss.filelist' and 'TRAILER!!!'
  1181. Xsum=255
  1182. Xblks=0
  1183. Xfnum=1
  1184. X
  1185. Xif [ ! -d $CACHE ]
  1186. Xthen
  1187. X    echo "We have 0 blocks on hand."
  1188. X    exit 0
  1189. Xfi
  1190. X
  1191. Xls -l $CACHE | tee $TMP1 | cut -c27-37,51- | sort -nr > $TMP2
  1192. Xa_blks=`cat $TMP1 2>/dev/null | sed -e '1 q' | cut -d' ' -f2`
  1193. Xif [ "$check" = "test" ]
  1194. Xthen
  1195. X# Add in 200 bytes for each file, 85 for the cpio header,
  1196. X# 59 for the 'contents' file and 6 for the 'ss.filest'.
  1197. X    blks=`awk 'BEGIN { sum = "'"$sum"'" }
  1198. X        { sum = sum + $1 + 134 + length ( $2 ) + 2 }
  1199. X        END { blks = sum / 512; printf "%d\n", blks }' $TMP2`
  1200. X    rm -f $TMP1 $TMP2
  1201. X    if [ $blks -ge $hi_lim ]
  1202. X    then
  1203. X        echo "\nThere are already $blks blocks in the 'cache'.
  1204. X    We won't need to read the next chapter now."
  1205. X        exit 3
  1206. X    else
  1207. X        echo "We have $blks blocks on hand."
  1208. X        exit 0
  1209. X    fi
  1210. Xelse
  1211. X    echo "Size will be $hi_lim blocks."
  1212. Xfi
  1213. X
  1214. Xfor i in $ARCDIR $SAVDIR $CACHE
  1215. Xdo
  1216. X    if [ ! -d $i ]
  1217. X    then
  1218. X        mkdir $i
  1219. X    fi
  1220. Xdone
  1221. X
  1222. Xecho "Chap $pchap, estimate = $hi_lim." >> vch
  1223. Xecho "$hi_lim" > hi_limit
  1224. X
  1225. Xls -l $SAVDIR | tee $TMP1 | cut -c27-37,51- | sort -nr > $TMP2
  1226. Xs_blks=`cat $TMP1 2>/dev/null | sed -e '1 q' | cut -d' ' -f2`
  1227. Xif [ $s_blks -ne 0 ]
  1228. Xthen
  1229. X    fnum=`wc -l $TMP2 | cut -c1-8`
  1230. X    sum=`awk 'BEGIN { sum = 0 }
  1231. X        { sum = sum + $1 + 82 }
  1232. X        END { print sum }' $TMP2`
  1233. X    rm -f $TMP1 $TMP2
  1234. Xfi
  1235. X
  1236. Xif [ $a_blks -ne 0 ]
  1237. Xthen
  1238. X    echo `date +%T`" Moving residual 'cache' to 'savdir'."
  1239. X    move_em $CACHE $SAVDIR
  1240. Xfi
  1241. X
  1242. Xc_blks=`ls -l $ARCDIR | sed -e '1 q' | cut -d' ' -f2`
  1243. Xif [ $c_blks -ne 0 ]
  1244. Xthen
  1245. X    echo `date +%T`" Moving 'cache' to 'savdir'."
  1246. X    move_em $ARCDIR $SAVDIR
  1247. Xfi
  1248. X
  1249. Xc_blks=`ls -l $ARCDIR | sed -e '1 q' | cut -d' ' -f2`
  1250. Xif [ $c_blks -ne 0 ]
  1251. Xthen
  1252. X    num=`ls -l $CACHE | sed -e '1 q' | cut -d' ' -f2`
  1253. X    (( num = num + 1 ))
  1254. X    echo `date +%T`" Moving residual 'cache' to 'cache'."
  1255. X    ls -1 $ARCDIR > $TMP1
  1256. X    while
  1257. X        read pntr
  1258. X    do
  1259. X        mv $ARCDIR/$pntr $CACHE/$$$num.Z
  1260. X        (( num = num + 1 ))
  1261. X    done < $TMP1
  1262. X    rm $TMP1
  1263. Xfi
  1264. X
  1265. X(( diff = $hi_lim - ( $sum / 512 ) ))
  1266. X
  1267. Xecho "Chap $pchap, difference = $diff." >> vch
  1268. Xecho "$sum" > sum
  1269. Xif [ $diff -gt 1 ]
  1270. Xthen
  1271. X#    $SRCDIR/read.vtoc -w9
  1272. X    echo \
  1273. X"\n\tWe will have $diff empty blocks remaining.
  1274. X\tShall we read another chapter? <y/n> \c"
  1275. X    read ch
  1276. X    if [ "$ch" = "y" -o "$ch" = "Y" ]
  1277. X    then
  1278. X        exit 1
  1279. X    fi
  1280. Xfi
  1281. Xexit 0
  1282. END_OF_utils/trim.sh
  1283. if test 3621 -ne `wc -c <utils/trim.sh`; then
  1284.     echo shar: \"utils/trim.sh\" unpacked with wrong size!
  1285. fi
  1286. chmod +x utils/trim.sh
  1287. # end of overwriting check
  1288. fi
  1289. if test -f utils/util.hdr.sh -a "${1}" != "-c" ; then 
  1290.   echo shar: Will not over-write existing file \"utils/util.hdr.sh\"
  1291. else
  1292. echo shar: Extracting \"utils/util.hdr.sh\" \(1256 characters\)
  1293. sed "s/^X//" >utils/util.hdr.sh <<'END_OF_utils/util.hdr.sh'
  1294. X
  1295. X# The purpose of this script is to prepare the 'squirrel'ed files
  1296. X# for transfer to tape.  This consists of building a 'contents'
  1297. X# file from the "Subject" line in the posted articles.  The 'contents'
  1298. X# is sorted and similar titles are moved together for easier reference.
  1299. X# The articles are then compressed and moved to the 'savdir' where
  1300. X# they can copied to tape.
  1301. X
  1302. Xexport NEWSDEV=/dev/fp002
  1303. Xexport WRKDIR=/news/.tape.ops/utils
  1304. Xexport CACHE=$WRKDIR/cache
  1305. Xexport ARCDIR=$WRKDIR/arcdir
  1306. Xexport RDPARMS=$WRKDIR/rd.params
  1307. Xexport PARAMS=$WRKDIR/rd.params        # was "wr.params"
  1308. Xexport SAVDIR=$WRKDIR/savdir
  1309. Xexport CONFILE=$WRKDIR/contents
  1310. Xexport SRCDIR=/news/.tape.ops/src
  1311. Xexport PNTRS=$WRKDIR/pntrs
  1312. Xexport CPNTRS=$WRKDIR/c.pntrs
  1313. Xexport LIST=$WRKDIR/save.list        # Directory list to be saved
  1314. Xexport LINKS=$WRKDIR/link.list
  1315. Xexport KLINKS=$WRKDIR/wrk.links
  1316. Xexport GOOFS=$WRKDIR/goofs
  1317. Xexport TMP1=$WRKDIR/tmpp1
  1318. Xexport TMP2=$WRKDIR/tmpp2
  1319. Xexport COPY=0
  1320. Xexport GRP=news
  1321. Xexport OWN=netnews
  1322. Xexport PERCENT=6200    # This is the last five percent of disk space
  1323. Xexport MAXOFFSET=45384  # or B1FE 512 byte blocks = 23329792 bytes
  1324. X# was 45566
  1325. X# If we add 2 blocks for header, B200 512 byte blocks
  1326. X# or 1DAA blocks per stream???
  1327. X# The MAXOFFSET revised 9-29-92 by experimentation.
  1328. END_OF_utils/util.hdr.sh
  1329. if test 1256 -ne `wc -c <utils/util.hdr.sh`; then
  1330.     echo shar: \"utils/util.hdr.sh\" unpacked with wrong size!
  1331. fi
  1332. chmod +x utils/util.hdr.sh
  1333. # end of overwriting check
  1334. fi
  1335. if test -f utils/util.prep.sh -a "${1}" != "-c" ; then 
  1336.   echo shar: Will not over-write existing file \"utils/util.prep.sh\"
  1337. else
  1338. echo shar: Extracting \"utils/util.prep.sh\" \(2564 characters\)
  1339. sed "s/^X//" >utils/util.prep.sh <<'END_OF_utils/util.prep.sh'
  1340. Xif [ ! "$WRKDIR" ]
  1341. Xthen
  1342. X    . /news/.tape.ops/utils/util.hdr.sh    # Use this for start up
  1343. Xfi
  1344. X
  1345. Xecho `date +%T`" Starting prep routines for transfer to tape."
  1346. X
  1347. X# Clean out any previous effort to generate a 'savdir' etc.  Then
  1348. X# create new ones.
  1349. X
  1350. Xif [ -d $SAVDIR ]
  1351. Xthen
  1352. X    rm -r $SAVDIR
  1353. Xfi
  1354. Xmkdir $SAVDIR
  1355. X
  1356. Xif [ -f $TMP1 ]
  1357. Xthen
  1358. X    rm $TMP1
  1359. Xfi
  1360. Xif [ -f $TMP2 ]
  1361. Xthen
  1362. X    rm $TMP2
  1363. Xfi
  1364. X
  1365. Xif [ -s $PARAMS ]
  1366. Xthen
  1367. X    fnum=`awk - '{ if ( $0 ~ /Last fnum:/ ) print $3 }' $PARAMS`
  1368. Xelse
  1369. X    echo "We are in trouble!"
  1370. X    echo "There is no $PARAMS file so the 'squirrel'ed data is"
  1371. X    echo "defective.  Clean it up before proceeding."
  1372. X    read
  1373. X    exit 1
  1374. Xfi
  1375. X
  1376. X> $CONFILE
  1377. Xls -1 $ARCDIR > $PNTRS
  1378. X
  1379. Xecho `date +%T`" Reading 'Subject:' lines from 'arcdir'. "
  1380. X
  1381. X# Go through all the files in 'arcdir' and read the 'Subject: ' line.
  1382. X# Add a tab and the file number to the line and put it in 'contents'.
  1383. Xwhile
  1384. X    read pntr
  1385. Xdo
  1386. X    subj=`sed -n '/^Subject:/ {
  1387. X            s/Subject: //p
  1388. X            q
  1389. X            }' $ARCDIR/$pntr`
  1390. X    if [ -n "$subj" ]
  1391. X    then
  1392. X        echo "$subj""\t"$pntr >> $CONFILE
  1393. X    fi
  1394. Xdone <$PNTRS
  1395. X
  1396. Xecho `date +%T`" Changing arrangement of the 'contents' file. "
  1397. X# Sort the 'contents' then run 'group' to place followup articles
  1398. X# following the original.  'Group' also produces 'c.pntrs' which is
  1399. X# a listing of the files in the same order that they appear
  1400. X# in the 'contents'.
  1401. X
  1402. Xsort -fd -o $CONFILE $CONFILE
  1403. X$SRCDIR/group
  1404. X
  1405. Xecho "\tYou should have a destination tape installed in the drive at
  1406. X\tthis point.  It will then have completed the retension phase
  1407. X\tbefore you need it."
  1408. X
  1409. Xecho `date +%T`" Moving and compressing files to be taped. "
  1410. X# Get the 'arcdir' file names from 'contents' and transfer to 'savdir'
  1411. X# while compressing.  Be careful not to use up the last 5 percent of
  1412. X# disk.  Strip the "Path:" line from the heading in the process.
  1413. X
  1414. Xwhile
  1415. X    read pntr
  1416. Xdo
  1417. X    sed '/^Path:/d' $ARCDIR/$pntr | compress > $SAVDIR/$pntr.Z
  1418. X    chgrp $GRP $SAVDIR/$pntr.Z
  1419. X    chown $OWN $SAVDIR/$pntr.Z
  1420. X    set `df $NEWSDEV`
  1421. X    if [ $3 -lt $PERCENT ]
  1422. X    then
  1423. X        total=`cat $PNTRS | wc -l`
  1424. X        lnum=`fgrep -nx $pntr $PNTRS | cut -f1 -d":"`
  1425. X        let needed="$total-$lnum"
  1426. Xecho "You are running low on disk space.  There are only $3 blocks
  1427. Xremaining.  So far, $lnum of $total files have been compressed.
  1428. X    A. Single step through the rest of the list.
  1429. X    B. Open another window and transfer data to floppy disks.
  1430. X    C. Go ahead and put what we have on tape, save the rest.
  1431. X    D. Quit for now.
  1432. XEnter A, B, C, or D. <cr>"
  1433. X        read ans
  1434. X        if [ "$ans" = "d" -o "$ans" = "D" ]
  1435. X        then
  1436. X            cd $currdir
  1437. X            exit 1
  1438. X        elif [ "$ans" = "c" -o "$ans" = "C" ]
  1439. X        then
  1440. X            break
  1441. X        fi
  1442. X    fi
  1443. Xdone < $CPNTRS
  1444. X
  1445. Xexit 0
  1446. END_OF_utils/util.prep.sh
  1447. if test 2564 -ne `wc -c <utils/util.prep.sh`; then
  1448.     echo shar: \"utils/util.prep.sh\" unpacked with wrong size!
  1449. fi
  1450. chmod +x utils/util.prep.sh
  1451. # end of overwriting check
  1452. fi
  1453. if test -f utils/util.rd.sh -a "${1}" != "-c" ; then 
  1454.   echo shar: Will not over-write existing file \"utils/util.rd.sh\"
  1455. else
  1456. echo shar: Extracting \"utils/util.rd.sh\" \(3269 characters\)
  1457. sed "s/^X//" >utils/util.rd.sh <<'END_OF_utils/util.rd.sh'
  1458. X# This is the sequence of operations to read articles from a tape
  1459. X# prepared using 'prep' and 'wr.tape'.
  1460. X
  1461. Xif [ ! "$WRKDIR" ]
  1462. Xthen
  1463. X    . /news/.tape.ops/utils/util.hdr.sh
  1464. Xfi
  1465. X
  1466. X
  1467. X# This should be the start of the program
  1468. X
  1469. Xecho `date +%T`" Starting read operations. "
  1470. Xtoday=`date '+%y-%m-%d'`
  1471. Xif [ ! -f $RDPARMS ]
  1472. Xthen
  1473. X    > $RDPARMS
  1474. X    chgrp $GRP $RDPARMS
  1475. X    chown $OWN $RDPARMS
  1476. Xfi
  1477. X
  1478. X# Check that the 'params' file has the proper entries.
  1479. Xawk -F"    " - '{ if ( $0 ~ /Name of work tape:/ ) ok1 = 1
  1480. X        if ( $0 ~ /Date last taped:/ ) ok2 = 1
  1481. X        if ( $0 ~ /Next chapter number:/ ) ok5 = 1
  1482. X        }
  1483. X        END{
  1484. X        if ( ok1 != 1 )    print "Name of work tape:    "
  1485. X        if ( ok2 != 1 )    print "Date last taped:    0"
  1486. X        if ( ok5 != 1 )    print "Next chapter number:    0"
  1487. X    }' $RDPARMS >> $RDPARMS
  1488. X
  1489. Xret=1
  1490. Xch=x
  1491. Xwhile [ $ret != 0 ]
  1492. Xdo
  1493. X    Tgetname -t
  1494. X    ret=$?
  1495. X    if [ $ret != 0 ]
  1496. X    then
  1497. Xecho "Please insert a source tape. <cr> to continue, Q)uit. \c"
  1498. X        read  ch
  1499. X        if [ "$ch" = "q" -o "$ch" = "Q" ]
  1500. X        then
  1501. X            exit 1
  1502. X        fi
  1503. X        ret=1
  1504. X    else
  1505. X# From here on, the tape drive is locked, any 'exit' must perform
  1506. X# 'Tgetname -l' to unlock the drive befor leaving.
  1507. X#        Tgetname +l
  1508. X        Tgetname -v > /dev/null
  1509. X        set `Tgetname -r | tr -d "'"`
  1510. X        name=$1
  1511. X        $SRCDIR/read.vtoc -w9 > this.tape
  1512. X        if [ -f old.tape ]
  1513. X        then
  1514. X            diff this.tape old.tape > /dev/null
  1515. X            ret=$?
  1516. X            if [ $ret != 0 ]
  1517. X            then
  1518. Xecho "This doesn't seen to be the tape that I have been reading.
  1519. XWaiting for another tape to be inserted.
  1520. X<cr> to continue. Q)uit \c"
  1521. X                read ch
  1522. X            if [ "$ch" = "q" -o "$ch" = "Q" ]
  1523. X                then
  1524. X                    Tgetname -l
  1525. X                    exit 1
  1526. X                fi
  1527. X            fi
  1528. X        else
  1529. Xecho "There isn't any info about any previous tape.  If this is the beginning
  1530. Xof a tape to be converted, <cr> to continue. Q)uit \c"
  1531. X            Tgetname -l
  1532. X            read ch
  1533. X            if [ "$ch" = "q" -o "$ch" = "Q" ]
  1534. X            then
  1535. X                exit 1
  1536. X            fi
  1537. Xawk -F"    " - '{ if ( $0 ~ /Name of work tape:/ ) $2 = "'"$name"'"
  1538. X        if ( $0 ~ /Date last taped:/ ) $2 = "'"$today"'"
  1539. X        if ( $0 ~ /Next chapter number:/ ) $2 = "1"
  1540. X        print $1"    "$2 >> "'$TMP1'"
  1541. X        }' $RDPARMS
  1542. X            mv $TMP1 $RDPARMS
  1543. X            ret=0
  1544. X        fi
  1545. X    fi
  1546. Xdone
  1547. X
  1548. X# Get params
  1549. Xtdate=`sed -n 's/Date last taped:\    //p' $RDPARMS`
  1550. Xchap=`sed -n 's/Next chapter number:\    //p' $RDPARMS`
  1551. X
  1552. Xset `$SRCDIR/read.vtoc -r$chap`
  1553. Xoffset=$2
  1554. Xblocks=$3
  1555. Xcat this.tape
  1556. Xbase=$PWD
  1557. Xif [ -d recover ]
  1558. Xthen
  1559. X    echo `date +%T`" Purging old 'recover' directory. "
  1560. X    rm -r recover
  1561. Xfi
  1562. Xmkdir recover
  1563. Xcd recover
  1564. X
  1565. Xecho `date +%T`" Reading chapter $chap from tape '$name' starting \
  1566. Xat $offset offset."
  1567. Xdbuf -iT248O$offset /dev/rft3 2>/dev/null | \
  1568. X    execStrip tapecpio -icdR"T248" >/dev/null 2>$WRKDIR/errs
  1569. X
  1570. Xret=$?
  1571. Xif [ $ret != 0 ]
  1572. Xthen
  1573. X    echo "ret = "$ret
  1574. X    echo "Whoops.  There was an error during the reading of '$name'.
  1575. XBailing out!  Please rerun this program."
  1576. X    Tgetname -l
  1577. X    exit 1
  1578. Xfi
  1579. Xecho `date +%T`" Rewinding tape."
  1580. Xnohup Tgetname -v >/dev/null 2>/dev/null &        # to rewind the tape
  1581. X
  1582. Xcd $base
  1583. X
  1584. X(( chap=chap+1 ))
  1585. X$SRCDIR/read.vtoc -r$chap > /dev/null
  1586. Xret=$?
  1587. Xif [ $chap -ge $ret ]
  1588. Xthen
  1589. X    rm old.tape
  1590. X    chap=1
  1591. X    echo "This was the last chapter on this tape.  Next time insert \
  1592. Xa different tape."
  1593. X    Tgetname -l
  1594. Xelse
  1595. X    mv this.tape old.tape
  1596. Xfi
  1597. Xawk -F"    " - '{ if ( $0 ~ /Name of work tape:/ ) $2 = "'"$name"'"
  1598. X        if ( $0 ~ /Next chapter number:/ ) $2 = "'"$chap"'"
  1599. X        print $1"    "$2 >> "'$TMP1'"
  1600. X        }' $RDPARMS
  1601. X        mv $TMP1 $RDPARMS
  1602. Xrm -f /tmp/tape.vtoc
  1603. Xexit 0
  1604. END_OF_utils/util.rd.sh
  1605. if test 3269 -ne `wc -c <utils/util.rd.sh`; then
  1606.     echo shar: \"utils/util.rd.sh\" unpacked with wrong size!
  1607. fi
  1608. chmod +x utils/util.rd.sh
  1609. # end of overwriting check
  1610. fi
  1611. if test -f utils/util.sq.sh -a "${1}" != "-c" ; then 
  1612.   echo shar: Will not over-write existing file \"utils/util.sq.sh\"
  1613. else
  1614. echo shar: Extracting \"utils/util.sq.sh\" \(3944 characters\)
  1615. sed "s/^X//" >utils/util.sq.sh <<'END_OF_utils/util.sq.sh'
  1616. X# The purpose of this script is to 'squirrel' away files in the news
  1617. X# files for transfer to tape.  By linking these files to entries in
  1618. X# the 'arcdir', they are protected from 'expire' yet do not use up an
  1619. X# great amount of disk space.
  1620. X
  1621. Xif [ ! "$WRKDIR" ]
  1622. Xthen
  1623. X    . /news/.start/utils/util.hdr.sh
  1624. Xfi
  1625. X
  1626. Xecho `date +%T`" Running 'squirrel' to link files into 'arcdir'. "
  1627. X
  1628. X# To commence, let's find out the status of our files and generate
  1629. X# the directories and file entries which are missing.
  1630. X
  1631. Xif [ ! -d $ARCDIR ]
  1632. Xthen
  1633. X    mkdir $ARCDIR
  1634. X    chmod 755 $ARCDIR
  1635. Xfi
  1636. X
  1637. Xif [ ! -s $PARAMS ]
  1638. Xthen
  1639. X    > $PARAMS
  1640. X    chgrp $GRP $PARAMS
  1641. X    chown $OWN $PARAMS
  1642. X    fnum = 1
  1643. Xelse
  1644. X    fnum=`sed -n 's/Next fnum to link:\    //p' $PARAMS`
  1645. Xfi
  1646. X
  1647. X# Check that the 'params' file has the proper entries.
  1648. Xawk -F"    " - '{ 
  1649. X        if ( $0 ~ /Next fnum to link:/ ) ok1 = 1
  1650. X        if ( $0 ~ /Number of bytes held:/ ) ok2 = 1
  1651. X        if ( $0 ~ /Date last squirreled:/ ) ok3 = 1
  1652. X        if ( $0 ~ /Name of work tape:/ ) ok4 = 1
  1653. X        if ( $0 ~ /Blocks of offset:/ ) ok5 = 1
  1654. X        if ( $0 ~ /Date last taped:/ ) ok6 = 1
  1655. X        if ( $0 ~ /Blocks available:/ ) ok7 = 1
  1656. X        if ( $0 ~ /Next chapter number:/ ) ok8 = 1
  1657. X        if ( $0 ~ /Compression factor:/ ) ok9 = 1
  1658. X        }
  1659. X        END{
  1660. X        if ( ok1 != 1 )    print "Next fnum to link:    0"
  1661. X        if ( ok2 != 1 )    print "Number of bytes held:    0"
  1662. X        if ( ok3 != 1 )    print "Date last squirreled:    0"
  1663. X        if ( ok4 != 1 )    print "Name of work tape:    News-000"
  1664. X        if ( ok5 != 1 )    print "Blocks of offset:    0"
  1665. X        if ( ok6 != 1 )    print "Date last taped:    0"
  1666. X        if ( ok7 != 1 )    print "Blocks available:    45566"
  1667. X        if ( ok8 != 1 )    print "Next chapter number:    0"
  1668. X        if ( ok9 != 1 )    print "Compression factor:    1000"
  1669. X    }' $PARAMS >> $PARAMS
  1670. X
  1671. Xtoday=`date '+%y-%m-%d'`
  1672. X
  1673. X# Check for a link list and either create a new one or copy
  1674. X# the current one to wrk.links for upadating.
  1675. X
  1676. Xif [ -s $LINKS ]
  1677. Xthen
  1678. X    cp $LINKS $KLINKS
  1679. Xelse
  1680. X    > $KLINKS
  1681. Xfi
  1682. X
  1683. Xx=fnum
  1684. Xwhile [ -f $ARCDIR/$x ]
  1685. Xdo
  1686. X    rm -f $ARCDIR/$x
  1687. X    (( x = x + 1 ))
  1688. Xdone
  1689. X
  1690. Xrm -f $WRKDIR/contents
  1691. Xrm -f $GOOFS
  1692. X
  1693. Xfunction recur
  1694. X{
  1695. X    if [ -d $1 -a `du -s $1 | cut -f1` = 1 ]
  1696. X    then
  1697. X        return -1
  1698. X    fi
  1699. X    typeset this next
  1700. X    this=$1
  1701. X    set `ls -1 $1`
  1702. X    while [ $1 ]
  1703. X    do
  1704. X        next=$this/$1
  1705. X        if [ -d $next ]
  1706. X        then
  1707. X            recur $next
  1708. X        fi
  1709. X        if [ -f $next ]
  1710. X        then
  1711. X            id=`sed -n '/^Message-ID:/ {
  1712. X                s/Message-ID: //p
  1713. X                q
  1714. X                }' $next | tr -d "/*?^$\[\]|"`
  1715. X            if [ -n "$id" ]
  1716. X            then
  1717. X                if
  1718. X                    [ -z "`sed -n '/'"$id"'/p' $KLINKS`" ]
  1719. X                then
  1720. X                    if ln $next $ARCDIR/$fnum
  1721. X                    then
  1722. X                        let fnum="fnum+1"
  1723. X                        echo "$id""\t"$today \
  1724. X                            >> $KLINKS
  1725. X                    else
  1726. X                echo $next",  "$ARCDIR/$fnum >> $GOOFS
  1727. X                    fi
  1728. X                fi
  1729. X            fi
  1730. X        fi
  1731. X        shift
  1732. X    done
  1733. X}
  1734. X
  1735. Xwhile
  1736. X    read fname
  1737. Xdo
  1738. X    dname=`echo $fname | cut -f1 -d"#"`
  1739. X    if [ -n "$dname" ]
  1740. X    then
  1741. X        echo `date +%T`" Squirreling "$dname.
  1742. X        recur $WRKDIR/recover$dname
  1743. X    fi
  1744. Xdone <$LIST
  1745. X
  1746. X# Fudge the sum by 80 bytes for each entry to account fot the 'contents'
  1747. X# file and the 'ss.filelist' which will added to the tape during write
  1748. X# operations.
  1749. Xnbytes=`ls -l $ARCDIR | awk - '{ sum = sum + $5 + 80 }
  1750. X        END{ print sum }' - `
  1751. X
  1752. Xsort -d -o $LINKS $KLINKS
  1753. X
  1754. X> $TMP1
  1755. Xawk -F"    " - '{ if ( $0 ~ /Next fnum to link:/ ) $2 = "'"$fnum"'"
  1756. X        if ( $0 ~ /Number of bytes held:/ ) $2 = "'"$nbytes"'"
  1757. X        if ( $0 ~ /Date last squirreled:/ ) $2 = "'"$today"'"
  1758. X        print $1"    "$2 >> "'$TMP1'"
  1759. X        }' $PARAMS
  1760. Xmv $TMP1 $PARAMS
  1761. Xchgrp $GRP $PARAMS
  1762. Xchown $OWN $PARAMS
  1763. Xchgrp $GRP $LINKS
  1764. Xchown $OWN $LINKS
  1765. Xrm -f $KLINKS
  1766. X
  1767. Xoffset=`sed -n 's/Blocks of offset:\    //p' $PARAMS`
  1768. Xchap=`sed -n 's/Next chapter number:\    //p' $PARAMS`
  1769. Xfactor=`sed -n 's/Compression factor:\    //p' $PARAMS`
  1770. X
  1771. X(( min_size = ( MAXOFFSET - offset ) / (10 - chap) ))  
  1772. X(( this = nbytes/$factor ))    # blocks for this collection
  1773. X
  1774. Xecho `date +%T`" Squirrling completed.
  1775. X    Recommended size of next tape entry:    $min_size
  1776. X    Approximate size of this collection:    $this"
  1777. X
  1778. Xif [ -d recover ]
  1779. Xthen
  1780. X
  1781. X    echo `date +%T`" Purging 'recover' directory."
  1782. X    rm -r recover
  1783. Xfi
  1784. X
  1785. Xif [ "$chap" -lt 9 ]
  1786. Xthen
  1787. X    (( this = this + 100 ))
  1788. Xfi
  1789. X
  1790. Xif [ "$this" -gt "$min_size" ]
  1791. Xthen
  1792. X    exit 2
  1793. Xelse
  1794. X    exit 0
  1795. Xfi
  1796. END_OF_utils/util.sq.sh
  1797. if test 3944 -ne `wc -c <utils/util.sq.sh`; then
  1798.     echo shar: \"utils/util.sq.sh\" unpacked with wrong size!
  1799. fi
  1800. chmod +x utils/util.sq.sh
  1801. # end of overwriting check
  1802. fi
  1803. echo shar: End of archive 3 \(of 4\).
  1804. cp /dev/null ark3isdone
  1805. MISSING=""
  1806. for I in 1 2 3 4 ; do
  1807.     if test ! -f ark${I}isdone ; then
  1808.     MISSING="${MISSING} ${I}"
  1809.     fi
  1810. done
  1811. if test "${MISSING}" = "" ; then
  1812.     echo You have unpacked all 4 archives.
  1813.     rm -f ark[1-9]isdone
  1814. else
  1815.     echo You still need to unpack the following archives:
  1816.     echo "        " ${MISSING}
  1817. fi
  1818. ##  End of shell archive.
  1819. exit 0
  1820.  
  1821. Vernon C. Hoxie                                {ncar,csn}!scicom!zebra!vern
  1822. 3975 W. 29th Ave.                                   vern@zebra.alphacdc.COM
  1823. Denver, Colo., 80212          voice: 303-477-1780        uucp: 303-455-2670
  1824.  
  1825. -- 
  1826. David H. Brierley
  1827. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  1828. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  1829. %% Pardon me Professor, can I be excused, my brain is full. **
  1830.