%%s 2/2/833 %%d D 1.3.6 22-Jul-83 11:19:27 sventek 9 8 %%c Modified manual entry to reflect name change of lookup to apropos. %%s 185/111/650 %%d D 1.3.5 22-Jul-83 10:36:41 sventek 8 7 %%c Modified man to search through all sections to find the entries for the %%c user. If more than one section has an entry for `name', only the first %%c is displayed, with a note as to the location of the other entries following %%c the displayed manual entry. The file ~man/mpath is used to determine the %%c order that the sections should be searched. If man is invoked with no %%c arguments, a two screenful help entry is displayed to the user. %%s 4/4/757 %%d D 1.3.4 15-Jun-83 11:03:21 sventek 7 6 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 8/6/753 %%d D 1.3.3 14-Jun-83 08:25:56 sventek 6 5 %%c When manual entries are being displayed on the user's terminal, such that %%c he/she is prompted for "more?", formfeed characters are no longer output. %%c In addition, the routine `allblk' counts formfeed characters (since they %%c are no longer output) as white space in its accounting. This modification %%c is motivated by systems (VMS) which output blank lines upon encountering %%c ^L and for terminals which blank the screen upon reception of such a %%c character. %%s 6/3/753 %%d D 1.3.2 01-Feb-83 14:42:23 stamerjohn 5 4 %%c Change man.w`man.r`gtconf so a ^Z response to more question is a 'no' %%c and not an infinite 'yes'. %%s 70/25/686 %%d D 1.3.1 24-Jun-82 13:31:30 dpm 4 3 %%c Added "bare -s" option to list available manual sections. %%c Required changes to man.w`man.r`dotoc and man.w`man.r`tfetch. %%c Altered man.w`man.fmt to reflect changes and added usage examples. %%s 61/4/650 %%d D 1.3 23-Apr-82 13:30:46 j 3 2 %%c Modified man.w`man.r`main to call dosyn to resolve synonyms for known %%c manual sections. %%c %%c Added man.w`man.r`dosyn to resolve synonyms. %%c %%c Modified man.w`man.fmt to reflect the addition of synonyms for the %%c standard manual sections. Also added information on the structure %%c of the known files in ~man for a given section such that users can %%c create their own manual sections. %%s 80/174/574 %%d D 1.2 23-Apr-82 12:55:24 j 2 1 %%c Eliminated man.w`manndx.sh, as it is no longer needed due to the existence %%c of `asam'. %%c %%c Updated manupd.sh to use `asam' as well as to use the new names for the %%c known directories in ~man -- sect ==> s and index ==> i. This permits %%c generally named sections of the manual to be implemented. %%c %%c Eliminated conditional code in man.w`man.r`defns,doman,tfetch. It was %%c decided that the code to handle TREE_STRUCT_FILE_SYS was superfluous. %%c This eliminated a large body of code. %%c %%c Modified man.w`man.r`main,doman,tfetch to reflect the new names in the %%c known directories, as described above. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:08:57 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 8 #-h- cman 129 asc 25-mar-82 08:08:49 v1.1 (sw-tools v1.1) common / cman / any, table %%E 8 %%I 8 #-h- cman 267 asc 22-jul-83 10:32:33 sventek (joseph sventek) common / cman / any, ifsect, table, done(MAX_ENTRIES) %%E 8 integer any # YES/NO for all entries in section %%I 8 integer ifsect # YES/NO if section was specified %%E 8 pointer table # pointer to in-memory storage table %%I 8 character done # 'Y'/'N' if the current entry has been done %%E 8 #-h- cpage 151 asc 25-mar-82 08:08:50 v1.1 (sw-tools v1.1) common / cpage / pagefd, pagesz filedes pagefd # file descriptor if paging enabled, ERR if not integer pagesz # page size - DEF_PAGE_LEN/HUGE/-/ %%D 2 #-h- man.r 7887 asc 25-mar-82 08:08:52 v1.1 (sw-tools v1.1) #-h- defns 231 asc 25-mar-82 08:08:31 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- man.r 6153 asc 23-apr-82 12:41:19 j (sventek j) %%E 3 %%I 3 %%D 4 #-h- man.r 6813 asc 23-apr-82 13:25:30 j (sventek j) %%E 4 %%E 3 %%I 4 %%D 5 #-h- man.r 7287 asc 24-jun-82 12:55:58 dpm (martin,d.p.) %%E 5 %%E 4 %%I 5 %%D 6 #-h- man.r 7336 asc 01-feb-83 14:40:16 stamerjohn (ralph stamerjohn) %%E 6 %%E 5 %%I 6 %%D 7 #-h- man.r 7434 asc 14-jun-83 08:23:04 sventek (joseph sventek) %%E 7 %%E 6 %%I 7 %%D 8 #-h- man.r 7439 asc 15-jun-83 11:02:36 sventek (joseph sventek) %%E 8 %%E 7 %%D 8 #-h- defns 138 asc 23-apr-82 12:25:51 j (sventek j) %%E 8 %%E 2 %%I 8 #-h- man.r 8745 asc 22-jul-83 10:32:36 sventek (joseph sventek) #-h- defns 170 asc 21-jul-83 13:16:58 sventek (joseph sventek) %%E 8 define(AVE_TOK_SIZE,10) %%D 8 define(MEM_SIZE,arith(256,*,AVE_TOK_SIZE)) %%E 8 %%I 8 define(MAX_ENTRIES,256) define(MEM_SIZE,arith(MAX_ENTRIES,*,AVE_TOK_SIZE)) %%E 8 define(RIGHT_MARGIN,80) define(DEF_PAGE_LEN,22) %%D 2 define(USE_ARCHIVES,) ifdef(TREE_STRUCT_FILE_SYS) define(SEP_STRING,"/") elsedef define(SEP_STRING,".") enddef #-h- main 1242 asc 25-mar-82 08:08:32 v1.1 (sw-tools v1.1) %%E 2 %%I 2 define(SEP_STRING,".") %%D 3 #-h- main 1239 asc 23-apr-82 12:33:10 j (sventek j) %%E 3 %%E 2 %%I 3 %%D 8 #-h- main 1299 asc 23-apr-82 13:13:40 j (sventek j) %%E 8 %%E 3 %%I 8 #-h- main 1303 asc 22-jul-83 09:50:37 sventek (joseph sventek) %%E 8 DRIVER(man) integer i, junk, pndx integer getarg, imput, isatty, ctoi filedes open pointer iminit character arg(FILENAMESIZE) include cman include cpage DS_DECL(Mem, MEM_SIZE) %%D 2 string docfil(FILENAMESIZE) "~man/sect" %%E 2 %%I 2 %%D 8 string docfil(FILENAMESIZE) "~man/s" %%E 8 %%E 2 string suffix(FILENAMESIZE) "1" string ttyfil TERMINAL_IN call query("usage: man [-] [-s
] [-a] [name] ...") if (isatty(STDOUT) == YES) { pagefd = open(ttyfil, READ) pagesz = DEF_PAGE_LEN } else { pagefd = ERR pagesz = HUGE } any = NO %%I 8 ifsect = NO %%E 8 pndx = 1 table = iminit(MEM_SIZE, AVE_TOK_SIZE) for (i=1; getarg(i, arg, FILENAMESIZE) != EOF; i=i+1) if (arg(1) == '-') if (IS_DIGIT(arg(2))) { junk = 2 pagesz = ctoi(arg, junk) if (pagesz <= 0 & pagefd != ERR) # turn off paging { call close(pagefd) # close the file pagefd = ERR } } else if (arg(2) == 'a' | arg(2) == 'A') any = YES else if (arg(2) == 's' | arg(2) == 'S') %%I 8 { ifsect = YES %%E 8 call scopy(arg, 3, suffix, 1) %%I 8 } %%E 8 else call badarg(arg) else { call fold(arg) junk = imput(table, arg) pndx = pndx + 1 } %%I 3 call dosyn(suffix) # resolve synonyms for manual sections %%E 3 %%D 8 call concat(docfil, suffix, docfil) %%E 8 if (pndx == 1 & any == NO) %%D 8 call dotoc(suffix, docfil) %%E 8 %%I 8 if (ifsect == YES) call dotoc(suffix) else call dointr %%E 8 else %%D 8 call doman(suffix, docfil) %%E 8 %%I 8 call doman(suffix) %%E 8 DRETURN end %%D 6 #-h- allblk 179 asc 25-mar-82 08:08:33 v1.1 (sw-tools v1.1) %%E 6 %%I 6 #-h- allblk 196 asc 14-jun-83 08:19:12 sventek (joseph sventek) %%E 6 integer function allblk(buf) character buf(ARB) integer i for (i=1; buf(i) != '@n' & buf(i) != EOS; i=i+1) %%D 6 if (buf(i) != ' ' & buf(i) != '@t') %%E 6 %%I 6 if (buf(i) != ' ' & buf(i) != '@t' & buf(i) != '@f') %%E 6 return(NO) return(YES) end %%D 2 #-h- doman 2707 asc 25-mar-82 08:08:34 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 8 #-h- doman 1761 asc 23-apr-82 12:33:11 j (sventek j) %%E 8 %%E 2 %%D 8 subroutine doman(suffix, file) %%E 8 %%I 8 #-h- doman 839 asc 22-jul-83 09:57:26 sventek (joseph sventek) subroutine doman(suffix) %%E 8 %%D 8 character suffix(ARB), file(ARB), name(FILENAMESIZE), buf(MAXLINE) character gtconf integer size(2), nentry, i integer imget %%E 8 %%I 8 character suffix(ARB), buf(MAXLINE) integer i integer getlin, length, imget %%E 8 filedes fd filedes open include cman %%D 2 ifdef(USE_ARCHIVES) character entry(FILENAMESIZE) integer fsize(2), s1, s2, cmp integer getlin, getwrd, agethd, strcmp filedes dd linepointer ptr enddef %%E 2 %%I 2 %%D 8 character entry(FILENAMESIZE) integer fsize(2), s1, s2, cmp integer getlin, getwrd, agethd, strcmp filedes dd linepointer ptr %%E 8 %%E 2 %%D 8 string noman " - no manual entry available.@n" string pstr "Next entry [n => NO]? " string docdir "~man/" %%E 8 %%D 2 string sindex "index" %%E 2 %%I 2 %%D 8 string sindex "i" %%E 8 %%E 2 %%D 8 string sepr8r SEP_STRING if (any == YES) call tfetch(suffix, file) # load names of all entries call imsort(table) # sort it, just in case call imuniq(table) # strip duplicate entry names nentry = 0 # initially no entries %%E 8 %%D 2 ifdef(USE_ARCHIVES) fd = open(file, READ) if (fd == ERR) call cant(file) %%E 2 %%I 2 %%D 8 fd = open(file, READ) if (fd == ERR) call cant(file) i = 1 call stcopy(docdir, 1, name, i) call stcopy(sindex, 1, name, i) call stcopy(suffix, 1, name, i) dd = open(name, READ) if (dd == ERR) call cant(name) s1 = imget(table, name) s2 = getlin(buf, dd) repeat { if (s1 == EOF | s2 == EOF) break %%E 8 %%E 2 %%D 8 i = 1 %%E 8 %%D 2 call stcopy(docdir, 1, name, i) call stcopy(sindex, 1, name, i) call stcopy(suffix, 1, name, i) dd = open(name, READ) if (dd == ERR) call cant(name) s1 = imget(table, name) s2 = getlin(buf, dd) repeat %%E 2 %%I 2 %%D 8 junk = getwrd(buf, i, entry) cmp = strcmp(entry, name) if (cmp == -1) s2 = getlin(buf, dd) else if (cmp == 0) %%E 8 %%E 2 %%D 8 { %%E 8 %%D 2 if (s1 == EOF | s2 == EOF) break i = 1 junk = getwrd(buf, i, entry) cmp = strcmp(entry, name) if (cmp == -1) s2 = getlin(buf, dd) else if (cmp == 0) %%E 2 %%I 2 %%D 8 nentry = nentry + 1 if (nentry > 1) %%E 8 %%E 2 %%I 8 for (i = 1; i <= MAX_ENTRIES; i = i + 1) done(i) = 'N' if (ifsect == YES) call prman(suffix) else { fd = open("~man/mpath", READ) # open search path file if (fd == ERR) call error("Cannot open search path file!") while (getlin(buf, fd) != EOF) # fetch next section name %%E 8 { %%D 2 nentry = nentry + 1 if (nentry > 1) %%E 2 %%I 2 %%D 8 if (gtconf(pstr) == 'n') %%E 8 %%E 2 %%D 8 { %%E 8 %%D 2 if (gtconf(pstr) == 'n') { s1 = EOF break } %%E 2 %%I 2 %%D 8 s1 = EOF break %%E 8 %%E 2 %%D 8 } %%E 8 %%D 2 call ctoptr(buf, i, ptr) call seek(ptr, fd) fsize(1) = MAX_INTEGER fsize(2) = 0 junk = agethd(fd, buf, size, fsize) call pruniq(fd, size) s1 = imget(table, name) s2 = getlin(buf, dd) %%E 2 %%I 8 i = length(buf) buf(i) = EOS call prman(buf) %%E 8 } %%D 2 else { call putlin(name, ERROUT) call putlin(noman, ERROUT) s1 = imget(table, name) } %%E 2 %%I 2 %%D 8 call ctoptr(buf, i, ptr) call seek(ptr, fd) fsize(1) = MAX_INTEGER fsize(2) = 0 junk = agethd(fd, buf, size, fsize) call pruniq(fd, size) s1 = imget(table, name) s2 = getlin(buf, dd) %%E 8 %%E 2 %%D 8 } %%E 8 %%D 2 call close(fd) call close(dd) while (s1 != EOF & any == NO) %%E 2 %%I 2 %%D 8 else %%E 8 %%E 2 %%D 8 { call putlin(name, ERROUT) call putlin(noman, ERROUT) s1 = imget(table, name) } %%E 8 %%D 2 elsedef while (imget(table, name) != EOF) { i = 1 ifdef(TREE_STRUCT_FILE_SYS) call stcopy(file, 1, buf, i) call stcopy(sepr8r, 1, buf, i) call stcopy(name, 1, buf, i) elsedef call stcopy(docdir, 1, buf, i) call stcopy(name, 1, buf, i) call stcopy(sepr8r, 1, buf, i) call stcopy(suffix, 1, buf, i) enddef fd = open(buf, READ) if (fd == ERR) { call putlin(name, ERROUT) call putlin(noman, ERROUT) } else { size(1) = MAX_INTEGER # dummy size for agtlin size(2) = 0 nentry = nentry + 1 if (nentry > 1) { if (gtconf(pstr) == 'n') break } call pruniq(fd, size) call close(fd) } } enddef %%E 2 %%I 2 %%D 8 } call close(fd) call close(dd) while (s1 != EOF & any == NO) { call putlin(name, ERROUT) call putlin(noman, ERROUT) s1 = imget(table, name) } %%E 8 %%E 2 %%I 8 call close(fd) } if (any == NO) # see if entries not found { call imrset(table) # reset table for (i = 1; imget(table, buf) != EOF; i = i + 1) if (done(i) == 'N') { call putlin(buf, ERROUT) call putlnl(" - no manual entry available.", ERROUT) } } %%E 8 return end %%D 4 #-h- dotoc 592 asc 25-mar-82 08:08:35 v1.1 (sw-tools v1.1) %%E 4 %%I 4 %%D 8 #-h- dotoc 743 asc 24-jun-82 12:54:20 dpm (martin,d.p.) %%E 8 %%E 4 %%D 8 subroutine dotoc(suffix, file) %%E 8 %%I 8 #-h- dotoc 720 asc 21-jul-83 13:17:07 sventek (joseph sventek) subroutine dotoc(suffix) %%E 8 %%D 8 character suffix(ARB), file(ARB), buf(MAXLINE) %%E 8 %%I 8 character suffix(ARB), buf(MAXLINE) %%E 8 integer nxtcol integer imget character name(FILENAMESIZE) include cman string intstr "Manual entries available in section " %%I 4 string secstr "Manual sections available:@n" %%E 4 %%D 8 call tfetch(suffix, file) %%E 8 %%I 8 call tfetch(suffix) %%E 8 call imsort(table) call imuniq(table) %%D 4 call putlin(intstr, STDOUT) # header line call putlnl(suffix, STDOUT) #... %%E 4 %%I 4 if( suffix(1) == EOS ) call putlin( secstr, STDOUT) # header line for sections else { call putlin(intstr, STDOUT) # header line for entries call putlnl(suffix, STDOUT) #... } %%E 4 call putch('@n', STDOUT) # ... call inpack(nxtcol, RIGHT_MARGIN, buf, STDOUT) # initialize packing while (imget(table, name) != EOF) call dopack(name, nxtcol, RIGHT_MARGIN, buf, STDOUT) call flpack(nxtcol, RIGHT_MARGIN, buf, STDOUT) return end %%D 5 #-h- gtconf 244 asc 25-mar-82 08:08:35 v1.1 (sw-tools v1.1) %%E 5 %%I 5 #-h- gtconf 284 asc 01-feb-83 14:35:58 stamerjohn (ralph stamerjohn) %%E 5 character function gtconf(pstr) character pstr(ARB), buf(MAXLINE), c character clower integer junk integer prompt include cpage if (pagefd != ERR) { junk = prompt(pstr, buf, pagefd) %%D 5 c = clower(buf(1)) %%E 5 %%I 5 if (junk == EOF) c = 'n' else c = clower(buf(1)) %%E 5 } else c = 'y' return(c) end %%D 6 #-h- pruniq 796 asc 25-mar-82 08:08:36 v1.1 (sw-tools v1.1) %%E 6 %%I 6 #-h- pruniq 869 asc 14-jun-83 08:19:13 sventek (joseph sventek) %%E 6 ## pruniq - locate duplicate lines in archive entry on int subroutine pruniq(int, size) integer agtlin, allblk %%D 6 integer t, size(2), n, blk %%E 6 %%I 6 integer t, size(2), n, blk, i %%E 6 character buf(MAXLINE) character gtconf include cpage string pstr "More [n => NO]? " if (pagefd == ERR) # no duplicate stripping if not paged { while (agtlin(buf, int, size) != EOF) call putlin(buf, STDOUT) return } n = 0 t = agtlin(buf, int, size) while (t != EOF) { n = n + 1 if (n > pagesz) { if (gtconf(pstr) == 'n') break else n = 0 } %%D 6 call putlin(buf, STDOUT) %%E 6 %%I 6 for (i = 1; buf(i) != EOS; i = i + 1) if (buf(i) != '@f') call putch(buf(i), STDOUT) %%E 6 blk = allblk(buf) t = agtlin(buf, int, size) if (blk == YES) while (t != EOF) if (allblk(buf) == NO) break else t = agtlin(buf, int, size) } while (t != EOF) t = agtlin(buf, int, size) return end %%D 2 #-h- tfetch 1312 asc 25-mar-82 08:08:37 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 4 #-h- tfetch 648 asc 23-apr-82 12:33:13 j (sventek j) %%E 4 %%E 2 %%I 4 %%D 7 #-h- tfetch 970 asc 24-jun-82 12:51:49 dpm (martin,d.p.) %%E 7 %%E 4 %%I 7 %%D 8 #-h- tfetch 968 asc 15-jun-83 11:01:59 sventek (joseph sventek) %%E 8 %%E 7 %%D 8 subroutine tfetch(suffix, file) %%E 8 %%I 8 #-h- tfetch 865 asc 21-jul-83 14:08:26 sventek (joseph sventek) subroutine tfetch(suffix) %%E 8 %%D 8 character suffix(ARB), file(ARB) %%E 8 %%I 8 character suffix(ARB) %%E 8 character name(MAXLINE) pointer iminit %%D 8 integer i, junk %%E 8 %%I 8 integer i, junk, count %%E 8 integer imput include cman %%D 2 ifdef(USE_ARCHIVES) integer index, getlin filedes fd filedes open elsedef character suf(10) integer desc integer opendr, gdrprm, indexs enddef %%E 2 %%I 2 %%D 4 integer index, getlin %%E 4 %%I 4 integer index, gdrprm, getlin %%E 4 filedes fd %%D 4 filedes open %%E 4 %%E 2 %%I 4 filedes open, opendr %%E 4 %%D 2 string sindex "index" string sect "sect" %%E 2 %%I 2 %%D 8 string sindex "i" string sect "s" %%E 8 %%E 2 %%D 8 string docdir "~man/" string sepr8r SEP_STRING %%E 8 table = iminit(MEM_SIZE, AVE_TOK_SIZE) %%D 8 i = 1 call stcopy(docdir, 1, name, i) %%E 8 %%D 2 ifdef(USE_ARCHIVES) call stcopy(sindex, 1, name, i) call stcopy(suffix, 1, name, i) fd = open(name, READ) if (fd == ERR) call error("Cannot open index for manual archive.") while (getlin(name, fd) != EOF) { i = index(name, ' ') name(i) = EOS junk = imput(table, name) } call close(fd) elsedef %%E 2 %%I 2 %%D 4 call stcopy(sindex, 1, name, i) call stcopy(suffix, 1, name, i) fd = open(name, READ) if (fd == ERR) call error("Cannot open index for manual archive.") while (getlin(name, fd) != EOF) { i = index(name, ' ') name(i) = EOS junk = imput(table, name) } call close(fd) %%E 4 %%E 2 %%I 4 if( suffix(1) == EOS ) # Generate table of section names { %%D 8 if( opendr( name, fd) == ERR ) %%E 8 %%D 7 call error( "Cannot open ~man directory.") %%E 7 %%I 7 %%I 8 if( opendr( "~man/", fd) == ERR ) %%E 8 call error( "Cannot open ~man directory") %%E 7 while( gdrprm( fd, name) != EOF ) if( name(1) == 's' | name(1) == 'S' ) junk = imput( table, name(2)) call closdr(fd) } else { %%D 8 call stcopy(sindex, 1, name, i) call stcopy(suffix, 1, name, i) %%E 8 %%I 8 call concat("~man/i", suffix, name) %%E 8 fd = open(name, READ) if (fd == ERR) %%D 7 call error("Cannot open index for manual archive.") %%E 7 %%I 7 call error("Cannot open index for manual archive") %%E 7 %%I 8 count = 0 %%E 8 while (getlin(name, fd) != EOF) { i = index(name, ' ') name(i) = EOS junk = imput(table, name) %%I 8 count = count + 1 done(count) = 'N' %%E 8 } call close(fd) } %%E 4 %%D 2 ifdef(TREE_STRUCT_FILE_SYS) call stcopy(sect, 1, name, i) call stcopy(suffix, 1, name, i) elsedef call concat(sepr8r, suffix, suf) enddef if (opendr(name, desc) == ERR) call cant(name) while (gdrprm(desc, name) != EOF) { ifdef(TREE_STRUCT_FILE_SYS) junk = imput(table, name) elsedef i = indexs(name, suf) if (i > 0) { name(i) = EOS junk = imput(table, name) } enddef } call closdr(desc) enddef %%E 2 return end %%D 3 #-h- man.fmt 1972 asc 25-mar-82 08:08:55 v1.1 (sw-tools v1.1) %%E 3 %%I 3 #-h- dosyn 534 asc 23-apr-82 13:13:42 j (sventek j) ### dosyn - translate synonyms for manual sections subroutine dosyn(sect) character sect(ARB) integer equal string cmd "cmd" string prim "prim" string lib "lib" string primer "primer" string one "1" string two "2" string three "3" string four "4" call fold(sect) if (equal(sect, cmd) == YES) call strcpy(one, sect) else if (equal(sect, prim) == YES) call strcpy(two, sect) else if (equal(sect, lib) == YES) call strcpy(three, sect) else if (equal(sect, primer) == YES) call strcpy(four, sect) return end %%D 4 #-h- man.fmt 2965 asc 23-apr-82 13:25:34 j (sventek j) %%E 4 %%E 3 %%I 4 %%D 8 #-h- man.fmt 3487 asc 24-jun-82 13:23:50 dpm (martin,d.p.) %%E 8 %%E 4 %%I 8 #-h- prman 1892 asc 22-jul-83 10:06:36 sventek (joseph sventek) subroutine prman(suffix) character suffix(ARB), file(FILENAMESIZE), name(FILENAMESIZE), buf(MAXLINE) character gtconf integer size(2), nentry, i, count integer imget filedes fd filedes open include cman character entry(FILENAMESIZE) integer fsize(2), s1, s2, cmp integer getlin, getwrd, agethd, strcmp filedes dd linepointer ptr string pstr "Next entry [n => NO]? " if (any == YES) call tfetch(suffix) # load names of all entries call imsort(table) # sort it, just in case call imuniq(table) # strip duplicate entry names call imrset(table) # reset it, in case been through before nentry = 0 # initially no entries call concat("~man/s", suffix, file) fd = open(file, READ) if (fd == ERR) call cant(file) call concat("~man/i", suffix, name) dd = open(name, READ) if (dd == ERR) call cant(name) s1 = imget(table, name) count = 1 s2 = getlin(buf, dd) repeat { if (s1 == EOF | s2 == EOF) break i = 1 junk = getwrd(buf, i, entry) cmp = strcmp(entry, name) if (cmp == -1) s2 = getlin(buf, dd) else if (cmp == 0) { if (done(count) == 'Y') # just list other section entries { call putlin("An additional entry for `", STDOUT) call putlin(entry, STDOUT) call putlin("' can be found in section ", STDOUT) call putlnl(suffix, STDOUT) } else { done(count) = 'Y' nentry = nentry + 1 if (nentry > 1) { if (gtconf(pstr) == 'n') { s1 = EOF break } } call ctoptr(buf, i, ptr) call seek(ptr, fd) fsize(1) = MAX_INTEGER fsize(2) = 0 junk = agethd(fd, buf, size, fsize) call pruniq(fd, size) } s1 = imget(table, name) count = count + 1 s2 = getlin(buf, dd) } else { s1 = imget(table, name) count = count + 1 } } call close(fd) call close(dd) return end #-h- dointr 232 asc 22-jul-83 09:57:30 sventek (joseph sventek) subroutine dointr filedes fd filedes open integer size(2) fd = open("~man/mintro", READ) if (fd == ERR) call error("Error opening intro file!") size(1) = MAX_INTEGER size(2) = 0 call pruniq(fd, size) call close(fd) return end %%D 9 #-h- man.fmt 4074 asc 22-jul-83 10:34:05 sventek (joseph sventek) %%E 9 %%E 8 %%I 9 #-h- man.fmt 4075 asc 22-jul-83 11:18:13 sventek (joseph sventek) %%E 9 .so ~bin/manhdr %%D 4 .hd Man (1) 11-Jan-79 run off section of users manual %%E 4 %%I 4 .hd Man (1) 24-Jun-82 display section of users manual %%E 4 .sy man [-] [-s
] [-a] [name] ... .ds man locates and displays the manual entries for the particular utility or function names found in the argument list. If no names are supplied, a list of those entries known to man in the %%D 4 section specified is supplied. %%E 4 %%I 4 section specified is displayed. If no section name is supplied (i.e. "-s") a list of available manual sections is displayed. %%E 4 .sp %%D 4 The manual currently consists of four sections: %%E 4 %%I 4 The manual as delivered consists of four sections: %%E 4 .sp .in +2 .ti -2 1 The writeups for the utilities are contained here. This is the default section if none is specified. %%I 3 A valid synonym for `1' is `cmd'. %%E 3 .sp .ti -2 2 The writeups for the primitive functions are contained here. The primitive functions are those which represent the virtual system calls for the Software Tools Virtual Machine. %%I 3 A valid synonym for `2' is `prim'. %%E 3 .sp .ti -2 3 The writeups for the portable library functions are found in this section. Routines for manipulating archive modules, in-memory storage, push-back stacks, pattern matching, and many others are described here. Many times a problem which you are trying to solve has been solved before, with the code for the solution appearing in the library. %%I 3 A valid synonym for `3' is `lib'. %%E 3 .sp .ti -2 4 Primers for using various utilities and function libraries appear here. %%I 3 A valid synonym for `4' is `primer'. %%E 3 .sp .in -2 %%I 3 In addition, site-dependent sections can be added by creating the necessary known files in ~man. The section on FILES below describes the structure of the known files. .sp %%E 3 %%I 8 By default, man will search through all sections for an entry describing `name'; the sections are searched in the order specified in the file `~man/mpath'. The first entry found along this search path is displayed; the remainder of the sections are scanned to see if other entries describing `name' can be found. If more are found, a note describing the section containing the additional entry is displayed to the user. .sp %%E 8 If the -a flag is specified, all of the manual entries for the particular section are displayed on standard output. %%I 8 If no section is specified, this results in the display of the entire manual. %%E 8 .sp When displaying to the terminal, excess white space is removed from the entries. The output is also paged when to a terminal, with the default page length being 22 lines. This value may be changed through the use of the '-' option. Specifying a pagelength of 0 turns the paging off. When in paging mode, the user will be asked if the next screenful of the current entry is desired. In addition, if more than one entry was requested, the user is asked if the next entry is desired. %%I 4 .ex To get a listing of all manual sections available: .ti +16 man -s %%D 8 To get a listing of all entries in the default section (1): %%E 8 %%I 8 To get a listing of all entries in section (1): %%E 8 .ti +16 %%D 8 man %%E 8 %%I 8 man -s1 %%E 8 To get the entry for the "format" utility: .ti +16 man format To get the primer for the "ed" text editor: .ti +16 man -sprimer ed To get the entry for the library routines "scopy" and "strcpy": .ti +16 %%D 8 man -slib scopy strcpy %%E 8 %%E 4 %%I 8 man scopy strcpy %%E 8 .fl %%D 3 Accesses the directory and files containing user documents. %%E 3 %%I 3 Accesses the known files for each section in the ~man directory. .sp Each section consists of two files in ~man: .sp .in +2 .ti -2 * s is an archive of the `format' output files for each entry, with each archive module having the name of the entry. For example, s1 has the entries for the commands, with the entry for `ar' being ar. .sp .ti -2 * i is an index of the s-file above generated by `asam'. This index must be sorted, and is generated by .sp asam | sort >i .sp .in -2 There is no restriction of `' to integers, such that if one wishes to create a local man section, simply archive the formatted entries in ~man/slocal and generate the index in ~man/slocal. %%E 3 %%I 8 The section name `local' should then be added to the search path file, `~man/mpath'. %%E 8 .sa %%D 8 The tool 'intro'; the Unix command 'man' %%E 8 %%I 8 %%D 9 The tools 'intro' and 'lookup'; the Unix command 'man' %%E 9 %%E 8 %%I 9 The tools 'intro' and 'apropos'; the Unix command 'man' %%E 9 .di A message is printed if the entry specified by 'name' cannot be located. .au %%D 4 Joe Sventek %%E 4 %%I 4 Joe Sventek. The "bare -s" option was added by Dave Martin. %%E 4 #-h- bdman.r 5523 asc 25-mar-82 10:50:29 v1.1 (sw-tools v1.1) #-h- defns 115 asc 25-mar-82 10:50:08 v1.1 (sw-tools v1.1) define(AVE_TOK_SIZE,10) define(MEM_SIZE,arith(256,*,AVE_TOK_SIZE)) define(RIGHT_MARGIN,80) define(DEF_PAGE_LEN,22) #-h- main 1242 asc 25-mar-82 10:50:10 v1.1 (sw-tools v1.1) DRIVER(man) integer i, junk, pndx integer getarg, imput, isatty, ctoi filedes open pointer iminit character arg(FILENAMESIZE) include cman include cpage DS_DECL(Mem, MEM_SIZE) string docfil(FILENAMESIZE) "~man/sect" string suffix(FILENAMESIZE) "1" string ttyfil TERMINAL_IN call query("usage: man [-] [-s
] [-a] [name] ...") if (isatty(STDOUT) == YES) { pagefd = open(ttyfil, READ) pagesz = DEF_PAGE_LEN } else { pagefd = ERR pagesz = HUGE } any = NO pndx = 1 table = iminit(MEM_SIZE, AVE_TOK_SIZE) for (i=1; getarg(i, arg, FILENAMESIZE) != EOF; i=i+1) if (arg(1) == '-') if (IS_DIGIT(arg(2))) { junk = 2 pagesz = ctoi(arg, junk) if (pagesz <= 0 & pagefd != ERR) # turn off paging { call close(pagefd) # close the file pagefd = ERR } } else if (arg(2) == 'a' | arg(2) == 'A') any = YES else if (arg(2) == 's' | arg(2) == 'S') call scopy(arg, 3, suffix, 1) else call badarg(arg) else { call fold(arg) junk = imput(table, arg) pndx = pndx + 1 } call concat(docfil, suffix, docfil) if (pndx == 1 & any == NO) call dotoc(suffix, docfil) else call doman(suffix, docfil) DRETURN end #-h- allblk 179 asc 25-mar-82 10:50:11 v1.1 (sw-tools v1.1) integer function allblk(buf) character buf(ARB) integer i for (i=1; buf(i) != '@n' & buf(i) != EOS; i=i+1) if (buf(i) != ' ' & buf(i) != '@t') return(NO) return(YES) end #-h- doman 1259 asc 25-mar-82 10:50:12 v1.1 (sw-tools v1.1) subroutine doman(suffix, file) character suffix(ARB), file(ARB), name(MAXLINE), buf(MAXLINE) character gtconf integer fsize(2), s1, s2, size(2), cmp, nentry integer nxtnam, agethd, strcmp filedes fd filedes open include cman string noman " - no manual entry available.@n" string pstr "Next entry [n => NO]? " call imsort(table) call imuniq(table) # strip duplicate entry names fd = open(file, READ) if (fd == ERR) call cant(file) fsize(1) = MAX_INTEGER fsize(2) = 0 nentry = 0 s1 = nxtnam(name) s2 = agethd(fd, buf, size, fsize) repeat { if (s1 == EOF | s2 == EOF) break if (any == YES) cmp = 0 else cmp = strcmp(buf, name) if (cmp == -1) { call askip(fd, size, fsize) s2 = agethd(fd, buf, size, fsize) } else if (cmp == 0) { nentry = nentry + 1 if (nentry > 1) { if (gtconf(pstr) == 'n') { s1 = EOF break } } call pruniq(fd, size) s1 = nxtnam(name) s2 = agethd(fd, buf, size, fsize) } else { call putlin(name, ERROUT) call putlin(noman, ERROUT) s1 = nxtnam(name) } } call close(fd) while (s1 != EOF & any == NO) { call putlin(name, ERROUT) call putlin(noman, ERROUT) s1 = nxtnam(name) } return end #-h- dotoc 932 asc 25-mar-82 10:50:14 v1.1 (sw-tools v1.1) subroutine dotoc(suffix, file) character suffix(ARB), file(ARB), buf(MAXLINE) integer nxtcol filedes fd filedes open integer fsize(2), size(2), stat integer agethd character name(MAXLINE) string intstr "Manual entries available in section " fd = open(file, READ) # open the archive help file if (fd == ERR) call cant(file) # problems fsize(1) = MAX_INTEGER # dummy size for file fsize(2) = 0 # ... call putlin(intstr, STDOUT) # header line call putlnl(suffix, STDOUT) #... call putch('@n', STDOUT) # ... call inpack(nxtcol, RIGHT_MARGIN, buf, STDOUT) # initialize packing repeat { stat = agethd(fd, name, size, fsize) # get next header if (stat == ERR) call error("Manual archive in improper format.") if (stat == EOF) break call dopack(name, nxtcol, RIGHT_MARGIN, buf, STDOUT) call askip(fd, size, fsize) # skip over entry } call close(fd) call flpack(nxtcol, RIGHT_MARGIN, buf, STDOUT) return end #-h- gtconf 244 asc 25-mar-82 10:50:15 v1.1 (sw-tools v1.1) character function gtconf(pstr) character pstr(ARB), buf(MAXLINE), c character clower integer junk integer prompt include cpage if (pagefd != ERR) { junk = prompt(pstr, buf, pagefd) c = clower(buf(1)) } else c = 'y' return(c) end #-h- nxtnam 172 asc 25-mar-82 10:50:16 v1.1 (sw-tools v1.1) integer function nxtnam(name) character name(ARB) integer imget include cman if (any == YES) { name(1) = EOS return(OK) } else return(imget(table, name)) end #-h- pruniq 796 asc 25-mar-82 10:50:17 v1.1 (sw-tools v1.1) ## pruniq - locate duplicate lines in archive entry on int subroutine pruniq(int, size) integer agtlin, allblk integer t, size(2), n, blk character buf(MAXLINE) character gtconf include cpage string pstr "More [n => NO]? " if (pagefd == ERR) # no duplicate stripping if not paged { while (agtlin(buf, int, size) != EOF) call putlin(buf, STDOUT) return } n = 0 t = agtlin(buf, int, size) while (t != EOF) { n = n + 1 if (n > pagesz) { if (gtconf(pstr) == 'n') break else n = 0 } call putlin(buf, STDOUT) blk = allblk(buf) t = agtlin(buf, int, size) if (blk == YES) while (t != EOF) if (allblk(buf) == NO) break else t = agtlin(buf, int, size) } while (t != EOF) t = agtlin(buf, int, size) return end %%D 2 #-h- manupd.sh 509 asc 25-mar-82 08:08:59 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- manupd.sh 449 asc 23-apr-82 12:18:35 j (sventek j) %%E 2 # # this script performs an update of the manual system # # usage: manupd section name [name] ... # # where section is one of {1,2,3,4} and name is the name of the # formatted output of the manual entry (eg. sh) # %%D 2 cat ~man/sect$1 >sect$1 %%E 2 %%I 2 cat ~man/s$1 >sect$1 %%E 2 echo Updating local copy of sect$1 ar uv sect$1 $2 $3 $4 $5 $6 $7 $8 $9 echo Creating index$1 locally %%D 2 isam tempdx ar t sect$1 | lam - tempdx | sort >index$1 rm tempdx; echo Now you can move the files sect$1 and index$1 to ~man #-h- manndx.sh 387 asc 25-mar-82 08:08:59 v1.1 (sw-tools v1.1) # # this script generates a new index for a given manual section # # usage: manndx section # # where section is one of {1,2,3,4} # # the file ~man/sect will be indexed, with the index left # in a local file index # isam <~man/sect$1 | find "%#-h-" | ch "%??????????" >tempdx ar t ~man/sect$1 | lam - tempdx | sort >index$1 rm tempdx; echo Now you can move the file index$1 to ~man %%E 2 %%I 2 asam index$1 echo Now copying updated files to ~man cat sect$1 >~man/s$1 cat index$1 >~man/i$1 %%E 2 %%E 1