home *** CD-ROM | disk | FTP | other *** search
- From: istvan@hhb.UUCP (Istvan Mohos)
- Newsgroups: alt.sources
- Subject: Subject: ILIB Unix Toolkit in C
- Message-ID: <555@hhb.UUCP>
- Date: 8 Jun 90 21:00:39 GMT
-
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # This is part 09 of a multipart archive
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= iman/iround.tex ==============
- echo "x - extracting iman/iround.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/iround.tex &&
- X% XREF iround
- X
- X\def\name{IROUND}
- X\def\IT{{\bb iround()}}
- X
- X\S{NAME}
- X{\bb iround} --- round to a given digit of a decimal fraction
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xiround (start, end, maxfrac)
- Xchar *start;
- Xchar *end;
- Xint maxfrac;
- X}
- X
- X\S{DESCRIPTION}
- XGiven arbitrary text beginning with a {\myit decimal number\/}
- Xin a buffer delimited by {\myit start\/} and {\myit end\/},
- X\IT\ limits the ``fraction'' part of the number to {\myit maxfrac\/}
- Xdigits, {\myit rounding\/} from the {\myit maxfrac+1\/}th digit.
- XIf {\myit maxfrac\/} is negative, the action of \IT\ consists of
- Xthe suppression of ``trailing 0'' digits of the fractional part.
- X\L
- XThe rounded number remains in the buffer and is terminated with a
- XNUL byte. When rounding up to a string of nines (for example
- X\dx{99.995}\ )
- Xthe nines ``bubble up'' and the leftmost \key{1} makes
- Xthe string one byte longer. In this case
- Xthe string is right-shifted one byte, over the digit that was used up
- Xduring the rounding. If this last fractional digit was the last
- Xbyte in the buffer immediately next to {\myit end\/}, an extra NUL
- Xbyte will not fit in the buffer past the number;
- X\IT\ assumes in these cases that the byte at
- X{\myit end\/} is a NUL byte.
- X\L
- XIf {\myit start\/} is the NULL pointer,
- X\IT\ returns the negative value of
- X{\myit sys\_nerr\/} in the standart ILIB manner. Otherwise,
- Xthe parsing of the number begins at {\myit start\/}, advancing a
- Xpointer past any leading {\myit white spaces\/}, a single
- Xoptional \key{+} or \key{-} sign, past any
- X{\myit white spaces\/} following
- X\key{+} or \key{-}, to the first decimal digit (or to the
- Xdecimal point if the number has no leading digits).
- XThe decimal point is found next, and any
- Xtrailing digits immediately following it.
- X\L
- XIf a number was
- Xnot found, or if the number does not contain a decimal point, rounding
- Xwould be meaningless: the buffer is left untouched, and \IT\
- Xreturns zero. If the number does prove to be
- Xa decimal fraction, \IT\ processes
- Xit and returns the length of the rounded number string. (The
- Xlength is computed by
- Xsubtracting the address of {\myit start\/} from the address of
- Xthe nulled-out byte past the terminating fractional digit
- Xor from the address of the nulled-out decimal point).
- X
- X\S{add PROGRAM EXAMPLE}
- XThe {\bb add} program sums decimal numbers appearing at the beginning
- Xof successive lines of input, and outputs the total. {\bb add}
- Xis a filter accepting input from \stin\ or from a file. The
- Xleading numbers of input lines are processed by the {\myit atof()\/}
- Xfunction of the math library: the program links with {\myit libm.a\/}
- Xas evidenced by the compilation script.
- XThe computed total is printed into an internal buffer, the
- Xbuffer is then passed to \IT\ for final formatting before output.
- XThe default {\myit maxfrac\/} argument passed to \IT\ is zero; the user
- Xcan override this by supplying a different value to the {\myit -r\/}
- X(``round flag'') command line option.
- X\L
- XThe command line example
- X\smallskip
- X\I{\mytt ls -l | leftrunc 23 | add}
- X\smallskip
- Xpasses a ``long listing'' of the directory contents to the
- X{\bb leftrunc} ILIB example program to strip off the left 23 bytes.
- XThe remaining columns of each line are then fed to {\bb add}, which
- Xsums the ``size fields'' of the listing, and outputs the size of the
- Xdirectory contents in bytes.
- X
- X\S{add.c PROGRAM TEXT}
- X\listing{../iex/add.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608101990 iman/iround.tex &&
- chmod 0644 iman/iround.tex ||
- echo "restore of iman/iround.tex failed"
- set `wc -c iman/iround.tex`;Wc_c=$1
- if test "$Wc_c" != "3360"; then
- echo original size 3360, current size $Wc_c
- fi
- # ============= iman/isearch.tex ==============
- echo "x - extracting iman/isearch.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/isearch.tex &&
- X% XREF inumsearch isearch ixsearch
- X
- X\def\name{ISEARCH}
- X\def\IT{{\bb isearch()}}
- X\def\ALT{{\bb ixsearch()}}
- X
- X\S{NAME}
- X{\bb isearch} --- binary string search in list of character pointers
- X
- X{\bb ixsearch} --- binary token search in list of character pointers
- X
- X{\bb inumsearch} --- binary (numeric) search in list of character pointers
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xisearch (comparee, wordlist, listcount)
- Xchar *comparee;
- Xchar *wordlist[];
- Xint listcount;
- X\L
- Xint
- Xinumsearch (comparee, wordlist, listcount)
- Xchar *comparee;
- Xchar *wordlist[];
- Xint listcount;
- X\L
- Xint
- Xixsearch (comparee, wordlist, listcount)
- Xchar *comparee;
- Xchar *wordlist[];
- Xint listcount;
- X}
- X
- X\S{DESCRIPTION}
- XILIB's {\myit isort()\/} functions
- Xsort an internal array of null
- Xterminated strings, by sorting a {\myit list of pointers\/} instead, to
- Xalphabetically or alphanumerically dereference the strings
- Xin the internal buffer. (A list of the appropriate pointers
- Xcan be created
- Xin turn by calling {\myit ilist()\/} or its variants.)
- X\IT, \ALT, or {\bb inumsearch} all
- Xexpect the type of sorted pointer list provided by
- X{\myit isort()\/} or {\myit inumsort()\/} as their {\myit wordlist\/}
- Xargument, and interpret {\myit listcount\/} as the count of the
- Xpointers in {\myit wordlist\/}.
- X\L
- XThe \IT\ functions then
- Xfind the {\myit wordlist\/} pointer that points to a string that is
- Xidentical to the first argument {\myit comparee\/},
- Xand return the {\myit wordlist\/} index of this pointer
- X(zero through one less than {\myit listcount\/})
- Xor -1 if {\myit comparee\/} was not found. The functions
- Xalso return -1 if
- X{\myit listcount\/} is less than one, but do not consider this an error.
- XThe status of {\myit wordlist\/} is not verified.
- X{\myit ierflag\/} is set and {\myit -sys\_nerr\/} is returned via
- X{\myit ierror()\/} if {\myit comparee\/} is the NULL pointer or
- Xhas no length.
- X\L
- X\IT\ uses {\myit strncmp()\/} for the comparisons, attempting to find
- Xa string in {\myit wordlist\/} that begins with a substring identical
- Xto {\myit comparee\/}.
- X\L
- X\ALT\ uses {\myit strcmp()\/} for
- Xthe comparisons. This means that the {\myit wordlist\/} string must
- Xmatch {\myit comparee\/} exactly, longer
- Xstrings in {\myit wordlist\/} that begin with the
- X{\myit comparee\/} substring are rejected.
- X\L
- X{\bb inumsearch()\/} uses the ILIB {\myit inumstrcmp()\/} for
- Xthe comparisons.
- XThe individual strings of {\myit wordlist\/}, and {\myit comparee\/}
- Xare matched against each other as complete strings,
- Xbut with decimal digit substrings
- Xcollapsed to integer values. The word \dx{test7}\ for example, will
- Xexactly match \dx{test007}.
- X
- X\S{SEE ALSO}
- X{\myit ilist, isort, inumstrcmp.}
- X
- X\S{area PROGRAM EXAMPLE}
- XSince the process overhead of
- Xbinary sort and search routines tends to
- Xdiminish as their effectiveness increases
- Xgeometrically with the expansion of the size of the data, \IT\ or
- X{\bb isort()} do not easily
- Xlend themselves to inclusion in short programs. The {\bb area}
- Xprogram, outputting the appropriate area code for a town or state
- Xspecified on the command line, bypasses the need to print
- Xlenghty lists in this manual, by simply assuming that the
- Xdata base does in
- Xfact exist, under the normal ASCII file
- X{\myit \dol HOME/.area\/}. The data
- Xis expected to consist of {\myit newline\/} terminated records
- Xwith fields {\myit TOWN\/} and {\myit AREACODE\/}, for example
- X\smallskip
- X\I{\mytt Fresno 209}
- X\I{\mytt Alaska 907}
- X\I{\mytt Manhattan 212}
- X\smallskip
- XThere must be at least one record in the file.
- XLines need not be sorted because {\bb area} does its own sort;
- Xhowever if the data grows large, time could be saved by sorting the
- Xdata file and removing the {\myit isort()\/} call from the program
- Xlisting.
- X\L
- X{\bb area} calls \IT\ to find the command-given
- Xgeographical location in the data base, and very simply, prints
- Xthe line to \sterr. Similar utilities can be cloned,
- Xto retrieve {\myit zip codes\/},
- Xtelephone numbers, birth days, etc.,
- Xjust by adding
- Xaliases to the command name and providing alternate data files
- X{\myit \dol HOME/.zip, \dol HOME/.phone\/}, and so on. The prototype clone
- X{\bb now} already {\myit \#include\/}d in the {\bb area} text, adds a
- Xpositive or negative offset (in hours) to
- Xthe current ``Greenwich Mean Time'', and prints the current time
- Xin various parts of the world. If the {\myit \dol HOME/.now\/}
- Xdata base contained the record
- X\smallskip
- X\I{\mytt New York -4}
- X\smallskip
- Xthe ``{\mytt now New York}'' command would display the current New York
- Xtime, formatted as \dx{hh:mm:ss}.
- X
- X\S{area.c PROGRAM TEXT}
- X\listing{../iex/area.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608102790 iman/isearch.tex &&
- chmod 0644 iman/isearch.tex ||
- echo "restore of iman/isearch.tex failed"
- set `wc -c iman/isearch.tex`;Wc_c=$1
- if test "$Wc_c" != "4548"; then
- echo original size 4548, current size $Wc_c
- fi
- # ============= iman/isort.tex ==============
- echo "x - extracting iman/isort.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/isort.tex &&
- X% XREF isort inumsort
- X
- X\def\name{ISORT}
- X\def\IT{{\bb isort()}}
- X
- X\S{NAME}
- X{\bb isort} --- sort list of character pointers to alphabetic order
- X
- X{\bb inumsort} --- sort list of character pointers to alphanumeric order
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xvoid
- Xisort (ptr, itemcount)
- Xchar *ptr[];
- Xint itemcount;
- X\L
- Xvoid
- Xinumsort (ptr, itemcount)
- Xchar *ptr[];
- Xint itemcount;
- X}
- X
- X\S{DESCRIPTION}
- XBoth \IT\ and {\bb inumsort()\/} perform a binary sort on a
- Xlist of character pointers pointing to null terminated strings
- X(such as produced from ``straight'' text by the {\myit ilist()\/}
- Xfunctions).
- X\L
- XPrevious to the call to
- X\IT\ or {\bb inumsort()\/}, pointers of the array
- Xbeginning at {\myit ptr\/}, are dereferencing various
- Xstrings in no particular order, successive pointers typically
- Xpointing to successive lines of the text to be sorted.
- XOn return from the call, the pointers will have been reorganized
- Xby \IT\ or {\bb inumsort()\/}, so
- Xthat the first pointer of the list ({\myit ptr[0]\/}) points to a
- Xline which
- Xalphabetically precedes all other lines of the text; the
- Xsecond pointer ({\myit ptr[1]\/}) points to the string with the next
- Xlowest value, and so on.
- X\L
- XThe {\bb inumsort()\/} function handles digit substrings embedded
- Xin text lines as decimal integers,
- Xsorting the pointer list to
- Xalphanumeric order rather than to alphabetic order.
- XLeading zeros of digit strings are ignored in the
- Xnumerical comparison; if the digit strings are otherwise identical
- Xthey are seen as a perfect match by {\bb inumsort()\/}.
- XIn a sorted list for example, either
- X``Cygnus N031'' or ``Cygnus N31'' may precede the other.
- X\L
- XBoth functions interpret
- X{\myit itemcount\/} as the number of pointers in the array (the
- Xnumber of lines to be sorted). If
- X{\myit itemcount\/} is one or zero, no sorting is done.
- X
- X\S{SEE ALSO}
- X{\myit ilist, isearch, ifamily\/}.
- X
- X\S{PROGRAM EXAMPLE}
- XThe {\bb group} program listed following the description
- Xof {\myit ifamily()}
- Xuses {\bb inumsort} to order its lines of input.
- X\eject
- SHAR_EOF
- $TOUCH -am 0531091090 iman/isort.tex &&
- chmod 0644 iman/isort.tex ||
- echo "restore of iman/isort.tex failed"
- set `wc -c iman/isort.tex`;Wc_c=$1
- if test "$Wc_c" != "1998"; then
- echo original size 1998, current size $Wc_c
- fi
- # ============= iman/istripcom.tex ==============
- echo "x - extracting iman/istripcom.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/istripcom.tex &&
- X% XREF istripcom istripstr istripdq istripsq
- X
- X\def\name{ISTRIPCOM}
- X\def\IT{{\bb istripcom()}}
- X
- X\S{NAME}
- X{\bb istripcom} --- ``white out'' comments in buffer with spaces
- X
- X{\bb istripstr} --- ``white out'' strings in buffer with spaces
- X
- X{\bb istripdq} --- ``white out'' double quotes in buffer with spaces
- X
- X{\bb istripsq} --- ``white out'' single quotes in buffer with spaces
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xistripcom (start, end, lcom, rcom)
- Xchar *start;
- Xchar *end;
- Xchar *lcom;
- Xchar *rcom;
- X\L
- Xint
- Xistripstr (start, end, str)
- Xchar *start;
- Xchar *end;
- Xchar *str;
- X\L
- Xint
- Xistripdq (start, end)
- Xchar *start;
- Xchar *end;
- X\L
- Xint
- Xistripsq (start, end)
- Xchar *start;
- Xchar *end;
- X}
- X
- X\S{DESCRIPTION}
- XGiven a buffer at {\myit start\/} and ending
- Xone byte before {\myit end\/}, \IT\ converts {\myit comments\/}
- Xoccurring in the buffer ---
- Xdelimited by {\myit lcom\/} and {\myit rcom\/} ---
- Xto spaces. {\bb istripstr()} converts
- Xoccurrences of {\myit str\/} to spaces. {\bb istripdq()}
- Xconverts text surrounded by
- Xdouble quotes \key{"}, to spaces. {\bb istripsq()}
- Xconverts text surrounded by single quotes \key{'}, to spaces.
- XAll four functions return the count of the erased strings.
- X{\myit ierflag\/} is set and negative {\myit sys\_nerr\/} is returned
- Xif {\myit lcom\/} or {\myit rcom\/} or {\myit str\/} have no length.
- X\L
- XThe \IT\ function also erases the comment delimiters
- Xthemselves, except
- X{\myit rcom\/} when it is a {\myit newline\/}. \IT\
- Xconsiders it an error to specify
- X{\myit newline\/} \dx{\mytt"\bsl n"}\ for {\myit lcom\/}.
- XIf {\myit rcom\/} is not
- X\dx{\mytt"\bsl n"}, and if {\myit lcom\/} and {\myit rcom\/} differ,
- X\IT\ calls itself recursively to erase nested
- Xcomments (returning the count of all
- Xcomment delimiter pairs encountered); except that in the case of the
- XC comment delimiters \twokey{/*}\ and \twokey{*/}
- Xthe function is not recursive and ignores escaped delimiters or
- Xdelimiters within quotes (within character or string constants).
- X\L
- XIf more than one of these functions are to transform C text,
- Xthe recommended succession of calls
- Xis \IT, {\bb istripdq()}, {\bb istripsq()}. Calling \IT\
- Xas the first function of the sequence
- Xensures that single or double quotes embedded in comment
- Xtext don't result in the ``runaway blanking'' of text beyond the
- Xclosing comment delimiter. For example, if
- X{\bb istripdq()} processed C text with the
- X\smallskip
- X\I{\mytt /* talking about the " character */}
- X\smallskip
- Xcomment embedded, it would start blanking characters at the
- Xdouble quote in the comment, and would overrun the closing
- Xcomment delimiter in its search for the closing quote.
- XCalling {\bb istripdq()} before
- X{\bb istripsq()} ensures that {\myit apostrophes\/}
- Xembedded in text strings don't result in similar damage, for
- Xexample when parsing
- X\smallskip
- X\I{\mytt "can't open file \%s\bsl n"}
- X\smallskip
- X{\bb istripdq()} and {\bb istripsq()} are both ``smart enough''
- Xto bypass escaped quotes:
- X{\bb istripdq()} does not start blanking in \dx{\mytt '"'}, and
- X{\bb istripsq()} does not stop blanking at the second tick of
- X\dx{\mytt'\bsl''}.
- X
- X\S{cweed PROGRAM EXAMPLE}
- XWhen comparing a changed version of
- Xsource code against the original, there are times when no amount of
- Xformatting or {\myit context-diff\/}ing seem to winnow out
- Xstylistic differences from changes that ``matter'' to the
- XC compiler. The {\bb cweed} program strips out non-essential text and
- Xputs a temporary copy of the input to \stout\ that contains
- Xonly ``meaningful differences'' when
- Xcontrasted against similarly ``weeded'' output from another file.
- X\L
- XText is input from {\myit file\/} if a filename is given on the
- Xcommand line, otherwise the program filters \stin.
- XThe source is read to an internal buffer. C comments and comment
- Xdelimiters are overwritten in the buffer with spaces.
- XTo resolve the stylistic differences between programs that append
- Xa left curly brace \key{\lcu} in line with
- Xa logical test, and programs
- Xthat put the
- Xleft curly brace in the next line below,
- X{\bb cweed} implements the unilateral solution of overwriting
- X{\myit newline\/} characters between left curly braces
- Xand the previous token with spaces in the buffer.
- X\L
- X{\bb cweed} then parses the buffer line by line,
- Xextracting and printing lexical C tokens.
- XIf successive tokens in a line are both alphanumeric
- X(the alphanumeric set in C also includes
- Xthe underscore and dollar
- Xcharacters), or if successive tokens are both non-alphanumeric,
- Xa space is printed as a separator.
- XOther combinations are output
- Xwithout separators. Empty lines (not containing tokens) are
- Xskipped.
- XThe {\myit q\/} program listed in the INTRO section can be used to
- Xcompare similar files processed by {\bb cweed}:
- X\smallskip
- X\I{\mytt diff `q cweed file1`\ \ `q cweed file2`}
- X\smallskip
- Xcompares the lines produced from
- X{\myit file1\/} and {\myit file2\/}.
- XThis sequence proves quite successful in {\myit diff\/}ing
- XC source, and probably would deserve upgrading to
- Xa one-liner shell script ({\myit cdiff\/}):
- X\dx{\mytt /bin/diff\ `q\ cweed\ \$1`\ `q\ cweed\ \$2`}.
- XIn this case, the above command would become:
- X\smallskip
- X\I{\mytt cdiff file1 file2}
- X
- X\S{cweed.c PROGRAM TEXT}
- X\listing{../iex/cweed.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608102990 iman/istripcom.tex &&
- chmod 0644 iman/istripcom.tex ||
- echo "restore of iman/istripcom.tex failed"
- set `wc -c iman/istripcom.tex`;Wc_c=$1
- if test "$Wc_c" != "5166"; then
- echo original size 5166, current size $Wc_c
- fi
- # ============= iman/iswap.tex ==============
- echo "x - extracting iman/iswap.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/iswap.tex &&
- X% XREF iswap ixswap
- X
- X\def\name{ISWAP}
- X\def\IT{{\bb iswap()}}
- X\def\ALT{{\bb ixswap()}}
- X
- X\S{NAME}
- X{\bb iswap} --- change one string to another everywhere in a buffer
- X
- X{\bb ixswap} --- change alphanumeric token to another everywhere in a buffer
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xiswap (start, end, from, to)
- Xchar *start;
- Xchar *end;
- Xchar *from;
- Xchar *to;
- X\L
- Xint
- Xixswap (start, end, from, to)
- Xchar *start;
- Xchar *end;
- Xchar *from;
- Xchar *to;
- X}
- X
- X\S{DESCRIPTION}
- XBoth \IT\ and \ALT\ search the buffer from {\myit start\/} to
- X{\myit end\/} for non-overlapping occurrences of the {\myit from\/}
- Xstring. Whenever a match is found, the {\myit to\/} string
- Xoverwrites the {\myit from\/} string (beginning at the leftmost byte of
- Xthe {\myit from\/} string), the parser is moved immediately past
- Xthe overlaid {\myit to\/} string; and the search continues from this
- Xpoint on.
- X\L
- XThe {\myit end\/} of the buffer is limiting
- Xonly with respect to searching, in that bytes at or beyond
- X{\myit end\/} will not be dereferenced during the pattern match.
- XA {\myit to\/} string may be longer than the {\myit from\/} string
- Xit is to replace, in which case bytes beyond the {\myit from\/}
- Xpattern in the buffer will get overwritten even if this means exceeding
- Xthe right boundary.
- XIt is the
- Xcaller's responsibility in such cases,
- Xto provide adequate buffer space past {\myit end\/}.
- X\L
- XThe difference between
- X\IT\ and \ALT\ is that \ALT\ limits {\myit from\/} strings to
- Xalphanumeric words or single printing characters (calling
- X{\myit ialntok()\/} for extracting tokens), and recognizes
- Xmatching {\myit from\/} patterns in the buffer only if
- Xthe buffer pattern is the same length word
- X(delimited by white spaces or by
- Xnon-alphanumeric characters) as the passed {\myit from\/} pattern is.
- XIn contrast the {\myit from\/} string passed to \IT\
- Xmay contain white spaces, and buffer matches are recognized even if
- Xprinting character-aggregates of the buffer
- Xembed the {\myit from\/} string.
- X\L
- XEither functions return the count of overlays, or
- Xcall {\myit ierror()\/} if
- Xthe source or target pattern is NULL or has no length.
- X
- X\eject
- SHAR_EOF
- $TOUCH -am 0531091590 iman/iswap.tex &&
- chmod 0644 iman/iswap.tex ||
- echo "restore of iman/iswap.tex failed"
- set `wc -c iman/iswap.tex`;Wc_c=$1
- if test "$Wc_c" != "2102"; then
- echo original size 2102, current size $Wc_c
- fi
- # ============= iman/itok.tex ==============
- echo "x - extracting iman/itok.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/itok.tex &&
- X% XREF itok
- X
- X\def\name{ITOK}
- X\def\IT{{\bb itok()}}
- X
- X\S{NAME}
- X{\bb itok} --- dynamic tokenizer
- X
- X\S{SYNOPSIS}
- X\settabs\+{\bb mdefine INITOKRRR} &0000&\cr
- X\+{\bb\#define INITOKF}&\hfill{\bb 1}&\kern 2em{\mytt/* setup forward parsing */}\cr
- X\+{\bb\#define INITOKR}&\hfill{\bb --1}&\kern 2em{\mytt/* setup reverse parsing */}\cr
- X\+{\bb\#define ITOKF }&\hfill{\bb 2}&\kern 2em{\mytt/* forward parse */}\cr
- X\+{\bb\#define ITOKR }&\hfill{\bb --2}&\kern 2em{\mytt/* reverse parse */}\cr
- X\L
- X{\obeylines \bb
- Xint
- Xitok (context, start, end, result)
- Xint context;
- Xchar *start;
- Xchar *end;
- Xchar **result;
- X}
- X
- X\S{DESCRIPTION}
- XIn many ways the true ``Rube Goldberg'' of ILIB, the opacity and
- Xless-than-intuitive behavior
- Xof \IT\ are only partially offset by the plain syntax
- Xfor calling this function in a loop.
- X\IT\ differentiates between four types of calls, decoding
- Xthe type at every call
- Xfrom the {\myit context\/} value passed as the first argument.
- X\L
- XThe {\myit INITOKF\/} value of {\myit context\/}
- Xinstructs \IT\ to initialize its state machine
- Xand get ready for retrieving tokens {\myit F\/}orward (that is,
- Xleft-to-right) in the buffer passed in along
- X{\myit INITOKF\/}
- Xvia its
- X{\myit start, end\/} boundaries.
- XIf the {\myit end\/} pointer is NULL, \IT\ finds the buffer end on
- Xits own, by looking ahead until the terminal NUL byte.
- XIn either case, \IT\ saves the
- Xbuffer boundaries, ignores the {\myit result\/} parameter,
- Xand moves its internal text marker to the beginning of
- Xthe buffer (to {\myit start\/}). \IT\ does not find a token during
- Xthis call, and returns the byte size of the buffer.
- X\L
- XSimilarly, {\myit INITOKR\/} instructs \IT\ to
- Xget ready for retrieving tokens in {\myit R\/}everse;
- Xbackward from the byte before {\myit end\/}, proceeding toward
- X{\myit start\/}. At such a call, \IT\ saves the
- Xbuffer boundaries, and moves its internal text marker to the
- Xrightmost available byte of the buffer.
- XAgain no token is found, and the size of the buffer is returned.
- X\L
- XAt a call with {\myit context\/} set to {\myit ITOKF\/}, \IT\
- Xfinds the next token in the buffer (from the text marker, skipping
- Xfirst any delimiter bytes that can not be a part of the token),
- Xand then advances its text marker to point to the byte immediately
- Xto the right of the last byte of the new token.
- XSince \IT\ has
- Xsaved the buffer boundaries from an earlier initializing call, the
- X{\myit start, end\/} parameters are now reused and point to the
- Xfirst byte and to the first ``off limit'' byte of a
- X{\myit string of delimiters\/}. Each byte of this string
- X(throughout the full ASCII range --- including NUL)
- Xis used for a possible delimiter, allowing \IT\ to recognize
- Xthe beginning and the
- Xend of the currently read token.
- XThat is, successive bytes of the buffer that do not match any of the
- Xdelimiter characters, are identified as a single token.
- XThe caller may take the shortcut of passing the valid {\myit start\/}
- Xof the delimiter string, and passing the NULL pointer as
- X{\myit end\/}, in which case \IT\ will assume that the
- Xdelimiters form a null terminated string, and will not include the
- Xfinal NUL in the character set of the delimiters.
- X\L
- XEven though \IT\ moves
- Xits text marker to the first delimiter byte to the right of the newly
- Xfound token in preparation for the next call, \IT\ sets {\myit result\/}
- Xto point to the beginning (first byte) of the recognized token,
- Xand returns the length (text marker minus the beginning)
- Xof the token. {\myit result\/} should be a {\myit (char *)\/} passed
- Xby address.
- X\L
- XIf {\myit context\/} is set to {\myit ITOKR\/}, \IT\
- Xfinds the next token in the buffer to the
- X{\myit left\/} of the text marker,
- Xand then advances its text marker to point to the byte immediately
- X{\myit before the first\/} byte of the new token, in preparation for
- Xthe next tokenizing call.
- XAgain \IT\ uses individual characters of the delimiter string bounded by
- X{\myit start, end\/} to extract the token from amidst
- Xthe ``chaff'' of delimiters.
- X\IT\ then sets {\myit result\/}
- Xto point to the beginning (still the leftmost byte) of the recognized
- Xtoken, and returns the length of the token.
- X\L
- X\IT\ is flexible, and operates without disturbing the buffer text
- Xor the delimiter string in any way.
- XThe parsing direction or the composition of the delimiter
- Xstring may be changed as often as every call.
- XIf the {\myit start\/} boundary is reached during reverse parsing,
- Xor if the byte before {\myit end\/} is reached during forward
- Xparsing, parsing stops whether the boundary byte
- Xwas a delimiter or a non-delimiter. If the byte
- Xwas a non-delimiter, the returned size includes the last byte.
- XIf no token could be isolated during a call,
- X\IT\ sets {\myit result\/} to NULL.
- X
- X\S{pathfiles PROGRAM EXAMPLE}
- XThe {\bb pathfiles} program lists the discreet directories of the
- Xuser's {\myit PATH\/} variable, one at a time, to a temporary file;
- Xand then prints the full path of those listed files whose access mode
- Xsatisfies the user's requirements. The user specifies the
- Xrequired access mode by invoking {\bb pathfiles} by one of its
- X{\myit alias\/} names
- X{\bb fpath} (requiring only that the {\myit F\/}ile is present),
- X{\bb rpath} (requiring that a given file be {\myit R\/}eadable),
- X{\bb wpath} (requiring that a given file be {\myit W\/}ritable), and
- X{\bb xpath} (requiring that a given file be e{\myit X\/}ecutable).
- XThe original name of the executable program, {\bb pathfiles\/},
- Xserves to trigger printing the ``usage'' message to \stout.
- X\L
- XThe directory list of \dol{\myit PATH\/} can be bypassed by
- Xgiving an alternate list of directories on the command line:
- X\smallskip
- X\I{\mytt wpath /bin /etc /usr/local .}
- X\smallskip
- XThe above command produces the full pathname of those
- Xfiles in the four specified directories
- Xthat are writable by the user.
- X
- X\S{pathfiles.c PROGRAM TEXT}
- X\listing{../iex/pathfiles.c}
- X
- X\S{fcat PROGRAM EXAMPLE}
- XA more interesting but very densely coded example is the {\bb fcat}
- Xprogram, evaluating input a line at a time, and printing selected
- Xfields of the input to \stout. {\bb fcat} produces results similar to
- Xthe System~V {\myit cut\/} command, but with a simplified
- Xcommand line syntax. {\bb fcat} is a filter, reading either
- X\stin\ or a file given as the optional last command line parameter.
- XThe mandatory
- X{\myit fieldmask\/}
- Xargument following the command on the command line
- Xis a word made of the character set
- X\dx{123456789abcdefg}\ exclusively. Each byte of this character set
- Xrepresents the index of successive tokens in the lines of input,
- Xcounting from left to right, from one to sixteen.
- X\key{2} for example stands for
- Xthe second token of a line, \key{f} stands for the fifteenth.
- X\L
- XThe {\myit fieldmask\/} may contain a valid mask character
- Xmore than once, and in any order. When the input line is scanned,
- X{\bb fcat} sets up separate pointers to the first sixteen tokens of
- Xthe line (if the line contains that many tokens), and then
- Xoutputs a space-separated list of the appropriate tokens in the
- Xorder dictated by the fieldmask characters. The token list is
- Xterminated by a {\myit newline\/} character; the process then
- Xrepeats with the next line of input. If the line has fewer tokens
- Xthan the index specified by a mask byte, the process simply skips
- Xthe oversize mask byte for the current line. Tokenless input lines
- Xproduce a single {\myit newline\/}.
- X\L
- XThe {\bb fcat} process reinitializes the \IT\ tokenizer
- Xat every input line, and constructs its token lists by repeated
- Xoperational calls to \IT. Nominally the
- XASCII SPACE and TAB
- Xcharacters are passed as token delimiters; the NL ({\myit newline\/})
- Xterminators of the input are automatically eliminated
- Xas a side-effect of using {\myit gets()\/} instead of {\myit fgets()\/}
- X(however dangerous it may be to bypass the buffer overrun test
- Xavailable to {\myit fgets()\/} clients only).
- XAn alternate set of
- Xcharacters can be specified with the {\myit --d\/} command
- Xline option. After any operational
- Xcalls to \IT, {\bb fcat} null-terminates
- Xthe newly recognized token in the line buffer,
- Xchanging the original SPACE or TAB delimiter byte to NUL.
- XAt the next call \IT\ is expected to find the beginning of the
- Xfollowing token by skipping any delimiter bytes, but instead,
- X\IT\ finds
- Xthat its internal marker is now pointing to a non-delimiter value (NUL);
- Xand would happily report a new token beginning at this point.
- XBecause of this, {\bb fcat} also includes NUL
- Xin the delimiter character set.
- X\L
- XThe ``solo minus'' option reverses the direction of the
- Xfield numbers, making field~1 the last field of a line. To \IT's
- Xcredit, the reversal is implemented by just passing it
- Xthe REVERSE flag instead of FORWARD.
- XThe reversed field mask is useful when the field-count of
- Xprocessed text lines is variable. For example, leaf nodes of paths
- Xproduced by {\myit find\/} could be made the leading token with the
- Xfollowing command:
- X\smallskip
- X\I{\mytt find\ \ .\ -print\ |\ fcat\ 1gfedcba98765432\ -\ -d/}
- X\smallskip
- XIn the command,
- Xthe output of {\myit find\/} is redirected to {\bb fcat}, providing
- Xinput lines of full pathnames whose components are separated by
- X\key{/}. The delimiter list of the command is therefore a single
- Xslash character. The solo minus option reverses field numbering to
- Xstart from the end, so the first character \key{1} of the fieldmask
- Xspecifies that the last field of each line is to be output first.
- XThe remaining bytes of the mask are in a straight decremental order,
- Xforcing the reprint of all other fields of the input in their
- Xoriginal sequence.
- X
- X\S{fcat.c PROGRAM TEXT}
- X\listing{../iex/fcat.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608102390 iman/itok.tex &&
- chmod 0644 iman/itok.tex ||
- echo "restore of iman/itok.tex failed"
- set `wc -c iman/itok.tex`;Wc_c=$1
- if test "$Wc_c" != "9555"; then
- echo original size 9555, current size $Wc_c
- fi
- # ============= iman/iuniq.tex ==============
- echo "x - extracting iman/iuniq.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/iuniq.tex &&
- X% XREF iuniq
- X
- X\def\name{IUNIQ}
- X\def\IT{{\bb iuniq()}}
- X
- X\S{NAME}
- X{\bb iuniq} --- return TRUE if parameter is passed for the first time
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xiuniq (item)
- Xint item;
- X}
- X
- X\S{DESCRIPTION}
- X\IT\ is a dynamic function, expecting a setup call, a number of
- Xoperational calls, and a terminating call.
- X\L
- XFrom an operational call \IT\ returns TRUE if it has not
- Xyet seen the current value of {\myit item\/} at a previous call
- Xwithin the life of its state machine.
- X\IT\ returns FALSE otherwise.
- X(If the caller needs to count how many times a parameter
- Xhas been passed, he should use {\myit icount()\/} instead.)
- X\L
- XThe setup call should pass a value that is one more than the
- Xlargest {\myit item\/} that may
- Xbe encountered during an operational call. This naturally corresponds
- Xto defining an array by its size, and indexing into it by lesser values.
- XThe smallest {\myit item\/} value of an operational call is 0.
- XAs an example, the caller using a hundred-element
- Xarray of items would initialize \IT\ with an {\myit item\/} value
- Xof 100, and
- Xcall \IT\ with values between 0 and 99 during normal operation.
- X\L
- XTo reset
- Xthe state machine, and to free dynamically allocated memory,
- Xa negative number is passed during the terminal call.
- X
- X\eject
- SHAR_EOF
- $TOUCH -am 0509104190 iman/iuniq.tex &&
- chmod 0644 iman/iuniq.tex ||
- echo "restore of iman/iuniq.tex failed"
- set `wc -c iman/iuniq.tex`;Wc_c=$1
- if test "$Wc_c" != "1256"; then
- echo original size 1256, current size $Wc_c
- fi
- # ============= iman/iwhich.tex ==============
- echo "x - extracting iman/iwhich.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/iwhich.tex &&
- X% XREF iwhich
- X
- X\def\name{IWHICH}
- X\def\IT{{\bb iwhich()}}
- X
- X\S{NAME}
- X{\bb iwhich} --- locate a file
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xchar *
- Xiwhich (item, perm)
- Xchar *item;
- Xint perm;
- X}
- X
- X\S{DESCRIPTION}
- X\IT\ searches the directory components of the caller's {\myit PATH\/}
- Xenvironment variable for acces to the file passed as {\myit item\/},
- Xand returns the full pathname of the first file that has
- Xpermissions coinciding with
- X{\myit perm\/}.
- XIf the specified {\myit item\/} forms a {\myit path\/} (i.e. contains
- Xone or more \key{/} characters), {\myit PATH\/} is not searched;
- Xinstead
- X\IT\ verifies that the literal {\myit item\/} string is a file
- Xwith access mode equal or better than {\myit perm\/}.
- X\L
- XStandard values of {\myit perm\/} are defined in {\myit stdio.h\/}
- Xunder System~V, and are defined in {\myit ilib.h\/} for running
- Xunder the Berkeley versions:
- X\smallskip
- X\I{{\mytt F\_OK 0} file exists}
- X\I{{\mytt X\_OK 1} executable by caller}
- X\I{{\mytt W\_OK 2} writable by caller}
- X\I{{\mytt R\_OK 4} readable by caller}
- X\smallskip
- X
- XIf the file does not exist, or if the the permission of the file
- Xdoes not meet the value specified by {\myit perm\/}, \IT\
- Xreturns the NULL pointer.
- X\IT\ calls {\myit ierror()\/} to set {\myit ierflag\/} and to
- Xinstall the appropriate error message in {\myit ierbuf\/} if
- Xthe NULL pointer is passed as {\myit item\/}, or if {\myit item\/}
- Xhas no length.
- X
- X\S{which PROGRAM EXAMPLE}
- XThis program emulates the standard Berkeley command of the same name,
- Xbut unlike the Berkeley version, it does not concern itself with
- Xidentifying additional command aliases implemented by the
- XBerkeley {\myit alias\/} mechanism. Perhaps because of this neglect,
- Xthe ILIB version is significantly faster than its BSD counterpart.
- X{\bb which} also implements a number of options that may be of use:
- Xfollowing a {\myit --m\/} flag on the command line an additional
- X\key{f},
- X\key{r}, or
- X\key{w}\ character specifies that the mere presence of a file,
- Xor the read or write permission of the file is being tested for,
- Xrather than the default ``execute'' permission. The null option
- X(the \key{-} sign by itself) on the command line indicates that
- Xinstead of evaluating files listed on the command line, file names
- Xwill be provided interactively, in a loop.
- X
- X\S{which.c PROGRAM TEXT}
- X\listing{../iex/which.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608103790 iman/iwhich.tex &&
- chmod 0644 iman/iwhich.tex ||
- echo "restore of iman/iwhich.tex failed"
- set `wc -c iman/iwhich.tex`;Wc_c=$1
- if test "$Wc_c" != "2328"; then
- echo original size 2328, current size $Wc_c
- fi
- # ============= iman/iwrite.tex ==============
- echo "x - extracting iman/iwrite.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/iwrite.tex &&
- X% XREF iwrite iwritopn
- X
- X\def\name{IWRITE}
- X\def\IT{{\bb iwrite()}}
- X\def\ALT{{\bb iwritopn()}}
- X
- X\S{NAME}
- X{\bb iwrite} --- open file, write buffer to file, close file
- X
- X{\bb iwritopn} --- open file, write buffer to file, leave file open
- X
- X\S{SYNOPSIS}
- X{\obeylines \bb
- Xint
- Xiwrite (fname, start, end)
- Xchar *fname;
- Xchar *start;
- Xchar *end;
- X\L
- Xint
- Xiwritopn (fname, start, end)
- Xchar *fname;
- Xchar *start;
- Xchar *end;
- X}
- X
- X\S{DESCRIPTION}
- X
- X\IT\ opens the file specified by {\myit fname\/},
- Xand writes the buffer delimited by {\myit start\/} and {\myit end\/}
- Xto the file. \IT\ then closes the file, and returns the number of
- Xbytes written.
- XThe file is opened for {\myit write()\/}
- Xusing the symbolic {\myit flag\/} constants
- X{\myit O\_WRONLY \pip\ O\_CREAT \pip\ O\_TRUNC\/};
- Xretaining the file access permissions of an existing file, or
- Xsetting \dx{0644}\ for a new file.
- X\L
- XIn the special case if {\myit start\/} is the NULL pointer,
- X\IT\ retrieves the status of {\myit fname\/} and ignores the passed
- Xbuffer, returning:
- X\smallskip
- X\I{-1 if the system does not allow writing to {\myit fname\/},}
- X
- X\I{0 if file {\myit fname\/} could be written to, but does not exist,}
- X
- X\I{1 if file {\myit fname\/} exists, and could be written to.}
- X\L
- X\ALT\ operates similarly to \IT,but does not implement
- Xthe the special {\myit fstat()\/} call.
- X\ALT\ opens {\myit fname\/},
- Xand writes the buffer delimited by {\myit start\/} and {\myit end\/}
- Xto the file. At this point, differently from \IT,
- Xthe file is left open, and the
- X{\myit (int) file descriptor\/} of the open file is returned.
- X\L
- XExcept for the special call to \IT, invalid {\myit fname\/} or
- Xinvalid buffer delimiters
- Xtrigger error reporting via {\myit ierror()\/},
- Xand produce the {\myit -sys\_nerr\/} return value.
- X
- X\S{objed PROGRAM EXAMPLE}
- X
- XMany C programmers face the occasional need to modify binary files
- Xdirectly. Binary files are either data files that contain byte
- Xvalues outside of the ASCII character set, or {\myit object\/}
- Xfiles containing executable machine code. A number of standard Unix
- Xtools and editors are capable of displaying and altering binary files
- Xdirectly (for example {\myit adb\/} or {\myit emacs\/}), but even
- Xthe best tools support binary editing as a capability of secondary
- Ximportance only, leaving the mechanics of binary editing
- X``user-unfriendly'' and painful.
- X\L
- XThe {\bb objed} ({\bb obj}ect {\bb ed}itor) program is a
- X``software sandwich'': the top layer is a
- Xa transparent binary-to-ASCII conversion process, the bottom layer is
- Xa transparent, ASCII-to-binary conversion process, with the user's
- Xfavorite text editor wedged in between. Because the user does not
- Xhave to learn the particulars of a new editor, editing binary files
- Xunder {\bb objed} should not yield unpleasant surprises.
- XThe default command line syntax
- X\smallskip
- X\I{\mytt objed file}
- X\smallskip
- Xreads the binary file into an internal buffer with {\myit iread()\/},
- Xthen converts chunks of 24 bytes into {\myit newline\/}-terminated
- XASCII text lines, in a temporary file in {\mytt /tmp}. The default
- Xeditor {\myit vi\/} is called next, and the user edits the temporary
- XASCII file in a conventional manner. When {\myit vi\/} terminates,
- Xthe temporary file is reconverted back to binary, and rewritten over
- Xthe original binary file with a single call to \IT.
- XA different editor can be specified with the {\mytt -e} command line flag:
- X\smallskip
- X\I{\mytt objed -e emacs file}
- X\smallskip
- Xor instead of the name of an editor, any Unix command can be given,
- Xwith embedded \key{\$} characters as
- X{\myit place holders\/} for ``file'':
- X\smallskip
- X\I{\mytt objed -e 'cat -n \dol\ \pip\ lp' file}
- X\L
- XIf the edit command does not modify the temporary ASCII copy of the
- Xfile, {\bb objed} will not attempt to recreate the (identical) binary
- Xversion; but simply deletes the temporary copy when
- Xterminating the process. If the ASCII copy is changed during editing
- Xbut the binary file cannot be written to (for example when editing
- Xthe image of a directory), {\bb objed} terminates
- Xwith an error message, leaving
- Xthe temporary file in {\mytt /tmp}.
- X\L
- XIn order to allow visual pattern discrimination and string recognition
- Xwhen editing the ASCII copy, the original binary data is translated
- Xunder four very simple rules:
- X\L
- XEach line at the beginning of the edit session will contain the
- XASCII translation of the same number of bytes of the original file
- X(here referred to as the {\myit modulo byte count\/}),
- Xexcept the last line which may contain the translation of
- Xa smaller number of the remaining original bytes.
- XThe translated
- XASCII text does not contain a counter to keep track of the addresses
- Xof the original bytes; but as long as the lines of the temporary file
- Xare kept intact, the address of the first byte in each line can be
- Xderived from the formula
- X\smallskip
- X\I{line\_number\_minus\_one * modulo\_byte\_count}
- X\smallskip
- XThe default modulo byte count is 24, but can be
- Xoverridden by specifying a different value along with the {\mytt-b}
- Xcommand line option.
- X\L
- XEach original byte value outside the ASCII printing range is
- Xtranslated as a two-digit, upper case hexadecimal number
- Xbetween 00 and FF({\myit hex\/}),
- Xseparated from the printing character
- Xto its right by a single blank space.
- X(The ASCII printing character set
- Xcomprises all ASCII characters that make
- Xa mark on the paper; ranging between
- Xdecimal values 33 \key{!} and 126 \key{\til} inclusive.)
- X\L
- XEach string in the original file
- Xformed by consecutive, printing ASCII bytes with
- Xstring length of three or longer, and within an imaginary original
- Xline of modulo byte count length,
- Xis printed as the string
- Xitself; and is separated from its right hand neighbor by a blank
- Xspace.
- X\L
- XEach printing ASCII byte that cannot fit into a string described
- Xabove (either because it is not a part of a long enough
- Xprinting ASCII string or because it is broken off from a preceding or
- Xsuccessive line) is translated as its own printing image; and is
- Xseparated from its neighbor to the right by two blank spaces.
- X\L
- XIf the solo minus flag \key{-} is present on the command line,
- X{\bb objed} produces a more homogeneous, less {\myit freeform\/}
- Xtranslation,
- Xby converting even the printing ASCII bytes of the original file
- Xto two-digit, hexadecimal, space-separated numbers.
- X\L
- XMethods of reconverting data from the temporary file are even simpler.
- XAny distinct (separated from the next printing byte)
- Xtwo-digit uppercase hexadecimal number will
- Xbe changed back into a binary byte, while all other printing characters
- Xwill be rewritten as themselves. The reconversion is insensitive to
- Xthe modulo byte count
- Xoperative during the construction of the temporary file,
- Xhowever a single edited
- Xline should not expand beyond 16 times of the
- Xmodulo byte count. More data can be added by inserting any number
- Xof new text lines.
- XThe reconversion is also insensitive to any non-printing
- Xcharacters, ignoring all spacing and {\myit control characters\/}
- X--- except as token delimiters.
- XThe total size of the data can shrink or grow arbitrarily.
- X\L
- X{\bb objed}'s use of the \IT\ function again addresses the concern
- Xthat piece-by-piece restoration of the binary file may prove
- Xdisastrous in case of an interrupt, or on system failures
- X(crashes, disk full, etc.). Under these circumstances,
- Xpiece-by-piece restoration would be
- Xlikely to truncate the file, or update it only partially. {\bb objed}
- Xrestores the edited file in an internal buffer, and writes
- Xthe final data with a single call to \IT.
- X
- X\S{objed.c PROGRAM TEXT}
- X\listing{../iex/objed.c}
- X\eject
- SHAR_EOF
- $TOUCH -am 0608095290 iman/iwrite.tex &&
- chmod 0644 iman/iwrite.tex ||
- echo "restore of iman/iwrite.tex failed"
- set `wc -c iman/iwrite.tex`;Wc_c=$1
- if test "$Wc_c" != "7540"; then
- echo original size 7540, current size $Wc_c
- fi
- # ============= iman/man.tex ==============
- echo "x - extracting iman/man.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/man.tex &&
- X\font\myit=cmti9
- X\font\mytt=cmtt9
- X\font\myletr=cmssq8
- X\font\bb=cmssbx10
- X\font\smallcaps=cmcsc10
- X
- X\hsize 5.2in
- X\vsize 7.6in
- X\raggedbottom
- X\parskip 0pt
- X\parindent 0pt
- X\myletr
- X
- X\def\stio{{\myit stdio\/}}
- X\def\stin{{\myit stdin\/}}
- X\def\stout{{\myit stdout\/}}
- X\def\sterr{{\myit stderr\/}}
- X\def\deg{{\kern -.2em\rm\char23}}
- X\def\mydots{$\ldots$}
- X\def\hole{\kern1pt\vrule height6pt width4pt depth2pt\kern1pt}
- X
- X% fill in line with dots or horizontal line, to last token
- X\def\dotf{\leaders\hbox to .12in{\hss{\myletr.}\hss}\hfill}
- X\def\linef{ \leaders\hrule\hfill\ }
- X
- X% to enclose a horizontal upper-case string in a rectangle
- X\def\dx#1{\kern -.15em\setbox0=\hbox{\thinspace{#1}\thinspace}
- X\dimen0=\ht0 \advance\dimen0 by 1.5pt % 1.5 pt higher than text
- X\dimen1=\dimen0 \advance\dimen1 by -.3pt % underside of top line
- X\dimen3=\dp0 \advance\dimen3 by 1.8pt % 1.8 pt lower than text
- X\dimen4=\dimen3 \advance\dimen4 by -.3pt % topside of bottom line
- X\vrule height \dimen0 depth \dimen3 width .3pt % left vertical
- X\vrule height \dimen0 depth -\dimen1 width \wd0 % top horizontal
- X\vrule width -\wd0 % go back to left
- X\vrule height -\dimen4 depth \dimen3 width \wd0 % bottom horizontal
- X\vrule width -\wd0 % go back to left
- X\box0 % install text
- X\vrule height \dimen0 depth \dimen3 width .3pt % right vertical
- X}
- X% to enclose a single \tt key in 11x11 (more or less) square, with
- X% small space automatically appended to right of box
- X%
- X\def\key#1{\setbox0=\hbox to 10.4pt{\hfill{\mytt#1}\hfill}
- X\dimen0=2ex \dimen1=\dimen0 \advance\dimen1 by -.3pt
- X\dimen3=.5ex \dimen4=\dimen3 \advance\dimen4 by -.3pt
- X\dimen5=\wd0
- X\vrule height \dimen0 depth \dimen3 width .3pt % left vertical
- X\vrule height \dimen0 depth -\dimen1 width \dimen5 % top horiz
- X\vrule width -\dimen5 % backup to left
- X\box0 % install text
- X\vrule width -\dimen5 % backup to left
- X\vrule height -\dimen4 depth \dimen3 width \dimen5 % bottom horiz
- X\vrule height \dimen0 depth \dimen3 width .3pt % right vertical
- X\thinspace
- X}
- X% to enclose two \tt keys (control sequences, etc.) in a rectangle
- X\def\twokey#1{\setbox0=\hbox to 16pt {\hfill{\mytt#1}\hfill}
- X\dimen0=2ex \dimen1=\dimen0 \advance\dimen1 by -.3pt
- X\dimen3=.5ex \dimen4=\dimen3 \advance\dimen4 by -.3pt
- X\dimen5=\wd0
- X\vrule height \dimen0 depth \dimen3 width .3pt % left vertical
- X\vrule height \dimen0 depth -\dimen1 width \dimen5 % top horiz
- X\vrule width -\dimen5 % backup to left
- X\box0 % install text
- X\vrule width -\dimen5 % backup to left
- X\vrule height -\dimen4 depth \dimen3 width \dimen5 % bottom horiz
- X\vrule height \dimen0 depth \dimen3 width .3pt % right vertical
- X\thinspace
- X}
- X\def\bsl{{\char92}} % \
- X\def\und{{\char95}} % _
- X\def\pip{{\mytt\char124}} % |
- X\def\lcu{{\char123}} % {
- X\def\rcu{{\char125}} % }
- X\def\lsq{{\char91}} % [
- X\def\rsq{{\char93}} % ]
- X\def\les{{\char60}} % <
- X\def\gre{{\char62}} % >
- X\def\cir{{\char94}} % ^
- X\def\car{{\char94}} % ^
- X\def\til{{\char126}} % ~
- X\def\dol{{\mytt\char36}} % $
- X\def\ats{{\char64}} % @
- X
- X\headline={{\myletr\name\hfil\mansection\hfil\name}}
- X\footline={\ifodd\pageno\rightfoot\else\leftfoot\fi}
- X\def\leftfoot{\rlap{\myletr\folio}\hfil{{\myletr\vers\ --- \date}}\hfil}
- X\def\rightfoot{\hfil{{\myletr\vers\ --- \date}}\hfil\llap{\myletr\folio}}
- X\def\S#1{\leftline{}\par\leftskip=-20pt{\bb#1}\smallskip\leftskip=0pt}
- X\def\SU#1{\par\leftskip=-20pt{\bb#1}\smallskip\leftskip=0pt}
- X\def\L{\par\kern 7pt\par}
- X\def\I#1{\leftskip=20pt{#1}\par\leftskip=0pt}
- X
- X% Verbatim macros from Appendix D (pages 381, 391) of The TeXbook
- X% but senza line numbering, and tabstopwidth set to four.
- X% Redefined Q to produce \longrightarrow at left margin of \listing
- X%
- X\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
- X\def\setupverbatim{\mytt
- X \def\par{\leavevmode\egroup\box0\endgraf}
- X \obeylines \uncatcodespecials \obeyspaces
- X \catcode`\`=\active \catcode`\^^I=\active
- X \catcode`Q=\active
- X \everypar{\startbox}}
- X\newdimen\w \setbox0=\hbox{\mytt\space} \w=4\wd0 % width of tab
- X\def\startbox{\setbox0=\hbox\bgroup}
- X{\catcode`\^^I=\active
- X \gdef^^I{\leavevmode\egroup
- X \dimen0=\wd0 % the width so far, or since the previous tab
- X \divide\dimen0 by\w
- X \multiply\dimen0 by\w % compute previous multiple of \w
- X \advance\dimen0 by\w % advance to next multiple of \w
- X \wd0=\dimen0 \box0 \startbox}}
- X\def\listing#1{\par\begingroup\setupverbatim\input#1 \endgroup}
- X{\obeyspaces\global\let =\ } % let active space become control space
- X{\catcode`\`=\active \gdef`{\relax\lq}}
- X{\catcode`Q=\active \gdefQ{\ \kern -30pt$\longrightarrow$\kern 14pt}}
- SHAR_EOF
- $TOUCH -am 0608125990 iman/man.tex &&
- chmod 0644 iman/man.tex ||
- echo "restore of iman/man.tex failed"
- set `wc -c iman/man.tex`;Wc_c=$1
- if test "$Wc_c" != "4877"; then
- echo original size 4877, current size $Wc_c
- fi
- # ============= iman/single.tex ==============
- echo "x - extracting iman/single.tex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/single.tex &&
- X\input man
- X\def\date{June, 1990}
- X\def\vers{Version 1.0}
- X\def\mansection{ILIB (3i)}
- X
- X\input ihash
- X
- X\bye
- SHAR_EOF
- $TOUCH -am 0608125890 iman/single.tex &&
- chmod 0644 iman/single.tex ||
- echo "restore of iman/single.tex failed"
- set `wc -c iman/single.tex`;Wc_c=$1
- if test "$Wc_c" != "103"; then
- echo original size 103, current size $Wc_c
- fi
- # ============= iman/stanquote.new ==============
- echo "x - extracting iman/stanquote.new (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/stanquote.new &&
- XThe sad truth is that there is a frustrating absence of crisp axioms from
- Xwhich you can build a logically consistent corpus of computer know-how.
- XIndeed, it is hard to find so much as a single simple sentence that you can
- Xswear to on your mother's white Corniche without first appending a list of
- Xcaveats and qualifications.
- X
- X Stan Kelly-Bootle, UNIX REVIEW VOL.5 NO.2
- SHAR_EOF
- $TOUCH -am 0504125590 iman/stanquote.new &&
- chmod 0644 iman/stanquote.new ||
- echo "restore of iman/stanquote.new failed"
- set `wc -c iman/stanquote.new`;Wc_c=$1
- if test "$Wc_c" != "386"; then
- echo original size 386, current size $Wc_c
- fi
- # ============= iman/stanquote.old ==============
- echo "x - extracting iman/stanquote.old (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iman/stanquote.old &&
- XThe sad truth is that there is a frustrating absence
- Xof crisp axioms from which you can build a logically
- Xconsistent corpus of computer know-how.
- XIndeed, it is hard to find so much as a single
- Xsimple sentence that you can swear to
- Xon your mother's white Corniche without first
- Xappending a list of caveats and qualifications.
- X
- X Stan Kelly-Bootle, UNIX REVIEW VOL.5 NO.2
- SHAR_EOF
- $TOUCH -am 0504125690 iman/stanquote.old &&
- chmod 0644 iman/stanquote.old ||
- echo "restore of iman/stanquote.old failed"
- set `wc -c iman/stanquote.old`;Wc_c=$1
- if test "$Wc_c" != "386"; then
- echo original size 386, current size $Wc_c
- fi
- exit 0
- --
- Istvan Mohos
- ...uunet!pyrdc!pyrnj!hhb!istvan
- RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
- ======================================================================
-