%%s 3/3/240 %%d D 1.2 04-May-82 11:32:07 j 2 1 %%c Modified alist.w`alist.r`defns to set the PAGE_LENGTH constant to 59. %%c Noticed that there were some problems with some printers with widowed %%c blank pages when it was set to 60. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:00:52 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- alist.r 5078 asc 25-mar-82 07:15:23 v1.1 (sw-tools v1.1) #-h- defns 205 asc 25-mar-82 07:15:02 v1.1 (sw-tools v1.1) define(PAGE_LENGTH,60) %%E 2 %%I 2 #-h- alist.r 5071 asc 04-may-82 11:30:58 j (sventek j) #-h- defns 205 asc 04-may-82 11:22:41 j (sventek j) define(PAGE_LENGTH,59) %%E 2 define(NUM_WIDTH,5) # with of page number field define(PAGE_WIDTH,72) # width of page define(INDEX_WIDTH,25) # width of index entry define(MEM_SIZE,arith(256,*,INDEX_WIDTH)) #-h- main 2326 asc 25-mar-82 07:15:02 v1.1 (sw-tools v1.1) DRIVER(alist) integer i, int, page, lcnt, j, junk, scrat integer nxtfil, open, getlin, getwrd, equal, imput, imget, remove character file(FILENAMESIZE), path(FILENAMESIZE), lin(MAXLINE), wrd(MAXLINE) DS_DECL(mem,MEM_SIZE) pointer inmemt pointer iminit string hdrstr "#-h-" string lipsis " ....." string biglip " Page" string toc "Table of Contents" string sindex "Index of Entries" call query("usage: alist [file] ...") for (i=1; nxtfil(i, file, path, scrat) != EOF; i=i+1) { int = open(file, READ) if (int == ERR) call cant(file) inmemt = iminit(MEM_SIZE, INDEX_WIDTH) if (inmemt == LAMBDA) call error("Error initializing in-memory sort area.") if (i > 1) call putch(FF, STDOUT) call fmthdr(path, toc, lin) call putlin(lin, STDOUT) call putch('@n', STDOUT) page = 0 lcnt = 0 while (getlin(lin, int) != EOF) { j = 1 junk = getwrd(lin, j, wrd) if (equal(wrd, hdrstr) == YES) { page = page + 1 call skipbl(lin, j) call puthdr(lin(j), lipsis, page) junk = getwrd(lin, j, wrd) # fetch file name call fold(wrd) call fmtndx(wrd, page, lin) junk = imput(inmemt, lin) # store index entry lcnt = 1 } else if (lcnt >= PAGE_LENGTH) { page = page + 1 lcnt = 1 } else lcnt = lcnt + 1 } call close(int) call imsort(inmemt) # sort the index call putch(FF, STDOUT) call fmthdr(path, sindex, lin) call putlin(lin, STDOUT) call putch('@n', STDOUT) while (imget(inmemt, lin) != EOF) { for (j=1; j <= arith(arith(PAGE_WIDTH,-,INDEX_WIDTH),/,2); j=j+1) call putch(' ', STDOUT) call putlin(lin, STDOUT) call putch('@n', STDOUT) } int = open(file, READ) page = 0 lcnt = 0 while (getlin(lin, int) != EOF) { j = 1 junk = getwrd(lin, j, wrd) if (equal(wrd, hdrstr) == YES) { page = page + 1 call putch(FF, STDOUT) call puthdr(lin, biglip, page) lcnt = 1 } else if (lcnt >= PAGE_LENGTH) { page = page + 1 call putch(FF, STDOUT) lcnt = 1 call putlin(lin, STDOUT) } else { lcnt = lcnt + 1 call putlin(lin, STDOUT) } } call close(int) if (scrat == YES) junk = remove(file) } DRETURN end #-h- fmthdr 647 asc 25-mar-82 07:15:04 v1.1 (sw-tools v1.1) subroutine fmthdr(path, middle, buf) character path(FILENAMESIZE), middle(ARB), buf(ARB), date(10), time(10) integer j, limit, init, now(7) integer length data init /YES/ if (init == YES) { init = NO call getnow(now) call fmtdat(date, time, now, LETTER) } j = 1 call stcopy(path, 1, buf, j) limit = (PAGE_WIDTH - length(middle)) / 2 + 1 while (j <= limit) call chcopy(' ', buf, j) call stcopy(middle, 1, buf, j) limit = PAGE_WIDTH - length(date) - length(time) - 1 while (j <= limit) call chcopy(' ', buf, j) call stcopy(date, 1, buf, j) call chcopy(' ', buf, j) call stcopy(time, 1, buf, j) call chcopy('@n', buf, j) return end #-h- fmtndx 348 asc 25-mar-82 07:15:05 v1.1 (sw-tools v1.1) subroutine fmtndx(file, page, buf) character file(FILENAMESIZE), buf(ARB), num(incr(NUM_WIDTH)) integer page, nblank, i, j integer length, itoc nblank = INDEX_WIDTH - length(file) - itoc(page, num, incr(NUM_WIDTH)) j = 1 call stcopy(file, 1, buf, j) for (i=1; i <= nblank; i=i+1) call chcopy(' ', buf, j) call scopy(num, 1, buf, j) return end #-h- nxtfil 652 asc 25-mar-82 07:15:05 v1.1 (sw-tools v1.1) integer function nxtfil(i, file, path, scrat) integer i, scrat, int integer getarg, create character file(FILENAMESIZE), path(FILENAMESIZE) string seed "als" string stdpth "Standard input" if (getarg(i, file, FILENAMESIZE) != EOF) { call mkpath(file, path) scrat = NO nxtfil = OK } else if (i > 1) nxtfil = EOF else { call scratf(seed, file) int = create(file, WRITE) if (int != ERR) { scrat = YES call fcopy(STDIN, int) call close(int) call scopy(stdpth, 1, path, 1) nxtfil = OK } else { call remark("Cannot create scratch file for standard input.") nxtfil = EOF } } return end #-h- puthdr 462 asc 25-mar-82 07:15:06 v1.1 (sw-tools v1.1) subroutine puthdr(first, middle, page) character first(ARB), middle(ARB) integer page, i, limit integer length limit = arith(PAGE_WIDTH,-,NUM_WIDTH) - length(middle) for (i=1; i <= limit; i=i+1) if (first(i) == '@n' | first(i) == EOS) break else call putch(first(i), STDOUT) for ( ; i <= limit; i=i+1) call putch(' ', STDOUT) call putlin(middle, STDOUT) call putdec(page, NUM_WIDTH) call putch('@n', STDOUT) return end #-h- alist.fmt 765 asc 25-mar-82 07:15:26 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Alist (1) 11-Jan-79 generate paginated listing of source archive .sy alist [file] ... .ds `alist' generates a paginated listing of archive files. A table of contents with the relative page number in the listing is displayed first, with each element of the archive file starting on a new page. The second page of the listing contains a sorted index of entries, with the starting page number. If no files are specified, the standard input is read. `alist' considers each line which starts with the string "#-h-" to be the beginning of a new entry, so that nested archives will be handled reasonably. The listing is displayed on standard output, and may be piped into lpr to queue to the printer. .fl .sa pr - print files .di .au Joe Sventek .bu %%E 1