%%s 34/3/112
%%d D 1.3 23-Apr-82 13:28:37 j 3 2
%%c Modified intro.w`intro.r`main to call dosyn to resolve synonyms for known
%%c manual sections.
%%c 
%%c Added intro.w`intro.r`dosyn to resolve synonyms.
%%c 
%%c Modified intro.w`intro.fmt to point user to manual entry for `man' for
%%c valid sections.
%%s 9/9/106
%%d D 1.2 23-Apr-82 12:51:50 j 2 1
%%c Modified intro.w`intro.r`main to handle suffices longer than one character.
%%c Modified intro.w`intro.r`dointr to relect name change of known files in
%%c ~man -- sect ==> s and index ==> i.  This permits addition of generally
%%c names manual sections.
%%s 0/0/0
%%d D 1.1 25-Mar-82 12:07:35 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- intro.r         2413  asc  25-mar-82 08:02:18  v1.1 (sw-tools v1.1)
#-h- main             392  asc  25-mar-82 08:02:08  v1.1 (sw-tools v1.1)
%%E 2
%%I 2
%%D 3
#-h- intro.r         2409  asc  23-apr-82 12:49:49  j (sventek j)
#-h- main             409  asc  23-apr-82 12:46:05  j (sventek j)
%%E 3
%%E 2
%%I 3
#-h- intro.r         3060  asc  23-apr-82 13:08:58  j (sventek j)
#-h- main             460  asc  23-apr-82 13:05:22  j (sventek j)
%%E 3
DRIVER(intro)

%%D 2
character arg(4)
%%E 2
%%I 2
character arg(12)
%%E 2
integer pat(MAXPAT)
integer getpat, getarg

%%D 2
string sect "1"
%%E 2
%%I 2
string sect(10) "1"
%%E 2
string name "NAME$"

call query("usage:  intro [-s<section>].")
if (getpat(name, pat) == ERR)
  call error("Bad karma in intro.")
%%D 2
if (getarg(1, arg, 4) != EOF)
%%E 2
%%I 2
if (getarg(1, arg, 12) != EOF)
%%E 2
  if (arg(1) == '-' & (arg(2) == 's' | arg(2) == 'S'))
%%D 2
    sect(1) = arg(3)
%%E 2
%%I 2
    call scopy(arg, 3, sect, 1)
%%E 2
  else
    call badarg(arg)
%%I 3
call dosyn(sect)			# resolve synonyms for sections
%%E 3
call dointr(sect, pat)

DRETURN
end
%%D 2
#-h- dointr          1875  asc  25-mar-82 08:02:08  v1.1 (sw-tools v1.1)
%%E 2
%%I 2
#-h- dointr          1868  asc  23-apr-82 12:42:59  j (sventek j)
%%E 2
subroutine dointr(sect, pat)

character sect(ARB)
integer pat(MAXPAT)
character indfil(FILENAMESIZE), secfil(FILENAMESIZE), name(FILENAMESIZE)
character buf(MAXLINE)
integer i, junk, fsize(2), size(2)
integer getlin, getwrd, agethd, agtlin, match
filedes ifd, sfd
filedes open
linepointer lptr

%%D 2
string indstr "~man/index"
string secstr "~man/sect"
%%E 2
%%I 2
string indstr "~man/i"
string secstr "~man/s"
%%E 2
string anounc "Manual entries are available for the following in section "
string tail   "For individual descriptions, type (for example):@nman "
string minuss "-s"

call concat(indstr, sect, indfil)
ifd = open(indfil, READ)
if (ifd == ERR)
  call error("? Error opening index file for specified section.")
call concat(secstr, sect, secfil)
sfd = open(secfil, READ)
if (sfd == ERR)
  {
  call close(ifd)
  call error("? Error opening archive of manual entries for section.")
  }
call putlin(anounc, STDOUT)
call putlnl(sect, STDOUT)
call putch('@n', STDOUT)
while (getlin(buf, ifd) != EOF)		# fetch next index
  {
  i = 1
  junk = getwrd(buf, i, name)
  call ctoptr(buf, i, lptr)
  call seek(lptr, sfd)			# seek to start of module
  fsize(1) = MAX_INTEGER
  fsize(2) = 0
  if (agethd(sfd, buf, size, fsize) != OK)	# bad format archive
    {
    call close(ifd)
    call close(sfd)
    call error("? Badly formatted archive of manual entries.")
    }
  while (agtlin(buf, sfd, size) != EOF)		# get next line of entry
    if (match(buf, pat) == YES)			# found sentinel
      {
      junk = getlin(buf, sfd)			# get name - description line
      i = 1
      call skipbl(buf, i)
      for( ; buf(i) != EOS; i=i+1)
        call putch(buf(i), STDOUT)
      break
      }
  }
call close(ifd)
call close(sfd)
call putch('@n', STDOUT)
call putlin(tail, STDOUT)
if (sect(1) != '1')
  {
  call putlin(minuss, STDOUT)
  call putlin(sect, STDOUT)
  call putch(' ', STDOUT)
  }
call putlin(name, STDOUT)
call putch('@n', STDOUT)

return
end
%%D 3
#-h- intro.fmt        404  asc  25-mar-82 08:02:19  v1.1 (sw-tools v1.1)
%%E 3
%%I 3
#-h- dosyn            534  asc  23-apr-82 13:04:41  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
#-h- intro.fmt        464  asc  23-apr-82 13:09:00  j (sventek j)
%%E 3
.so ~bin/manhdr
.hd Intro (1) 11-Jan-79
list on-line documentation
.sy
intro [-s<section]
.ds
Intro lists a short synopsis of each manual entry which is available
for the specified section (section 1 is the default).
%%I 3
Valid section names are described in the writeup for `man'.
%%E 3
These documents can then be accessed via the tool 'man'.
.fl
Intro accesses the archive file containing the user documentation.
.sa
man; the Unix tool 'help'
.di
none
.au
Joe Sventek
.bu
%%E 1
