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: <549@hhb.UUCP>
- Date: 8 Jun 90 20:52:44 GMT
-
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # This is part 03 of a multipart archive
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= i/iwrite.c ==============
- echo "x - extracting i/iwrite.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/iwrite.c &&
- X/* iwrite.c */
- X/********************************************
- X* write file from buffer, return size written
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- X#include "i.h"
- X
- Xint
- Xiwrite (fname, start, end)
- Xchar *fname;
- Xregister char *start;
- Xregister char *end;
- X{
- X struct stat sbuf;
- X int checkval, descr;
- X int perm = 0644;
- X
- X if (BADCHARP(fname))
- X return(ierror("iwrite: invalid file name"));
- X
- X if ((checkval = stat(fname, &sbuf)) != -1)
- X perm = (int)sbuf.st_mode;
- X
- X if (NULCHARP(start)) {
- X if ((descr = open(fname, O_RDWR | O_CREAT, perm)) == -1)
- X return(-1); /* no access */
- X if (checkval != -1) {
- X close(descr);
- X return(1); /* it was there, it's OK, didn't touch it */
- X }
- X unlink(fname);
- X return(0); /* wasn't there, not there now, looks OK */
- X }
- X
- X if ((descr = open(fname, O_WRONLY | O_CREAT | O_TRUNC, perm)) == -1)
- X return(ierror("iwrite: can't write to"));
- X
- X ITOEND;
- X
- X if ((checkval = write(descr, start, end-start)) != end-start) {
- X sprintf(ierbuf+200, "iwrite: tried: %d, wrote: %d",
- X end-start, checkval);
- X return(ierror(ierbuf+200));
- X }
- X
- X close(descr);
- X return(checkval);
- X}
- SHAR_EOF
- $TOUCH -am 0605074590 i/iwrite.c &&
- chmod 0644 i/iwrite.c ||
- echo "restore of i/iwrite.c failed"
- set `wc -c i/iwrite.c`;Wc_c=$1
- if test "$Wc_c" != "1143"; then
- echo original size 1143, current size $Wc_c
- fi
- # ============= i/iwritopn.c ==============
- echo "x - extracting i/iwritopn.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/iwritopn.c &&
- X/* iwritopn.c */
- X/**********************************************
- X* write file from buffer, leave open, return fd
- X* Istvan Mohos, 1987 --- in the Public Domain
- X***********************************************/
- X
- X#include "i.h"
- X
- Xint
- Xiwritopn (fname, start, end)
- Xregister char *fname;
- Xregister char *start;
- Xchar *end;
- X{
- X struct stat sbuf;
- X int checkval, descr;
- X int perm = 0644;
- X
- X if (BADCHARP(fname))
- X return(ierror("iwritopn: invalid file name"));
- X
- X if ((checkval = stat(fname, &sbuf)) != -1)
- X perm = (int)sbuf.st_mode;
- X
- X if ((descr = open(fname, O_WRONLY | O_CREAT | O_TRUNC, perm)) == -1)
- X return(ierror("iwritopn: can't write to"));
- X
- X if (NULCHARP (start))
- X return (ierror ("iwritopn: invalid buffer"));
- X ITOEND;
- X
- X if ((checkval = write(descr, start, end-start)) != end-start) {
- X sprintf(ierbuf+200, "iwritopn: tried: %d, wrote: %d",
- X end-start, checkval);
- X return(ierror(ierbuf+200));
- X }
- X
- X return(descr);
- X}
- SHAR_EOF
- $TOUCH -am 0605074590 i/iwritopn.c &&
- chmod 0644 i/iwritopn.c ||
- echo "restore of i/iwritopn.c failed"
- set `wc -c i/iwritopn.c`;Wc_c=$1
- if test "$Wc_c" != "916"; then
- echo original size 916, current size $Wc_c
- fi
- # ============= i/ixmatch.c ==============
- echo "x - extracting i/ixmatch.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/ixmatch.c &&
- X/* ixmatch.c */
- X/********************************************
- X* find word in buffer
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- X#include "i.h"
- X
- Xchar *
- Xixmatch (start, end, word)
- Xregister char *start;
- Xchar *end, *word;
- X{
- X register char *off;
- X register char *tail;
- X char *sc, *tc;
- X char *pp, *wp;
- X int length;
- X
- X if (NULCHARP (start) || BADCHARP (word)) {
- X ierror("ixmatch: invalid word");
- X return(NULL);
- X }
- X ITOEND;
- X
- X for (sc = off = word; *off++;);
- X length = --off - word;
- X tc = --off;
- X
- X off = end;
- X
- X for (off -= --length; start < off;) {
- X
- X /* proceed to first black character */
- X for (;WHITE(*start);)
- X if (++start == off)
- X return(NULL);
- X
- X tail = start + length;
- X if (*start++ == *sc && *tail == *tc)
- X if (length > 1) {
- X for (wp = tc, pp = tail; *--wp == *--pp;)
- X if (pp == start)
- X if (start == off || WHITE(*++tail))
- X return(--start);
- X }
- X else if (start == off || WHITE(*++tail))
- X return(--start);
- X
- X /* proceed to next white character */
- X for (;BLACK(*start);)
- X if (++start >= off)
- X return(NULL);
- X }
- X return(NULL);
- X}
- SHAR_EOF
- $TOUCH -am 0605074590 i/ixmatch.c &&
- chmod 0644 i/ixmatch.c ||
- echo "restore of i/ixmatch.c failed"
- set `wc -c i/ixmatch.c`;Wc_c=$1
- if test "$Wc_c" != "1113"; then
- echo original size 1113, current size $Wc_c
- fi
- # ============= i/ixsearch.c ==============
- echo "x - extracting i/ixsearch.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/ixsearch.c &&
- X/* ixsearch.c */
- X/*********************************************
- X* binary search in array of character pointers
- X* Istvan Mohos, 1987 --- in the Public Domain
- X**********************************************/
- X
- X#include "i.h"
- X
- Xint
- Xixsearch (comparee, wordlist, listcount)
- Xchar *comparee;
- Xchar *wordlist[];
- Xint listcount;
- X{
- X register int lo, hi;
- X register int m, mid;
- X
- X if (BADCHARP (comparee))
- X return(ierror("ixsearch: invalid comparee"));
- X if (listcount < 1)
- X return (-1);
- X
- X for (lo = 0, hi = listcount -1; lo <= hi;) {
- X mid = (lo + hi) >> 1;
- X if ((m = strcmp(comparee, wordlist[mid])) < 0)
- X hi = mid -1;
- X else if (m > 0)
- X lo = mid +1;
- X else
- X return(mid);
- X }
- X return (-1);
- X}
- SHAR_EOF
- $TOUCH -am 0605074590 i/ixsearch.c &&
- chmod 0644 i/ixsearch.c ||
- echo "restore of i/ixsearch.c failed"
- set `wc -c i/ixsearch.c`;Wc_c=$1
- if test "$Wc_c" != "684"; then
- echo original size 684, current size $Wc_c
- fi
- # ============= i/ixswap.c ==============
- echo "x - extracting i/ixswap.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/ixswap.c &&
- X/* ixswap.c */
- X/********************************************
- X* change one word to another in buffer
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- X#include "i.h"
- X
- Xint
- Xixswap (start, end, from, to)
- Xchar *start, *end, *from, *to;
- X{
- X register char *off;
- X register char *inp, *we;
- X register char ch;
- X char *mark;
- X char tok[SHORTSTR];
- X int frsiz, tosiz;
- X int count = 0;
- X
- X if (NULCHARP (start))
- X return (ierror ("ixswap: null buffer"));
- X ITOEND;
- X
- X if (BADCHARP(from))
- X return(ierror("ixswap: bad source pattern"));
- X if (BADCHARP(to))
- X return(ierror("ixswap: bad target pattern"));
- X
- X for (off = from; *off++;);
- X frsiz = --off - from;
- X
- X for (off = to; *off++;);
- X tosiz = --off - to;
- X
- X off = end;
- X inp = start;
- X
- X /* get alphanumeric word only */
- X for (;(we = ialntok(inp, off, tok)) != (char *)NULL;) {
- X if (strcmp (from, tok) == 0) {
- X mark = we - frsiz;
- X inp = mark + tosiz;
- X ch = *inp;
- X strcpy (mark, to);
- X *inp = ch;
- X ++count;
- X }
- X else
- X inp = we;
- X }
- X return(count);
- X}
- SHAR_EOF
- $TOUCH -am 0605074590 i/ixswap.c &&
- chmod 0644 i/ixswap.c ||
- echo "restore of i/ixswap.c failed"
- set `wc -c i/ixswap.c`;Wc_c=$1
- if test "$Wc_c" != "1049"; then
- echo original size 1049, current size $Wc_c
- fi
- # ============= i/i.h ==============
- echo "x - extracting i/i.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/i.h &&
- X/* i.h */
- X/**************************************
- X* local include file for ilib functions
- X* Istvan Mohos, 1987
- X***************************************/
- X
- X#ifdef pyr
- X#include <sys/time.h>
- X#else
- X#include <time.h>
- X#endif
- X
- X#include <stdio.h>
- X#include <signal.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X
- X#ifndef X_OK
- X# ifdef REALUNIX
- X# define F_OK 0
- X# define X_OK 1
- X# define W_OK 2
- X# define R_OK 4
- X# include <fcntl.h>
- X# else
- X# include <sys/file.h>
- X# endif
- X#endif
- X
- X#ifdef REALUNIX
- X void memcpy(); /* in truth, char* */
- X# define ibcopy(a,b,c) memcpy((a),(b),(c))
- X
- X int memcmp();
- X# define ibcmp(a,b,c) memcmp((a),(b),(c))
- X#else
- X void bcpy();
- X# define ibcopy(a,b,c) bcopy((b),(a),(c))
- X
- X int bcmp();
- X# define ibcmp(a,b,c) bcmp((a),(b),(c))
- X#endif
- X
- X#define ITOEND if (end == (char *)NULL) for (end = start; *end; end++)
- X
- X#define NUL 0 /* the ASCII 0 byte */
- X#define MAXSTR 1892
- X#define BIGBUFSIZ 4096
- X#define SHORTSTR 256
- X#define IFOURK 4096
- X#define ITWOK 2048
- X#define IONEK 1024
- X#define IHALFK 512
- X#define IQUARTK 256
- X#define BADCHARP(p) ((p) == (char *)NULL || *(p) == '\0')
- X#define NULCHARP(p) ((p) == (char *)NULL)
- X#define WHITE(c) ((c) < 33)
- X#define BLACK(c) ((c) > 32)
- X#define SMALL(c) ((c) < 32)
- X
- X#define INITOKF 1 /* setup forward parsing */
- X#define INITOKR -1 /* setup reverse parsing */
- X#define ITOKF 2 /* forward parse */
- X#define ITOKR -2 /* reverse parse */
- X
- Xint fstat();
- Xint stat();
- Xchar *calloc();
- Xchar *ctime();
- Xchar *getenv();
- Xchar *malloc();
- Xlong lseek();
- Xlong time();
- Xstruct tm *_igetdate();
- X
- Xchar *ialntok();
- Xchar *ianytok();
- Xchar *ictok();
- Xchar *ilast();
- Xchar *inull();
- Xchar *iwhich();
- Xint ierror();
- Xint ifamily();
- Xint ilongest();
- Xint iread();
- Xint itexrect();
- X
- Xextern int errno, sys_nerr;
- Xextern char *sys_errlist[];
- X
- X#ifndef IAMIERROR
- Xextern char ierbuf[];
- Xextern int ierflag;
- X#endif
- SHAR_EOF
- $TOUCH -am 0601073090 i/i.h &&
- chmod 0644 i/i.h ||
- echo "restore of i/i.h failed"
- set `wc -c i/i.h`;Wc_c=$1
- if test "$Wc_c" != "1975"; then
- echo original size 1975, current size $Wc_c
- fi
- # ============= i/icmapalnum.h ==============
- echo "x - extracting i/icmapalnum.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/icmapalnum.h &&
- X/* icmapalnum.h */
- X/********************************************
- X* character map array used by ictok.c
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- Xstatic char cmapalnum[] = {
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- X 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
- X 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- X};
- SHAR_EOF
- $TOUCH -am 0425094890 i/icmapalnum.h &&
- chmod 0644 i/icmapalnum.h ||
- echo "restore of i/icmapalnum.h failed"
- set `wc -c i/icmapalnum.h`;Wc_c=$1
- if test "$Wc_c" != "748"; then
- echo original size 748, current size $Wc_c
- fi
- # ============= i/idowncas.h ==============
- echo "x - extracting i/idowncas.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/idowncas.h &&
- X/* idowncas.h */
- X/********************************************
- X* character map array used by ilower.c
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- Xstatic char downcas[] = {
- X 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- X 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- X 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- X 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- X 64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
- X112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95,
- X 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
- X112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
- X};
- SHAR_EOF
- $TOUCH -am 0425094890 i/idowncas.h &&
- chmod 0644 i/idowncas.h ||
- echo "restore of i/idowncas.h failed"
- set `wc -c i/idowncas.h`;Wc_c=$1
- if test "$Wc_c" != "745"; then
- echo original size 745, current size $Wc_c
- fi
- # ============= i/ifonetic.h ==============
- echo "x - extracting i/ifonetic.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/ifonetic.h &&
- X/* ifonetic.h */
- X/********************************************
- X* name list and map array used by ifonetic.c
- X* Istvan Mohos, 1990 --- in the Public Domain
- X*********************************************/
- X
- X#define IFONCNT 106
- X
- Xstatic char *listfonet[] = {
- X "ack","amp","apo","ast","ats","ban","bar","bel","bqu","bsl","bsp","can","car",
- X "cca","ccb","ccc","ccd","cce","ccf","ccg","cch","cci","ccj",
- X "cck","ccl","ccm","ccn","cco","ccp","ccq","ccr","ccs","cct",
- X "ccu","ccv","ccw","ccx","ccy","ccz",
- X "cir","col","com","das","dc1","dc2","dc3","dc4","del","dle","dol","dot","eks",
- X "eme","enq","eot","equ","esc","etb","etx","exc","exx","fil","gra","gre","gro",
- X "has","lan","lcu","les","lpa","lsq","min","nak","new","nul","pag",
- X "per","pip","plu","poi","pou","que","quo","ran","rcu","rec","ret","rpa","rsq",
- X "sem","sha","sin","sla","soh","sou","spa","sta","stx","sub",
- X "syn","tab","tic","til","und","uni","ver",};
- X
- Xstatic char mapfonet[] = {
- X 6, 38, 39, 42, 64, 33, 124, 7, 96, 92, 8, 24, 94,
- X 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- X 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- X 21, 22, 23, 24, 25, 26,
- X 94, 58, 44, 45, 17, 18, 19, 20, 127, 16, 36, 46, 88,
- X 25, 5, 4, 61, 27, 23, 3, 33, 88, 28, 96, 62, 29,
- X 35, 60, 123, 60, 40, 91, 45, 21, 10, 0, 12,
- X 37, 124, 43, 46, 35, 63, 34, 62, 125, 30, 13, 41, 93,
- X 59, 35, 15, 47, 1, 14, 32, 42, 2, 26,
- X 22, 9, 39, 126, 95, 31, 11, };
- SHAR_EOF
- $TOUCH -am 0601070590 i/ifonetic.h &&
- chmod 0644 i/ifonetic.h ||
- echo "restore of i/ifonetic.h failed"
- set `wc -c i/ifonetic.h`;Wc_c=$1
- if test "$Wc_c" != "1617"; then
- echo original size 1617, current size $Wc_c
- fi
- # ============= i/ilib.h ==============
- echo "x - extracting i/ilib.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/ilib.h &&
- X/* ilib.h */
- X/*********************************************************************
- X* This is the client's #include file for accessing functions in ilib.a
- X* Istvan Mohos, 1987 --- in the Public Domain
- X**********************************************************************/
- X
- X/* functions archived in ilib.a: */
- Xchar * ialntok();
- Xchar * ianymatch();
- Xchar * ianytok();
- Xvoid iblank();
- Xint ibreakl();
- Xchar * ictok();
- Xchar * icopy();
- Xint icount();
- Xvoid icue();
- Xint idamage();
- Xchar * idate();
- Xvoid idump();
- Xint iego();
- Xint ierror();
- Xint iexpect();
- Xint ifamily();
- Xint ifilter();
- Xint ifonetic();
- Xint ifrombit();
- Xint igroup();
- Xint ihash();
- Xint ihasharg();
- Xchar * ihms();
- Xint iinput();
- Xint iline();
- Xint ilist();
- Xint ilistn();
- Xint illistn();
- Xint ilongest();
- Xint ilower();
- Xchar * imatch();
- Xint imode();
- Xint imonth();
- Xint inest();
- Xchar * inl();
- Xchar * inull();
- Xint inumsearch();
- Xvoid inumsort();
- Xint inumstrcmp();
- Xchar * inextl();
- Xint ioctal();
- Xint iopt();
- Xint iread();
- Xint irotate();
- Xint iround();
- Xint isearch();
- Xvoid isort();
- Xchar * istartl();
- Xint istripcom();
- Xint istripdq();
- Xint istripsq();
- Xint istripstr();
- Xint iswap();
- Xint itexrect();
- Xchar * itobit();
- Xint itoday();
- Xint itohour();
- Xint itok();
- Xint itomin();
- Xint itomonth();
- Xint itosec();
- Xint itoyear();
- Xint itran();
- Xvoid itwin();
- Xint iuniq();
- Xint iuniqa();
- Xint iupper();
- Xchar * iwhich();
- Xint iwrite();
- Xint iwritopn();
- Xchar * ixmatch();
- Xint ixsearch();
- Xint ixswap();
- X
- Xchar * malloc();
- Xchar * calloc();
- Xchar * gets();
- Xlong lseek();
- X
- X#include <stdio.h>
- X#ifndef X_OK
- X# ifdef REALUNIX
- X# define F_OK 0
- X# define X_OK 1
- X# define W_OK 2
- X# define R_OK 4
- X# include <fcntl.h>
- X# else
- X# include <sys/file.h>
- X# endif
- X#endif
- X
- X#ifdef REALUNIX
- X void memcpy(); /* in truth, char* */
- X# define ibcopy(a,b,c) memcpy((a),(b),(c))
- X
- X int memcmp();
- X# define ibcmp(a,b,c) memcmp((a),(b),(c))
- X#else
- X void bcpy();
- X# define ibcopy(a,b,c) bcopy((b),(a),(c))
- X
- X int bcmp();
- X# define ibcmp(a,b,c) bcmp((a),(b),(c))
- X#endif
- X
- Xextern char ierbuf[];
- Xextern int ierflag;
- X
- X/* imode symbolic constants, modeled after stat.h list */
- X#define ISSOCK 0140000 /* socket */
- X#define ISLNK 0120000 /* symbolic link */
- X#define ISREG 0100000 /* regular */
- X#define ISBLK 0060000 /* block special */
- X#define ISDIR 0040000 /* directory */
- X#define ISCHR 0020000 /* character special */
- X#define ISFIFO 0010000 /* named pipe */
- X#define ISUID 0004000 /* set uid on execution */
- X#define ISGID 0002000 /* set gid on execution */
- X#define ISSTICK 0001000 /* keep text in memory (sticky bit) */
- X#define ISROWN 0000400 /* read, owner */
- X#define ISWOWN 0000200 /* write, owner */
- X#define ISXOWN 0000100 /* execute/search, owner */
- X#define ISRGRP 0000040 /* read, group */
- X#define ISWGRP 0000020 /* write, group */
- X#define ISXGRP 0000010 /* execute/search, group */
- X#define ISRALL 0000004 /* read, others */
- X#define ISWALL 0000002 /* write, others */
- X#define ISXALL 0000001 /* execute/search, others */
- X
- X#define INITOKF 1 /* setup forward parsing */
- X#define INITOKR -1 /* setup reverse parsing */
- X#define ITOKF 2 /* forward parse */
- X#define ITOKR -2 /* reverse parse */
- X
- X#define DOUNCOUN(x,y) (y) = (x); --(y) >= 0
- X#define BADCHARP(p) ((p) == (char *)NULL || *(p) == '\0')
- X#define NULCHARP(p) ((p) == (char *)NULL)
- X#define ZPT (char *)NULL
- X
- X#define IANYTOK 0
- X#define IALNTOK 1
- X#define ICTOK 2
- X
- X#define SPACE_LINE -1
- X#define LINE_ONLY 0
- X#define LINE_SPACE 1
- X
- X#define IROTR 1 /* rotate 90 deg. to right */
- X#define IROTL -1 /* rotate 90 deg. to left */
- X#define IROTOR 3 /* rotate 180 deg. over and 90 deg. to right */
- X#define IROTOL -3 /* rotate 180 deg. over and 90 deg. to left */
- X
- X#define SHORTMO 0 /* idate format: Jun 23 1988 */
- X#define SHORTUPMO 1 /* idate format: JUN 23 1988 */
- X#define LONGMO 2 /* idate format: June 23, 1988 */
- X#define LONGUPMO 3 /* idate format: JUNE 23, 1988 */
- X
- X#define WHITE(c) ((c) < 33)
- X#define BLACK(c) ((c) > 32)
- X#define TONEXWHITE(p) while (*(p) && (*(p)>32)) (p)++
- X#define TONEXBLACK(p) while (*(p) && (*(p)<33)) (p)++
- X
- X#define IFOURK 4096
- X#define ITWOK 2048
- X#define IONEK 1024
- X#define IHALFK 512
- X#define IQUARTK 256
- X
- X/* man page macro converts line-starting Q into right arrow */
- X#ifdef IMANFMT
- X#define Q
- X#endif
- SHAR_EOF
- $TOUCH -am 0601073090 i/ilib.h &&
- chmod 0644 i/ilib.h ||
- echo "restore of i/ilib.h failed"
- set `wc -c i/ilib.h`;Wc_c=$1
- if test "$Wc_c" != "4616"; then
- echo original size 4616, current size $Wc_c
- fi
- # ============= i/imapalnum.h ==============
- echo "x - extracting i/imapalnum.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/imapalnum.h &&
- X/* imapalnum.h */
- X/********************************************
- X* character map array used by ialntok.c
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- Xstatic char mapalnum[] = {
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- X 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- X 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- X};
- SHAR_EOF
- $TOUCH -am 0425094990 i/imapalnum.h &&
- chmod 0644 i/imapalnum.h ||
- echo "restore of i/imapalnum.h failed"
- set `wc -c i/imapalnum.h`;Wc_c=$1
- if test "$Wc_c" != "748"; then
- echo original size 748, current size $Wc_c
- fi
- # ============= i/iupcas.h ==============
- echo "x - extracting i/iupcas.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/iupcas.h &&
- X/* iupcas.h */
- X/********************************************
- X* character map array used by iupper.c
- X* Istvan Mohos, 1987 --- in the Public Domain
- X*********************************************/
- X
- Xstatic char upcas[] = {
- X 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- X 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- X 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- X 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- X 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- X 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- X 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- X 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
- X};
- SHAR_EOF
- $TOUCH -am 0425095090 i/iupcas.h &&
- chmod 0644 i/iupcas.h ||
- echo "restore of i/iupcas.h failed"
- set `wc -c i/iupcas.h`;Wc_c=$1
- if test "$Wc_c" != "741"; then
- echo original size 741, current size $Wc_c
- fi
- # ============= i/makefile ==============
- echo "x - extracting i/makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > i/makefile &&
- X#
- XCC=/bin/cc
- XCFLAGS=-O
- X
- X# SYSV: comment out 'ranlib ilib.a'
- X# CFLAGS=-O -DREALUNIX
- X# 6300+: -DPLUS6300
- X
- X#.SILENT:
- X
- XCOMPLEX=ialntok.o ictok.o ifonetic.o ilower.o iupper.o
- X
- XPLAIN=ianymatch.o ianytok.o iblank.o ibreakl.o \
- X icopy.o icount.o \
- X icue.o idamage.o idate.o idump.o iego.o ierror.o \
- X iexpect.o ifamily.o ifilter.o ifrombit.o \
- X igroup.o ihash.o ihasharg.o ihms.o \
- X ilast.o iline.o ilist.o ilistn.o illistn.o \
- X ilongest.o imatch.o imode.o imonth.o \
- X iinput.o inest.o inl.o inumstrcmp.o inumsearch.o \
- X inumsort.o inextl.o ioctal.o iopt.o iread.o irotate.o \
- X iround.o isearch.o isort.o istartl.o istripcom.o \
- X istripdq.o istripsq.o istripstr.o iswap.o ixswap.o \
- X itexrect.o itoday.o \
- X itok.o itran.o iuniq.o iuniqa.o iwhich.o iwrite.o \
- X iwritopn.o ixmatch.o ixsearch.o
- X
- Xilib.a: ${PLAIN} ${COMPLEX}
- X ar rul ilib.a ${PLAIN} ${COMPLEX}
- X ranlib ilib.a
- X
- X${PLAIN}: i.h
- Xialntok.o: i.h imapalnum.h ialntok.c
- Xictok.o: i.h icmapalnum.h ictok.c
- Xifonetic.o: i.h ifonetic.h ifonetic.c
- Xilower.o: i.h idowncas.h ilower.c
- Xiupper.o: i.h iupcas.h iupper.c
- SHAR_EOF
- $TOUCH -am 0605074590 i/makefile &&
- chmod 0644 i/makefile ||
- echo "restore of i/makefile failed"
- set `wc -c i/makefile`;Wc_c=$1
- if test "$Wc_c" != "1080"; then
- echo original size 1080, current size $Wc_c
- fi
- # ============= iex/add.c ==============
- if test ! -d 'iex'; then
- echo "x - creating directory iex"
- mkdir 'iex'
- fi
- echo "x - extracting iex/add.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/add.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -lm -o $BIN/add
- Xexit 0
- X#endif
- X
- X/* add leading number on each line of input, print total */
- X#include "ilib.h"
- Xdouble atof();
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char number[32];
- X char **opt = &argv[1];
- X char *buf;
- X char *list;
- X char **lp;
- X int bufsiz;
- X int lines;
- X int frac = 0;
- X double total = 0.;
- X
- XQ if (iopt (&opt) == 'r')
- X frac = atoi (*opt++);
- X if ((bufsiz = ifilter (*opt, &buf)) < 0)
- X puts (ierbuf), exit (1);
- X if ((lines = illistn (buf, buf + bufsiz, &list)) < 0)
- X puts (ierbuf), exit (1);
- X
- XQ for (lp = (char **)list; --lines >= 0; total += atof (*lp++));
- X sprintf (number, "%.8f", total);
- XQ iround (number, inull(number), frac);
- X puts (number);
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/add.c &&
- chmod 0755 iex/add.c ||
- echo "restore of iex/add.c failed"
- set `wc -c iex/add.c`;Wc_c=$1
- if test "$Wc_c" != "740"; then
- echo original size 740, current size $Wc_c
- fi
- # ============= iex/area.c ==============
- echo "x - extracting iex/area.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/area.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -DAREAF=\"$HOME/.area\" -DNOWF=\"$HOME/.now\" \
- X-I../i $0 ../i/ilib.a -o $BIN/area
- X(/bin/rm -f $BIN/now)
- X/bin/ln $BIN/area $BIN/now
- Xexit 0
- X#endif
- X
- X/* data base lookup */
- X#include "ilib.h"
- X#define NOW 244
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X static char cmdstr[IONEK]; /* concatenate disjoint argv strings */
- X static char space[] = {32};/* space, to separate argv strings */
- X char **word = &argv[1]; /* ptr to argv strings */
- X char *db; /* pointer to file name */
- X char *buffer; /* for storing data base */
- X char *list; /* pointer list to lines of data base */
- X int bytes; /* byte count of data base */
- X int lines; /* count of ptrs to lines of data base */
- X int context; /* which command to execute */
- X int indx; /* of matching record in data base */
- X int offset; /* from Greenwich Mean, in record */
- X int hours; /* in GMT time stamp */
- X
- X if ((context = ihasharg(argv[0],'/')) == NOW)
- X db = NOWF;
- X else
- X db = AREAF;
- X
- X /* unify individual command line arguments like: New York City */
- X for (; !NULCHARP (*word); word++)
- X strcat (cmdstr, *word), strcat (cmdstr, space);
- X cmdstr[strlen (cmdstr) -1] = 0; /* loose trailing space */
- X
- X /* read data base, create pointer list, sort pointers */
- X if ((bytes = iread (db, &buffer)) < 0)
- X fprintf (stderr, "%s\n", ierbuf), exit (1);
- XQ if ((lines = illistn (buffer, buffer + bytes, &list)) < 0)
- X fprintf (stderr, "%s\n", ierbuf), exit (1);
- XQ isort ((char **)list, lines);
- X
- X /* find the matching string in the data base */
- XQ if ((indx = isearch (cmdstr, (char **)list, lines)) < 0)
- X fprintf (stderr, "No record of %s in %s\n", cmdstr, db),
- X exit (1);
- X
- X if (context == NOW) {
- X offset = atoi (*((char **)list + indx) + strlen (cmdstr));
- X strcpy (cmdstr, ihms (0));
- X if ((hours = atoi (cmdstr)) + offset > 24)
- X sprintf (cmdstr, "%.2d", hours + offset - 24);
- X else if (hours + offset < 0)
- X sprintf (cmdstr, "%.2d", hours + offset + 24);
- X else
- X sprintf (cmdstr, "%.2d", hours + offset);
- X cmdstr[2] = ':';
- X puts (cmdstr);
- X }
- X else
- X puts (*((char **)list + indx));
- X
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/area.c &&
- chmod 0755 iex/area.c ||
- echo "restore of iex/area.c failed"
- set `wc -c iex/area.c`;Wc_c=$1
- if test "$Wc_c" != "2221"; then
- echo original size 2221, current size $Wc_c
- fi
- # ============= iex/banner.c ==============
- echo "x - extracting iex/banner.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/banner.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/banner
- Xexit 0
- X#endif
- X
- X/* output command line strings in large letters */
- X#include "ilib.h"
- X
- Xstatic char banchars[96][7] = {
- X{ 0, 0, 0, 0, 0, 0, 0}, { 28, 28, 28, 8, 0, 28, 8},
- X{119,119, 34, 68, 0, 0, 0}, { 20, 20,127, 20,127, 20, 20},
- X{ 62, 73, 72, 62, 9, 73, 62}, {113, 82,116, 8, 23, 37, 71},
- X{ 24, 36, 24, 56, 69, 66, 57}, { 28, 28, 8, 16, 0, 0, 0},
- X{ 12, 16, 32, 32, 32, 16, 12}, { 24, 4, 2, 2, 2, 4, 24},
- X{ 0, 34, 20,127, 20, 34, 0}, { 0, 8, 8, 62, 8, 8, 0},
- X{ 0, 0, 0, 28, 28, 8, 16}, { 0, 0, 0, 62, 0, 0, 0},
- X{ 0, 0, 0, 0, 28, 28, 28}, { 1, 2, 4, 8, 16, 32, 64},
- X{ 28, 34, 65, 65, 65, 34, 28}, { 8, 24, 40, 8, 8, 8, 62},
- X{ 62, 65, 1, 62, 64, 64,127}, { 62, 65, 1, 62, 1, 65, 62},
- X{ 64, 66, 66, 66,127, 2, 2}, {127, 64, 64,126, 1, 65, 62},
- X{ 62, 65, 64,126, 65, 65, 62}, {127, 66, 4, 8, 16, 16, 16},
- X{ 62, 65, 65, 62, 65, 65, 62}, { 62, 65, 65, 63, 1, 65, 62},
- X{ 8, 28, 8, 0, 8, 28, 8}, { 28, 28, 0, 28, 28, 8, 16},
- X{ 4, 8, 16, 32, 16, 8, 4}, { 0, 0, 62, 0, 62, 0, 0},
- X{ 16, 8, 4, 2, 4, 8, 16}, { 62, 65, 1, 14, 8, 0, 8},
- X{ 62, 65, 93, 93, 94, 64, 62}, { 8, 20, 34, 65,127, 65, 65},
- X{126, 65, 65,126, 65, 65,126}, { 62, 65, 64, 64, 64, 65, 62},
- X{126, 65, 65, 65, 65, 65,126}, {127, 64, 64,124, 64, 64,127},
- X{127, 64, 64,124, 64, 64, 64}, { 62, 65, 64, 79, 65, 65, 62},
- X{ 65, 65, 65,127, 65, 65, 65}, { 28, 8, 8, 8, 8, 8, 28},
- X{ 1, 1, 1, 1, 65, 65, 62}, { 66, 68, 72,112, 72, 68, 66},
- X{ 64, 64, 64, 64, 64, 64,127}, { 65, 99, 85, 73, 65, 65, 65},
- X{ 65, 97, 81, 73, 69, 67, 65}, { 62, 65, 65, 65, 65, 65, 62},
- X{126, 65, 65,126, 64, 64, 64}, { 62, 65, 65, 65, 69, 66, 61},
- X{126, 65, 65,126, 68, 66, 65}, { 62, 65, 64, 62, 1, 65, 62},
- X{127, 8, 8, 8, 8, 8, 8}, { 65, 65, 65, 65, 65, 65, 62},
- X{ 65, 65, 65, 65, 34, 20, 8}, { 65, 73, 73, 73, 73, 73, 54},
- X{ 65, 34, 20, 8, 20, 34, 65}, { 65, 34, 20, 8, 8, 8, 8},
- X{127, 2, 4, 8, 16, 32,127}, { 62, 32, 32, 32, 32, 32, 62},
- X{ 64, 32, 16, 8, 4, 2, 1}, { 62, 2, 2, 2, 2, 2, 62},
- X{ 8, 20, 34, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0,127},
- X{ 28, 28, 8, 4, 0, 0, 0}, { 0, 12, 18, 33, 63, 33, 33},
- X{ 0, 62, 33, 62, 33, 33, 62}, { 0, 30, 33, 32, 32, 33, 30},
- X{ 0, 62, 33, 33, 33, 33, 62}, { 0, 63, 32, 62, 32, 32, 63},
- X{ 0, 63, 32, 62, 32, 32, 32}, { 0, 30, 33, 32, 39, 33, 30},
- X{ 0, 33, 33, 63, 33, 33, 33}, { 0, 4, 4, 4, 4, 4, 4},
- X{ 0, 1, 1, 1, 1, 33, 30}, { 0, 33, 34, 60, 36, 34, 33},
- X{ 0, 32, 32, 32, 32, 32, 63}, { 0, 33, 51, 45, 33, 33, 33},
- X{ 0, 33, 49, 41, 37, 35, 33}, { 0, 30, 33, 33, 33, 33, 30},
- X{ 0, 62, 33, 33, 62, 32, 32}, { 0, 30, 33, 33, 37, 34, 29},
- X{ 0, 62, 33, 33, 62, 34, 33}, { 0, 30, 32, 30, 1, 33, 30},
- X{ 0, 31, 4, 4, 4, 4, 4}, { 0, 33, 33, 33, 33, 33, 30},
- X{ 0, 33, 33, 33, 33, 18, 12}, { 0, 33, 33, 33, 45, 51, 33},
- X{ 0, 33, 18, 12, 12, 18, 33}, { 0, 17, 10, 4, 4, 4, 4},
- X{ 0, 63, 2, 4, 8, 16, 63}, { 28, 32, 16,112, 16, 32, 28},
- X{ 8, 8, 8, 0, 8, 8, 8}, { 28, 2, 4, 7, 4, 2, 28},
- X{ 48, 73, 6, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0}
- X};
- X
- X#define SPACE 32
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char **word; /* pointer to argv list */
- X char line[ITWOK]; /* 2K buffer to hold single line of 'pixels' */
- X char *cp; /* point to individual chars of 'word' */
- X char *ip; /* pointer in 'line' buffer */
- X int ri; /* loop counter of pixel height (7) */
- X int wlen; /* string length of a given word */
- X
- X if (argc < 2)
- X fprintf(stderr,
- X"Usage: %s word ...\n%s", argv[0],
- X"\toutput each 'word' in large characters, on a line by itself\n"),
- X exit(1);
- X
- X for (word = argv+1; !NULCHARP (*word); word++) {
- X wlen = ifonetic (*word);
- X if (wlen > 256) /* horizontal pixel string would overrun line */
- X fprintf(stderr, "Word too long: %s (max. 256 bytes)\n",
- X *word), exit (1);
- X }
- X
- X for (word = argv+1; !NULCHARP (*word); word++) {
- X for (ri = 0; ri < 7; ri++) {
- X for (ip = line, cp = *word; *cp; cp++) {
- X if (*cp < SPACE)
- X continue;
- X sprintf (ip, "%s%c",
- XQ itobit (banchars[*cp-SPACE][ri],7,SPACE,'#'), SPACE);
- X icue (&ip);
- X }
- X *--ip = '\0'; /* erase last space */
- X puts (line);
- X }
- X puts (""); /* extra line at bottom of banner text */
- X }
- X
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/banner.c &&
- chmod 0755 iex/banner.c ||
- echo "restore of iex/banner.c failed"
- set `wc -c iex/banner.c`;Wc_c=$1
- if test "$Wc_c" != "4609"; then
- echo original size 4609, current size $Wc_c
- fi
- # ============= iex/behead.c ==============
- echo "x - extracting iex/behead.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/behead.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/behead
- Xexit 0
- X#endif
- X
- X/* in place, delete leading lines of files */
- X#include "ilib.h"
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char **file = argv;
- X char *buf; /* point to buffer malloc'd by iread() */
- X char *end; /* point to one byte past buffer */
- X char *ptr; /* working pointer */
- X int filesize; /* size of malloc'd buffer */
- X int string = 0; /* assume number option on command line */
- X int delcount; /* number of lines to delete */
- X int linesize; /* byte count of current line */
- X int cnt; /* working counter */
- X
- X if (argc < 3)
- X fprintf (stderr,
- X"Usage: %s number|string file ...\n\%s%s%s", *file,
- X"\tdelete first <number> lines of each file or\n",
- X"\tall leading lines until a line begins with <string>\n",
- X"\t(nothing is deleted if no line begins with <string>)\n\n"), exit(1);
- X
- X if ((delcount = atoi(*++file)) < 1) /* look for a string */
- X string = 1, ifonetic (*file);
- X
- X for (++file; !NULCHARP (*file); file++) {
- X if ((filesize = iread (*file, &buf)) < 1) {
- X fprintf (stderr, "%s %s\n", ierbuf, *file);
- X continue;
- X }
- X ptr = buf;
- X end = buf + filesize;
- X
- X if (string) {
- XQ if ((ptr = istartl (buf, end, argv[1])) == NULL) {
- X free (buf);
- X fprintf (stderr, "No line starts with '%s' in %s\n",
- X argv[1], *file);
- X continue;
- X }
- X while (ptr > buf && WHITE (*(ptr-1)) && *(ptr-1) != '\n')
- X --ptr; /* back up to beginning of line */
- X }
- X else {
- X for (DOUNCOUN (delcount, cnt);) {
- X if ((linesize = iline (ptr, end)) < 1)
- X break; /* not enough lines in file */
- X ptr += linesize;
- X }
- X }
- X
- X /* write remainder over original file */
- X if (iwrite (*file, ptr, end) < 0)
- X fprintf (stderr, "%s %s\n", ierbuf, *file);
- X free (buf);
- X }
- X exit (0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/behead.c &&
- chmod 0755 iex/behead.c ||
- echo "restore of iex/behead.c failed"
- set `wc -c iex/behead.c`;Wc_c=$1
- if test "$Wc_c" != "1862"; then
- echo original size 1862, current size $Wc_c
- fi
- # ============= iex/char.c ==============
- echo "x - extracting iex/char.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/char.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/char
- Xexit 0
- X#endif
- X
- X/* output space separated character lists */
- X#include "ilib.h"
- X#define SPACE 32
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char **range; /* defines range of ASCII values to output */
- X char *first, *last; /* limit pointers */
- X int begin = 1; /* flag to suppress first (leading) space */
- X int ri; /* scratch counter */
- X
- X if (argc < 2)
- X fprintf(stderr, "Usage: %s range [range ...]\n%s", argv[0],
- X"\toutput space-separated ASCII byte sequence delimited by 'range'\n"),
- X exit(1);
- X
- X /* in each range, output character list */
- X for (range = argv+1; !NULCHARP (*range); range++) {
- XQ if (ifonetic (*range) < 2)
- X first = last = *range;
- X else
- X first = *range, last = first+1;
- X
- X if (*first < *last) {
- X for (ri = *first; ri <= *last; ri++)
- X if (begin)
- X putchar (ri), begin = 0;
- X else
- X putchar (SPACE), putchar (ri);
- X }
- X else {
- X for (ri = *first; ri >= *last; ri--)
- X if (begin)
- X putchar (ri), begin = 0;
- X else
- X putchar (SPACE), putchar (ri);
- X }
- X }
- X puts (""); /* final newline */
- X
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/char.c &&
- chmod 0755 iex/char.c ||
- echo "restore of iex/char.c failed"
- set `wc -c iex/char.c`;Wc_c=$1
- if test "$Wc_c" != "1143"; then
- echo original size 1143, current size $Wc_c
- fi
- # ============= iex/cnum.c ==============
- echo "x - extracting iex/cnum.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/cnum.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/cnum
- Xexit 0
- X#endif
- X
- X/* custom line numbering via command line options */
- X#include "ilib.h"
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char line[IHALFK];
- X char build[IHALFK*4];
- X char format[32];
- X char *prepend;
- X char *append;
- X char *tail;
- XQ char **optval;
- XQ int optchar;
- X int linecount = 100;
- X int thisnum = 1;
- X int increment = 1;
- X int justify = 1;
- X int new = 0;
- X int aftertext = 0;
- X int zerofill = 0;
- X char base = 'd';
- X
- X if (argc == 1)
- X printusage (argv[0]), exit (1);
- X
- X /* command line args, subject file, or both */
- XQ optval = &(argv[1]);
- XQ while (optchar = iopt (&optval)) {
- XQ switch (optchar) {
- X case 'c':
- XQ linecount = abs (atoi (*optval));
- X new = 1;
- X break;
- X case 'f':
- X aftertext = 1;
- X break;
- X case 's':
- X thisnum = atoi (*optval);
- X break;
- X case 'i':
- X increment = atoi (*optval);
- X break;
- X case 'j':
- X justify = atoi (*optval);
- X break;
- X case '-':
- X zerofill = 1;
- X break;
- X case 'b':
- X base = **optval;
- X if (base != 'x' && base != 'X' && base != 'o')
- X base = 'd';
- X break;
- X case 'p':
- X prepend = *optval;
- X break;
- X case 'a':
- X append = *optval;
- X break;
- X case 't':
- X tail = *optval;
- X break;
- X default:
- X printusage (argv[0]);
- X exit (1);
- X }
- X }
- X
- XQ if (!new && !NULCHARP (*optval)) /* rename file to stdin */
- X if (freopen (*optval, "r", stdin) == NULL)
- X fprintf (stderr, "Open failed on %s\n", *optval), exit (1);
- X
- X if (justify > 1 && zerofill)
- X sprintf(format, "%cs%c.%d%c%cs", '%', '%', justify, base, '%');
- X else
- X sprintf(format, "%cs%c%d%c%cs", '%', '%', justify, base, '%');
- X
- X if (new)
- X for (strcat (format, "\n"); linecount--; thisnum += increment)
- X printf(format, prepend, thisnum, append);
- X else {
- X while (gets (line) != NULL) {
- X sprintf (build, format, prepend, thisnum, append);
- X if (aftertext)
- X printf ("%s%s%s\n",line, build, tail);
- X else
- X printf ("%s%s%s\n", build, line, tail);
- X thisnum += increment;
- X }
- X }
- X
- X exit (0);
- X}
- X
- Xprintusage (objname)
- Xchar *objname;
- X{
- X fprintf(stderr, "Usage: %s options [infile]\n%s", objname,
- X"Options: (flag and value may be combined into a single token)\n");
- X
- X fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s\n",
- X"\t- ......... print leading zeros in conjunction with -jN\n",
- X"\t-c N CREATE... N new lines instead of numbering input\n",
- X"\t-s N START.... the first line with N (may be negative)\n",
- X"\t-i N INCREMENT or decrement to next line number by N\n",
- X"\t-j N JUSTIFY.. right to N bytes (-N for left justify)\n",
- X"\t-f * FOLLOWING instead of leading the line (* is any char)\n",
- X"\t-b B BASE..... (number base) d=decimal, o=octal, x/X=hex\n",
- X"\t-p S PREPEND.. string S before sequence numbers\n",
- X"\t-a S APPEND... string S after sequence numbers\n",
- X"\t-t S TAIL..... string S past source lines\n");
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/cnum.c &&
- chmod 0755 iex/cnum.c ||
- echo "restore of iex/cnum.c failed"
- set `wc -c iex/cnum.c`;Wc_c=$1
- if test "$Wc_c" != "2846"; then
- echo original size 2846, current size $Wc_c
- fi
- # ============= iex/cweed.c ==============
- echo "x - extracting iex/cweed.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/cweed.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/cweed
- Xexit 0
- X#endif
- X
- X/* list tokens of input with comments removed */
- X#include "ilib.h"
- X#include "../i/icmapalnum.h"
- X
- X#define SPACE 32
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char token[IHALFK]; /* buffer for token */
- X char *inp; /* malloc pointer to buffer */
- X char *endp; /* end of input text */
- X char *anchor; /* save place in buffer */
- X char *wp; /* word pointer in line of input text */
- X int strsiz; /* size of input text */
- X int firsttok = 1; /* first token in line */
- X int toktype; /* TRUE if token begins with ALNUM */
- X
- X if (argc > 2)
- X fprintf (stderr, "Usage: %s [file]\n%s%s%s", argv[0],
- X "\tCopy C tokens of input to stdout (excluding comments),\n",
- X "\tseparate consecutive non-alphanumeric tokens by a space,\n",
- X "\tseparate consecutive alphanumeric tokens by a space.\n"),
- X exit(1);
- X
- X /* read file into buffer at inp */
- XQ if ((strsiz = ifilter (argv[1], &inp)) < 1)
- X fprintf (stderr, "%s at: %s\n", ierbuf, argv[1]), exit(1);
- X endp = inp + strsiz;
- X
- X /* remove comments and comment delimiters */
- XQ istripcom (inp, endp, "/*", "*/");
- X
- X /* side with the Lilliputian hordes who believe that '{' should
- X go on the test line; blow away intervening newlines
- X */
- X for (anchor = inp;;) {
- X while (anchor < endp && *anchor++ != '{');
- X if (anchor == endp) /* no further '{' in file */
- X break;
- X if ((wp = anchor - 3) < inp) /* back from byte past '{' */
- X continue;
- X while (WHITE (*wp))
- X *wp-- = SPACE; /* brute force */
- X }
- X
- X /* print tokens to stdout */
- XQ for (; strsiz = iline (inp, endp); firsttok = 1) {
- X anchor = inp;
- X inp += strsiz;
- XQ for (wp = anchor; (wp = ictok (wp, inp, token)) != NULL;)
- X if (firsttok) {
- X printf ("%s", token), firsttok = 0;
- XQ toktype = cmapalnum[*token];
- X }
- X else {
- X if (toktype == cmapalnum[*token])
- X printf (" %s", token);
- X else
- X printf ("%s", token);
- X toktype = cmapalnum[*token];
- X }
- X if (!firsttok)
- X puts ("");
- X }
- X
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/cweed.c &&
- chmod 0755 iex/cweed.c ||
- echo "restore of iex/cweed.c failed"
- set `wc -c iex/cweed.c`;Wc_c=$1
- if test "$Wc_c" != "2114"; then
- echo original size 2114, current size $Wc_c
- fi
- # ============= iex/defilter.c ==============
- echo "x - extracting iex/defilter.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/defilter.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/defilter
- Xexit 0
- X#endif
- X
- X/* replace input file text of filter commands with their output */
- X#include "ilib.h"
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char *mktemp(), *realloc();
- X static char delims[3] = {32, 9, 0}; /* SPACE, TAB */
- X char outfname[32]; /* collect output in /tmp file */
- X char line[IFOURK]; /* buffer for line of input */
- X char **file; /* pointer to file list in command line */
- X char **argp; /* pointer to new arg vector */
- X char *newargv; /* dynamically allocated new arg vector */
- X int newargc; /* new arg vector count */
- X int childstat; /* termination status of child process */
- X
- X if (argc < 3)
- X fprintf(stderr,
- X"\nUsage: %s 'command' file ...\n%s%s%s%s%s\n", argv[0],
- X"\tsupply input to 'command' from each 'file' in turn;\n",
- X"\treplace text of input 'file' with the output of 'command'.\n",
- X"\t'command' should be an executable object or the name of an\n",
- X"\texecutable script, with or without option flags and options,\n",
- X"\twithout pipes or redirection, quoted to form a single token.\n"),
- X exit(1);
- X
- X sprintf (outfname, "/tmp/%s", mktemp ("defil.XXXXXX"));
- X
- X /* create a NULL terminated, new argv list from 'command' */
- XQ if ((newargc = ilist (argv[1],inull(argv[1]),delims, &newargv)) < 1)
- X fprintf (stderr, "'command' argument error\n"), exit (1);
- X
- X /* ilist allocated an unreported NULL pointer at the end of
- X newargv, but we still need another pointer for the 'file' arg.
- X */
- X if ((newargv = realloc
- X (newargv, (unsigned int)(newargc+2)*sizeof(char*))) == NULL)
- X fprintf (stderr, "%s: realloc error\n", argv[0]), exit (1);
- X *((char **)newargv + newargc + 1) = NULL; /* new sentinel NULL */
- X
- X for (argp = (char**)newargv; !NULCHARP(*argp); argp++)
- XQ ifonetic (*argp);
- X /* argp now points to the next-to-last cell of newargv */
- X
- X for (file = argv + 2; !NULCHARP (*file); file++) {
- X /* complete the new command with the name of the next file */
- XQ *argp = *file;
- X
- X /* rename input file to stdin, create output file as stdout */
- X if (freopen (*file, "r", stdin) == NULL)
- X fprintf (stderr, "Open failed on %s\n", *file), exit (1);
- X if (freopen (outfname, "w", stdout) == NULL)
- X fprintf (stderr, "Can't write to %s\n", outfname), exit (1);
- X
- X switch (fork()) {
- X case -1: /* fork failed */
- X fprintf (stderr, "Can't create new process\n"), exit (1);
- X case 0: /* child process */
- XQ execvp (*((char **)newargv), (char **)newargv);
- X /* exec failed; use ierror to get system error message */
- X ierror ("");
- X fprintf(stderr, "%sduring execvp of %s ... %s\n", ierbuf,
- X *((char **)newargv), *argp), exit (1);
- X default: /* parent process */
- X wait(&childstat); /* for child to die */
- X if (childstat == 0) { /* terminated normally */
- X sprintf (line, "/bin/mv %s %s", outfname, *file);
- X if (system (line))
- X fprintf (stderr,
- X "Can't mv %s to %s\n",outfname, *file), exit (1);
- X }
- X else /* leave source intact if command error occurred */
- X unlink (outfname);
- X break;
- X }
- X }
- X
- X exit (0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/defilter.c &&
- chmod 0755 iex/defilter.c ||
- echo "restore of iex/defilter.c failed"
- set `wc -c iex/defilter.c`;Wc_c=$1
- if test "$Wc_c" != "3151"; then
- echo original size 3151, current size $Wc_c
- fi
- # ============= iex/distrib.c ==============
- echo "x - extracting iex/distrib.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/distrib.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/distrib
- Xexit 0
- X#endif
- X
- X/* count strings in lines */
- X#include "ilib.h"
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char **pat; /* 'pattern' --- pointer to argv list */
- X char inline[IONEK]; /* 1K buffer to hold line of input */
- X char *rp; /* pointer; let optimizer make it 'register' */
- X int item; /* counter of patterns in argv list */
- X int plen; /* string length of a given pattern */
- X
- X if (argc < 2)
- X fprintf(stderr, "Usage: %s pattern1 [pattern2 ...]\n%s", argv[0],
- X "(count occurrence of each pattern in lines of input)\n"), exit(1);
- X
- X for (pat = argv+1; !NULCHARP (*pat); pat++)
- X ifonetic (*pat);
- X /* initialize icount(); non-zero return indicates malloc fail */
- XQ if (icount (argc-1))
- X fprintf(stderr, "%s\n", ierbuf), exit(1);
- X
- X /* in each line read, count occurrence of patterns */
- X while (fgets (inline, IONEK, stdin) != NULL) {
- X
- X /* replay line for each pattern, avoid strncmp if possible */
- X for (item = 0, pat = argv+1; !NULCHARP(*pat); item++, pat++) {
- X if ((plen = strlen (*pat)) == 1) {
- X for (rp = inline; *rp; rp++)
- X if (*rp == **pat)
- XQ icount (item);
- X }
- X else {
- X for (rp = inline; *rp; rp++)
- X if (*rp == **pat)
- X if (strncmp (rp, *pat, plen) == 0)
- XQ icount (item);
- X }
- X }
- X }
- X
- X /* dummy recall for each pattern, to capture the returned count */
- X for (item = 0, pat = argv+1; !NULCHARP(*pat); item++, pat++)
- XQ printf ("%s: %d\n", *pat, icount (item));
- X
- X /* reset call necessary only if icount() was to be used again:
- XQ icount (-1);
- X */
- X
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/distrib.c &&
- chmod 0755 iex/distrib.c ||
- echo "restore of iex/distrib.c failed"
- set `wc -c iex/distrib.c`;Wc_c=$1
- if test "$Wc_c" != "1667"; then
- echo original size 1667, current size $Wc_c
- fi
- # ============= iex/ego.c ==============
- echo "x - extracting iex/ego.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/ego.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/ego
- X(/bin/rm -f $BIN/ext $BIN/path $BIN/egoext)
- X/bin/ln $BIN/ego $BIN/ext
- X/bin/ln $BIN/ego $BIN/path
- X/bin/ln $BIN/ego $BIN/egoext
- Xexit 0
- X#endif
- X
- X/* Get path/, extension, basename, basename.extension from file names */
- X#include "ilib.h"
- X#define EGO 219
- X#define EXT 241
- X#define PATH 301
- X#define EGOEXT 460
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char buf[IONEK];
- X char **file = argv;
- X int cmd, pathlen, baselen;
- X
- X if (argc < 2)
- X fprintf (stderr, "Usage: ego|ext|path|egoext file ...\n%s%s%s%s",
- X "\tego --- print name without path/ and .ext to stdout\n",
- X "\text --- print ext without path/name.\n",
- X "\tpath --- print path/ component only, without name.ext\n",
- X "\tegoext --- print name.ext without leading path\n\n", *file),
- X exit (0);
- XQ cmd = ihasharg (*file++, '/');
- X for (; !NULCHARP (*file); file++) {
- X switch (cmd) {
- X default:
- X case EGO:
- XQ iego (*file, buf, '/', '.');
- X break;
- X case EXT:
- XQ pathlen = iego (*file, buf, '/', 0);
- XQ baselen = iego (*file, buf, '/', '.');
- X *buf = 0;
- X if (*(*file+pathlen+baselen) == '.')
- X strcpy (buf, *file+pathlen+baselen+1);
- X break;
- X case PATH:
- XQ iego (*file, buf, '/', 0);
- X break;
- X case EGOEXT:
- XQ iego (*file, buf, '/', '/');
- X break;
- X }
- X puts(buf);
- X }
- X exit(0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/ego.c &&
- chmod 0755 iex/ego.c ||
- echo "restore of iex/ego.c failed"
- set `wc -c iex/ego.c`;Wc_c=$1
- if test "$Wc_c" != "1412"; then
- echo original size 1412, current size $Wc_c
- fi
- # ============= iex/excise.c ==============
- echo "x - extracting iex/excise.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/excise.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/excise
- Xexit 0
- X#endif
- X
- X/* delete line(s) of files that contain a specified string */
- X#include "ilib.h"
- X#define FIRSTONLY 0
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char *mktemp();
- X char outfname[32]; /* collect output in /tmp file */
- X char line[IFOURK]; /* buffer for line of input */
- X char **opt = &argv[1]; /* command line arguments */
- X char **file;
- X register char *str;
- X register char *byt; /* parser in input buffer */
- X register char *end; /* pointing to end of input buffer */
- X int optval; /* FIRSTONLY unless '-' option was given */
- X int len; /* lenght of 'string' */
- X int lcount; /* lenght of 'string' */
- X
- X if (argc < 3)
- X fprintf(stderr, "\nUsage: %s [-] string files\n%s%s\n", argv[0],
- X"\tdelete from each <file> the first line that contains <string>,\n",
- X"\tor delete every such line from each <file> with the - option\n"),
- X exit(1);
- X
- X if ((optval = iopt (&opt)) == '-')
- X str = argv[2], file = &argv[3];
- X else
- X str = argv[1], file = &argv[2], optval = FIRSTONLY;
- X if ((len = ifonetic (str)) < 1)
- X fprintf (stderr, "Null 'string' in command line\n"), exit (1);
- X sprintf (outfname, "/tmp/%s", mktemp ("excise.XXXXXX"));
- X
- X for (; !NULCHARP (*file); file++) {
- X /* rename input file to stdin, create output file as stdout */
- XQ if (freopen (*file, "r", stdin) == NULL)
- X fprintf (stderr, "Open failed on %s\n", *file), exit (1);
- XQ if (freopen (outfname, "w", stdout) == NULL)
- X fprintf (stderr, "Can't write to %s\n", outfname), exit (1);
- X
- X /* withhold input line from output if it contains 'string' */
- X for (lcount = 1; gets (line) != NULL; lcount++) {
- XQ end = inl (line); /* set 'end' to terminating NUL byte */
- X /* set 'end' to last possible point of match in line */
- X if ((end -= len-1) < line) { /* too small for match */
- X puts (line);
- X continue;
- X }
- X for (byt = line; byt < end; byt++) {
- X /* strcmp only if first bytes match */
- X if (*byt == *str && strncmp (byt, str, len) == 0) {
- X fprintf (stderr, "%s: line %d\n", *file, lcount);
- X break;
- X }
- X }
- X if (byt == end) /* no string match */
- X puts (line);
- X else if (optval == FIRSTONLY) /* string did match */
- X while (gets (line) != NULL)
- X puts (line);
- X }
- X
- XQ fflush (stdout);
- X sprintf (line, "/bin/mv %s %s", outfname, *file);
- X if (system (line))
- X fprintf (stderr, "Can't move %s to %s\n", outfname, *file),
- X exit (1);
- X }
- X exit (0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/excise.c &&
- chmod 0755 iex/excise.c ||
- echo "restore of iex/excise.c failed"
- set `wc -c iex/excise.c`;Wc_c=$1
- if test "$Wc_c" != "2495"; then
- echo original size 2495, current size $Wc_c
- fi
- # ============= iex/fcat.c ==============
- echo "x - extracting iex/fcat.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > iex/fcat.c &&
- X#ifdef NEVER
- X/bin/cc -O -DIMANFMT -I../i $0 ../i/ilib.a -o $BIN/fcat
- Xexit 0
- X#endif
- X
- X/* print fields from lines of input, concatenated by spaces */
- X#include "ilib.h"
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X static char defdel[] = {32,9,0}; /* SPACE, TAB, NUL */
- X char *dp = defdel; /* to default delimiters */
- X char line[IONEK]; /* to hold single input line */
- X char *mp = argv[1]; /* fieldmask of command line */
- X char **argp;
- X char *toklist[16], **tl; /* pointers to tokens in line */
- X int masksiz; /* byte width of fieldmask */
- X int *masklist, *ml; /* int list of field ids to output */
- X int ri; /* loop index (of last token in line) */
- X int fwd = 1; /* field numbering starts at left */
- X int delsiz = 3;
- X int toksiz;
- X int firsttok; /* do not output preceding SPACE */
- X int optchar;
- X
- X if (argc < 2)
- X fprintf (stderr,
- X"Usage: %s fieldmask [-] [-d delimiters] [file]\n\%s%s%s%s\n", argv[0],
- X"\t<fieldmask> is from the set '123456789abcdefg', each byte causes\n",
- X"\tthe output of the 1st,2nd,...16th field of the lines of input.\n",
- X"\t'Solo minus' option reverses field numbering (last field = 1). \n",
- X"\tField delimiters are SPACE and TAB, or each byte of <delimiters>\n"),
- X exit(0);
- X
- X masksiz = strlen (mp);
- X if ((masklist = (int *)malloc ((unsigned int)(masksiz + 1) *
- X sizeof (int))) == NULL) /* one extra for the sentinel */
- X fprintf (stderr, "No memory for mask\n"), exit (1);
- X *(masklist + masksiz) = 16; /* sentinel value */
- X
- X /* convert mask bytes to indices 0 through 15, in masklist */
- X for (ml = masklist; *mp; mp++)
- X if (*mp >= '1' && *mp <= '9')
- X *ml++ = *mp - '1';
- X else if (*mp >= 'a' && *mp <= 'g')
- X *ml++ = *mp - 'X'; /* ASCII X = 88, ASCII a = 97 */
- X else
- X fprintf (stderr, "Mask character set: 123456789abcdefg\n"),
- X exit (1);
- X
- X for (argp = argv + 2; optchar = iopt (&argp); argp++) {
- X if (optchar == 'd') {
- X dp = *argp;
- X delsiz = ifonetic (dp);
- X delsiz++; /* include terminating NUL */
- X }
- X else if (optchar == '-')
- X fwd = 0;
- X else
- X fprintf (stderr, "Option error: -%c%s\n", optchar, *argp),
- X exit (1);
- X }
- X
- X /* rename file on command line (if any) to stdin */
- X if (!NULCHARP(*argp) && freopen (*argp, "r", stdin) == NULL)
- X fprintf (stderr, "Can't read %s\n", *argp), exit (1);
- X
- X while (gets (line) != NULL) {
- X /* Set pointers to the first (last) 16 tokens in 'line', max.;
- X after recognizing a token, terminate it with NUL.
- X Because the internal itok() text marker will find that
- X its dereferenced byte was changed from a normal ASCII
- X SPACE, TAB, etc. to NUL; the NUL character also gets
- X included in the delimiter set, letting the internal
- X pointer skip over it during the search for the next token.
- X */
- XQ itok (fwd?INITOKF:INITOKR, line, (char *)NULL);
- X for (ri = 0, tl = toklist;
- XQ (toksiz = itok(fwd?ITOKF:ITOKR, dp, dp+delsiz, &(*tl)))
- X && ri < 16; tl++, ri++)
- X *(*tl + toksiz) = '\0'; /* NUL terminate token */
- X
- X /* output fields indexed by successive elements of mask list */
- X for (firsttok = 1, ml = masklist; *ml < 16; ml++)
- X if (*ml < ri)
- X if (firsttok)
- X fputs (*(toklist + *ml), stdout), firsttok = 0;
- X else /* use leading space */
- X fprintf (stdout, " %s", *(toklist + *ml));
- X puts (""); /* print newline even if no tokens */
- X }
- X
- X exit (0);
- X}
- SHAR_EOF
- $TOUCH -am 0605075390 iex/fcat.c &&
- chmod 0755 iex/fcat.c ||
- echo "restore of iex/fcat.c failed"
- set `wc -c iex/fcat.c`;Wc_c=$1
- if test "$Wc_c" != "3349"; then
- echo original size 3349, current size $Wc_c
- fi
- echo "End of part 3, continue with part 4"
- exit 0
- --
- Istvan Mohos
- ...uunet!pyrdc!pyrnj!hhb!istvan
- RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
- ======================================================================
-