[comp.sources.misc] v09i071: newsclip 1.1, part 2 of 15

brad@looking.ON.CA (Brad Templeton) (12/20/89)

Posting-number: Volume 9, Issue 71
Submitted-by: brad@looking.ON.CA (Brad Templeton)
Archive-name: newsclip/part02

#! /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 2 (of 15)."
# Contents:  About Licence comp/clib.c comp/node.m4 comp/tree.c
#   comp/ucode.h comp/wrdata.c nllib.c sysdefs.bsd sysdefs.h
#   sysdefs.sysv sysdefs.v7 ucode.h
# Wrapped by allbery@uunet on Tue Dec 19 20:09:52 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'About' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'About'\"
else
echo shar: Extracting \"'About'\" \(3320 characters\)
sed "s/^X//" >'About' <<'END_OF_FILE'
X
X			  What is NewsClip?
X
XNewsClip is a language that allows you to compile filtering programs
Xfor USENET and ClariNet news.   You can use a full C-link language, with
Xarbitrary expressions involving header items and pattern searches, to decide
Xwhat articles you wish to read or not read.
X
XThe resulting filter program can be used to:
X
X	o) Filter a '.newsrc' stand-alone, marking as read articles
X	   that you don't wish to read (run it from the cron, for example)
X	o) Filter while you read news, with slight mods to your newsreader.
X		(patches for RN and RRN are provided)
X	o) Filter a list of article filenames (such as a batch list) to
X	   control a news feed as finely as desired.
X	o) Generate a filtered list of filenames of unread articles from
X	   a .newsrc file (updating it) -- thus allowing a feed to be run
X	   from a .newsrc file instead of the news "sys" file.  (The fed
X	   site becomes like a reader on your system with an arbitrary
X	   subscription list.)
X	o) Search all or part of USENET for articles that match a description
X	   you give, then generate a .newsrc with just those articles unread
X	   to be fed to your newsreader.
X
XJust about any description that can be programmed can usually be easily
Xmade to filter articles.  Filter out users, crossposts, topics, message
Xtrees, followups, remote articles, articles with long signatures or too
Xmuch included text.  At the same time, filter *in* local articles, followups
Xto your own articles or anything else.   Only read articles from specific
Xusers or sites, and their followups if you like.  Elminate a user from the
Xnet by filtering all his/her postings and all followups.
X
XYou set up your program to accept, reject or give a *weight* to articles
Xbased on things about them.  For example:
X
X	reject if is rec.humor && is talk.bizarre && domain(from) != my_domain;
X
Xrejects all articles crossposted to rec.humor AND talk.bizarre,
Xunless they were posted by somebody within your local domain.
X
X	reject if line_count(signature) > 20 || newtext has "ron.*reagan";
X
Xrejects articles where the signature is longer than 20 lines or the new
Xtext (not included from previous articles) mentions a famous ex-president of
Xthe USA>
X
XOf course this can do everything that a KILL file in RN does, but it also
Xdoes much more.  This includes the abliity to do the reverse of a KILL --
Xaccept *only* articles that match what you're looking for.  You can regularly
Xread a big group for a rare topic this way.  (The background mode can even
Xsearch unsubscribed groups for you, resubscribing you if something interesting
Xcomes up.)
X
XAnd because it's compiled, it's far more efficient.  Your programs are
Xtranslated to C programs and linked with the NewsClip library.
X
XRather than complain about somebody or something you don't like on USENET --
Xfilter it out.  Chances are that a NewsClip licence will cost you a lot
Xless than what whining on USENET will cost you and other people in
Xtime, space and transmission costs.
X
X(Currently, only the filter-while-you-read mode, which works in tandem
Xwith RRN, can be used on NNTP client-only sites.)
X
XNewsClip is Evalu-Ware.  It is a commercial product, but you may distribute
Xthe source freely and try it out for a few weeks before deciding to buy.
XIf you like it, check out the terms and fees described in the file 'Licence'
END_OF_FILE
if test 3320 -ne `wc -c <'About'`; then
    echo shar: \"'About'\" unpacked with wrong size!
fi
# end of 'About'
fi
if test -f 'Licence' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Licence'\"
else
echo shar: Extracting \"'Licence'\" \(4102 characters\)
sed "s/^X//" >'Licence' <<'END_OF_FILE'
X
X		NewsClip Filtering System Evaluation Licence
X			       Nov 25, 1989
X
X
XThis product has been released as what we call "EVALU-Ware."  (This is our
Xname for what some people call Shareware.)  This means that you may copy
Xthis source package, unmodified, and with this Licence and all copyright
Xnotices intact, and provide copies to your friends and associates.
X
XRecipients of the package may compile it on their machines and try it out
Xin an 'evaluation' period.   At the end of the evaluation period (20 days),
Xyou decide if you wish to continue using the system.  If you do, you
Xare required to pay a fee to register the program and licence the software
Xfor ongoing use.   Registered users also get typeset manuals, support and
Xupdates.  (No manual with student single-user licence.)
X
XIf you make a binary of this package for a specific variant of the Unix OS,
Xyou may also distribute that, so long as you include this Licence file.
XOnce you register the product, check for terms regarding its use in the
Xuse manual.
X
XYou can register by phone (toll-free), mail or electronic mail!
X
XWhat stops you from using the product after the evaluation period
Xwithout licencing it?  Only your own honesty.  We have released this
Xproduct as EVALU-ware, because many users wish a chance to get a full look
Xat a system before paying for it.  In addition, in the Unix world, there
Xis no one medium of distribution that is convenient for all customers.
XSo in theory, it's good for us and good for the customers.
X
XUnfortunately, we do this at considerable risk.  This history of 'Shareware'
Xis grim.  All but a tiny handful of 'shareware' software publishers report
Xthat they received neglibable revenues from this method of distribution.
XWhile bad software and dishonest users are part of the reason for this, it
Xis believed that the principle cause of this problem is honest users who
Xsimply never get around to paying.  To combat this, we have made it very
Xeasy to arrange payment.
X
XIf you decide to licence this product, you may pay in several ways.  Major
Xfirms may send a purchase order.  Other users may pay by cheque, money order
Xor Visa/MasterCard/American Express.
X
X	Telephone: 519 884 7473
X
X	For a limited time, in the USA: 800 265 2782 (toll free)
X
X	E-mail:  newsclip@clarinet.com
X
XOr Write:
X	ClariNet Communications Corp.
X	124 King St. N.
X	Waterloo, ON
X	N2J 2X8
X
X
XCurrent Prices: (USD)
X
X	ClariNet subscribers:			NO CHARGE!
X	Single User				$50
X	Single User -- student			$30
X	Small System/Workstation/etc.		$150
X	Minicomputer, small deptartmental LAN	$250
X	Supermini, medium sized Vax, plant LAN	Call
X	Corporate site licence or other		Call
X
XPrices are subject to change without notice.  Credit card customers
Xwill be billed in Canadian dollars at current exchange rates.  These
Xprices are effective December, 1989.
X
XProperly typeset NewsClip manuals are available for $20 USD ($24 CDN)
Xvia mail or phone order.  This amount will be deducted from any licence
Xfee paid at a later date.
X
XClariNet customers may use NewsClip at no charge.  If you cancel your
XClariNet subscription after a short time, 50% of all money paid for the
Xsubscription can be applied to the above licence fees if you wish to
Xcontinue using NewsClip after the subscription terminates.
X
XIf you have an E-mail link that allows commercial traffic (some limited
Xsections of the Internet don't) you can actually E-mail your registration
Xorder.  Beware that if you use multiple UUCP hops, Unix E-mail is anything
Xbut secure.  On the other hand, as you are allowed to contest any unsigned
Xcredit card charge, things can't get too bad.
X
XE-mail your card number and expiry, your name, company's name (if applicable)
Xand address, along with the size and type of computer you plan to run
XNewsClip on to newsclip@clarinet.com.
X
XBug Reports:
X	All software has bugs, of course, particularly the first release
X	of something to wide distribution.   Thus, if you're the first
X	to report a bug, single user registration is free.  Thanks!
X	Mail to clipsupport@clarinet.com.   This is also the address
X	for technical support for already registered users.
X
END_OF_FILE
if test 4102 -ne `wc -c <'Licence'`; then
    echo shar: \"'Licence'\" unpacked with wrong size!
fi
# end of 'Licence'
fi
if test -f 'comp/clib.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp/clib.c'\"
else
echo shar: Extracting \"'comp/clib.c'\" \(3316 characters\)
sed "s/^X//" >'comp/clib.c' <<'END_OF_FILE'
X
X#include "nc.h"
X/*
X * General library for the compiler
X */
X /*
X  * Newsclip(TM) Compiler Source Code.
X  * Copyright 1989 Looking Glass Software Limited.  All Rights Reserved.
X  * Unless otherwise licenced, the only authorized use of this source
X  * code is compilation into a binary of the newsclip compiler for the
X  * use of licenced Newsclip customers.  Minor source code modifications
X  * are allowed before compiling.
X  * A short time evaluation of this product is also permitted.  See the file
X  * 'Licence' in the library source directory for details.
X  */
X
Xchar *
Xcheckalloc( size )
Xunsigned int size;
X{
X	char *p, *malloc();
X
X	p = malloc( size );
X	if( p )
X		return p;
X	 else
X		fatal( TRUE, "Out of memory" );
X}
X
Xchar *
Xperm_alloc(size)
Xunsigned int size;
X{
X	return checkalloc(size);
X}
X
Xperm_free(mem)
Xchar *mem;
X{
X	free(mem);
X}
X/*
X * error message routines 
X * These routines use the non-portable variable arguments method of
X * just passing a bunch of int arguments on the stack and using them.
X * Then again, there really isn't a portable way to write these routines.
X * This method works on most machines you find Unix on.
X * For those where it doesn't, these routines are easy to redo.
X */
X
X/* error detected while parsing */
Xint got_error = 0;
X
Xparerror( form, a, b, c, d, e, f )
Xchar *form;
Xint a,b,c,d,e,f;
X{
X	extern char *yyfilename;
X	extern int yylineno;
X
X
X	if( yylineno )
X		fprintf( stderr, "%s(%d): ", yyfilename, yylineno );
X	fprintf( stderr, form, a,b,c,d,e,f );
X	fprintf( stderr, "\n" );
X
X	got_error |= SYNTAX_ERROR;
X
X}
X
Xerror( form, a, b, c, d, e, f )
Xchar *form;
Xint a,b,c,d,e,f;
X{
X	fatal(TRUE, form,a,b,c,d,e,f );
X}
X
Xfatal( giveline, form, a, b, c, d, e, f )
Xbool giveline;			/* give the line number and file name */
Xchar *form;
Xint a,b,c,d,e,f;
X{
X	extern char *yyfilename;
X	extern int yylineno;
X
X	if( giveline && yylineno )
X		fprintf( stderr, "%s(%d): ", yyfilename, yylineno );
X	fprintf( stderr, form, a,b,c,d,e,f );
X	fprintf( stderr, "\n" );
X	wrapup();
X}
X
Xcprintf( form, a,b,c,d,e,f,g,h,i,j,k )
Xchar *form;
Xint a,b,c,d,e,f,g,h,i,j,k;
X{
X	extern FILE *outstream;
X
X	/* at this point line numbers don't matter */
X
X	/* check for write error? */
X	fprintf( outstream, form, a,b,c,d,e,f,g,h,i,j,k );
X}
X
Xwrapup()
X{
X	exit(1);
X}
X
Xlowercase( str )
Xregister char *str;
X{
X	while( *str ) {
X		if( isupper( *str ) )
X			*str |= 0x20;
X		str++;
X		}
X}
X
Xchar *
Xallocstring( str )
Xchar *str;
X{
X	char *res;
X
X	res = perm_alloc( strlen(str) + 1 );
X	strcpy( res, str );
X	return res;
X}
X
X/* type error in the tree */
X
Xterror( tp, format, a,b,c,d,e,f )
Xnodep tp;		/* node at which the error took place */
Xchar *format;		/* main string of error */
Xint a,b,c,d,e,f;
X{
X	extern char *findfile AC((nodep));
X
X	/* scan up to a list node to file line number and file */
X	fprintf( stderr, "%s(%d): ", findfile(tp), tp->line_num );
X
X	fprintf( stderr, format, a,b,c,d,e,f );
X	fprintf( stderr, "\n" );
X
X	got_error |= TYPE_ERROR;
X}
X/* Zero out a region of memory.  Your system may have a routine around to
X   do this faster.  If so, remove this and use your own. */
X
Xzero( mem, bytes )
Xchar *mem;
Xint bytes;
X{
X	register int *p;
X	register char *cp;
X	int words, extra;
X
X	words = bytes/sizeof(int);
X	extra = bytes - sizeof(int)*words;
X
X	p = (int *)mem;
X	while( words-- )
X		*p++ = 0;
X	cp = (char *)p;
X	while( extra-- )
X		*cp++ = 0;
X}
END_OF_FILE
if test 3316 -ne `wc -c <'comp/clib.c'`; then
    echo shar: \"'comp/clib.c'\" unpacked with wrong size!
fi
# end of 'comp/clib.c'
fi
if test -f 'comp/node.m4' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp/node.m4'\"
else
echo shar: Extracting \"'comp/node.m4'\" \(3545 characters\)
sed "s/^X//" >'comp/node.m4' <<'END_OF_FILE'
X/*
X *	The node types for the first byte in any node
X */
Xdefine( `nodenum', -1 )
X/* macro arguments
X * $1 - name of node
X * $2 - print code
X * $3 - flags for the node
X * $4 - number of tree-type children for the node
X * $5 - number of total children for the node
X */
Xdefine(makenode,`divert(9)define(`nodenum',incr(nodenum))
X`#define' N_$1 nodenum 
Xdivert(1) {$2, $3, $4, $5},
Xdivert(-1)' )
X
X`#include' "nc.h"
Xdivert(1)struct node_info node_table[] = {
Xdivert(9)
X/* BEGIN_DEFINE */
Xdivert(10)
X
Xmakenode( NULL, "", 0, 0, 0 )
Xmakenode( LIST, "", 0, 0, 0 )
Xmakenode( EXTERN, "extern !0d;", 0, 1, 1 )
Xmakenode( EXT_FUNC, "extern !0d();", 0, 2, 2 )
Xmakenode( DECL_VAR, "!0d;", 0, 1, 1 )
Xmakenode( ID, "!0i", 0, 0, 1 )
Xmakenode( ROUTINE, "!0l\n!1l", 0, 2, 2 )
Xmakenode( LABELED, "!0t : !1t", 0, 2, 2 )
Xmakenode( CASE, "case !0t :\n!1t", 0, 2, 2 )
Xmakenode( DEFAULT, "default:\n!0t", 0, 1, 1 )
Xmakenode( COMPOUND, "{\n!0l\n}", 0, 1, 1 )
Xmakenode( SEMISTAT, "!0t;", 0, 1, 1 )
Xmakenode( ADJUST, "score += (!0t);", 0, 1, 1 )
Xmakenode( CALL, "", 0, 2, 2 )
Xmakenode( ASSIGN, "!0t = !1t", 0, 2, 2 )
Xmakenode( IF, "if( !0t )!>\n!1t!<", 0, 2, 2 )
Xmakenode( IFELSE, "if( !0t )!>\n!1t!<\nelse!>\n!2t!<", TF_ONEINT, 3, 3 )
Xmakenode( SWITCH, "switch( !0t ) !>\n!1t!<", TF_ONEINT, 2, 2 )
Xmakenode( WHILE, "while( !0t )!>\n!1t!<", TF_ONEINT, 2, 2 )
Xmakenode( FOR, "for( !0t; !1t; !2t ) !>\n!3t!<", 0, 4, 4 )
Xmakenode( FOREACH, "", 0, 3, 3 )
Xmakenode( GOTO, "goto !0t;", 0, 1, 1 )
Xmakenode( CONTINUE, "continue;", 0, 0, 0 )
Xmakenode( BREAK, "break;", 0, 0, 0 )
Xmakenode( RETURN, "return !0t;", 0, 1, 1 ) /* special */
Xmakenode( ACCEPT, "return score = Accept;", TF_RET, 0, 0 )
Xmakenode( IFACCEPT, "{if( !0t ) return score = Accept;}", TF_ONEINT|TF_RET, 1, 1 )
Xmakenode( REJECT, "return score = Reject;", TF_RET, 0, 0 )
Xmakenode( IFREJECT, "{if( !0t ) return score = Reject;}", TF_ONEINT|TF_RET, 1, 1 )
Xmakenode( INDEX, "!0t->vals[!1t]", 0, 2, 2 )
Xmakenode( FUNCALL, "!0t(!1,)", 0, 2, 2 )
Xmakenode( INT, "!0N", 0, 0, 1 )
Xmakenode( STRING, "!0$", 0, 0, 1 )
Xmakenode( NGROUP, "!0n", 0, 0, 1 )
Xmakenode( QGROUP, "gquery(!0n)", TF_RETINT, 0, 1 )
Xmakenode( PAREN, "(!0t)", 0, 1, 1 )
Xmakenode( POSTINC, "!0t++", 0, 1, 1 )
Xmakenode( POSTDEC, "!0t--", 0, 1, 1 )
Xmakenode( PREINC, "++!0t", 0, 1, 1 )
Xmakenode( PREDEC, "--!0t", 0, 1, 1 )
Xmakenode( UPLUS, "+!0t", TF_ONEINT, 1, 1, )
Xmakenode( UMINUS, "-!0t", TF_ONEINT, 1, 1 )
Xmakenode( NOT, "!!!0t", TF_ONEINT|TF_RETINT, 1, 1 )
Xmakenode( MULT, "!0t*!1t", TF_2INT, 2, 2 )
Xmakenode( DIVIDE, "!0t/!1t", TF_2INT, 2, 2 )
Xmakenode( MODULUS, "!0t%!1t", TF_2INT, 2, 2 )
Xmakenode( PLUS, "!0t + !1t", TF_2INT, 2, 2 )
Xmakenode( MINUS, "!0t - !1t", TF_2INT, 2, 2 )
Xmakenode( LT, "!0t < !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( GT, "!0t > !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( LE, "!0t <= !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( GE, "!0t >= !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( EQ, "", TF_RETINT, 2, 2 )
Xmakenode( NE, "", TF_RETINT, 2, 2 )
Xmakenode( IN, "", TF_RETINT, 2, 2 )
Xmakenode( NOT_IN, "", TF_RETINT, 2, 2 )
Xmakenode( HAS, "", TF_RETINT, 2, 2 )
Xmakenode( NOT_HAS, "", TF_RETINT, 2, 2 )
Xmakenode( BAND, "!0t & !1t", TF_2INT, 2, 2 )
Xmakenode( BOR, "!0t | !1t", TF_2INT, 2, 2 )
Xmakenode( AND, "!0t && !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( XOR, "!0t ^ !1t", TF_2INT, 2, 2 )
Xmakenode( OR, "!0t || !1t", TF_2INT|TF_RETINT, 2, 2 )
Xmakenode( QUERY, "!0t ? !1t : !2t", 0, 3, 3 )
Xmakenode( PATTERN, "!0P", 0, 0, 1 )
Xmakenode( PARSE, "", 0, 3, 3 )
Xmakenode( ARINIT, "", 0, 2, 2 )
X
Xdivert(9)
X/* any extra defines */
Xdivert(1)
X };
END_OF_FILE
if test 3545 -ne `wc -c <'comp/node.m4'`; then
    echo shar: \"'comp/node.m4'\" unpacked with wrong size!
fi
# end of 'comp/node.m4'
fi
if test -f 'comp/tree.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp/tree.c'\"
else
echo shar: Extracting \"'comp/tree.c'\" \(3941 characters\)
sed "s/^X//" >'comp/tree.c' <<'END_OF_FILE'
X
X#include "nc.h"
X/*
X * Variable argument, general tree node creation routine.
X *
X * Given the node type and some kids, it builds a tree node for
X * you.
X */
X /*
X  * Newsclip(TM) Compiler Source Code.
X  * Copyright 1989 Looking Glass Software Limited.  All Rights Reserved.
X  * Unless otherwise licenced, the only authorized use of this source
X  * code is compilation into a binary of the newsclip compiler for the
X  * use of licenced Newsclip customers.  Minor source code modifications
X  * are allowed before compiling.
X  * A short time evaluation of this product is also permitted.  See the file
X  * 'Licence' in the library source directory for details.
X  */
X
X/*VARARGS1*/
Xnodep 
Xtree(type, a1, a2, a3, a4)
Xbyte type;		/* node type */
Xnodep a1, a2, a3, a4;	/* various args */
X{
X	register nodep	newnode;	/* pointer to built node */
X	int		num;
X	int i;
X	extern struct node_info node_table[];
X	extern int yylineno;		/* curent parser line number */
X
X	num = node_table[type].fullkids;
X
X	newnode = (nodep)checkalloc(sizeof(struct node)+sizeof(nodep)*(num-1));
X
X	newnode->ntype = type;
X	newnode->nflags = 0;
X
X	switch (num) {
X	case 4:
X		newnode->kids[3] = a4;
X	case 3:
X		newnode->kids[2] = a3;
X	case 2:
X		newnode->kids[1] = a2;
X	case 1:
X		newnode->kids[0] = a1;
X	case 0:
X		break;
X	default:
X		break;
X		}
X	num = node_table[type].kids;
X	newnode->line_num = yylineno;
X	/* now loop and set the parents */
X	for( i = 0; i < num; i++ ) {
X		nodep kid;
X		kid = newnode->kids[i];
X		if( kid )
X			kid->parent = newnode;
X		}
X	return newnode;
X}
X
X/* Turn a node into a linked list element.  If already a list, return it */
X
Xlistp
Xfreshlist( node )
Xnodep node;		/* the single node to form into a list */
X{
X	listp newlist;
X	extern int yylineno;
X	extern char *yyfilename;
X
X	if( node == NIL || node->ntype != N_LIST ) {
X		newlist = (listp)checkalloc( sizeof(struct link_list) );
X		newlist->kid = node;
X		newlist->next = (listp)0;
X		newlist->line_num = yylineno;
X		newlist->filename = yyfilename;
X		newlist->parent = NIL;
X		newlist->ntype = N_LIST;
X		if( node != NIL )
X			node->parent = (nodep)newlist;
X		return newlist;
X		}
X	 else
X		return (listp)node;
X}
X
X/* Join two lists, two nodes or a node an a list together in a linked list */
X
Xlistp
Xllist( n1, n2 )
Xnodep n1;		/* the list we are joining to - or perhaps a node? */
Xnodep n2;		/* the node to add -- or possibly another list */
X{
X	listp main, scan;
X	listp addon;
X
X	main = freshlist(n1);
X
X	/* chain to the end of the first list */
X	for( scan = main; scan->next; scan = scan->next )
X		;
X	addon = freshlist(n2);
X	scan->next = addon;
X	addon->parent = (nodep)scan;
X	return main;
X}
X
X/* compare two argument lists for two routines */
X
Xbool
Xarglists_match( l1, l2 )
Xstruct typelist *l1;		/* the user declared list */
Xstruct typelist *l2;		/* the system defined list */
X{
X	int i;
X	int checkcount;
X
X	if( l1->argcount >= l2->argmin && l1->argcount <= l2->argmax ) {
X		checkcount = min( l1->argcount, l2->argcount );
X		for( i = 0; i < checkcount; i++ )
X			if( l1->args[i] != l2->args[i] )
X				return FALSE;
X		return TRUE;
X		}
X	return FALSE;
X}
X
Xchar *
Xfindfile( tp )
Xnodep tp;
X{
X	extern char *yyfilename;;
X
X	while( tp && tp->ntype != N_LIST )
X		tp = tp->parent;
X	if( tp )
X		return ((listp)tp)->filename;
X	 else
X		return yyfilename;
X}
X
X/* Free up a code tree  - a recursive routine */
X
Xtreefree(np)
Xnodep np;
X{
X	extern struct node_info node_table[];
X	int fkids;			/* number of kids to free */
X	int i;
X
X	if( np == NIL )
X		return;
X
X
X	if( np->ntype == N_LIST ) {
X		listp flist;
X		for( flist = (listp)np; flist; flist = flist->next ) {
X			treefree( flist->kid );
X			free( flist );
X			}
X		return;
X		}
X	 else {
X		fkids = node_table[np->ntype].kids;
X		for( i = 0; i < fkids; i++ ) 
X			treefree( np->kids[i] );
X		}
X
X	switch( np->ntype ) {
X		case N_STRING:
X			free( (char *)kid0(np) );
X			break;
X		/* We do not free IDs, we leave that up to the freeing of
X		   the symbol table */
X		}
X	/* get rid of ourselves and go */
X	free( np );
X}
END_OF_FILE
if test 3941 -ne `wc -c <'comp/tree.c'`; then
    echo shar: \"'comp/tree.c'\" unpacked with wrong size!
fi
# end of 'comp/tree.c'
fi
if test -f 'comp/ucode.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp/ucode.h'\"
else
echo shar: Extracting \"'comp/ucode.h'\" \(3731 characters\)
sed "s/^X//" >'comp/ucode.h' <<'END_OF_FILE'
X
X/* Declarations that run before the user program */
X/* Copyright 1989 Looking Glass Software Limited.  All Rights Reserved. */
X
X
X#ifdef INTS_32
Xtypedef int int32;
Xtypedef short int16;
X#else
Xtypedef long int32;
Xtypedef int int16;
X#endif
X
Xtypedef long datehold;
Xtypedef int newsgroup;
Xtypedef unsigned char byte;
Xtypedef unsigned char bool;
X
X/* fake definition for database pointer */
Xtypedef struct database_struct {
X		int foo;
X		} *dbptr;
X
Xtypedef struct user_name {
X	char *emailname;	/* the mail name, ie: user@site.foo */
X	char *fullname;		/* the full name or comment */
X	} username;
X
X
Xtypedef union d_union {
X	int	uinteger;	/* integer or newsgroup types */
X	long	udate;		/* date or long int types */
X	char	*ustring;	/* string types */
X	char	*regexp;	/* compiled regular expressions */
X	username *uusername;	/* a user name struct */
X	} datau;
X
X/* The struct for a multi-valued array.  The array is declared with only
X   one element, but in fact this structure can be allocated with enough
X   space for any number of elements, and C lets us access them without
X   checks. */
X
Xtypedef struct h_array {
X	int arsize;		/* number of elements in the array */
X	byte artype;		/* type of the elements in the array */
X	datau vals[1];		/* actually an extensible array, as allocated */
X	} array;
X
X/* database structure */
X
Xtypedef struct db_record {
X	char *name;
X	struct db_record *next;
X	byte hflags;
X	int intval;			/* the cell's value */
X	datehold access_date;		/* last time of access */
X	} userdb;
X
Xtypedef struct ng_record {
X	char *key;
X	struct ng_record *next;
X	byte hflags;
X	/* extras not important */
X	} ngrec;
X
X/* Struct defining header items to process */
Xstruct hitem_list {
X	char *hname;		/* name of header */
X	int dtype;		/* data type of header data */
X	char *delims;		/* delimiters to use if an array */
X	datau *var;		/* address of variable to put data into */
X	};
X
Xextern ngrec **ngarray;
Xextern int score;
X#define Reject -30000
X#define Accept 30000
X
X/* Macros used in the code */
X
X#define count(x)  (x->arsize)		/* array count */
X#define mailname(x)	(x->emailname)
X#define realname(x)	(x->fullname)	/* from id full name */
X#define ngn(x)	ngarray[x]->key		/* news group name */
X
X/* date constants */
X#define	day		(60*60*24l)
X#define	week		(7*day)
X#define	month		2629728l	/* special 'average' month 30.4 days */
X/* special text variables */
X#define signature	1
X#define included	2
X#define newtext		4
X#define	text		6	
X#define	body		7
X
X#define article_bytes art_bytes()
X
X/* function declarations for predefineds */
Xextern dbptr read_database();
Xextern write_database();
Xextern free_database();
Xextern dbptr fresh_database();
X
X#define chindex(str,dex)  str[dex]
X#define permstring allocstring
X
Xextern int db_lookup();			/* user database lookup fun */
Xextern userdb *db_create();		/* lookup and create function */
Xextern userdb *ufirst_rec();
X#define unext_rec(db,rec)	rec->next
X
X/* array creating routines */
Xextern array *uparse_array();
Xextern array *fresh_array();
X
X
X/* special externals, that might be repeated, for indirectly referenced
X   header items */
X
Xextern array *newsgroups;		/* always present */
Xextern array *distribution;		/* for Rdistribution */
Xextern array *followup_to;		/* for Rfollowup_to */
Xextern array *references;		/* for is_followup */
Xextern username *reply_to;		/* for Rreply_to */
Xextern username *sender;		/* For Rsender */
Xextern username *from;			/* for the two above */
X
X#define true 1
X#define false 0
X
X/* various nil constants */
X#define nilstring (char *) 0
X#define niluserid (username *)0
X#define nildatabase (dbptr)0
X#define nilnewsgroup (newsgroup)0
X#define nilarray (array *)0
X
X/* Functions for the IN and HAS operators all return booleans (ints) and
X   as such do not have to be declared */
END_OF_FILE
if test 3731 -ne `wc -c <'comp/ucode.h'`; then
    echo shar: \"'comp/ucode.h'\" unpacked with wrong size!
fi
# end of 'comp/ucode.h'
fi
if test -f 'comp/wrdata.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp/wrdata.c'\"
else
echo shar: Extracting \"'comp/wrdata.c'\" \(3505 characters\)
sed "s/^X//" >'comp/wrdata.c' <<'END_OF_FILE'
X
X#include "nc.h"
X/*
X *
X * Routines to write data elements out to the source code file
X * Plus routines to manage selected data elements.
X *
X */
X /*
X  * Newsclip(TM) Compiler Source Code.
X  * Copyright 1989 Looking Glass Software Limited.  All Rights Reserved.
X  * Unless otherwise licenced, the only authorized use of this source
X  * code is compilation into a binary of the newsclip compiler for the
X  * use of licenced Newsclip customers.  Minor source code modifications
X  * are allowed before compiling.
X  * A short time evaluation of this product is also permitted.  See the file
X  * 'Licence' in the library source directory for details.
X  */
Xbool wants_dist = FALSE;
X
Xwrite_data()
X{
X	extern bool needs_stat;
X
X	cprintf( "bool needs_stat = %d;\n", needs_stat );
X	cprintf( "bool wants_dist = %d;\n", wants_dist );
X
X	dump_header();
X	write_ngnames();
X	write_patterns();
X}
X
X/* write out the newsgroup names referenced by the user */
X
Xwrite_ngnames()
X{
X	extern struct stringmap thegroups;
X	numstring *ourng;
X	int groupcount;
X
X	groupcount = 0;
X	cout( "char *user_groupnames[] = {\n" );
X	for( ourng = thegroups.first; ourng; ourng = ourng->ng_next ) {
X		cprintf( "\"%s\",\n", ourng->name );
X		groupcount++;
X		}
X	cprintf( "0 };\n" );
X	cprintf( "int user_gcount = %d;\n", groupcount );
X}
X
Xwrite_patterns()
X{
X	extern struct stringmap thepatterns;
X	numstring *outpat;
X	int patcount;
X
X	patcount = 0;
X	cout( "char *user_patterns[] = {\n" );
X	for( outpat = thepatterns.first; outpat; outpat = outpat->ng_next ) {
X		patrout( outpat->name );
X		patcount++;
X		cout ( ",\n" );
X		}
X	cprintf( "0 };\n" );
X	cprintf( "int pattern_count = %d;\n", patcount );
X}
X
Xint
Xnums_lookup( numsbase, str )
Xstruct stringmap *numsbase;
Xchar *str;
X{
X	numstring *ngptr;
X
X	ngptr = (numstring *)add_rec( numsbase->dbase, str, AR_CREATE );
X
X	if( ngptr->ngnum )
X		return ngptr->ngnum;
X	 else  {
X		/* build a chain of the newsgroups, in order */
X		if( numsbase->counter ) {
X			/* putting on a further group */
X			numsbase->current->ng_next = ngptr;
X			numsbase->current = ngptr;
X			}
X		 else
X			numsbase->first = numsbase->current = ngptr;
X
X		ngptr->ng_next = (numstring *)0;
X
X		return ngptr->ngnum = ++numsbase->counter;
X		}
X}
X
Xstruct stringmap thepatterns = { 0,0,0,0 };
X
Xint
Xpat_number( str )
Xchar *str;
X{
X	return nums_lookup( &thepatterns, str );
X}
X
X#define REQUIRED 1		/* number of routines below that 
X					really should be there */
X/* Handle null definitions for routines that must be present */
X
Xchar *mustlist[] = {
X"article",			/* main article code REQUIRED */
X"init",				/* start of program */
X"startgroup",			/* start a new newsgroup */
X"endgroup",			/* end of a newsgroup */
X"post_article",			/* after article accept/reject */
X"terminate",			/* termination of program */
X"command",			/* programmed commands in pipe mode */
X0
X};
X
Xwrite_null()
X{
X	int i;
X	symptr defsym;			/* symbol definition for our routine */
X	extern dbptr global_symtab;
X
X	/* make sure there's a definition for each of our desired routines.
X	   If there is not a local definition in the global symtab, define
X	   a null one in the output program. */
X
X	for( i = 0; mustlist[i]; i++ ) {
X		defsym = (symptr)get_rec( global_symtab, mustlist[i] );
X		if( defsym && defsym->sflags & SF_LOCAL ) {
X			if( defsym->decl_type != ST_PROC )
X				parerror( "Symbol '%s' must be a procedure", defsym->name );
X			}
X		 else {
X			cprintf( "U%s(){}\n", mustlist[i] );
X			if( i < REQUIRED ) 
X				fprintf( stderr, "Warning: No definition of procedure '%s'\n", mustlist[i] );
X			}
X		}
X}
END_OF_FILE
if test 3505 -ne `wc -c <'comp/wrdata.c'`; then
    echo shar: \"'comp/wrdata.c'\" unpacked with wrong size!
fi
# end of 'comp/wrdata.c'
fi
if test -f 'nllib.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'nllib.c'\"
else
echo shar: Extracting \"'nllib.c'\" \(4098 characters\)
sed "s/^X//" >'nllib.c' <<'END_OF_FILE'
X#include "nl.h"
X
X/* This function contains some general library routines used by
X * the newsclip system.  A few are even available to user programs.
X *
X * Also found here are the error handling routines, which are variable
X * argument programs involving non-portable calls to printf.
X * On some machines you will have to add your own ways to do this with
X * ifdefs.
X */
X
X /*
X  * Newsclip(TM) Library Source Code.
X  * Copyright 1989 Looking Glass Software Limited.  All Rights Reserved.
X  * Unless otherwise licenced, the only authorized use of this source
X  * code is compilation into a binary of the newsclip library for the
X  * use of licenced Newsclip customers.  Minor source code modifications
X  * are allowed.
X  * Use of this code for a short term evaluation of the product, as defined
X  * in the associated file, 'Licence', is permitted.
X  */
X
X
X/* Takes a string and makess all the letters lower case */
X
X
Xlowercase( str )
Xregister char *str;
X{
X	while( *str ) {
X		if( isupper( *str ) )
X			*str |= 0x20;
X		str++;
X		}
X}
X
X/* strip white space from a string's end, and returns a pointer to
X   the first non-white character in the string.  Sort of an
X   'affirmative action' routine */
X
Xchar *
Xwhitestrip( str )
Xchar *str;
X{
X	return white_delim_strip( str, 0 );
X}
X
X
X/* strip white space from a string's ends and remove a possible terminator
X   char */
X
Xchar *
Xwhite_delim_strip( str, delim )
Xchar *str;
Xchar delim;		/* if this character terminates string, null it */
X{
X	register char *fp;		/* first pointer */
X	char *first;
X	char *last;
X	int len;
X
X	for( fp = str; *fp == ' ' || *fp == '\t'; fp++ )
X		;
X	first = fp;
X	last = 0;
X	for( fp = first; *fp; fp++ )
X		if( *fp != ' ' && *fp != '\t' )
X			last = fp;
X	if( last ) {
X		last[1] = 0;
X		if( *last == delim )
X			*last = 0;
X		}
X	return first;
X}
X
X/* Make a copy of a string in permanent memory */
X
Xchar *
Xallocstring( str )
Xchar *str;
X{
X	char *res;
X
X	res = perm_alloc( strlen(str) + 1 );
X	strcpy( res, str );
X	return res;
X}
X
X/* Make a copy of a string in temporary memory */
X
Xchar *
Xtemp_string( str )
Xchar *str;
X{
X	char *res;
X
X	res = temp_alloc( strlen(str) + 1 );
X	strcpy( res, str );
X	return res;
X}
X
X/* directory/file open */
X
XFILE *
Xdfopen( prefix, fname, mode )
Xchar *prefix;
Xchar *fname;
Xchar *mode;
X{
X	char buf[MAX_FNAME];
X	FILE *res;
X
X	sprintf( buf, "%s/%s", prefix, fname );
X	return fopen( buf, mode );
X}
X
X/* Open a file, and abort if it can't be opened */
X
XFILE *
Xmustopen( fname, mode, reason )
Xchar *fname;
Xchar *mode;
Xchar *reason;
X{
X	FILE *res;
X
X	if( res = fopen( fname, mode ) )
X		return res;
X	 else
X		error( "Could not open %s (%s)\n", fname, reason );
X}
X
X/* Zero out a region of memory.  Your system may have a routine around to
X   do this faster.  If so, remove this and use your own. */
X
Xzero( mem, bytes )
Xchar *mem;
Xint bytes;
X{
X	register int *p;
X	register char *cp;
X	int words, extra;
X
X	words = bytes/sizeof(int);
X	extra = bytes - sizeof(int)*words;
X
X	p = (int *)mem;
X	while( words-- )
X		*p++ = 0;
X	cp = (char *)p;
X	while( extra-- )
X		*cp++ = 0;
X}
X
X/* Convert a character numeric string into a number, guaranteed to be
X   able to handle numbers up to 2^31.*/
X
Xint32
Xatoi32( str )
Xchar *str;
X{
X#ifdef INTS_32
X	return atoi(str);
X#else
X	extern long atol();
X	return (int32)atol(str);
X#endif
X}
X
X/* debug printf for user programs */
X
Xdprintf( form, a,b,c,d,e,f )
Xlong a,b,c,d,e,f;
Xchar *form;
X{
X	/* check debug flag ? */
X	fprintf( stderr, form,a,b,c,d,e,f );
X}
X
X/* Issue a warning on stderr */
X
Xint warning_level = 1;
X
Xwarning( level, f, a, b, c, d, e )
Xint level;
Xchar *f;
X{
X	if( level <= warning_level ) {
X		fprintf( stderr, "NewsClip: " );
X		fprintf( stderr, f,a,b,c,d,e );
X		}
X}
X
X/* case-less string equality routine */
X
Xcleq(s1, s2)
Xregister char *s1;
Xregister char *s2;
X{
X	while( *s1 )
X		if( (*s1++ | 0x20) != (*s2++ | 0x20) )
X			return FALSE;
X	return *s2 == 0;
X}
X
X/* Takes a long and returns an int.  If the long is too big, then we
X * return the biggest (magnitude) int we can */
X
Xint
Xmakeint( bnum )
Xlong bnum;
X{
X	if( bnum > MAXINT )
X		return MAXINT;
X	 else if( bnum < -MAXINT )
X		return -MAXINT;
X	 else
X		return (int)bnum;
X}
END_OF_FILE
if test 4098 -ne `wc -c <'nllib.c'`; then
    echo shar: \"'nllib.c'\" unpacked with wrong size!
fi
# end of 'nllib.c'
fi
if test -f 'sysdefs.bsd' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sysdefs.bsd'\"
else
echo shar: Extracting \"'sysdefs.bsd'\" \(4037 characters\)
sed "s/^X//" >'sysdefs.bsd' <<'END_OF_FILE'
X/*
X * Various system dependent and fine-tuning #defines
X */
X
X
X/* define if ints are 32 bits, or more */
X
X#define	INTS_32		1
X/*
X * Define this macro according to whether your compiler takes ANSI C
X * style function prototypes or not.  (ie.  int f( int, char * ); )
X */
X
X#undef ANSI_PROTO 1
X
X#ifdef ANSI_PROTO
X# define AC(x)	x
X#else 
X# define AC(x)	()
X#endif /*ANSI_PROTO*/
X
X/* Define these according to the directories of your system */
X
X#define NEWSLIB		"/usr/lib/news"		/* lib directory for news */
X#define	NEWSSPOOL	"/usr/spool/news"	/* spool dir for news */
X/* Define this to be the name of the file that contains the sizes for
X * the various distributions
X */
X#define DISTLIST	"distlist"	/* level of distrs */
X
X/*
X * Define this to be, in lower case, the domain name your news programs use
X * when they generate a From: address.  If you don't define this, you will
X * get your sitename appended with the default domain. (uucp unless you change
X * it below)
X */
X#undef MAILDOMAIN	"foobar.uucp"		/* All lower case!!!! */
X
X#define DEFDOMAIN	 "uucp"			/* all lower case, please */
X
X
X/*
X * Some raw system-type defines
X */
X
X#define NEED_SLIB 1			/* for systems without system V string
X					calls, such as V7 or BSD */
X
X#ifdef NEED_SLIB
X/* why don't the BSD people get with it and include these new names? */
X#define strchr index
X#define strrchr rindex
X#endif
X
X#undef HAS_UNAME 1			/* for systems with the uname call */
X
X/*
X * Define this if you are a BSD system with the gethostname call.
X */
X#define GETHOSTNAME 1				/* BSD gethostname call */
X
X/*
X * If you don't have this call, and you aren't a SYSV system with the
X * uname call, or a Xenix or other system with the /etc/systemid file,
X * then you should define the symbol 'sysname' to be a string with your
X * system name, as it appears in Xref: lines.  You can often do this on
X * older systems by saying '#include <whoami.h>'
X */
X
X#undef sysname "mysite"
X
X/* The maximum length of a single component in a filename */
X/* too bad there's not a portable way to get this.  Even dir.h doesn't work */
X
X#define MAX_FNAME_LEN 255		/* isn't BSD nice? */
X
X#ifndef MAX_FNAME_LEN
X
X# define MAX_FNAME_LEN 14		/* normal for most unix */
X
X#endif /*MAX_FNAME_LEN*/
X
X/* System dependent definitions for calling the C compiler */
X
X/* How to call the C preprocessor on a file.  Usually either /lib/cpp or
X   cc -E, depending on the system */
X
X#define CPP "/lib/cpp"
X
X/* The pathname of the 'cc' C compiler */
X
X#define CCOMP "/bin/cc"
X
X/* Option to tell cc about where the "ucode.h" file can be found */
X/* Other system include files may go there as well */
X
X#define UCODEDIR "-I/usr/lib/news/newsclip"
X
X/* Location of the newsclip library -- if it isn't present the user
X   must provide it himself as a command line options */
X
X#define CLIPLIB "/usr/lib/news/newsclip/cliplib.a"
X/* The basename of the clip library, so that it can be found in the
X * current dir
X */
X#define CLIPBASE "cliplib.a"
X
X/* Up to 3 extra options for the C compiler.  You may want to do things
X   like set a stack size here.  Note that extra options can be given on
X   the ncc command line */
X
X#undef EXTRAOPT1 
X#undef EXTRAOPT2
X#undef EXTRAOPT3
X
X
X/* probably fixed, unless you have 64 bit ints */
X
X#ifdef INTS_32
X# define MAXINT	 2147483647
X#else
X# define MAXINT  32767				/* change this if need be */
X#endif
X
X/*
X * Don't change these unless you want to fine tune the program
X */
X
X#define MAX_FNAME 300			/* max length of file name */
X
X#define MAX_LLEN 300			/* max length of typical input line */	
X
X#define MAX_HLINES 50			/* max number of header lines */
X
X#define MAX_ARRAY 200			/* max elements in an array */
X
X#define MAX_NGLEN 60			/* max length of newgroup name */
X
X#define BITMAP_SIZE 1000		/* at most 8000 articles at a time? */
X
X#define MAX_OPTS 30			/* max options for C compiler or
X						user program */
X
X#define TBLOCK_SIZE 5000		/* size of chunks for use in temporary
X						allocator */
X#define MIN_TBLOCK TBLOCK_SIZE/64	/* smallest block to allocate */
X
X#define HLINE_SIZE 2500			/* buffer for header line */
X
END_OF_FILE
if test 4037 -ne `wc -c <'sysdefs.bsd'`; then
    echo shar: \"'sysdefs.bsd'\" unpacked with wrong size!
fi
# end of 'sysdefs.bsd'
fi
if test -f 'sysdefs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sysdefs.h'\"
else
echo shar: Extracting \"'sysdefs.h'\" \(3969 characters\)
sed "s/^X//" >'sysdefs.h' <<'END_OF_FILE'
X/*
X * Various system dependent and fine-tuning #defines
X */
X
X#define PAID 1
X
X/* define if ints are 32 bits, or more */
X
X/* #define	INTS_32		1 */
X/*
X * Define this macro according to whether your compiler takes ANSI C
X * style function prototypes or not.  (ie.  int f( int, char * ); )
X */
X
X#define ANSI_PROTO 1
X
X#ifdef ANSI_PROTO
X# define AC(x)	x
X#else
X# define AC(x)	()
X#endif /*ANSI_PROTO*/
X/* Define these according to the directories of your system */
X
X#define NEWSLIB		"/usr/lib/news"		/* lib directory for news */
X#define	NEWSSPOOL	"/u/news"		/* spool dir for news */
X/* Define this to be the name of the file that contains the sizes for
X * the various distributions
X */
X#define DISTLIST	"distlist"	/* level of distrs */
X
X/*
X * Define this to be, in lower case, the domain name your news programs use
X * when they generate a From: address.  If you don't define this, you will
X * get your sitename appended with the default domain. (uucp unless you change
X * it below)
X */
X#undef MAILDOMAIN	/* "looking.uucp"		All lower case!!!! */
X
X#define DEFDOMAIN	 "on.ca"
X
X
X/*
X * Some raw system-type defines
X */
X
X#undef NEED_SLIB /* 1			for systems without system V string
X					calls, such as V7 or BSD */
X
X#ifdef NEED_SLIB
X/* why don't the BSD people get with it and include these new names? */
X#define strchr index
X#define strrchr rindex
X#endif
X
X#define HAS_UNAME 1			/* for systems with the uname call */
X
X/*
X * Define this if you are a BSD system with the gethostname call.
X */
X#undef GETHOSTNAME /* 1				BSD gethostname call */
X
X/*
X * If you don't have this call, and you aren't a SYSV system with the
X * uname call, or a Xenix or other system with the /etc/systemid file,
X * then you should define the symbol 'sysname' to be a string with your
X * system name, as it appears in Xref: lines.  You can often do this on
X * older systems by saying '#include <whoami.h>'
X */
X
X#undef sysname /*"mysite"*/
X
X/* The maximum length of a single component in a filename */
X/* too bad there's not a portable way to get this.  Even dir.h doesn't work */
X
X#ifndef MAX_FNAME_LEN
X
X# define MAX_FNAME_LEN 14		/* normal for most unix */
X
X#endif /*MAX_FNAME_LEN*/
X
X/* System dependent definitions for calling the C compiler */
X
X/* How to call the C preprocessor on a file.  Usually either /lib/cpp or
X   cc -E, depending on the system */
X
X#define CPP "/lib/cpp"
X
X/* The pathname of the 'cc' C compiler */
X
X#define CCOMP "/bin/cc"
X
X/* Option to tell cc about where the "ucode.h" file can be found */
X/* Other system include files may go there as well */
X
X#define UCODEDIR "-I/v/src/nl"
X
X/* Location of the newsclip library -- if it isn't present the user
X   must provide it himself as a command line options */
X
X#define CLIPLIB "/v/src/nl/cliplib.a"
X/* The basename of the clip library, so that it can be found in the
X * current dir
X */
X#define CLIPBASE "cliplib.a"
X
X/* Up to 3 extra options for the C compiler.  You may want to do things
X   like set a stack size here.  Note that extra options can be given on
X   the ncc command line */
X
X#define EXTRAOPT1 "-Ml2"
X#define EXTRAOPT2 "-F"
X#define EXTRAOPT3 "2000"
X
X
X/* probably fixed, unless you have 64 bit ints */
X
X#ifdef INTS_32
X# define MAXINT	 2147483647
X#else
X# define MAXINT  32767				/* change this if need be */
X#endif
X
X/*
X * Don't change these unless you want to fine tune the program
X */
X
X#define MAX_FNAME 300			/* max length of file name */
X
X#define MAX_LLEN 300			/* max length of typical input line */	
X
X#define MAX_HLINES 50			/* max number of header lines */
X
X#define MAX_ARRAY 200			/* max elements in an array */
X
X#define MAX_NGLEN 80			/* max length of newgroup name */
X
X#define BITMAP_SIZE 1000		/* at most 8000 articles at a time? */
X
X#define MAX_OPTS 30			/* max options for C compiler or
X						user program */
X
X#define TBLOCK_SIZE 5000		/* size of chunks for use in temporary
X						allocator */
X#define MIN_TBLOCK TBLOCK_SIZE/64	/* smallest block to allocate */
X
X#define HLINE_SIZE 2500			/* buffer for header line */
X
END_OF_FILE
if test 3969 -ne `wc -c <'sysdefs.h'`; then
    echo shar: \"'sysdefs.h'\" unpacked with wrong size!
fi
# end of 'sysdefs.h'
fi
if test -f 'sysdefs.sysv' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sysdefs.sysv'\"
else
echo shar: Extracting \"'sysdefs.sysv'\" \(3951 characters\)
sed "s/^X//" >'sysdefs.sysv' <<'END_OF_FILE'
X/*
X * Various system dependent and fine-tuning #defines
X */
X
X
X/* define if ints are 32 bits, or more */
X
X#define	INTS_32		1
X/*
X * Define this macro according to whether your compiler takes ANSI C
X * style function prototypes or not.  (ie.  int f( int, char * ); )
X */
X
X#undef ANSI_PROTO 1
X
X#ifdef ANSI_PROTO
X# define AC(x)	x
X#else
X# define AC(x)	()
X#endif /*ANSI_PROTO*/
X
X/* Define these according to the directories of your system */
X
X#define NEWSLIB		"/usr/lib/news"		/* lib directory for news */
X#define	NEWSSPOOL	"/usr/spool/news"	/* spool dir for news */
X/* Define this to be the name of the file that contains the sizes for
X * the various distributions
X */
X#define DISTLIST	"distlist"	/* level of distrs */
X
X/*
X * Define this to be, in lower case, the domain name your news programs use
X * when they generate a From: address.  If you don't define this, you will
X * get your sitename appended with the default domain. (uucp unless you change
X * it below)
X */
X#undef MAILDOMAIN	"foo.uucp"		/* All lower case!!!! */
X
X#define DEFDOMAIN	 "uucp"
X
X
X/*
X * Some raw system-type defines
X */
X
X#undef NEED_SLIB 1			/* for systems without system V string
X					calls, such as V7 or BSD */
X
X#ifdef NEED_SLIB
X/* why don't the BSD people get with it and include these new names? */
X#define strchr index
X#define strrchr rindex
X#endif
X
X#define HAS_UNAME 1			/* for systems with the uname call */
X
X/*
X * Define this if you are a BSD system with the gethostname call.
X */
X#undef GETHOSTNAME 1				/* BSD gethostname call */
X
X/*
X * If you don't have this call, and you aren't a SYSV system with the
X * uname call, or a Xenix or other system with the /etc/systemid file,
X * then you should define the symbol 'sysname' to be a string with your
X * system name, as it appears in Xref: lines.  You can often do this on
X * older systems by saying '#include <whoami.h>'
X */
X
X#undef sysname "mysite"
X
X/* The maximum length of a single component in a filename */
X/* too bad there's not a portable way to get this.  Even dir.h doesn't work */
X
X#ifndef MAX_FNAME_LEN
X
X# define MAX_FNAME_LEN 14		/* normal for most unix */
X
X#endif /*MAX_FNAME_LEN*/
X
X/* System dependent definitions for calling the C compiler */
X
X/* How to call the C preprocessor on a file.  Usually either /lib/cpp or
X   cc -E, depending on the system */
X
X#define CPP "/lib/cpp"
X
X/* The pathname of the 'cc' C compiler */
X
X#define CCOMP "/bin/cc"
X
X/* Option to tell cc about where the "ucode.h" file can be found */
X/* Other system include files may go there as well */
X
X#define UCODEDIR "-I/usr/lib/news/newsclip"
X
X/* Location of the newsclip library -- if it isn't present the user
X   must provide it himself as a command line options */
X
X#define CLIPLIB "/usr/lib/news/newsclip/cliplib.a"
X/* The basename of the clip library, so that it can be found in the
X * current dir
X */
X#define CLIPBASE "cliplib.a"
X
X/* Up to 3 extra options for the C compiler.  You may want to do things
X   like set a stack size here.  Note that extra options can be given on
X   the ncc command line */
X
X#undef EXTRAOPT1
X#undef EXTRAOPT2
X#undef EXTRAOPT3 
X
X
X/* probably fixed, unless you have 64 bit ints */
X
X#ifdef INTS_32
X# define MAXINT	 2147483647
X#else
X# define MAXINT  32767				/* change this if need be */
X#endif
X
X/*
X * Don't change these unless you want to fine tune the program
X */
X
X#define MAX_FNAME 300			/* max length of file name */
X
X#define MAX_LLEN 300			/* max length of typical input line */	
X
X#define MAX_HLINES 50			/* max number of header lines */
X
X#define MAX_ARRAY 200			/* max elements in an array */
X
X#define MAX_NGLEN 60			/* max length of newgroup name */
X
X#define BITMAP_SIZE 1000		/* at most 8000 articles at a time? */
X
X#define MAX_OPTS 30			/* max options for C compiler or
X						user program */
X
X#define TBLOCK_SIZE 5000		/* size of chunks for use in temporary
X						allocator */
X#define MIN_TBLOCK TBLOCK_SIZE/64	/* smallest block to allocate */
X
X#define HLINE_SIZE 2500			/* buffer for header line */
X
END_OF_FILE
if test 3951 -ne `wc -c <'sysdefs.sysv'`; then
    echo shar: \"'sysdefs.sysv'\" unpacked with wrong size!
fi
# end of 'sysdefs.sysv'
fi
if test -f 'sysdefs.v7' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sysdefs.v7'\"
else
echo shar: Extracting \"'sysdefs.v7'\" \(3796 characters\)
sed "s/^X//" >'sysdefs.v7' <<'END_OF_FILE'
X
X/*
X * Various system dependent and fine-tuning #defines
X */
X
X
X/* define if ints are 32 bits, or more */
X
X#undef	INTS_32		1
X/*
X * Define this macro according to whether your compiler takes ANSI C
X * style function prototypes or not.  (ie.  int f( int, char * ); )
X */
X
X#undef ANSI_PROTO 1
X
X#ifdef ANSI_PROTO
X# define AC(x)	x
X#else
X# define AC(x)	()
X#endif /*ANSI_PROTO*/
X
X/* Define these according to the directories of your system */
X
X#define NEWSLIB		"/usr/lib/news"		/* lib directory for news */
X#define	NEWSSPOOL	"/usr/spool/news"	/* spool dir for news */
X/* Define this to be the name of the file that contains the sizes for
X * the various distributions
X */
X#define DISTLIST	"distlist"	/* level of distrs */
X
X/*
X * Define this to be, in lower case, the domain name your news programs use
X * when they generate a From: address.  If you don't define this, you will
X * get your sitename appended with the default domain. (uucp unless you change
X * it below)
X */
X#undef MAILDOMAIN	"foo.uucp"		/* All lower case!!!! */
X
X#define DEFDOMAIN	 "uucp"
X
X
X/*
X * Some raw system-type defines
X */
X
X#define NEED_SLIB 1			/* for systems without system V string
X					calls, such as V7 or BSD */
X
X#ifdef NEED_SLIB
X/* why don't the BSD people get with it and include these new names? */
X#define strchr index
X#define strrchr rindex
X#endif
X
X#undef HAS_UNAME 1			/* for systems with the uname call */
X
X/*
X * Define this if you are a BSD system with the gethostname call.
X */
X#undef GETHOSTNAME 1				/* BSD gethostname call */
X
X/*
X * If you don't have this call, and you aren't a SYSV system with the
X * uname call, or a Xenix or other system with the /etc/systemid file,
X * then you should define the symbol 'sysname' to be a string with your
X * system name, as it appears in Xref: lines.  You can often do this on
X * older systems by saying '#include <whoami.h>'
X */
X
X#ifndef sysname
X#define sysname "mysite"
X#endif
X
X#define MAX_FNAME_LEN 14		/* max length of filename component */
X
X/* System dependent definitions for calling the C compiler */
X
X/* How to call the C preprocessor on a file.  Usually either /lib/cpp or
X   cc -E, depending on the system */
X
X#define CPP "/lib/cpp"
X
X/* The pathname of the 'cc' C compiler */
X
X#define CCOMP "/bin/cc"
X
X/* Option to tell cc about where the "ucode.h" file can be found */
X/* Other system include files may go there as well */
X
X#define UCODEDIR "-I/usr/lib/news/newsclip"
X
X/* Location of the newsclip library -- if it isn't present the user
X   must provide it himself as a command line options */
X
X#define CLIPLIB "/usr/lib/news/newsclip/cliplib.a"
X/* The basename of the clip library, so that it can be found in the
X * current dir
X */
X#define CLIPBASE "cliplib.a"
X
X/* Up to 3 extra options for the C compiler.  You may want to do things
X   like set a stack size here.  Note that extra options can be given on
X   the ncc command line */
X
X#undef EXTRAOPT1
X#undef EXTRAOPT2
X#undef EXTRAOPT3 
X
X
X/* probably fixed, unless you have 64 bit ints */
X
X#ifdef INTS_32
X# define MAXINT	 2147483647
X#else
X# define MAXINT  32767				/* change this if need be */
X#endif
X
X/*
X * Don't change these unless you want to fine tune the program
X */
X
X#define MAX_FNAME 300			/* max length of file name */
X
X#define MAX_LLEN 300			/* max length of typical input line */	
X
X#define MAX_HLINES 50			/* max number of header lines */
X
X#define MAX_ARRAY 200			/* max elements in an array */
X
X#define MAX_NGLEN 60			/* max length of newgroup name */
X
X#define BITMAP_SIZE 1000		/* at most 8000 articles at a time? */
X
X#define MAX_OPTS 30			/* max options for C compiler or
X						user program */
X
X#define TBLOCK_SIZE 5000		/* size of chunks for use in temporary
X						allocator */
X#define MIN_TBLOCK TBLOCK_SIZE/64	/* smallest block to allocate */
X
X#define HLINE_SIZE 2500			/* buffer for header line */
X
END_OF_FILE
if test 3796 -ne `wc -c <'sysdefs.v7'`; then
    echo shar: \"'sysdefs.v7'\" unpacked with wrong size!
fi
# end of 'sysdefs.v7'
fi
if test -f 'ucode.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ucode.h'\"
else
echo shar: Extracting \"'ucode.h'\" \(3731 characters\)
sed "s/^X//" >'ucode.h' <<'END_OF_FILE'
X
X/* Declarations that run before the user program */
X/* Copyright 1989 Looking Glass Software Limited.  All Rights Reserved. */
X
X
X#ifdef INTS_32
Xtypedef int int32;
Xtypedef short int16;
X#else
Xtypedef long int32;
Xtypedef int int16;
X#endif
X
Xtypedef long datehold;
Xtypedef int newsgroup;
Xtypedef unsigned char byte;
Xtypedef unsigned char bool;
X
X/* fake definition for database pointer */
Xtypedef struct database_struct {
X		int foo;
X		} *dbptr;
X
Xtypedef struct user_name {
X	char *emailname;	/* the mail name, ie: user@site.foo */
X	char *fullname;		/* the full name or comment */
X	} username;
X
X
Xtypedef union d_union {
X	int	uinteger;	/* integer or newsgroup types */
X	long	udate;		/* date or long int types */
X	char	*ustring;	/* string types */
X	char	*regexp;	/* compiled regular expressions */
X	username *uusername;	/* a user name struct */
X	} datau;
X
X/* The struct for a multi-valued array.  The array is declared with only
X   one element, but in fact this structure can be allocated with enough
X   space for any number of elements, and C lets us access them without
X   checks. */
X
Xtypedef struct h_array {
X	int arsize;		/* number of elements in the array */
X	byte artype;		/* type of the elements in the array */
X	datau vals[1];		/* actually an extensible array, as allocated */
X	} array;
X
X/* database structure */
X
Xtypedef struct db_record {
X	char *name;
X	struct db_record *next;
X	byte hflags;
X	int intval;			/* the cell's value */
X	datehold access_date;		/* last time of access */
X	} userdb;
X
Xtypedef struct ng_record {
X	char *key;
X	struct ng_record *next;
X	byte hflags;
X	/* extras not important */
X	} ngrec;
X
X/* Struct defining header items to process */
Xstruct hitem_list {
X	char *hname;		/* name of header */
X	int dtype;		/* data type of header data */
X	char *delims;		/* delimiters to use if an array */
X	datau *var;		/* address of variable to put data into */
X	};
X
Xextern ngrec **ngarray;
Xextern int score;
X#define Reject -30000
X#define Accept 30000
X
X/* Macros used in the code */
X
X#define count(x)  (x->arsize)		/* array count */
X#define mailname(x)	(x->emailname)
X#define realname(x)	(x->fullname)	/* from id full name */
X#define ngn(x)	ngarray[x]->key		/* news group name */
X
X/* date constants */
X#define	day		(60*60*24l)
X#define	week		(7*day)
X#define	month		2629728l	/* special 'average' month 30.4 days */
X/* special text variables */
X#define signature	1
X#define included	2
X#define newtext		4
X#define	text		6	
X#define	body		7
X
X#define article_bytes art_bytes()
X
X/* function declarations for predefineds */
Xextern dbptr read_database();
Xextern write_database();
Xextern free_database();
Xextern dbptr fresh_database();
X
X#define chindex(str,dex)  str[dex]
X#define permstring allocstring
X
Xextern int db_lookup();			/* user database lookup fun */
Xextern userdb *db_create();		/* lookup and create function */
Xextern userdb *ufirst_rec();
X#define unext_rec(db,rec)	rec->next
X
X/* array creating routines */
Xextern array *uparse_array();
Xextern array *fresh_array();
X
X
X/* special externals, that might be repeated, for indirectly referenced
X   header items */
X
Xextern array *newsgroups;		/* always present */
Xextern array *distribution;		/* for Rdistribution */
Xextern array *followup_to;		/* for Rfollowup_to */
Xextern array *references;		/* for is_followup */
Xextern username *reply_to;		/* for Rreply_to */
Xextern username *sender;		/* For Rsender */
Xextern username *from;			/* for the two above */
X
X#define true 1
X#define false 0
X
X/* various nil constants */
X#define nilstring (char *) 0
X#define niluserid (username *)0
X#define nildatabase (dbptr)0
X#define nilnewsgroup (newsgroup)0
X#define nilarray (array *)0
X
X/* Functions for the IN and HAS operators all return booleans (ints) and
X   as such do not have to be declared */
END_OF_FILE
if test 3731 -ne `wc -c <'ucode.h'`; then
    echo shar: \"'ucode.h'\" unpacked with wrong size!
fi
# end of 'ucode.h'
fi
echo shar: End of archive 2 \(of 15\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 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