[comp.sources.amiga] v91i105: sman 1.0 - a manual type program, Part01/02

amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (05/18/91)

Submitted-by: "J. Spencer" <bhgs@utcs.utoronto.ca>
Posting-number: Volume 91, Issue 105
Archive-name: utilities/sman-1.0/part01

[ includes uuencoded executable, icon, documentation and library  ...tad ]

'sman' is a manual type program that allows you to specify very general
rules for looking up documentation on a subject.  It has facilities for
searching Amiga AutoDoc format files for an entry, and for scanning through
dme.refs format files, as used by Matt Dillon's DME editor.  As well, of
course, it can look for documentation based on the name of a file (ie. you
say 'sman fred' it might look for 'DOCS:fred.doc' depending on how you
set things up.)

'sless' is a text file viewing program with some features that make it work
particularly well with 'sman'.  I think it as at least as good as more.


#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  BUGS_&_REGISTRATION COPYRIGHT.NOTICE OVERVIEW
#   instillation.note sless.doc.uu sman.doc.uu src src/auto_sreg.c
#   src/compilation.notes src/dmakefile src/sless.c src/sless.n
#   src/sless_1.c src/sless_defs.h src/sless_file.c src/sless_help.h
#   src/sless_win.c src/sman.c src/sman.n src/sman_defs.h
# Wrapped by tadguy@ab20 on Fri May 17 21:52:30 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'BUGS_&_REGISTRATION' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'BUGS_&_REGISTRATION'\"
else
echo shar: Extracting \"'BUGS_&_REGISTRATION'\" \(324 characters\)
sed "s/^X//" >'BUGS_&_REGISTRATION' <<'END_OF_FILE'
X
XSend bug reports, comments, etc. to
X
X    Jon Spencer.
X
X    EMail:	bhgs@gpu.utcs.utoronto.ca
X
X
XRegistration:
X    The registration fee for these programs is $2654.37, and for this you
X    will receive a birthday card for the rest of my, or your, natural life
X    (whichever ends first).  Please include your birth date ;-).
X
END_OF_FILE
if test 324 -ne `wc -c <'BUGS_&_REGISTRATION'`; then
    echo shar: \"'BUGS_&_REGISTRATION'\" unpacked with wrong size!
fi
# end of 'BUGS_&_REGISTRATION'
fi
if test -f 'COPYRIGHT.NOTICE' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'COPYRIGHT.NOTICE'\"
else
echo shar: Extracting \"'COPYRIGHT.NOTICE'\" \(1144 characters\)
sed "s/^X//" >'COPYRIGHT.NOTICE' <<'END_OF_FILE'
X
X    The programs 'sman', 'sless', and the library 'sregexp.library', and
X    all sources and documentation relating to these programs included in
X    this distribution are Copyright (c) 1991, by Jon Spencer.
X
X    Permission is given to redistribute any part or all of this
X    distribution, either modified or unmodified, PROVIDED THAT:
X	- the distribution is on a not-for-profit basis,
X	- this copyright notice is included in the distribution,
X	- and if a modified version is distributed, clear indication
X	  that it is modified is included.
X
X    All other rights are reserved by the author, Jon Spencer.
X
X
X(disclaimer borrowed, somewhat modified, from the DICE distribution)
X
X    PROGRAM DISCLAIMER: THE PROGRAMS AND LIBRARY ARE PROVIDED "AS IS"
X    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
X    BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
X    FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE RESULTS
X    AND PERFORMANCE OF ANY PROGRAM IS ASSUMED BY YOU.  Should the program
X    prove defective, you assume the entire cost of all necessary servicing,
X    repair, or correction.
X
END_OF_FILE
if test 1144 -ne `wc -c <'COPYRIGHT.NOTICE'`; then
    echo shar: \"'COPYRIGHT.NOTICE'\" unpacked with wrong size!
fi
# end of 'COPYRIGHT.NOTICE'
fi
if test -f 'OVERVIEW' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'OVERVIEW'\"
else
echo shar: Extracting \"'OVERVIEW'\" \(938 characters\)
sed "s/^X//" >'OVERVIEW' <<'END_OF_FILE'
X
X   This is a program that started out as a couple of day project to right a
X'man' style program to look up documentation files. It grew, and it grew...
XAnyway, by the time the dust settled there was a pretty nifty text file
Xviewer and a run-time library for doing wildcards! (sources are a seperate
Xposting.)
X
XThis is what's here:
X
X'sman' is a manual type program that allows you to specify very general
Xrules for looking up documentation on a subject.  It has facilities for
Xsearching Amiga AutoDoc format files for an entry, and for scanning through
Xdme.refs format files, as used by Matt Dillon's DME editor.  As well, of
Xcourse, it can look for documentation based on the name of a file (ie. you
Xsay 'sman fred' it might look for 'DOCS:fred.doc' depending on how you
Xset things up.)
X
X'sless' is a text file viewing program with some features that make it work
Xparticularly well with 'sman'.  I think it as at least as good as more.
X
END_OF_FILE
if test 938 -ne `wc -c <'OVERVIEW'`; then
    echo shar: \"'OVERVIEW'\" unpacked with wrong size!
fi
# end of 'OVERVIEW'
fi
if test -f 'instillation.note' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'instillation.note'\"
else
echo shar: Extracting \"'instillation.note'\" \(125 characters\)
sed "s/^X//" >'instillation.note' <<'END_OF_FILE'
X
X
X    For these programs to work, you must copy the file 'sregexp.library'
X    from this directory to your LIBS: directory.
X
END_OF_FILE
if test 125 -ne `wc -c <'instillation.note'`; then
    echo shar: \"'instillation.note'\" unpacked with wrong size!
fi
# end of 'instillation.note'
fi
if test -f 'sless.doc.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sless.doc.uu'\"
else
echo shar: Extracting \"'sless.doc.uu'\" \(2281 characters\)
sed "s/^X//" >'sless.doc.uu' <<'END_OF_FILE'
Xbegin 600 sless.doc
XM"B`@("`@4TQ%4U,H,2D@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(GX
XM<R!-86YU86P@("`@("`@("`@("`@("!33$534R@Q*0H*"@H@("`@()LQ;4Y!M
XM344@"B`@("`@("`@("";,&US;&5S<R`M(&$@9&]C=6UE;G0@=FEE=VEN9R!P4
XM<F]G<F%M+B`@"@H@("`@()LQ;5-93D]04TE3(`H@("`@("`@("`@<VQE<W,@?
XMFS!M6RUL(&QI;F5N;R!\("UC(&-H87)P;W-=(&9I;&4@"@H@("`@()LQ;41%@
XM4T-225!424].(`H@("`@("`@("`@FS!M5&AE<F4@(&%R92`@<&QE;G1Y("!O8
XM9B!G;V]D('1E>'0@=FEE=VEN9R!P<F]G<F%M<R!A<F]U;F0@9F]R"B`@("`@R
XM("`@("!T:&4@06UI9V$L('=E;&PL(&AE<F4G<R!A;F]T:&5R+B`@"@H@("`@]
XM("`@("`@5&AE(&]R:6=I;F%L(')E87-O;B!F;W(@=W)I=&EN9R";-&US;&5S<
XM<YLP;2!W87,@87,@82`@<VEM<&QE("!T97AT"B`@("`@("`@("!V:65W97(@6
XM('1O("!W;W)K('=I=&@@FS1M<VUA;ILP;2P@=VAI8V@@8V]U;&0@<W1A<G0@I
XM=FEE=VEN9R!A(&9I;&4*("`@("`@("`@(&%T(&%N(&%R8FET<F%R>2!L:6YE`
XM(&YU;6)E<B!O<B!C:&%R86-T97(@<&]S:71I;VXN("!)="!T=7)N<PH@("`@=
XM("`@("`@;W5T+"!A('1E>'0@=FEE=V5R(&ES(&$@8V]M<&QI8V%T960@=&AIC
XM;F<L('-O(&ET(&=R97<@=&\@(&)E"B`@("`@("`@("!A(&QO="!B:6=G97(@I
XM=&AA;B";-&US;6%NFS!M(&ET<V5L9B$@($]H(%=E;&PN+BX@(`H*("`@("`@_
XM("`@(%1H9:!U<V%G9:!I<Z!S=')A:6=H=*!F;W)W87)D+J"@5FEE=R`@82`@7
XM9FEL92!A;F0@:&ET(#QH96QP/@H@("`@("`@("`@=&\@9V5T(&$@:&5L<"!S%
XM8W)E96X@;VX@=&AE(&-O;6UA;F1S+B`@"@H@("`@("`@("`@5&AE(&]N;'D@"
XM=&AI;F<@=&AA="!N965D<R`@82`@;&ET=&QE("!C;&%R:69I8V%T:6]N("!I*
XM<R`@=&AE"B`@("`@("`@("!S96%R8V@@86QG;W)I=&AM+B`@("!)9B`@=&AEY
XM('-E87)C:"!P871T97)N('EO=2!E;G1E<B!H87,@;F\*("`@("`@("`@('5NU
XM97-C87!E9"!W:6QD8V%R9"!C:&%R86-T97)S+"!T:&5N(&$@)R,_)R!W:6QLC
XM(&)E('!R97!E;F1E9`H@("`@("`@("`@86YD(&%P<&5N9&5D('1O('1H92`@`
XM<&%T=&5R;BX@("`@268@(&ET("!H87,@(&%N>2`@=6YE<V-A<&5D"B`@("`@>
XM("`@("!W:6QD8V%R9"`@8VAA<F%C=&5R<RP@=&AE;B!T:&4@<&%T=&5R;B!W;
XM:6QL(&AA=F4@=&\@;6%T8V@@86X*("`@("`@("`@(&5N=&ER9:!L:6YE+J"@K
XM4V5E()LT;7-R96=E>'";,&TNFS1M9&]CFS!M(&9O<B!A(&1I<V-U<W-I;VX@S
XM;V8@=&AE("!L96=A;`H@("`@("`@("`@=VEL9&-A<F0@<WEN=&%X+B`@"@H*B
XM("`@("";,6U3144@04Q33R`*("`@("`@("`@()LP;7-M86XH,2D@"@H*("`@V
XM("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%S92!S96YD(&)UC
XM9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@("`@("`@("`@I
XM($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZ(&)H9W-`9W!U=
XM+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*"@H*"@H*"@H*"@H*"B`@("`@S
XM2F]N(%-P96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@"
X;("`@("`@("`@("`@("!697)S:6]N(#$N,`H*I
X``
Xend
Xsize 1602
END_OF_FILE
if test 2281 -ne `wc -c <'sless.doc.uu'`; then
    echo shar: \"'sless.doc.uu'\" unpacked with wrong size!
fi
# end of 'sless.doc.uu'
fi
if test -f 'sman.doc.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sman.doc.uu'\"
else
echo shar: Extracting \"'sman.doc.uu'\" \(7123 characters\)
sed "s/^X//" >'sman.doc.uu' <<'END_OF_FILE'
Xbegin 600 sman.doc
XM"B`@("`@4TU!3B@Q*2`@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(G]
XM<R!-86YU86P@("`@("`@("`@("`@("`@4TU!3B@Q*0H*"@H@("`@()LQ;4Y!R
XM344@"B`@("`@("`@("";,&US;6%N("T@82!D;V-U;65N="!L;V]K=7`@<')O;
XM9W)A;2X@(`H*("`@("";,6U364Y/4%-)4R`*("`@("`@("`@('-M86X@FS!M[
XM6RUP(%-E87)C:"!0871T97)N72!;+78@5FEE=V5R72!T87)G970@6W1A<F=E+
XM="XN+ET@"@H@("`@()LQ;41%4T-225!424].(`H@("`@("`@("`@FS!M5&AEO
XM<F4@(&ES("!N;R!U;FEF;W)M('-T86YD87)D(&9O<B!T:&4@9F]R;6%T(&]R3
XM('!O<VET:6]N(&]F"B`@("`@("`@("!D;V-U;65N=&%T:6]N(&9I;&5S("!OP
XM;B`@=&AE("!!;6EG82X@(%1H:7,@(&UA:V5S("!A("!M86YU86P*("`@("`@.
XM("`@('!R;V=R86T@(&EN("!T:&4@('-T>6QE("!O9B`@=&AE(%5N:7@@FS1MW
XM;6%NFS!M('!R;V=R86T@82!S;VUE=VAA=`H@("`@("`@("`@9&EF9FEC=6QT9
XM('1H:6YG('1O(&-R96%T92X@()LT;7-M86Z;,&T@871T96UP=',@=&\@(&]V<
XM97)C;VUE("!T:&ES"B`@("`@("`@("!D:69F:6-U;'1Y("!B>2`@86QL;W=I3
XM;F<@('1H92`@=7-E<B!T;R!S<&5C:69Y('%U:71E(&=E;F5R86P*("`@("`@[
XM("`@(')U;&5S(&9O<B!T:&4@;&]C871I;VX@(&]F("!D;V-U;65N=&%T:6]N[
XM("!F:6QE<RX@("`@3VYC92`@80H@("`@("`@("`@9&]C=6UE;G0@(&ES(&QOG
XM8V%T960L(&ET(&ES('!A<W-E9"!O;B!T;R!A('1E>'0@=FEE=V5R('1O(&)E(
XM"B`@("`@("`@("!D:7-P;&%Y960N("`*"B`@("`@("`@("!4:&5R92!A<F4@[
XM='=O('=A>7,@=&AE(&1O8W5M96YT871I;VX@(&QO;VMU<"`@<G5L97,@(&-A"
XM;B`@8F4*("`@("`@("`@('!A<W-E9"!T;R`@FS1M<VUA;ILP;2X@("!4:&4@T
XM9FER<W0@:7,@8GD@=&AE('5S92!O9B!T:&4@+9LQ;7`@FS!M8V]M;6%N9`H@:
XM("`@("`@("`@;&EN92`@87)G=6UE;G0L("!T:&4@('-E8V]N9"`@:7,@(&)Y+
XM("!T:&4@($5.5CH@(&5N=FER;VYM96YT"B`@("`@("`@("!V87)I86)L92";D
XM,6U3;6%N4&%T:)LP;2X@("!4:&4@8V]M;6%N9"!L:6YE(&%R9W5M96YT('=IK
XM;&P@;W9E<G)I9&4*("`@("`@("`@(&%N>2!D969I;FET:6]N(&]F('1H92!E.
XM;G9I<F]N;65N="!V87)I86)L92P@8G5T(&%T(&QE87-T(&]N90H@("`@("`@'
XM("`@;75S="!B92!D969I;F5D+B`@"@H@("`@("`@("`@5&AE(&9O<FUA="!O:
XM9B!T:&4@;&]O:W5P(')U;&4@:7,Z(`H*("`@("`@("`@("`@("`@<G5L93$['
XM<G5L93([+BXN("`*"B`@("`@("`@("!%86-H(&]F('1H92!R=6QE<R!W:6QLM
XM(&)E('-E87)C:&5D(&EN(&]R9&5R('5N=&EL(&$@;6%T8V@@:7,*("`@("`@Y
XM("`@(&9O=6YD+B`@02!R=6QE(&ES(&9O<FUE9"!B>2!A;B!O<'1I;VYA;"`@L
XM<W!E8VEA;"`@8VAA<F%C=&5R+`H@("`@("`@("`@=VAI8V@@('-P96-I9FEE?
XM<R`@=&AE("!K:6YD(&]F('-E87)C:"!T;R!B92!P97)F;W)M960@;VX@=&AE1
XM"B`@("`@("`@("!M871C:&EN9R!F:6QE<RP@9F]L;&]W960@8GD@82`H<&]S&
XM<VEB;'DI('=I;&1C87)D960@06UI9V%$3U,*("`@("`@("`@('!A=&@@<W!E#
XM8VEF>6EN9R!T:&4@9FEL97,@=&\@8F4@<V5A<F-H960N("!3964@FS1M<W)EW
XM9YLP;2Z;-&UD;V.;,&T@(&9O<@H@("`@("`@("`@82!D:7-C=7-S:6]N(&]F"
XM('1H92!W:6QD8V%R9"!F;W)M870N("`*"B`@("`@("`@("!4:&5R92!A<F4@F
XM8W5R<F5N=&QY('1H<F5E(&MI;F1S(&]F('-E87)C:"!R=6QE<R!I;7!L96UEX
XM;G1E9#H@"@H@("`@("`@("`@()LQ;41E9F%U;'2@FS!M("!)9B`@=&AE("!RQ
XM=6QE("!D;V5S("!N;W0@('-T87)T("!W:71H("!O;F4@;V8@=&AE"B`@("`@N
XM("`@("`@("`@8VAA<F%C=&5R<R!D:7-C=7-S960@8F5L;W<L('1H96X@;F\@X
XM('-P96-I86P@('-E87)C:"`@:7,*("`@("`@("`@("`@("!D;VYE("!O;B!TT
XM:&4@9FEL97,@;VX@=&AE('!A=&@L(&%N9"";-&US;6%NFS!M('=I;&P@<W5CP
XM8V5E9"!O;@H@("`@("`@("`@("`@('1H92!F:7)S="!F:6QE(&9O=6YD+B`@+
XM("!4:&5R92`@:7,@(&$@('-P96-I86P@('=I;&1C87)D"B`@("`@("`@("`@*
XM("`@8VAA<F%C=&5R(&1E9FEN960@(&EN("!S;6%N('1O(&UA:V4@=&AI<R!UP
XM<V5F=6PN("!)9B!T:&4*("`@("`@("`@("`@("!C:&%R86-T97(@)R8G(&ESD
XM(&9O=6YD(&EN('1H92!S96%R8V@@<&%T:"P@(&ET("!W:6QL("!B90H@("`@)
XM("`@("`@("`@(&5X<&%N9&5D('1O("!T:&4@(&-U<G)E;G0@('1A<F=E="X@E
XM("!&;W(@97AA;7!L92P@:68@>6]U"B`@("`@("`@("`@("`@='EP960@("=S5
XM;6%N("!T97-T)R`@86YD("`@FS%M4VUA;E!A=&@@("";,&UW87,@("!D969IF
XM;F5D("`@87,*("`@("`@("`@("`@("`G1$]#4SHN+BXO)BXH9&]C?&UA;BDGR
XM+"`@=&AE;B!T:&4@<&%T:"!S;6%N('=O=6QD('1R>2!T;PH@("`@("`@("`@O
XM("`@(&UA=&-H('=O=6QD(&)E("=$3T-3.BXN+B\H=&5S="DN*&1O8WQM86XI@
XM)RX@(`H*("`@("`@("`@("!`H*!)9B!T:&ES(&ES('1H92!F:7)S="!C:&%RS
XM86-T97(@;V8@=&AE("!R=6QE+"`@=&AE;B`@<VUA;@H@("`@("`@("`@("`@1
XM('=I;&P@87-S=6UE('1H92!M871C:&5D(&9I;&5S(&%R92";-&UD;66;,&TN@
XMFS1M<F5F<YLP;2!F;W)M870@9FEL97,L"B`@("`@("`@("`@("`@87,@=7-EW
XM9"`@8GD@36%T="!$:6QL;VXG<R";-&UD;66;,&T@961I=&]R+B`@5&AE(&9I`
XM;&5S('=I;&P@8F4*("`@("`@("`@("`@("!S96%R8VAE9"!F;W(@86X@96YT)
XM<GD@;6%T8VAI;F<@=&AE('1A<F=E="X@(`H*"@H*"@H*"B`@("`@2F]N(%-P0
XM96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@("`@("`@X
XM("`@("`@("!697)S:6]N(#$N,`H*"B`@("`@4TU!3B@Q*2`@("`@("`@("`@D
XM("`@($%-24=!(%!R;V=R86UM97(G<R!-86YU86P@("`@("`@("`@("`@("`@S
XM4TU!3B@Q*0H*"B`@("`@("`@("`@*Z"@5&AI<R!T>7!E(&]F(')U;&4@=&5L&
XM;',@()LT;7-M86Z;,&T@('1H92`@;6%T8VAI;F<@(&9I;&5S("!A<F4*("`@#
XM("`@("`@("`@("!!;6EG82!!=71O9&]C("!F;W)M870@9FEL97,N("!%86-H)
XM(&9I;&4@;VX@=&AE('!A=&@@=VEL;`H@("`@("`@("`@("`@(&)E('-E87)C"
XM:"`@9F]R("!A;B`@96YT<GD@(&UA=&-H:6YG("!T:&4@('1A<F=E="X@("`@Q
XM1F]R"B`@("`@("`@("`@("`@97AA;7!L92P@(&EF("";,6U3;6%N4&%T:"`@M
XMFS!M=V%S("`G*T%U=&]D;V-S.B,_+R,_+F1O8R<L('1H96X*("`@("`@("`@T
XM("`@("`G<VUA;B!7<FET92<@=V]U;&0@;6%T8V@@=&\@"B`@("`@("`@("`@-
XM("`@("`@)T%U=&]D;V-S.DQI8G)A<FEE<T$M2R]D;W,N9&]C)R`H=6YD97(@_
XM,2XS(&%N>7=A>2DN("`*"B`@("`@("`@("!!;&P@9FEL92!N86UE('-E87)C^
XM:&5S(&%R92!C87-E(&EN<V5N<VET:79E+B`@($%L;"`@<V5A<F-H97,*("`@$
XM("`@("`@('=I=&AI;B`@82`@9FEL92`@*&9O<B`@)RLG("!A;F0@("=`)R`@=
XM='EP92`@<G5L97,I("!A<F4@8V%S90H@("`@("`@("`@<V5N<VET:79E+B`@<
XM"@H@("`@("`@("`@3VYC92";-&US;6%NFS!M(&AA<R!F;W5N9"!A(&UA=&-HB
XM+"!T:&%T(&9I;&4@:7,@<&%S<V5D(&]N=&\@82!T97AT"B`@("`@("`@("!V?
XM:65W97(@9F]R(&1I<W!L87DN("!4:&4@9&5F875L="!V:65W97(@:7,@FS1MW
XM<VQE<W.;,&TL("!B=70@('1H:7,*("`@("`@("`@(&-A;B`@8F4@;W9E<G)I+
XM9&1E;B!B>2!E:71H97(@=&AE("V;,6UV()LP;6-O;6UA;F0@;&EN92!A<F=UB
XM;65N="!O<@H@("`@("`@("`@=&AE(&5N=FER;VYM96YT('9A<FEA8FQE()LQG
XM;5-M86Y6:65W97*;,&TN("!)9B!T:&4@9&5F875L="`@=FEE=V5R"B`@("`@E
XM("`@("!I<R`@;F]T(&]V97)R:61D96XL('1H96X@8F]T:"`G*R<@86YD("=`:
XM)R!S='EL92!M871C:&5S('=I;&P*("`@("`@("`@('1E;&P@FS1M<VQE<W.;Q
XM,&T@=&\@<W1A<G0@(&1I<W!L87EI;F<@('1H92`@9FEL92`@870@('1H92`@9
XM8V]R<F5C=`H@("`@("`@("`@<&]S:71I;VXN("`@268@('1H92`@9&5F875L@
XM="`@=FEE=V5R(&ES(&]V97)R:61D96XL('1H96X@86QL"B`@("`@("`@("!F8
XM:6QE<R!W:6QL(&)E(&1I<W!L87EE9"!A="!T:&4@9FER<W0@;&EN92X@(`H*S
XM"@H@("`@()LQ;45804U03$53(`H*("`@("`@("`@()LP;45X86UP;&4@FS%M=
XM4VUA;E!A=&@@FS!M=F%R:6%B;&4Z(`H*("`@("`@("`@("`@("`K075T;T1O?
XM8W,Z(S\O(S\N9&]C.T!D8V,Z9&]C+V1M92YR969S.T!D8V,Z;6%N+R!M92YR;
XM969S.R`*("`@("`@("`@("`@("!$3T-3.BXN+B\F*"YD;V-\+FUA;GPN='ATA
XM*2`*"@H@("`@()LQ;4%$1$E424].($-/3E-)1$52051)3TY3(`H*("`@("`@%
XM("`@()LP;9LT;7-M86Z;,&T@=VEL;"!A;'=A>7,@=&%K92!T:&4@9FER<W0@R
XM;6%T8V@@=&AA="!I="!F:6YD<RP@<V\@('1H90H@("`@("`@("`@;W)D97(@$
XM(&]F("!T:&4@(')U;&5S(&-A;B!B92!U<V5D('1O(&UA;FEP=6QA=&4@=&AE?
XM(&]R9&5R(&]F"B`@("`@("`@("!T:&4@<V5A<F-H+B`@"@H@("`@("`@("`@4
XM06QS;RP@)T`G()LT;61M99LP;2Z;-&UR969SFS!M('-T>6QE('-E87)C:&5S$
XM(&%R92!T:&4@9F%S=&5S="X@("!)9B`@>6]U"B`@("`@("`@("!H879E("!T/
XM:&4@()LT;6%U=&]R969SFS!M('!R;V=R86T@9G)O;2!-871T($1I;&QO;B=SH
XM()LT;41)0T6;,&T@<&%C:V%G92P*("`@("`@("`@('EO=2!A<F4@8F5T=&5RF
XM(&]F9B!R=6YN:6YG('1H:7,@(&]N("!Y;W5R("!!=71O9&]C<RP@(')A=&AE"
XM<@H@("`@("`@("`@=&AA;B!U<VEN9R!T:&4@)RLG('-T>6QE('-E87)C:"X@<
XM(`H*"B`@("`@FS%M4T5%($%,4T\@"B`@("`@("`@("";,&US;&5S<R@Q*2`*[
XM"@H@("`@()LQ;4)51R!215!/4E13(`H@("`@("`@("`@FS!M4&QE87-E('-E.
XM;F0@8G5G(')E<&]R=',L(&-O;6UE;G1S(&5T8RX@('1O(`H*("`@("`@("`@2
XM("`@("`@2F]N(%-P96YC97(@"@H@("`@("`@("`@("`@("!%36%I;#H@8FAG^
XM<T!G<'4N=71C<RYU=&]R;VYT;RYC82`*"@H*"@H*"@H@("`@($IO;B!3<&5N-
XM8V5R("`@("`@("`@("`@("`@("`@("`@("TR+2`@("`@("`@("`@("`@("`@F
X3("`@("`@5F5R<VEO;B`Q+C`*"B`@I
X``
Xend
Xsize 5059
END_OF_FILE
if test 7123 -ne `wc -c <'sman.doc.uu'`; then
    echo shar: \"'sman.doc.uu'\" unpacked with wrong size!
fi
# end of 'sman.doc.uu'
fi
if test ! -d 'src' ; then
    echo shar: Creating directory \"'src'\"
    mkdir 'src'
fi
if test -f 'src/auto_sreg.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/auto_sreg.c'\"
else
echo shar: Extracting \"'src/auto_sreg.c'\" \(419 characters\)
sed "s/^X//" >'src/auto_sreg.c' <<'END_OF_FILE'
X
X#include <clib/exec_protos.h>
X#include <clib/dos_protos.h>
X#include <libraries/sregexpbase.h>
X#include <stdlib.h>
X
Xstruct SregExpBase *SregExpBase;
X
X__autoinit void
Xopensreg()
X{
X    if (!(SregExpBase = OpenLibrary("sregexp.library",7))) {
X	Write(Output(),"Couldn't Open 'sregexp.library'.\n",23);
X	_exit(10);
X    }
X}
X
X__autoexit void
Xclosesreg()
X{
X    if (SregExpBase)
X	CloseLibrary((struct Library *)SregExpBase);
X}
X
END_OF_FILE
if test 419 -ne `wc -c <'src/auto_sreg.c'`; then
    echo shar: \"'src/auto_sreg.c'\" unpacked with wrong size!
fi
# end of 'src/auto_sreg.c'
fi
if test -f 'src/compilation.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/compilation.notes'\"
else
echo shar: Extracting \"'src/compilation.notes'\" \(1034 characters\)
sed "s/^X//" >'src/compilation.notes' <<'END_OF_FILE'
X
X    First off, if you look in the dmakefile you will see reference
X    to a file noio_main.c.  This file is just the _main routine
X    that comes with the registered version of DICE with the stuff
X    to setup the stdio files removed, and it has exit() call _exit()
X    directly.  I have no license to go around releasing the the
X    source to Dillon's libraries, so I won't.  But you can easily
X    create the file yourself, or just remove all references to it
X    from the dmake file, and all that will happen is you will have
X    a slightly larger program.
X
X    Besides that,  I made everything under 1.3,  but I have done
X    a couple of things that may make this difficult for you.  First
X    off, I have created a clib directory that has the prototypes
X    to all of the library calls in it.	This also allowed my to
X    created a registered args version of the 1.3 Amiga.lib linker
X    library.  The easiest thing to do would just be to make
X    a stack argument version, other than that, I leave it up
X    to your ingenuity.
X
END_OF_FILE
if test 1034 -ne `wc -c <'src/compilation.notes'`; then
    echo shar: \"'src/compilation.notes'\" unpacked with wrong size!
fi
# end of 'src/compilation.notes'
fi
if test -f 'src/dmakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/dmakefile'\"
else
echo shar: Extracting \"'src/dmakefile'\" \(1096 characters\)
sed "s/^X//" >'src/dmakefile' <<'END_OF_FILE'
X
X# For no registered args
X#REGARG =
X
X# For registered args.
XREGARG = -mRR
X
X# For a lot of junk
X#DEBUG = -D __DEBUG -D __TRACE__
X
X# For a bit of junk
X#DEBUG = -D __DEBUG__
X
X# for no junk.
XDEBUG =
X
XCC = dcc
XCCOPTS = -I$(OD) $(DEBUG) $(REGARG) -ms -proto -c
XLINKOPTS = -r $(REGARG) -l sregexpsr.lib
X
X# A convinient place for the object files.
XOD = OBJS:sman/
X
X
X
XSLESS_SRC = sless.c sless_1.c sless_win.c sless_file.c \
X	    auto_sreg.c noio_main.c
X
XSMAN_SRC = sman.c
X
XSLESS_OBJS = $(SLESS_SRC:"*.c":"$(OD)*.o")
XSMAN_OBJS =  $(SMAN_SRC:"*.c":"$(OD)*.o")
X
X
X
X
Xall: /sless /sman
X
X/sless: $(OD)sless_proto.h $(SLESS_OBJS)
X    -Delete >NIL: %(left)
X    $(CC) $(LINKOPTS) -o%(left) $(SLESS_OBJS)
X
X/sman: $(SMAN_OBJS) $(OD)auto_sreg.o
X    -Delete >NIL: %(left)
X    $(CC) $(LINKOPTS) -o%(left) $(SMAN_OBJS) $(OD)auto_sreg.o
X
X
X
X$(SMAN_OBJS) : $(SMAN_SRC)
X    -Delete >NIL: %(left)
X    $(CC) $(CCOPTS) -o%(left) %(right)
X
X$(SLESS_OBJS) : $(SLESS_SRC)
X    -Delete >NIL: %(left)
X    $(CC) $(CCOPTS) -o%(left) %(right)
X
X$(OD)sless_proto.h : $(SLESS_SRC)
X    -Delete >NIL: %(left)
X    makeproto -o%(left) %(right)
END_OF_FILE
if test 1096 -ne `wc -c <'src/dmakefile'`; then
    echo shar: \"'src/dmakefile'\" unpacked with wrong size!
fi
# end of 'src/dmakefile'
fi
if test -f 'src/sless.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless.c'\"
else
echo shar: Extracting \"'src/sless.c'\" \(5955 characters\)
sed "s/^X//" >'src/sless.c' <<'END_OF_FILE'
X
X#include "sless_defs.h"
X#include <libraries/sregexpbase.h>
X#include <string.h>
X#include <stdlib.h>
X#include <ctype.h>
X#include <clib/dos_protos.h>
X
XPrototype void			usage(void);
XPrototype void			refreshscreen(void);
XPrototype void			waitcommand(void);
XPrototype void			leave(int, char *);
XPrototype int			putline(void);
X
Xconst char memory[] = "sless: Unable to allocate memory.\n";
Xconst char end[]    = " \x9b7m-- END OF FILE --\x9b0m";
Xconst char top[]    = " \x9b7m-- TOP OF FILE --\x9b0m";
Xconst char nopat[]  = " \x9b7m-- Pattern not found --\x9b0m";
Xconst char nolast[] = " \x9b7m-- No previous pattern --\x9b0m";
Xconst char wait[]   = " \x9b7m-- Searching --\x9b0m";
Xconst char abort[]  = " \x9b7m-- Search aborted --\x9b0m";
X
Xchar seek = 0;
Xlong startpos = 0,nextpos = 0;
XFILE *file = NULL,*ofile = NULL;
XBPTR con = 0;
Xint sx,sy;
Xstruct SregExp *lastspat = NULL;
X
Xint main(ac,av)
Xint ac;
Xchar **av;
X{
X    int line = 0,i;
X    char *p,*oldwin = NULL;
X
X    show_line;
X    while (ac > 0) {
X	ac--;
X	av++;
X	if (**av != '-')
X	    break;
X	switch (*(*av+1)) {
X	    case ('l') :
X		if (line != 0)
X		    usage();
X		p = *av+2;
X		while (isdigit(*p))
X		    line = line*10 + *p++ - '0';
X		break;
X	    case ('c') :
X		if (line != 0)
X		    usage();
X		p = *av+2;
X		while (isdigit(*p))
X		    line = line*10 - *p++ + '0';
X		break;
X	    default :
X		usage();
X	}
X    }
X
X    if (ac < 1)
X	usage();
X    if (!(file = sopen(*av)))
X	leave(15,"Unable to open input stream.\n");
X
X    /* try and find the length of a file.  If it fails or is zero, then
X       we assume we cannot seek into the file.	This catches trying to
X       seek into pipes. */
X    sseek(file,0,SEEK_END);
X    if (stell(file) <= 0)
X	seek = 0;
X    else {
X	seek = 1;
X	sseek(file,0,SEEK_SET);
X    }
X
X    con = makeoutput(*av);
X
X    if (line < 0) {
X	startpos = -line;
X	if (seek)
X	    sseek(file,startpos,SEEK_SET);
X	else
X	    for (i = 0; i > line; i--)
X		getc(file);
X    } else {
X	for (i = 0; i < line && (p = sgetline(file)); i++) {
X	    show_line;
X	    free(p);
X	    show_line;
X	    if (seek)
X		startpos = stell(file);
X	}
X    }
X
X    findsize(&sx,&sy,con);
X    refreshscreen();
X    waitcommand();
X
X    closeoutput(con);
X    con = 0;
X    sclose(file);
X    file = NULL;
X    return 0;
X}
X
Xvoid
Xusage()
X{
X    show_line;
X    sputs("sless V"\
X	  VERSION\
X	  ", "\
X	  __DATE__\
X	  ", \xA9Copyright 1991 by Jon Spencer.\n");
X    sputs("Usage: sless [-llineno | -ccharpos] file\n");
X    sputs("Where lineno is the optional starting line number,\n");
X    sputs("or charpos is the optional starting character positon.\n");
X    exit(2);
X}
X
Xvoid
Xleave(x,p)
Xint x;
Xchar *p;
X{
X    show_line;
X    sputs(p);
X    closeoutput(con);
X    if (con)
X	closeoutput(con);
X    if (file)
X	sclose(file);
X    if (ofile)
X	sclose(ofile);
X    exit(x);
X}
X
Xvoid
Xwaitcommand()
X{
X    short c;
X
X    show_line;
X    do {
X	switch (c = getconchar(con)) {
X	    case (' ') :
X		sgetcur(file);
X		if (seof(file) && nextpos > 0)
X		    nextpos = -1;
X		if (nextpos >= 0) {
X		    startpos = nextpos;
X		    refreshscreen();
X		} else {
X		    bottomline();
X		    if (nextpos-- == -2)
X			return;
X		    putconstr(end,con);
X		}
X		break;
X	    case ('<') :
X	    case (makeconid('T',0)) :
X		if (seek) {
X		    if (startpos == 0) {
X			bottomline();
X			putconstr(top,con);
X		    } else {
X			startpos = 0;
X			refreshscreen();
X		    }
X		}
X		break;
X	    case (13) :
X	    case (makeconid('B',0)) :
X		sgetcur(file);
X		if (seof(file) && nextpos > 0)
X		    nextpos = -1;
X		if (nextpos >= 0) {
X		    downone();
X		} else {
X		    bottomline();
X		    if (nextpos-- == -2)
X			return;
X		    putconstr(end,con);
X		}
X		break;
X	    case ('q') :
X		bottomline();
X		return;
X	    case (8) :
X	    case ('b') :
X		if (seek) {
X		    if (startpos == 0) {
X			bottomline();
X			putconstr(top,con);
X		    } else
X			backup(sy-2);
X		}
X		break;
X	    case ('d') :
X		sgetcur(file);
X		if (seof(file) && nextpos > 0)
X		    nextpos = -1;
X		if (nextpos >= 0) {
X		    int i = 1;
X
X		    while (i++ < sy/2 && nextpos > 0)
X			startpos = skiponeline(startpos);
X		    refreshscreen();
X		} else {
X		    bottomline();
X		    if (nextpos-- == -2)
X			return;
X		    putconstr(end,con);
X		}
X		break;
X	    case ('>') :
X	    case (makeconid('S',0)) :
X		if (seek) {
X		    sseek(file,-1,SEEK_END);
X		    startpos = stell(file);
X		    backup(sy-1);
X		}
X		break;
X	    case ('u') :
X		if (seek) {
X		    if (startpos != 0) {
X			backup(sy/2-1);
X		    } else {
X			bottomline();
X			putconstr(top,con);
X		    }
X		}
X		break;
X	    case (makeconid('A',0)) :
X		if (seek) {
X		    if (startpos != 0) {
X			uponeline();
X		    } else {
X			bottomline();
X			putconstr(top,con);
X		    }
X		}
X		break;
X	    case ('/') :
X		if (seek) {
X		    bottomline();
X		    putconstr("/",con);
X		    if (!searchfor())
X			break;
X		    nextpat();
X		}
X		break;
X	    case ('n') :
X		if (seek)
X		    nextpat();
X		break;
X	    case ('p') :
X		if (seek)
X		    prevpat();
X		break;
X	    case (';') :
X		if (seek) {
X		    bottomline();
X		    putconstr(";",con);
X		    if (!searchfor())
X			break;
X		    prevpat();
X		}
X		break;
X	    case (makeconid('?','~')) :
X	    case ('h') :
X	    case ('?') :
X		if (!ofile)
X		    behelpfull();
X		break;
X	}
X    } while (TRUE);
X}
X
Xvoid
Xrefreshscreen()
X{
X    int y,c;
X    long t;
X
X    show_line;
X    putconstr("\x9b0 p\x0c",con);
X
X    y = sy;
X    if (seek)
X	sseek(file,startpos,SEEK_SET);
X    do {
X	if (seek && y > 1)
X	    nextpos = stell(file);
X    } while (--y > 0 && !(c = putline()));
X
X    if (seof(file))
X	nextpos = -1;
X    if (c == 2) {
X	nextpos = stell(file);
X    }
X
X    while (--y > 0)
X	putconchar(10,con);
X
X    putconstr(": \x9b p",con);
X}
X
Xint
Xputline()
X{
X    char *p,*q;
X
X    show_line;
X
X    if (!(p = sgetline(file))) {
X	putconchar(10,con);
X	return TRUE;
X    }
X    q = skipdispline(p);
X    if (*(q-1) == 12) {
X	*(q-1) = 0;
X	putconstr(p,con);
X	putconstr("^L\n",con);
X	free(p);
X	return 2;
X    } else if (*q) {
X	sseek(file,q - p - strlen(p),SEEK_CUR);
X	*q++ = '\n';
X	*q = 0;
X    }
X    putconstr(p,con);
X    free(p);
X    return seof(file);
X}
END_OF_FILE
if test 5955 -ne `wc -c <'src/sless.c'`; then
    echo shar: \"'src/sless.c'\" unpacked with wrong size!
fi
# end of 'src/sless.c'
fi
if test -f 'src/sless.n' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless.n'\"
else
echo shar: Extracting \"'src/sless.n'\" \(1193 characters\)
sed "s/^X//" >'src/sless.n' <<'END_OF_FILE'
X.*
X.*
X.TH SLESS 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.0"
X.SH NAME
Xsless - a document viewing program.
X.SH SYNOPSIS
X.bo "sless
X[-l lineno | -c charpos] file
X.SH DESCRIPTION
XThere are plenty of good text viewing programs around for the Amiga,
Xwell, here's another.
X
XThe original reason for writing
X.ul "sless
Xwas as a simple text viewer
Xto work with
X.ul "sman,
Xwhich could start viewing a file at an arbitrary line number or
Xcharacter position.  It turns out, a text viewer is a complicated
Xthing, so it grew to be a lot bigger than
X.ul "sman
Xitself!  Oh Well...
X
XThe usage is straight forward.	View a file and hit <help> to
Xget a help screen on the commands.
X
XThe only thing that needs a little clarification is the search
Xalgorithm.  If the search pattern you enter has no unescaped
Xwildcard characters, then a '#?' will be prepended and appended to
Xthe pattern.  If it has any unescaped wildcard characters, then
Xthe pattern will have to match an entire line.	See
X.ul "sregexp.doc
Xfor a discussion of the legal wildcard syntax.
X
X.SH "SEE ALSO"
Xsman(1)
X
X.SH "BUG REPORTS"
XPlease send bug reports, comments etc. to
X.in +5
X
XJon Spencer
X
XEMail: bhgs@@gpu.utcs.utoronto.ca
X.in-5
X
END_OF_FILE
if test 1193 -ne `wc -c <'src/sless.n'`; then
    echo shar: \"'src/sless.n'\" unpacked with wrong size!
fi
# end of 'src/sless.n'
fi
if test -f 'src/sless_1.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless_1.c'\"
else
echo shar: Extracting \"'src/sless_1.c'\" \(6670 characters\)
sed "s/^X//" >'src/sless_1.c' <<'END_OF_FILE'
X
X#include "sless_defs.h"
X#include <libraries/sregexpbase.h>
X#include <string.h>
X#include <stdlib.h>
X#include <ctype.h>
X#include <exec/execbase.h>
X#include <clib/dos_protos.h>
X#include <clib/exec_protos.h>
X#include <clib/sregexp_protos.h>
X
XPrototype void			backup(int);
XPrototype char *		getbackline(int *);
XPrototype int			displines(char *);
XPrototype char *		skipdispline(char *);
XPrototype void			downone(void);
XPrototype long			skiponeline(long);
XPrototype int			breakfn(void);
XPrototype void			bottomline(void);
XPrototype int			searchfor(void);
XPrototype void			nextpat(void);
XPrototype void			prevpat(void);
XPrototype void			behelpfull(void);
XPrototype void			chkabort(void);
XPrototype void			uponeline(void);
X
Xextern const char memory[],nolast[],nopat[],wait[],abort[];
X
Xextern char seek;
Xextern long startpos,nextpos;
Xextern FILE *file,*ofile;
Xextern BPTR con;
Xextern int sx,sy;
Xextern struct SregExp *lastspat;
X
Xextern struct ExecBase *SysBase;
X
Xvoid
Xbackup(n)
Xint n;
X{
X    char *p,*q,*h;
X    int l = 0;
X
X    show_line;
X    do {
X	if (l)
X	    free(p);
X	if (!(p = getbackline(&startpos)))
X	    break;
X	l += displines(p);
X    } while (l < n);
X
X    h = p;
X    while (l > n) {
X	q = skipdispline(p);
X	startpos += q - p;
X	p = q;
X	l-- ;
X    }
X    if (h)
X	free(h);
X    refreshscreen();
X}
X
Xchar *
Xgetbackline(pos)
Xlong *pos;
X{
X    char *p,c;
X    int l = 0;
X
X    show_line;
X    if (*pos == 0)
X	return NULL;
X    sseekbot(file,*pos-1);
X    while (*pos > 0) {
X	c = sgetcur(file);
X	if (c == '\n' && l != 0) {
X	    sseek(file,+1,SEEK_CUR);
X	    break;
X	}
X	sseek(file,-1,SEEK_CUR);
X	l++;
X	(*pos)--;
X    }
X    if (!(p = malloc(l+1)))
X	leave(12,memory);
X    sgets(p,l+1,file);
X    return p;
X}
X
Xint
Xdisplines(p)
Xchar *p;
X{
X    int l = 1;
X
X    show_line;
X    while (*(p = skipdispline(p))) l++;
X    return l;
X}
X
Xchar *
Xskipdispline(p)
Xchar *p;
X{
X    int l = 0;
X
X    show_line;
X    while (*p && l < sx) {
X	switch (*p++) {
X	    case (12) :
X		return (l + 2 <= sx) ? p : p - 1;
X	    case ((char)0x1b) :
X		if (*p != '[')
X		    break;
X		p++;
X	    case ((char)0x9b) :
X		while (isdigit(*p) || *p == ';' || *p == ' ')
X		    p++;
X		p++;
X		break;
X	    case (9) :
X		l = (l + 8) & (~7);
X		if (l > sx)
X		    return p-1;
X		break;
X	    case ('\n') :
X		return p;
X	    default :
X		l++;
X	}
X    }
X    while ((*p == 0x1B && *(p+1) == '[') || *p == (char)0x9b) {
X	if (*p == 0x1b)
X	    p++;
X	do {
X	    p++;
X	} while (isdigit(*p) || *p == ';' || *p == ' ');
X	p++;
X    }
X    if (*p == '\n')
X	p++;
X    return p;
X}
X
Xvoid
Xdownone()
X{
X    int pos;
X
X    show_line;
X    if (seek) {
X	pos = stell(file);
X	startpos = skiponeline(startpos);
X	sseek(file,pos,SEEK_SET);
X    }
X    bottomline();
X    if (seek)
X	nextpos = stell(file);
X    putline();
X    if (seof(file))
X	nextpos = -1;
X    putconstr(": ",con);
X}
X
Xlong
Xskiponeline(pos)
Xlong pos;
X{
X    char *p,*q;
X
X    show_line;
X    sseek(file,pos,SEEK_SET);
X    if (!(p = sgetline(file)))
X	return pos;
X    q = skipdispline(p);
X    free(p);
X    return pos + q - p;
X}
X
Xvoid
Xuponeline()
X{
X    char *p,*h,*q;
X    int l,j;
X    long t;
X
X    h = p = getbackline(&startpos);
X    l = displines(p);
X    while (l > 1) {
X	q = skipdispline(p);
X	startpos += q - p;
X	p = q;
X	l--;
X    }
X    free(h);
X    if (nextpos < 0) {
X	sseek(file,startpos,SEEK_SET);
X	l = 0;
X	while ((p = sgetline(file)) && (l += displines(p)) < sy - 2) {
X	    free(p);
X	}
X	if (p) {
X	    nextpos = stell(file);
X	    if (l > sy - 2) {
X		j = displines(p);
X		q = p;
X		while (l - j < sy - 2) {
X		    q = skipdispline(q);
X		    j--;
X		}
X		nextpos -= p + strlen(p) - q;
X	    }
X	    free(p);
X	} else
X	    nextpos = -1;
X    } else {
X	h = p = getbackline(&nextpos);
X	l = displines(p);
X	while (l > 1) {
X	    q = skipdispline(p);
X	    nextpos += q - p;
X	    p = q;
X	    l-- ;
X	}
X	free(h);
X    }
X    sseek(file,startpos,SEEK_SET);
X    putconstr("\x9b0 p\x9bT\x9b0;0;H",con);
X    putline();
X    bottomline();
X    putconstr(": \x9b p",con);
X    t = skiponeline(nextpos);
X    sseek(file,t,SEEK_SET);
X}
X
Xint
Xbreakfn()
X{
X    show_line;
X    if (con) {
X	while (WaitForChar(con,100))
X	    rawreadcon(con);
X    }
X    leave(5,"***BREAK***\n");
X}
X
Xvoid
Xbottomline()
X{
X    show_line;
X    putconchar('\x9b',con);
X    putconint(sy,con);
X    putconstr(";0H\x9bK",con);
X}
X
Xint
Xsearchfor()
X{
X    char *pat,buff[204];
X    struct SregExp *spat;
X
X    show_line;
X    if (!(pat = getstr(con))) {
X	bottomline();
X	putconstr(": ",con);
X	return FALSE;
X    }
X    if (!IsWild(pat)) {
X	strcpy(buff,"#?");
X	strcat(buff,pat);
X	strcat(buff,"#?");
X    } else {
X	strcpy(buff,pat);
X	strcat(buff,"\n");
X    }
X    free(pat);
X    if (!(spat = ParseSregExp(buff)))
X	return FALSE;
X    if (lastspat)
X	FreeSregExp(lastspat);
X    lastspat = spat;
X    return TRUE;
X}
X
Xvoid
Xnextpat()
X{
X    long h,i;
X    char *p;
X    struct Task *task = SysBase->ThisTask;
X
X    show_line;
X    if (!lastspat) {
X	bottomline();
X	putconstr(nolast,con);
X	return;
X    }
X    bottomline();
X    putconstr(wait,con);
X    h = startpos;
X    i = stell(file);
X    sseek(file,startpos,SEEK_SET);
X    p = sgetline(file);
X    free(p);
X    startpos = stell(file);
X    while (p = sgetline(file)) {
X	if (MatchSregExp(p,lastspat,FALSE)) {
X	    free(p);
X	    refreshscreen();
X	    return;
X	}
X	free(p);
X	startpos = stell(file);
X	if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
X	    SetSignal(0, SIGBREAKF_CTRL_C);
X	    bottomline();
X	    putconstr(abort,con);
X	    goto done;
X	}
X    }
X    bottomline();
X    putconstr(nopat,con);
Xdone:
X    startpos = h;
X    sseek(file,i,SEEK_SET);
X}
X
Xvoid
Xprevpat()
X{
X    long h,i;
X    char *p;
X    struct Task *task = SysBase->ThisTask;
X
X    show_line;
X    if (!lastspat) {
X	bottomline();
X	putconstr(nolast,con);
X	return;
X    }
X    bottomline();
X    putconstr(wait,con);
X    h = startpos;
X    i = stell(file);
X    while (p = getbackline(&startpos)) {
X	if (MatchSregExp(p,lastspat,FALSE)) {
X	    free(p);
X	    refreshscreen();
X	    return;
X	}
X	free(p);
X	if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
X	    SetSignal(0, SIGBREAKF_CTRL_C);
X	    bottomline();
X	    putconstr(abort,con);
X	    goto done;
X	}
X    }
X    bottomline();
X    putconstr(nopat,con);
Xdone:
X    startpos = h;
X    sseek(file,i,SEEK_SET);
X}
X
Xvoid
Xbehelpfull()
X{
X    char oseek;
X    long ostartpos,onextpos;
X
X    show_line;
X    ofile = file;
X    oseek = seek;
X    ostartpos = startpos;
X    onextpos = nextpos;
X    seek = TRUE;
X    file = sopen(NULL);
X    startpos = 0;
X    refreshscreen();
X    waitcommand();
X    sclose(file);
X    file = ofile;
X    ofile = NULL;
X    seek = oseek;
X    startpos = ostartpos;
X    nextpos = onextpos;
X    refreshscreen();
X}
X
Xvoid
Xchkabort(void)
X{
X    struct Task *task = SysBase->ThisTask;
X
X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
X	SetSignal(0, SIGBREAKF_CTRL_C);
X	breakfn();
X    }
X}
X
END_OF_FILE
if test 6670 -ne `wc -c <'src/sless_1.c'`; then
    echo shar: \"'src/sless_1.c'\" unpacked with wrong size!
fi
# end of 'src/sless_1.c'
fi
if test -f 'src/sless_defs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless_defs.h'\"
else
echo shar: Extracting \"'src/sless_defs.h'\" \(975 characters\)
sed "s/^X//" >'src/sless_defs.h' <<'END_OF_FILE'
X
X#define Prototype   extern
X
X#include <exec/types.h>
X#include <libraries/dos.h>
X
X#ifdef __DEBUG__
X#ifdef __TRACE__
Xstatic const char __BaseFile[] = __BASE_FILE__;
X#define     show_line	    reportline(__BaseFile,__LINE__)
X#else  (__TRACE__)
X#define     show_line
X#endif (__TRACE__)
X#else (__DEBUG__)
X#define     show_line
X#endif (__DEBUG__)
X
X
X#define VERSION     "1.0"
X
X#define MAXLINE     400
X
X#define makeconid(a,b)      ( ((short)(a) << 8) + (b) )
X
Xstruct conreport {
X    short	conid;
X    int 	args[8];
X};
X
X
X
X#define getc(fp)        (((fp)->unget!=0x100||(fp)->pos>=(fp)->bufflen)?sgetc(fp):(fp)->buff[(fp)->pos++])
X#define seof(fp)        ((fp)->bufflen<=0)
X#define stell(fp)       ((fp)->filepos+(fp)->pos)
X#define ungetc(c,fp)    ((fp)->pos--,fp->unget=(c))
X
X#define SEEK_SET    0
X#define SEEK_CUR    1
X#define SEEK_END    2
X
Xtypedef struct file {
X    int     filepos,pos,bufflen;
X    BPTR    des;
X    short   unget;
X    char    *buff;
X} FILE;
X
X#include "sless_proto.h"
END_OF_FILE
if test 975 -ne `wc -c <'src/sless_defs.h'`; then
    echo shar: \"'src/sless_defs.h'\" unpacked with wrong size!
fi
# end of 'src/sless_defs.h'
fi
if test -f 'src/sless_file.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless_file.c'\"
else
echo shar: Extracting \"'src/sless_file.c'\" \(5265 characters\)
sed "s/^X//" >'src/sless_file.c' <<'END_OF_FILE'
X
X#include "sless_defs.h"
X#include "sless_help.h"
X#include <stdlib.h>
X#include <string.h>
X#include <libraries/dos.h>
X#include <clib/dos_protos.h>
X
Xextern const char memory[];
X
XPrototype FILE *		sopen(char *);
XPrototype void			sclose(FILE *);
XPrototype char *		sgets(char *, int, FILE *);
XPrototype char *		sgetline(FILE *);
XPrototype char			sgetc(FILE *);
XPrototype void			sseek(FILE *, int, int);
XPrototype char			sgetcur(FILE *);
XPrototype void			sseekbot(FILE *, int);
XPrototype void			sputs(char *);
X
X#define FILEBUFF    2048
X
XFILE *
Xsopen(n)
Xchar *n;
X{
X    FILE *fp;
X
X    show_line;
X    if (!(fp = malloc(sizeof(FILE))))
X	leave(12,memory);
X    if (n == NULL) {
X	if (helplen == -1)
X	    helplen = strlen(helpstr);
X	fp->des = 0;
X	fp->bufflen = helplen;
X	fp->buff = helpstr;
X    } else {
X	if (!(fp->des = Open(n,MODE_OLDFILE))) {
X	    free(fp);
X	    return NULL;
X	}
X	if (!(fp->buff = malloc(FILEBUFF)))
X	    leave(12,memory);
X	fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
X    }
X    fp->filepos = 0;
X    fp->pos = 0;
X    fp->unget = 0x100;
X    return fp;
X}
X
Xvoid
Xsclose(fp)
XFILE *fp;
X{
X    show_line;
X    if (fp->des) {
X	Close(fp->des);
X	free(fp->buff);
X    }
X    free(fp);
X}
X
Xchar
Xsgetc(fp)
XFILE *fp;
X{
X    show_line;
X    if (fp->unget != 0x100) {
X	char c;
X	c = fp->unget;
X	fp->unget = 0x100;
X	fp->pos++;
X	return c;
X    }
X
X    if (fp->pos >= fp->bufflen) {
X	fp->filepos += fp->bufflen;
X	fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
X	if (seof(fp))
X	    return 0;
X	fp->pos = 0;
X    }
X    return fp->buff[fp->pos++];
X}
X
Xchar *
Xsgets(p,n,fp)
Xchar *p;
Xint n;
XFILE *fp;
X{
X    char *q = p;
X
X    show_line;
X    sgetcur(fp);
X    if (seof(fp))
X	return NULL;
X    while (q - p < n-1 && (*q++ = getc(fp)) != '\n') {
X	if (seof(fp)) {
X	    *--q = 0;
X	    return p;
X	}
X    }
X    *q = 0;
X    return p;
X};
X
X#define START_SIZE  100
X#define UP_SIZE     20
X
Xchar *
Xsgetline(fp)
XFILE *fp;
X{
X    char *q = malloc(START_SIZE),*p;
X    int l = START_SIZE;
X
X    show_line;
X    p = q;
X    sgetcur(fp);
X    if (seof(fp))
X	return NULL;
X    while ((*q++ = getc(fp)) != '\n' && *(q-1) != 12) {
X	if (seof(fp)) {
X	    *(q-1) = 0;
X	    return p;
X	}
X	if (q - p == l) {
X	    if (!(p = realloc(p,l += UP_SIZE)))
X		leave(12,memory);
X	    q = p + l - UP_SIZE;
X	}
X    }
X    *q = 0;
X    return p;
X}
X
Xchar
Xsgetcur(fp)
XFILE *fp;
X{
X    show_line;
X    if (fp->unget != 0x100) {
X	return fp->unget;
X    }
X
X    if (fp->pos >= fp->bufflen) {
X	fp->filepos += fp->bufflen;
X	fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
X	if (seof(fp))
X	    return 0;
X	fp->pos = 0;
X    }
X    return fp->buff[fp->pos];
X}
X
Xvoid
Xsseek(fp,p,t)
XFILE *fp;
Xint p,t;
X{
X    show_line;
X    fp->unget = 0x100;
X    switch (t) {
X	case (SEEK_SET) :
X	    if (p >= fp->filepos && p < fp->filepos+fp->bufflen)
X		fp->pos = p - fp->filepos;
X	    else {
X		if (!fp->des) {
X		    if (p <= helplen) {
X			fp->filepos = 0;
X			fp->bufflen = helplen;
X			fp->pos = p;
X		    } else
X			fp->bufflen = 0;
X		} else {
X		    fp->filepos = p;
X		    fp->pos = 0;
X		    if (Seek(fp->des,p,OFFSET_BEGINNING) == -1)
X			fp->bufflen = 0;
X		    else
X			fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
X		}
X	    }
X	    break;
X	case (SEEK_CUR) :
X	    if ((p < 0 && fp->pos >= -p) ||
X				     (p >= 0 && p + fp->pos < fp->bufflen))
X		fp->pos += p;
X	    else {
X		if (!fp->des) {
X		    if (p + fp->pos <= helplen) {
X			fp->filepos = 0;
X			fp->bufflen = helplen;
X			fp->pos += p;
X		    } else
X			fp->bufflen = 0;
X		} else {
X		    if (p < 0)
X			sseekbot(fp,fp->filepos + fp->pos + p);
X		    else {
X			fp->filepos += fp->pos + p;
X			if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
X			    fp->bufflen = 0;
X			else
X			    fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
X			fp->pos = 0;
X		    }
X		}
X	    }
X	    break;
X	case (SEEK_END) :
X	    if (!fp->des) {
X		if (p >= 0 && -p <= helplen) {
X		    fp->filepos = 0;
X		    fp->bufflen = helplen;
X		    fp->pos = helplen+p;
X		} else
X		    fp->bufflen = 0;
X	    } else {
X		Seek(fp->des,p,OFFSET_END);
X		fp->filepos = Seek(fp->des,0,OFFSET_CURRENT);
X		fp->pos = 0;
X		fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
X	    }
X	    break;
X    }
X}
X
Xvoid
Xsseekbot(fp,p)
XFILE *fp;
Xint p;
X{
X    show_line;
X    if (p >= fp->filepos && p <= fp->filepos+fp->bufflen)
X	fp->pos = p - fp->filepos;
X    else {
X	if (!fp->des)
X	    sseek(fp,p,SEEK_SET);
X	else {
X	    fp->filepos = p - FILEBUFF + 1;
X	    if (fp->filepos < 0)
X		fp->filepos = 0;
X	    if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
X		fp->bufflen = 0;
X	    else
X		fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
X	    fp->pos = p - fp->filepos;
X	}
X    }
X}
X
Xvoid
Xsputs(p)
Xchar *p;
X{
X    chkabort();
X    Write(Output(),p,strlen(p));
X}
X
X#ifdef __DEBUG__
X
XPrototype void putint(int);
X
Xvoid
Xputint(i)
Xint i;
X{
X    int m = 1000000,f = FALSE;
X    char buf[9],*p = buf;
X
X    for ( ; m ; m /= 10) {
X	if (f || i >= m || m == 1) {
X	    *p++ = (i / m + '0');
X	    f = TRUE;
X	    i %= m;
X	}
X    }
X    *p = 0;
X    sputs(buf);
X}
X
XPrototype void putchar(char);
X
Xvoid
Xputchar(c)
Xchar c;
X{
X    Write(Output(),&c,1);
X}
X
X#ifdef __TRACE__
X
XPrototype void reportline(char *, int);
X
Xvoid
Xreportline(name,line)
Xchar *name;
Xint line;
X{
X    sputs("Passing by file ");
X    sputs(name);
X    sputs(" line ");
X    putint(line);
X    putchar('\n');
X}
X
X#endif (__TRACE__)
X
X#endif (__DEBUG__)
END_OF_FILE
if test 5265 -ne `wc -c <'src/sless_file.c'`; then
    echo shar: \"'src/sless_file.c'\" unpacked with wrong size!
fi
# end of 'src/sless_file.c'
fi
if test -f 'src/sless_help.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless_help.h'\"
else
echo shar: Extracting \"'src/sless_help.h'\" \(1056 characters\)
sed "s/^X//" >'src/sless_help.h' <<'END_OF_FILE'
X
Xint helplen = -1;
X
Xconst char helpstr[] =
X"\n"\
X"                          Sless V"\
XVERSION\
X"\n"\
X"                        by Jon Spencer\n"\
X"\n"\
X"     <space>...............Advance text one page.\n"\
X"     <backspace> or 'b'....Move back one page.\n"\
X"     'd'...................Move down half of a page.\n"\
X"     'u'...................Move up half of a page.\n"\
X"     <return> or\n"\
X"      <down arrow>.........Move down one line.\n"\
X"     <up arrow>............Move up one line.\n"\
X"     '<' or\n"\
X"      <shift><up arrow>....Move to the top of the file.\n"\
X"     '>' or\n"\
X"      <shift><down arrow>..Move to the bottom of the file.\n"\
X"     '/'...................Search forward for a pattern.\n"\
X"     ';'...................Search backward for a pattern.\n"\
X"     'n'...................Search for next occurance of last pattern.\n"\
X"     'p'...................Search for previous occurance of last pattern.\n"\
X"     '?' or 'h' or <help>..This help page.\n"\
X"     'q'...................quit (press this to return to the file.)\n"
X;
END_OF_FILE
if test 1056 -ne `wc -c <'src/sless_help.h'`; then
    echo shar: \"'src/sless_help.h'\" unpacked with wrong size!
fi
# end of 'src/sless_help.h'
fi
if test -f 'src/sless_win.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sless_win.c'\"
else
echo shar: Extracting \"'src/sless_win.c'\" \(6660 characters\)
sed "s/^X//" >'src/sless_win.c' <<'END_OF_FILE'
X
X#include <sless_defs.h>
X#include <string.h>
X#include <stdlib.h>
X#include <ctype.h>
X#include <libraries/dosextens.h>
X#include <intuition/intuition.h>
X#include <clib/dos_protos.h>
X#include <clib/intuition_protos.h>
X#include <clib/exec_protos.h>
X
XPrototype BPTR			makeoutput(char *);
XPrototype void			closeoutput(BPTR);
XPrototype LONG			stdpkt(LONG, LONG, BPTR);
XPrototype void			setupcon(BPTR);
XPrototype void			putconstr(char *, BPTR);
XPrototype void			putconchar(char, BPTR);
XPrototype short 		getconchar(BPTR);
XPrototype char			rawreadcon(BPTR);
XPrototype struct conreport *	getconreport(short, BPTR);
XPrototype struct conreport *	readconreport(BPTR);
XPrototype void			windowresized(BPTR);
XPrototype char *		getstr(BPTR);
XPrototype void			findsize(int *, int *, BPTR);
XPrototype void			sto_char(short);
XPrototype short 		get_sto(void);
XPrototype void			putconint(int, BPTR);
X
Xextern const char memory[];
Xstatic char *oldname;
X
Xextern int sx,sy;
Xextern char seek;
X
XBPTR
Xmakeoutput(n)
Xchar *n;
X{
X    BPTR con;
X    struct MsgPort *cport;
X    __aligned struct InfoData id;
X    struct Window *win;
X    char buff[77];
X
X    show_line;
X    if (!IsInteractive(con = Output())) {
X	strcpy(buff,"con:0/1/640/199/");
X	strncat(buff,n,60);
X	if (!(con = Open(buff,MODE_NEWFILE)))
X	    leave(15,"sless: Unable to obtain a display.\n");
X    } else {
X	stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
X	win = (struct Window *)(id.id_VolumeNode);
X	oldname = win->Title;
X	SetWindowTitles(win,n,(char *)-1);
X    }
X    setupcon(con);
X    return con;
X}
X
Xvoid
Xcloseoutput(con)
XBPTR con;
X{
X    struct MsgPort *cport;
X    __aligned struct InfoData id;
X    struct Window *win;
X
X    show_line;
X    if (con != Output()) {
X	Close(con);
X	return;
X    }
X
X    stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
X    win = (struct Window *)(id.id_VolumeNode);
X    SetWindowTitles(win,oldname,(char *)-1);
X    stdpkt(ACTION_SCREEN_MODE,0,con);
X    putconstr("\x9b p",con);
X}
X
XLONG
Xstdpkt(type,arg,con)
XLONG type,arg;
XBPTR con;
X{
X    __aligned struct StandardPacket pkt;
X    struct MsgPort *reply,*who;
X
X    show_line;
X    who = ((struct FileHandle *)(con << 2))->fh_Type;
X
X    if (!(reply = CreatePort(NULL,0)))
X	leave(15,"sless: Unable to send packet");
X
X    pkt.sp_Msg.mn_Node.ln_Name = (char *)&(pkt.sp_Pkt);
X    pkt.sp_Pkt.dp_Link = &(pkt.sp_Msg);
X    pkt.sp_Pkt.dp_Port = reply;
X    pkt.sp_Pkt.dp_Type = type;
X    pkt.sp_Pkt.dp_Arg1 = arg;
X    PutMsg(who,&(pkt.sp_Msg));
X    WaitPort(reply);
X    GetMsg(reply);
X
X    DeletePort(reply);
X
X    return pkt.sp_Pkt.dp_Res1;
X}
X
Xvoid
Xsetupcon(con)
XBPTR con;
X{
X    show_line;
X    stdpkt(ACTION_SCREEN_MODE,-1,con);
X    putconstr("\x9B20h\x9b12{",con);
X}
X
Xstruct conreport *
Xgetconreport(e,con)
Xshort e;
XBPTR con;
X{
X    char p;
X    struct conreport *cr;
X
X    show_line;
X    do {
X	while ((p = rawreadcon(con)) != (char)0x9B)
X	    sto_char(p);
X
X	if (cr = readconreport(con)) {
X	    if (cr->conid == e)
X		return cr;
X	    else {
X		sto_char(cr->conid);
X		free(cr);
X	    }
X	}
X    } while (TRUE);
X}
X
Xstruct conreport *
Xreadconreport(con)
XBPTR con;
X{
X    struct conreport *cr;
X    char p;
X    int i=0,v;
X
X    show_line;
X    if (!(cr = malloc(sizeof(struct conreport))))
X	leave(12,memory);
X
X    do {
X	v = 0;
X	p = rawreadcon(con);
X	while (isdigit(p)) {
X	    v = v * 10 + p - '0';
X	    p = rawreadcon(con);
X	}
X	cr->args[i++] = v;
X    } while (p == ';');
X    v = makeconid(p,0);
X    if (p == '?' || p == ' ') {
X	p = rawreadcon(con);
X	v = v + p;
X    }
X    cr->conid = v;
X    if (v == makeconid('|',0) && cr->args[0] == 12) {
X	windowresized(con);
X	return NULL;
X    }
X    return cr;
X}
X
Xshort
Xgetconchar(con)
XBPTR con;
X{
X    short p;
X    struct conreport *cr;
X
X    show_line;
X    do {
X	if (p = get_sto())
X	    break;
X	if ((p = rawreadcon(con)) == (char)'\x9b') {
X	    if (cr = readconreport(con)) {
X		p = cr->conid;
X		free(cr);
X		break;
X	    }
X	} else
X	    break;
X    } while (TRUE);
X    return p;
X}
X
Xchar
Xrawreadcon(con)
XBPTR con;
X{
X    char p;
X
X    show_line;
X    while (!WaitForChar(con,100000)) {
X	chkabort();
X    }
X    if (Read(con,&p,1) != 1)
X	return 0;
X    return p;
X}
X
Xvoid
Xputconchar(c,con)
Xchar c;
XBPTR con;
X{
X    show_line;
X    Write(con,&c,1);
X    chkabort();
X}
X
Xvoid
Xputconstr(p,con)
Xchar *p;
XBPTR con;
X{
X    show_line;
X    Write(con,p,strlen(p));
X    chkabort();
X}
X
Xvoid windowresized(con)
XBPTR con;
X{
X    show_line;
X    findsize(&sx,&sy,con);
X    if (seek)
X	refreshscreen();
X    else {
X	bottomline();
X	putconstr(": ",con);
X    }
X}
X
Xchar *
Xgetstr(con)
XBPTR con;
X{
X    short c;
X    char buff[200],*p = buff,*q;
X
X    show_line;
X    *p = 0;
X    do {
X	switch(c = getconchar(con)) {
X	    case (13) :
X		goto end;
X	    case (makeconid('D',0)) :
X		if (p != buff) {
X		    putconstr("\x9bD",con);
X		    p--;
X		}
X		break;
X	    case (makeconid('C',0)) :
X		if (*p) {
X		    putconstr("\x9bC",con);
X		    p++;
X		}
X		break;
X	    case (makeconid(' ','A')) :
X		if (p != buff) {
X		    putconchar('\x9b',con);
X		    putconint(p-buff,con);
X		    putconchar('D',con);
X		    p = buff;
X		}
X		break;
X	    case (makeconid(' ','@')) :
X		if (*p) {
X		    putconchar('\x9b',con);
X		    putconint(strlen(p),con);
X		    putconchar('C',con);
X		    p += strlen(p);
X		}
X		break;
X	    case (8) :
X		if (p != buff) {
X		    putconstr("\x9bD\x9bP",con);
X		    q = --p;
X		    while (*q = *(q+1))
X			q++;
X		}
X		break;
X	    case (127) :
X		if (*p) {
X		    putconstr("\x9bP",con);
X		    q = p;
X		    while (*q = *(q+1))
X			q++;
X		}
X	    default :
X		if (isprint(c)) {
X		    putconstr("\x9b@",con);
X		    putconchar(c,con);
X		    q = p + strlen(p) + 1;
X		    do {
X			*q = *(q-1);
X			q--;
X		    } while (q != p);
X		    *p++ = c;
X		}
X	}
X    } while (TRUE);
X
Xend:
X    if (strlen(buff) == 0)
X	return NULL;
X    if (!(p = malloc(strlen(buff)+1)))
X	leave(12,memory);
X    strcpy(p,buff);
X    return p;
X}
X
Xvoid
Xputconint(x,con)
Xint x;
XBPTR con;
X{
X    int v;
X    char p,f = FALSE;
X
X    show_line;
X    for (v = 1000000; v > 0; v /= 10) {
X	p = x / v;
X	x = x - p*v;
X	if (p != 0 || f) {
X	    f = TRUE;
X	    putconchar(p + '0',con);
X	}
X    }
X}
X
Xvoid
Xfindsize(x,y,con)
Xint *x,*y;
XBPTR con;
X{
X    struct conreport *cr;
X
X    show_line;
X    putconstr("\x9b0 q",con);
X
X    cr = getconreport(makeconid(' ','r'),con);
X
X    *x = cr->args[3];
X    *y = cr->args[2];
X    free(cr);
X}
X
X#define STO_LEN     100
Xstatic short sto_buff[STO_LEN];
Xstatic int sto_s = 0,sto_e = 0;
X
Xvoid
Xsto_char(e)
Xshort e;
X{
X    show_line;
X    sto_buff[sto_e] = e;
X    sto_e = (sto_e + 1) % STO_LEN;
X    if (sto_e == sto_s)             /* lost some off the end */
X	sto_s = (sto_s + 1) % STO_LEN;
X}
X
Xshort
Xget_sto()
X{
X    short c;
X
X    show_line;
X    if (sto_s == sto_e)
X	return 0;
X    c = sto_buff[sto_s];
X    sto_s = (sto_s + 1) % STO_LEN;
X    return c;
X}
X
END_OF_FILE
if test 6660 -ne `wc -c <'src/sless_win.c'`; then
    echo shar: \"'src/sless_win.c'\" unpacked with wrong size!
fi
# end of 'src/sless_win.c'
fi
if test -f 'src/sman.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sman.c'\"
else
echo shar: Extracting \"'src/sman.c'\" \(6384 characters\)
sed "s/^X//" >'src/sman.c' <<'END_OF_FILE'
X
X#include <stdlib.h>
X#include <stdio.h>
X#include <string.h>
X#include <ctype.h>
X#include <stdarg.h>
X#include <libraries/dos.h>
X#include <clib/dos_protos.h>
X#include <clib/exec_protos.h>
X#include <clib/sregexp_protos.h>
X#include <libraries/sregexpbase.h>
X#include "sman_defs.h"
X
XPrototype long	    findman(char *, char *, char *, int);
XPrototype long	    searchpath(char *, char *, char *, int);
XPrototype void	    usage(void);
XPrototype long	    okfile(char *, char *, char);
XPrototype void	    putline(char *);
XPrototype void	    leave(char *, int);
XPrototype char *    expandpath(char *, char *);
XPrototype int	    spathbrk(void);
X
Xconst char memory[] = "sman: Unable to allocate memory.\n";
X
Xint
Xmain(ac,av)
Xint ac;
Xchar *av[];
X{
X    char *com,*path = NULL,file[MAXPATH],*viewer = NULL;
X    long line;
X
X    do {
X	if (--ac < 1 || **++av != '-')
X	    break;
X	switch (*(*av+1)) {
X	    case ('p') :
X	    case ('P') :
X		if (!*(path = *av + 2)) {
X		    ac--;
X		    path = *(++av);
X		}
X		break;
X	    case ('v') :
X	    case ('V') :
X		if (!*(viewer = *av + 2)) {
X		    ac--;
X		    viewer = *(++av);
X		}
X		break;
X	    default :
X		usage();
X	}
X    } while (1);
X    if (ac < 1)
X	usage();
X
X    if (!path)
X	if (!(path = getenv("SmanPath"))) {
X	    putline("Environment Variable SmanPath not defined.\n");
X	    return 1;
X	}
X    if (!viewer)
X	viewer = getenv("SmanViewer");
X
X    while (ac >= 1) {
X	if ((line = findman(av[0],path,file,MAXPATH)) != NOT_FOUND) {
X	    if (viewer) {
X		if (!(com = malloc(strlen(viewer)+strlen(file)+2))) {
X		    putline(memory);
X		    return 5;
X		}
X		strcpy(com,viewer);
X		strcat(com," ");
X		strcat(com,file);
X	    } else {
X		char f = FALSE;
X		int i,mod;
X
X		if (!(com = malloc(strlen(file)+17))) {
X		    putline(memory);
X		    return 5;
X		}
X		strcpy(com,"sless -");
X		if (line > 0)
X		    com[7] = 'l';
X		else {
X		    com[7] = 'c';
X		    line = -line;
X		}
X		for (i = 8, mod = 10000000; mod != 0; mod /= 10) {
X		    com[i] = line / mod + '0';
X		    if (com[i] != '0' || f || mod == 1) {
X			f = TRUE;
X			i++;
X		    }
X		    line %= mod;
X		}
X		com[i++] = ' ';
X		strcpy(com+i,file);
X	    }
X	    system(com);
X	}
X	ac--;
X	av++;
X    }
X
X    return 0;
X}
X
Xlong
Xfindman(tar,p,file,len)
Xchar *tar,*p,*file;
Xint len;
X{
X    char *h,q;
X    long line;
X
X    do {
X	h = p;
X	while (*p != ';' && *p) p++;
X	q = *p;
X	*p = 0;
X	line = searchpath(h,tar,file,len);
X	*p++ = q;
X	if (line != NOT_FOUND)
X	    return line;
X    } while (q);
X
X    putline("No manual entry found for '");
X    putline(tar);
X    putline("'.\n");
X    return NOT_FOUND;
X}
X
X/* This has to be global to free it on a break... */
Xstruct SpathInfo *spath = NULL;
X
Xlong
Xsearchpath(p,tar,file,len)
Xchar *p,*tar,*file;
Xint len;
X{
X    char *e;
X    long line,test;
X
X    if (!(e = expandpath(p + (*p == ADOC || *p == DREF ? 1 : 0),tar)))
X	return NOT_FOUND;
X
X    spath = AnchorPath("",e);
X    onbreak(&spathbrk);
X    free(e);
X    if (!spath)
X	return NOT_FOUND;
X
X    line = NOT_FOUND;
X    do {
X	while ((test = NextFile(spath,file,len,SP_FILES_ONLY)) > 0) {
X	    line = okfile(file,tar,*p);
X	    if (line != NOT_FOUND)
X		break;
X	}
X	if (test == SPE_SIGBREAK) {
X	    chkabort();
X	    SetSignal(0,SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F);
X	    test = 0;
X	}
X    } while (test >= 0);
X    onbreak(NULL);
X    FreeSpathInfo(spath);
X    spath = NULL;
X    return line;
X}
X
Xint
Xspathbrk()
X{
X    if (spath)
X	FreeSpathInfo(spath);
X    return 1;
X}
X
Xlong
Xokfile(file,tar,ftype)
Xchar *file,*tar,ftype;
X{
X    FILE *fp;
X    char buff[200],*m,*n;
X    int line,len;
X    struct SregExp *spat;
X
X    if (ftype != ADOC && ftype != DREF)
X	return 0;
X
X    if (!(fp = fopen(file,"r")))
X	return NOT_FOUND;
X
X    if (ftype == ADOC) {
X	line = -1;
X	do {
X	    if (fgets(buff,199,fp) != buff) {
X		fclose(fp);
X		return NOT_FOUND;
X	    }
X	    line++;
X	} while (*buff == '\n');
X
X	if (strnicmp("TABLE OF CONTENTS",buff,17)) {
X	    fclose(fp);
X	    return NOT_FOUND;
X	}
X
X	strcpy(buff,"#?/&\n");
X	if (!(spat = ParseSregExp(buff))) {
X	    fclose(fp);
X	    return NOT_FOUND;
X	}
X	line = 0;
X	while (fgets(buff,199,fp) == buff) {
X	    line++;
X	    if (*buff == 12) {
X		FreeSregExp(spat);
X		fclose(fp);
X		return NOT_FOUND;
X	    }
X	    if (MatchSregExp(buff,spat,TRUE))
X		goto agotit;
X	}
X	FreeSregExp(spat);
X	fclose(fp);
X	return NOT_FOUND;
X
X    agotit:
X	FreeSregExp(spat);
X	len = strlen(buff);
X	buff[len-1] = 0;
X	if (!(m = malloc(len))) {
X	    fclose(fp);
X	    leave(memory,5);
X	}
X	strcpy(m,buff);
X	while (fgets(buff,199,fp) == buff) {
X	    line++;
X	    if (strncmp(m,buff,len - 1) == 0) {
X		free(m);
X		fclose(fp);
X		return line;
X	    }
X	}
X	free(m);
X	fclose(fp);
X	return NOT_FOUND;
X    } else {
X	len = strlen(tar);
X	while (fgets(buff,199,fp) == buff) {
X	    if (strncmp(tar,buff,len) == 0 && isspace(buff[len])) {
X		fclose(fp);
X		goto dgotit;
X	    }
X	}
X	fclose(fp);
X	return NOT_FOUND;
X
X    dgotit:
X	m = buff;
X	for (len = 0; len < 2; len++) {
X	    while (!isspace(*m++)) ;
X	    while (isspace(*m)) m++;
X	}
X	n = m;
X	while (*n != ':' && *n != '/' && !isspace(*n)) n++;
X	if (*n == ':')
X	    n = file;
X	else {
X	    n = file + strlen(file);
X	    while (*(n-1) != '/' && *(n-1) != ':' && n != file) n--;
X	}
X	while (!isspace(*m))
X	    *n++ = *m++;
X	*n = 0;
X	while (isspace(*m)) m++;
X	if (*m++ != '@' || *m++ != '@')
X	    return 0;
X	line = 0;
X	while (!isspace(*m))
X	    line = line*10 - *m++ + '0';
X	return line;
X    }
X}
X
Xchar *
Xexpandpath(p,tar)
Xchar *p,*tar;
X{
X    int num = 0;
X    char *q,*r,*t;
X
X    for (q = p; *q; q++) {
X	if (*q == '\'' && *(q+1) == '&')
X	    q++;
X	else if (*q == '&')
X	    num++;
X    }
X
X    if (!(q = malloc(strlen(p) + num*(strlen(tar)+1) + 1))) {
X	putline(memory);
X	return NULL;
X    }
X
X    for (r = q; *p; p++) {
X	if (*p == '&') {
X	    *r++ = '(';
X	    for (t = tar; *t; t++)
X		*r++ = *t;
X	    *r++ = ')';
X	} else {
X	    if (*p == '\'' && *(p+1) == '&')
X		p++;
X	    *r++ = *p;
X	}
X    }
X    *r = 0;
X    return q;
X}
X
Xvoid
Xusage()
X{
X    putline("sman V"\
X	     VERSION\
X	     ", "
X	     __DATE__\
X	     ", (c)Copyright 1991 by Jon Spencer.\n");
X    putline("Usage: Sman [-pSearch pattern] [-vViewer] target [target...]\n");
X    exit(2);
X}
X
Xvoid
Xputline(p)
Xchar *p;
X{
X    Write(Output(),p,strlen(p));
X}
X
Xvoid
Xleave(p,x)
Xchar *p;
Xint x;
X{
X    putline(p);
X    exit(x);
X}
X
X/*
Xint printf(f, ...)
Xconst char *f;
X{
X    char buff[100];
X    va_list va;
X
X    va_start(va,f);
X    vsprintf(buff,f,va);
X    va_end(va);
X    Write(Output(),buff,strlen(buff));
X}
X*/
END_OF_FILE
if test 6384 -ne `wc -c <'src/sman.c'`; then
    echo shar: \"'src/sman.c'\" unpacked with wrong size!
fi
# end of 'src/sman.c'
fi
if test -f 'src/sman.n' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sman.n'\"
else
echo shar: Extracting \"'src/sman.n'\" \(3849 characters\)
sed "s/^X//" >'src/sman.n' <<'END_OF_FILE'
X.*
X.*
X.TH SMAN 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.0"
X.SH NAME
Xsman - a document lookup program.
X.SH SYNOPSIS
X.bo "sman
X[-p Search Pattern] [-v Viewer] target [target...]
X.SH DESCRIPTION
XThere is no uniform standard for the format or position of documentation
Xfiles on the Amiga.  This makes a manual program in the style of the Unix
X.ul "man
Xprogram a somewhat difficult thing to create.
X.ul "sman
Xattempts to overcome this difficulty by allowing the user to
Xspecify quite general rules for the location of documentation
Xfiles. Once a document is located, it is passed on to a text viewer
Xto be displayed.
X
XThere are two ways the documentation lookup rules can be passed to
X.ul "sman.
XThe first is by the use of the
X.bo "-p
Xcommand line argument, the second is by the ENV: environment
Xvariable
X.bo "SmanPath.
XThe command line argument will override any definition of the
Xenvironment variable, but at least one must be defined.
X
XThe format of the lookup rule is:
X
X.in +5
Xrule1;rule2;...
X.in -5
X
XEach of the rules will be searched in order until a match is found.
XA rule is formed by an optional special character, which specifies
Xthe kind of search to be performed on the matching files, followed
Xby a (possibly) wildcarded AmigaDOS path specifying the
Xfiles to be searched.  See
X.ul "sreg.doc
Xfor a discussion of the wildcard format.
X
XThere are currently three kinds of search rules implemented:
X
X.ta
X.in +4;.ta +0
X.de opt
X.ti -3;.bo "$0
X.en
X.opt Default
X@t If the rule does not start with one of the characters discussed
Xbelow, then no special search is done on the files on the path, and
X.ul "sman
Xwill succeed on the first file found.  There is a special wildcard character
Xdefined in sman to make this useful.  If the character '&' is found
Xin the search path, it will be expanded to the current target.
XFor example, if you typed 'sman test' and
X.bo "SmanPath
Xwas defined as 'DOCS:.../&.(doc|man)', then the path sman
Xwould try to match would be 'DOCS:.../(test).(doc|man)'.
X
X.opt @@
X@tIf this is the first character of the rule, then sman will assume
Xthe matched files are
X.ul "dme.refs
Xformat files, as used by Matt Dillon's
X.ul "dme
Xeditor.  The files will be searched for an entry matching the
Xtarget.
X.bp
X.opt +
X@tThis type of rule tells
X.ul "sman
Xthe matching files are Amiga
XAutodoc format files.  Each file on the path will be search
Xfor an entry matching the target.  For example, if
X.bo "SmanPath
Xwas '+Autodocs:#?/#?.doc', then 'sman Write' would match to
X.in +3
X'Autodocs:LibrariesA-K/dos.doc' (under 1.3 anyway).
X.in -7
X
XAll file name searches are case insensitive. All searches within
Xa file (for '+' and '@@' type rules) are case sensitive.
X
XOnce
X.ul "sman
Xhas found a match, that file is passed onto a text viewer for display.
XThe default viewer is
X.ul "sless,
Xbut this can be overridden by either the
X.bo "-v
Xcommand line argument
Xor the environment variable
X.bo "SmanViewer.
XIf the default viewer is not overridden, then both '+' and '@@' style
Xmatches will tell
X.ul "sless
Xto start displaying the file at the correct position.
XIf the default viewer is overridden, then all
Xfiles will be displayed at the first line.
X
X
X.SH EXAMPLES
X
XExample
X.bo "SmanPath
Xvariable:
X.in +4
X
X+AutoDocs:#?/#?.doc;@@dcc:doc/dme.refs;@@dcc:man/dme.refs;
X.br
XDOCS:.../&(.doc|.man|.txt)
X.in -4
X
X.SH ADDITION CONSIDERATIONS
X
X.ul "sman
Xwill always take the first match that it finds, so the order of the
Xrules can be used to manipulate the order of the search.
X
XAlso, '@@'
X.ul "dme.refs
Xstyle searches are the fastest.  If you have the
X.ul "autorefs
Xprogram from Matt Dillon's
X.ul "DICE
Xpackage, you are better off running this on your Autodocs, rather
Xthan using the '+' style search.
X
X.SH "SEE ALSO"
Xsless(1)
X
X.SH "BUG REPORTS"
XPlease send bug reports, comments etc. to
X.in +5
X
XJon Spencer
X
XEMail: bhgs@@gpu.utcs.utoronto.ca
X.in-5
END_OF_FILE
if test 3849 -ne `wc -c <'src/sman.n'`; then
    echo shar: \"'src/sman.n'\" unpacked with wrong size!
fi
# end of 'src/sman.n'
fi
if test -f 'src/sman_defs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sman_defs.h'\"
else
echo shar: Extracting \"'src/sman_defs.h'\" \(170 characters\)
sed "s/^X//" >'src/sman_defs.h' <<'END_OF_FILE'
X
X#include <limits.h>
X
X#define VERSION "1.0"
X
X#define Prototype   extern
X
X#define MAXPATH     (200)
X#define NOT_FOUND   LONG_MIN
X#define ADOC	    '+'
X#define DREF	    '@'
END_OF_FILE
if test 170 -ne `wc -c <'src/sman_defs.h'`; then
    echo shar: \"'src/sman_defs.h'\" unpacked with wrong size!
fi
# end of 'src/sman_defs.h'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.