mkid 01/11 (identifier cross reference tool)

Tom Horsley tom at ssd.csd.harris.com
Thu Dec 13 01:38:53 AEST 1990


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 11)."
# Contents:  MANIFEST TODO basename.c bitcount.c bitops.c bitops.h
#   bool.h bsearch.c bzero.c document.c extern.h fid.1 gets0.c
#   getsFF.c gid.el idx.c init.c numtst.c patchlevel.h radix.h
#   string.h tty.c uerror.c wmatch.c
# Wrapped by tom at hcx2 on Wed Dec 12 07:21:54 1990
#
# This is the mkid package originally posted to the net around September of
# 1987 by Greg McGary (who then vanished from the net). Since then I have been
# extensively hacking it, and so have others. In an effort to have all of us
# benefit from the modifications and improvements we all have made, I have
# (probably foolishly :-) volunteered to "take over" mkid.
# 
# To get the ball rolling, I am posting this version to alt.sources, and I
# expect people to send me their patches. I will merge them all and eventually
# post an "official" version to comp.sources.unix.
# 
# I know there are probably portability problems with this version of the
# source, I have some stuff in here that references functions you only have if
# your system supports symbolic links, etc, so it will need to have some
# config parameters and ifdef code added for sure.
# 
# Anyway, keep those patches rolling in...
# 
# ======================================================================
# domain: tahorsley at csd.harris.com       USMail: Tom Horsley
#   uucp: ...!uunet!hcx1!tahorsley               511 Kingbird Circle
#                                                Delray Beach, FL  33444
# +==== Censorship is the only form of Obscenity ======================+
# |     (Wait, I forgot government tobacco subsidies...)               |
# +====================================================================+
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1695 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   5	
X Status                     2	
X TODO                       1	
X TUTORIAL                   8	
X basename.c                 1	
X bitcount.c                 1	
X bitops.c                   1	
X bitops.h                   1	
X bitsvec.c                  2	
X bool.h                     1	
X bsearch.c                  1	
X bzero.c                    1	
X cannoname.c                3	
X document.c                 1	
X extern.h                   1	
X fid.1                      1	
X fid.c                      2	
X gets0.c                    1	
X getsFF.c                   1	
X getscan.c                  6	
X gid.el                     1	
X hash.c                     2	
X id.h                       2	
X idx.c                      1	
X iid.1                      4	
X iid.help                   3	
X iid.y                      7	
X iiddef.h                   5	
X iidfun.c                   9	
X init.c                     1	
X kshgetwd.c                 2	
X lid.1                      4	
X lid.c                     11	
X mkid.1                     4	
X mkid.c                    10	
X numtst.c                   1	
X opensrc.c                  2	
X patchlevel.h               1	
X paths.c                    3	
X radix.h                    1	
X scan-asm.c                 5	
X scan-c.c                   6	
X scan-text.c                3	
X stoi.c                     2	
X string.h                   1	
X symfunc.el                 3	
X tty.c                      1	
X uerror.c                   1	
X unsymlink.c                2	
X wmatch.c                   1	
END_OF_FILE
if test 1695 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'TODO' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'TODO'\"
else
echo shar: Extracting \"'TODO'\" \(546 characters\)
sed "s/^X//" >'TODO' <<'END_OF_FILE'
XEnhancements:
X~~~~~~~~~~~~~
Xmkid:
X	handle attributes: IDN_NOISE
X	add makefile scanner
X
Xgetid-c:
X	add stuff to recognize float & double constants properly.
X
X[lgea]id:
X	recursively search sub-dirs for ID databases and optionally
X		merge everything into one BIG list
Xlid:
X	print attribute flags, add cmd-line args to query by flags
X	break out searching junk into lib-funcs that are useful to editors
X
XNew Applications:
X~~~~~~~~~~~~~~~~~
Xignid:
X	frob the IDN_NOISE attribute of an id in an existing ID database.
X		takes ids on command line or stdin.
END_OF_FILE
if test 546 -ne `wc -c <'TODO'`; then
    echo shar: \"'TODO'\" unpacked with wrong size!
fi
# end of 'TODO'
fi
if test -f 'basename.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'basename.c'\"
else
echo shar: Extracting \"'basename.c'\" \(433 characters\)
sed "s/^X//" >'basename.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)basename.c	1.1 86/10/09";
X
X#include	<string.h>
X
Xchar *basename();
Xchar *dirname();
X
Xchar *
Xbasename(path)
X	char		*path;
X{
X	char		*base;
X
X	if ((base = strrchr(path, '/')) == 0)
X		return path;
X	else
X		return ++base;
X}
X
Xchar *
Xdirname(path)
X	char		*path;
X{
X	char		*base;
X
X	if ((base = strrchr(path, '/')) == 0)
X		return ".";
X	else
X		return strnsav(path, base - path);
X}
END_OF_FILE
if test 433 -ne `wc -c <'basename.c'`; then
    echo shar: \"'basename.c'\" unpacked with wrong size!
fi
# end of 'basename.c'
fi
if test -f 'bitcount.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitcount.c'\"
else
echo shar: Extracting \"'bitcount.c'\" \(643 characters\)
sed "s/^X//" >'bitcount.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)bitcount.c	1.1 86/10/09";
X
Xint bitCount();
Xint bitsCount();
X
X/*
X	Count the number of 1 bits in the given integer.
X*/
Xstatic char bitcnt[] = {
X/*	0 1 2 3 4 5 6 7	8 9 a b c d e f	*/
X	0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4
X};
Xint
XbitCount(mask)
X	register unsigned	mask;
X{
X	register int	nybbles = 8;
X	register int	cnt = 0;
X
X	while (mask && nybbles--) {
X		cnt += bitcnt[mask&0xf];
X		mask >>= 4;
X	}
X	return cnt;
X}
X
Xint
XbitsCount(bitv, n)
X	register char	*bitv;
X	register int	n;
X{
X	register int	count = 0;
X
X	while (n--) {
X		count += bitcnt[*bitv&0xf] + bitcnt[(*bitv>>4)&0xf];
X		bitv++;
X	}
X}
END_OF_FILE
if test 643 -ne `wc -c <'bitcount.c'`; then
    echo shar: \"'bitcount.c'\" unpacked with wrong size!
fi
# end of 'bitcount.c'
fi
if test -f 'bitops.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitops.c'\"
else
echo shar: Extracting \"'bitops.c'\" \(992 characters\)
sed "s/^X//" >'bitops.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)bitops.c	1.1 86/10/09";
X
X#include	<bitops.h>
X
Xchar *bitsset();
Xchar *bitsclr();
Xchar *bitsand();
Xchar *bitsxor();
Xint bitstst();
Xint bitsany();
X
Xchar *
Xbitsset(s1, s2, n)
X	register char	*s1;
X	register char	*s2;
X	register int	n;
X{
X	while (n--)
X		*s1++ |= *s2++;
X
X	return s1;
X}
X
Xchar *
Xbitsclr(s1, s2, n)
X	register char	*s1;
X	register char	*s2;
X	register int	n;
X{
X	while (n--)
X		*s1++ &= ~*s2++;
X
X	return s1;
X}
X
Xchar *
Xbitsand(s1, s2, n)
X	register char	*s1;
X	register char	*s2;
X	register int	n;
X{
X	while (n--)
X		*s1++ &= *s2++;
X
X	return s1;
X}
X
Xchar *
Xbitsxor(s1, s2, n)
X	register char	*s1;
X	register char	*s2;
X	register int	n;
X{
X	while (n--)
X		*s1++ ^= *s2++;
X
X	return s1;
X}
X
Xint
Xbitstst(s1, s2, n)
X	register char	*s1;
X	register char	*s2;
X	register int	n;
X{
X	while (n--)
X		if (*s1++ & *s2++)
X			return 1;
X
X	return 0;
X}
X
Xint
Xbitsany(s, n)
X	register char	*s;
X	register int	n;
X{
X	while (n--)
X		if (*s++)
X			return 1;
X
X	return 0;
X}
END_OF_FILE
if test 992 -ne `wc -c <'bitops.c'`; then
    echo shar: \"'bitops.c'\" unpacked with wrong size!
fi
# end of 'bitops.c'
fi
if test -f 'bitops.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitops.h'\"
else
echo shar: Extracting \"'bitops.h'\" \(537 characters\)
sed "s/^X//" >'bitops.h' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
X/* @(#)bitops.h	1.1 86/10/09 */
X
X#define	BITTST(ba, bn)	((ba)[(bn) >> 3] &  (1 << ((bn) & 0x07)))
X#define	BITSET(ba, bn)	((ba)[(bn) >> 3] |= (1 << ((bn) & 0x07)))
X#define	BITCLR(ba, bn)	((ba)[(bn) >> 3] &=~(1 << ((bn) & 0x07)))
X#define	BITAND(ba, bn)	((ba)[(bn) >> 3] &= (1 << ((bn) & 0x07)))
X#define	BITXOR(ba, bn)	((ba)[(bn) >> 3] ^= (1 << ((bn) & 0x07)))
X
Xextern char *bitsand();
Xextern char *bitsclr();
Xextern char *bitsset();
Xextern char *bitsxor();
Xextern int bitsany();
Xextern int bitstst();
END_OF_FILE
if test 537 -ne `wc -c <'bitops.h'`; then
    echo shar: \"'bitops.h'\" unpacked with wrong size!
fi
# end of 'bitops.h'
fi
if test -f 'bool.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bool.h'\"
else
echo shar: Extracting \"'bool.h'\" \(128 characters\)
sed "s/^X//" >'bool.h' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
X/* @(#)bool.h	1.1 86/10/09 */
X
Xtypedef	int	bool;
X#define	TRUE	(0==0)
X#define	FALSE	(0!=0)
END_OF_FILE
if test 128 -ne `wc -c <'bool.h'`; then
    echo shar: \"'bool.h'\" unpacked with wrong size!
fi
# end of 'bool.h'
fi
if test -f 'bsearch.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bsearch.c'\"
else
echo shar: Extracting \"'bsearch.c'\" \(692 characters\)
sed "s/^X//" >'bsearch.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)bsearch.c	1.1 86/10/09";
X
Xchar *bsearch();
X
X/*
X	Binary search -- from Knuth (6.2.1) Algorithm B
X*/
Xchar *
Xbsearch(key, base, nel, width, compar)
X	char		*key;
X	register char	*base;
X	unsigned int	nel;
X	int		width;
X	int		(*compar)();
X{
X	register char	*last;
X	register char	*position;
X	register int	result;
X	int		width2;
X
X	width2 = width * 2;
X	last = &base[width * (nel - 1)];
X
X	while (last >= base) {
X		position = &base[width * ((last - base)/width2)];
X		
X		if ((result = (*compar)(key, position)) == 0)
X			return position;
X		if (result < 0)
X			last = position - width;
X		else
X			base = position + width;
X	}
X	return (char *)0;
X}
END_OF_FILE
if test 692 -ne `wc -c <'bsearch.c'`; then
    echo shar: \"'bsearch.c'\" unpacked with wrong size!
fi
# end of 'bsearch.c'
fi
if test -f 'bzero.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bzero.c'\"
else
echo shar: Extracting \"'bzero.c'\" \(199 characters\)
sed "s/^X//" >'bzero.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)bzero.c	1.1 86/10/09";
X
Xvoid bzero();
X
Xvoid
Xbzero(s, n)
X	register char	*s;
X	register int	n;
X{
X	if (n) do
X		*s++ = 0;
X	while (--n);
X}
END_OF_FILE
if test 199 -ne `wc -c <'bzero.c'`; then
    echo shar: \"'bzero.c'\" unpacked with wrong size!
fi
# end of 'bzero.c'
fi
if test -f 'document.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'document.c'\"
else
echo shar: Extracting \"'document.c'\" \(188 characters\)
sed "s/^X//" >'document.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)document.c	1.1 86/10/09";
X
Xvoid document();
X
Xvoid
Xdocument(doc)
X	char		**doc;
X{
X	while (*doc)
X		printf("%s\n", *doc++);
X}
END_OF_FILE
if test 188 -ne `wc -c <'document.c'`; then
    echo shar: \"'document.c'\" unpacked with wrong size!
fi
# end of 'document.c'
fi
if test -f 'extern.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'extern.h'\"
else
echo shar: Extracting \"'extern.h'\" \(1386 characters\)
sed "s/^X//" >'extern.h' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
X/* @(#)extern.h	1.1 86/10/09 */
X
X/* miscellaneous external declarations */
X
Xextern FILE *initID();
Xextern char *getFilter();
Xextern FILE *openSrcFILE();
Xextern void closeSrcFILE();
Xextern char *(*getScanner())();
Xextern char *basename();
Xextern char *bsearch();
Xextern char *calloc();
Xextern char *coRCS();
Xextern char *dirname();
Xextern char *getAsmId();
Xextern char *getCId();
Xextern char *getLanguage();
Xextern char *getTextId();
Xextern char *getSCCS();
Xextern char *getVhilId();
Xextern char *getenv();
Xextern char *hashSearch();
Xextern char *intToStr();
Xextern char *malloc();
Xextern char *regcmp();
Xextern char *regex();
Xextern char *rootName();
Xextern char *spanPath();
Xextern char *relPath();
Xextern char *LookUp();
Xextern char *suffName();
Xextern char *uerror();
Xextern int bitCount();
Xextern int bitsCount();
Xextern int bitsToVec();
Xextern int canCrunch();
Xextern int dtoi();
Xextern int fgets0();
Xextern int getsFF();
Xextern int h1str();
Xextern int h2str();
Xextern int strToInt();
Xextern int otoi();
Xextern int radix();
Xextern int stoi();
Xextern int vecToBits();
Xextern int wordMatch();
Xextern int xtoi();
Xextern void bzero();
Xextern void document();
Xextern void filerr();
Xextern void setAsmArgs();
Xextern void setCArgs();
Xextern void setScanArgs();
Xextern void setTextArgs();
Xextern void skipFF();
X
Xextern char *MyName;
Xextern int errno;
END_OF_FILE
if test 1386 -ne `wc -c <'extern.h'`; then
    echo shar: \"'extern.h'\" unpacked with wrong size!
fi
# end of 'extern.h'
fi
if test -f 'fid.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fid.1'\"
else
echo shar: Extracting \"'fid.1'\" \(576 characters\)
sed "s/^X//" >'fid.1' <<'END_OF_FILE'
X.TH FID 1
X.SH NAME
Xfid \- query id database for specific files
X.SH SYNOPSIS
X.B fid
X.RB [ \-f \^file]
Xfile1 [ file2 ]
X.SH DESCRIPTION
X.I Fid
Xis a query tool for the id database. If you specify a single file
Xname as an argument, it prints a list of all the identifiers that
Xoccur in that file.
X.PP
XWhen you give it two file names it takes the intersection. It prints
Xonly the list of identifiers that occur in both files.
X.PP
XThe following options are recognized:
X.TP 10
X.BR \-f file\^
XUse
X.I file\^
Xas the database instead of the default
X.BR ID .
X.SH SEE ALSO
Xmkid(1),
Xlid(1).
END_OF_FILE
if test 576 -ne `wc -c <'fid.1'`; then
    echo shar: \"'fid.1'\" unpacked with wrong size!
fi
# end of 'fid.1'
fi
if test -f 'gets0.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gets0.c'\"
else
echo shar: Extracting \"'gets0.c'\" \(575 characters\)
sed "s/^X//" >'gets0.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)gets0.c	1.1 86/10/09";
X
X#include	<stdio.h>
X
Xint fgets0();
X
X/*
X	This is like fgets(3s), except that lines are
X	delimited by NULs rather than newlines.  Also,
X	we return the number of characters gotten rather
X	than the address of buf0.
X*/
Xint
Xfgets0(buf0, size, inFILE)
X	char		*buf0;
X	int		size;
X	register FILE	*inFILE;
X{
X	register char	*buf;
X	register int	c;
X	register char	*end;
X
X	buf = buf0;
X	end = &buf[size];
X	while ((c = getc(inFILE)) > 0 && buf < end)
X		*buf++ = c;
X	*buf = '\0';
X	return (buf - buf0);
X}
END_OF_FILE
if test 575 -ne `wc -c <'gets0.c'`; then
    echo shar: \"'gets0.c'\" unpacked with wrong size!
fi
# end of 'gets0.c'
fi
if test -f 'getsFF.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getsFF.c'\"
else
echo shar: Extracting \"'getsFF.c'\" \(418 characters\)
sed "s/^X//" >'getsFF.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)getsFF.c	1.1 86/10/09";
X
X#include	<stdio.h>
X
Xint getsFF();
Xvoid skipFF();
X
Xint
XgetsFF(buf0, inFILE)
X	char		*buf0;
X	register FILE	*inFILE;
X{
X	register char	*buf = buf0;
X
X	while (((*buf++ = getc(inFILE)) & 0xff) != 0xff)
X		;
X	return (buf - buf0 - 1);
X}
X
Xvoid
XskipFF(inFILE)
X	register FILE	*inFILE;
X{
X	while ((getc(inFILE) & 0xff) != 0xff)
X		;
X	return;
X}
END_OF_FILE
if test 418 -ne `wc -c <'getsFF.c'`; then
    echo shar: \"'getsFF.c'\" unpacked with wrong size!
fi
# end of 'getsFF.c'
fi
if test -f 'gid.el' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gid.el'\"
else
echo shar: Extracting \"'gid.el'\" \(788 characters\)
sed "s/^X//" >'gid.el' <<'END_OF_FILE'
X;;; put this in your GnuEmacs startup file  '~/.emacs' .
X;;; or autoload it from some other file. -wsr
X
X(require 'symfunc)
X
X(defun gid (command)
X  "Run gid, with user-specified args, and collect output in a buffer.
XWhile gid runs asynchronously, you can use the \\[next-error] command
Xto find the text that gid hits refer to."
X  (interactive (list (read-input "Run gid (with args): "
X				 (symbol-around-point))))
X  (require 'compile)
X  (compile1
X     (concat "gid " command)
X     "No more gid hits" "gid"
X  )
X)
X
X(defun aid (command)
X  "Run aid, with user-specified args, and collect output in a buffer."
X  (interactive (list (read-input "Run aid (with args): "
X				 (symbol-around-point))))
X  (require 'compile)
X  (compile1
X     (concat "aid -k " command)
X     "No aid hits" "aid"
X  )
X)
END_OF_FILE
if test 788 -ne `wc -c <'gid.el'`; then
    echo shar: \"'gid.el'\" unpacked with wrong size!
fi
# end of 'gid.el'
fi
if test -f 'idx.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'idx.c'\"
else
echo shar: Extracting \"'idx.c'\" \(1437 characters\)
sed "s/^X//" >'idx.c' <<'END_OF_FILE'
Xstatic char copyright[] = "@(#)Copyright (c) 1986, Greg McGary";
Xstatic char sccsid[] = "@(#)idx.c	1.2 86/10/17";
X
X#include	<stdio.h>
X#include	<string.h>
X#include	<id.h>
X#include	<extern.h>
X
Xvoid idxtract();
X
Xchar	*MyName;
Xstatic void
Xusage()
X{
X	fprintf(stderr, "Usage: %s [-u] [+/-a<ccc>] [-c<ccc>] files\n", MyName);
X	exit(1);
X}
Xmain(argc, argv)
X	int		argc;
X	char		**argv;
X{
X	char		*arg;
X	int		op;
X	char		*sccsDir = NULL;
X	char		*rcsDir = NULL;
X
X	MyName = basename(GETARG(argc, argv));
X	while (argc) {
X		arg = GETARG(argc, argv);
X		switch (op = *arg++)
X		{
X		case '-':
X		case '+':
X			break;
X		default:
X			UNGETARG(argc, argv);
X			goto argsdone;
X		}
X		switch (*arg++)
X		{
X		case 's': sccsDir = arg; break;
X		case 'r': rcsDir = arg; break;
X		case 'S': setScanArgs(op, arg); break;
X		default: usage();
X		}
X	}
Xargsdone:
X
X	if (argc == 0)
X		usage();
X	while (argc)
X		idxtract(GETARG(argc, argv), sccsDir, rcsDir);
X	exit(0);
X}
X
Xvoid
Xidxtract(path, sccsDir, rcsDir)
X	char		*path;
X	char		*sccsDir;
X	char		*rcsDir;
X{
X	register char	*key;
X	register char	*(*getId)();
X	register FILE	*srcFILE;
X	char		*(*getScanner())();
X	int		flags;
X	char		*suffix;
X	char		*filter;
X
X	if ((getId = getScanner(getLanguage(suffix=strrchr(path, '.')))) == NULL)
X		return;
X	if ((srcFILE = openSrcFILE(path, sccsDir, rcsDir, filter=getFilter(suffix))) == NULL)
X		return;
X
X	while ((key = (*getId)(srcFILE, &flags)) != NULL)
X		puts(key);
X
X	closeSrcFILE(srcFILE, filter);
X}
END_OF_FILE
if test 1437 -ne `wc -c <'idx.c'`; then
    echo shar: \"'idx.c'\" unpacked with wrong size!
fi
# end of 'idx.c'
fi
if test -f 'init.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'init.c'\"
else
echo shar: Extracting \"'init.c'\" \(1442 characters\)
sed "s/^X//" >'init.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)init.c	1.1 86/10/09";
X
X#include	<id.h>
X#include	<string.h>
X#include	<stdio.h>
X#include	<extern.h>
X
X/* initID opens idFile, reads the header into idhp (and verifies the magic
X * number), then builds the idArgs list holding the names of all the
X * files recorded in the database.
X */
XFILE *
XinitID(idFile, idhp, idArgs)
X	char		*idFile;
X	struct idhead	*idhp;
X	struct idarg	**idArgs;
X{
X	FILE		*idFILE;
X	register int	i;
X	register char	*strings;
X	register struct idarg	*idArg;
X
X	if ((idFILE = fopen(idFile, "r")) == NULL)
X		return NULL;
X
X	fseek(idFILE, 0L, 0);
X	fread(idhp, sizeof(struct idhead), 1, idFILE);
X	if (!strnequ(idhp->idh_magic, IDH_MAGIC, sizeof(idhp->idh_magic))) {
X		fprintf(stderr, "%s: Not an id file: `%s'\n", MyName, idFile);
X		exit(1);
X	}
X	if (idhp->idh_vers != IDH_VERS) {
X		fprintf(stderr, "%s: ID version mismatch (want: %d, got: %d)\n", MyName, IDH_VERS, idhp->idh_vers);
X		exit(1);
X	}
X
X	fseek(idFILE, idhp->idh_argo, 0);
X	strings = malloc(i = idhp->idh_namo - idhp->idh_argo);
X	fread(strings, i, 1, idFILE);
X	idArg = *idArgs = (struct idarg *)calloc(idhp->idh_pthc, sizeof(struct idarg));
X	for (i = 0; i < idhp->idh_argc; i++) {
X		if (*strings == '+' || *strings == '-')
X			goto skip;
X		idArg->ida_flags = (*strings) ? 0 : IDA_BLANK;
X		idArg->ida_arg = strings;
X		idArg->ida_next = idArg + 1;
X		idArg++;
X	skip:
X		while (*strings++)
X			;
X	}
X	return idFILE;
X}
END_OF_FILE
if test 1442 -ne `wc -c <'init.c'`; then
    echo shar: \"'init.c'\" unpacked with wrong size!
fi
# end of 'init.c'
fi
if test -f 'numtst.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'numtst.c'\"
else
echo shar: Extracting \"'numtst.c'\" \(60 characters\)
sed "s/^X//" >'numtst.c' <<'END_OF_FILE'
X000004
X00010
X012
X020
X04
X0x00004
X0x00010
X0x00a
X0XA
X10
X16
X4
X8
END_OF_FILE
if test 60 -ne `wc -c <'numtst.c'`; then
    echo shar: \"'numtst.c'\" unpacked with wrong size!
fi
# end of 'numtst.c'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 1
END_OF_FILE
if test 21 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'radix.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'radix.h'\"
else
echo shar: Extracting \"'radix.h'\" \(225 characters\)
sed "s/^X//" >'radix.h' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
X/* @(#)radix.h	1.1 86/10/09 */
X
X#define	RADIX_DEC	(1 << (10 - 1))
X#define	RADIX_OCT	(1 << (010 - 1))
X#define	RADIX_HEX	(1 << (0x10 - 1))
X#define	RADIX_ALL	(RADIX_DEC|RADIX_OCT|RADIX_HEX)
END_OF_FILE
if test 225 -ne `wc -c <'radix.h'`; then
    echo shar: \"'radix.h'\" unpacked with wrong size!
fi
# end of 'radix.h'
fi
if test -f 'string.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'string.h'\"
else
echo shar: Extracting \"'string.h'\" \(525 characters\)
sed "s/^X//" >'string.h' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
X/* @(#)string.h	1.1 86/10/09 */
X
X#ifdef RINDEX
X#define	strchr	index
X#define	strrchr	rindex
X#endif
X
Xextern char
X	*strcpy(),
X	*strncpy(),
X	*strcat(),
X	*strncat(),
X	*strchr(),
X	*strrchr(),
X	*strpbrk(),
X	*strtok();
X
Xextern long
X	strtol();
X
Xextern char	*calloc();
X
X#define	strequ(s1, s2)		(strcmp((s1), (s2)) == 0)
X#define	strnequ(s1, s2, n)	(strncmp((s1), (s2), (n)) == 0)
X#define	strsav(s)		(strcpy(calloc(1, strlen(s)+1), (s)))
X#define	strnsav(s, n)		(strncpy(calloc(1, (n)+1), (s), (n)))
END_OF_FILE
if test 525 -ne `wc -c <'string.h'`; then
    echo shar: \"'string.h'\" unpacked with wrong size!
fi
# end of 'string.h'
fi
if test -f 'tty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.c'\"
else
echo shar: Extracting \"'tty.c'\" \(1114 characters\)
sed "s/^X//" >'tty.c' <<'END_OF_FILE'
X#ifdef TERMIO
X#include	<sys/termio.h>
X
Xstruct termio linemode, charmode, savemode;
X
Xsavetty()
X{
X	ioctl(0, TCGETA, &savemode);
X	charmode = linemode = savemode;
X
X	charmode.c_lflag &= ~(ECHO|ICANON|ISIG);
X	charmode.c_cc[VMIN] = 1;
X	charmode.c_cc[VTIME] = 0;
X
X	linemode.c_lflag |= (ECHO|ICANON|ISIG);
X	linemode.c_cc[VEOF] = 'd'&037;
X	linemode.c_cc[VEOL] = 0377;
X}
X
Xrestoretty()
X{
X	ioctl(0, TCSETA, &savemode);
X}
X
Xlinetty()
X{
X	ioctl(0, TCSETA, &linemode);
X}
X
Xchartty()
X{
X	ioctl(0, TCSETA, &charmode);
X}
X
X#else
X#include	<sgtty.h>
X
Xstruct sgttyb linemode, charmode, savemode;
X
Xsavetty()
X{
X#ifdef TIOCGETP
X	ioctl(0, TIOCGETP, &savemode);
X#else
X	gtty(0, &savemode);
X#endif
X	charmode = linemode = savemode;
X
X	charmode.sg_flags &= ~ECHO;
X	charmode.sg_flags |= RAW;
X
X	linemode.sg_flags |= ECHO;
X	linemode.sg_flags &= ~RAW;
X}
X
Xrestoretty()
X{
X#ifdef TIOCSETP
X	ioctl(0, TIOCSETP, &savemode);
X#else
X	stty(0, &savemode);
X#endif
X}
X
Xlinetty()
X{
X#ifdef TIOCSETP
X	ioctl(0, TIOCSETP, &linemode);
X#else
X	stty(0, &savemode);
X#endif
X}
X
Xchartty()
X{
X#ifdef TIOCSETP
X	ioctl(0, TIOCSETP, &charmode);
X#else
X	stty(0, &savemode);
X#endif
X}
X#endif
END_OF_FILE
if test 1114 -ne `wc -c <'tty.c'`; then
    echo shar: \"'tty.c'\" unpacked with wrong size!
fi
# end of 'tty.c'
fi
if test -f 'uerror.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uerror.c'\"
else
echo shar: Extracting \"'uerror.c'\" \(586 characters\)
sed "s/^X//" >'uerror.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)uerror.c	1.1 86/10/09";
X
X#include	<stdio.h>
X
Xchar *uerror();
Xvoid filerr();
X
Xextern int	errno;
Xextern int	sys_nerr;
Xextern char	*sys_errlist[];
Xextern char	*MyName;
X
Xchar	cannot[] = "%s: Cannot %s `%s' (%s)\n";
X
Xchar *
Xuerror()
X{
X	static char	errbuf[10];
X
X	if (errno == 0 || errno >= sys_nerr) {
X		sprintf(errbuf, "error %d", errno);
X		return(errbuf);
X	}
X	return(sys_errlist[errno]);
X}
X
Xvoid
Xfilerr(syscall, fileName)
X	char		*syscall;
X	char		*fileName;
X{
X	fprintf(stderr, cannot, MyName, syscall, fileName, uerror());
X}
END_OF_FILE
if test 586 -ne `wc -c <'uerror.c'`; then
    echo shar: \"'uerror.c'\" unpacked with wrong size!
fi
# end of 'uerror.c'
fi
if test -f 'wmatch.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wmatch.c'\"
else
echo shar: Extracting \"'wmatch.c'\" \(830 characters\)
sed "s/^X//" >'wmatch.c' <<'END_OF_FILE'
X/* Copyright (c) 1986, Greg McGary */
Xstatic char sccsid[] = "@(#)wmatch.c	1.1 86/10/09";
X
X#include	<bool.h>
X#include	<ctype.h>
X
Xbool wordMatch();
X
X/*
X	Does `name' occur in `line' delimited by non-alphanumerics??
X*/
Xbool
XwordMatch(name0, line)
X	char		*name0;
X	register char	*line;
X{
X	register char	*name = name0;
X#define IS_ALNUM(c)	(isalnum(c) || (c) == '_')
X
X	for (;;) {
X		/* find an initial-character match */
X		while (*line != *name) {
X			if (*line == '\n')
X				return FALSE;
X			line++;
X		}
X		/* do we have a word delimiter on the left ?? */
X		if (IS_ALNUM(line[-1])) {
X			line++;
X			continue;
X		}
X		/* march down both strings as long as we match */
X		while (*++name == *++line)
X			;
X		/* is this the end of `name', is there a word delimiter ?? */
X		if (*name == '\0' && !IS_ALNUM(*line))
X			return TRUE;
X		name = name0;
X	}
X}
END_OF_FILE
if test 830 -ne `wc -c <'wmatch.c'`; then
    echo shar: \"'wmatch.c'\" unpacked with wrong size!
fi
# end of 'wmatch.c'
fi
echo shar: End of archive 1 \(of 11\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 11 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
--
======================================================================
domain: tahorsley at csd.harris.com       USMail: Tom Horsley
  uucp: ...!uunet!hcx1!tahorsley               511 Kingbird Circle
                                               Delray Beach, FL  33444
+==== Censorship is the only form of Obscenity ======================+
|     (Wait, I forgot government tobacco subsidies...)               |
+====================================================================+



More information about the Alt.sources mailing list