From: frank.kaefer@stasys.sta.sub.org (Frank Kaefer)
Newsgroups: de.comp.sources.os9,comp.os.os9
Subject: MNews Prerelease Part04/09
Date: 23 Dec 92 19:41:32 GMT
Followup-To: de.comp.sources.d
Organization: Stasys News Server, Starnberg, Germany
NNTP-Posting-Host: stasys.sta.sub.org

Submitted-by: Ulrich Dessauer <ud@Nightmare.ddt.sub.org>
Archive-name: mnews/part04

: ----- Cut here ----- Cut here ----- Cut here ----- Cut here -----
: Use  sh filename  to extract shell archive
: This shell archive contains following files:
:     'INEWS/inrd.c                                 1557 bytes'
:     'INEWS/limit.c                                1752 bytes'
:     'INEWS/list.c                                 1183 bytes'
:     'INEWS/mail.c                                 1947 bytes'
:     'INEWS/makh.c                                 2443 bytes'
:     'INEWS/mcan.c                                 2482 bytes'
:     'INEWS/mhead.c                                1363 bytes'
:     'INEWS/mid.c                                  3093 bytes'
:     'INEWS/misc.c                                 5154 bytes'
:     'INEWS/mit.c                                   314 bytes'
:     'INEWS/oart.c                                 1037 bytes'
:     'INEWS/ohist.c                                3849 bytes'
:     'INEWS/pargs.c                                6543 bytes'
:     'INEWS/pit.c                                  1246 bytes'
:     'INEWS/pmail.c                                2650 bytes'
: 
if test -f 'INEWS/inrd.c' ; then
  echo 'File INEWS/inrd.c already exists, overwriting it'
  del 'INEWS/inrd.c'
fi
echo Extracting \"'INEWS/inrd.c'\"
sed "s/^X//" >'INEWS/inrd.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	inrd.c_v $
X * Revision 1.2  91/05/22  13:04:04  ud
X * Added flag driven character conversation
X * 
X * Revision 1.1  90/08/31  15:34:22  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: inrd.c_v 1.2 91/05/22 13:04:04 ud Exp $";
X# endif		LINT
X# include	"inews.h"
X
Xint
Xreadin (fd, buf, len)
Xregister int fd;
Xregister char *buf;
Xregister int len;
X{
X	register int	n, siz;
X	register char	*ptr;
X
X	ptr = buf;
X	siz = 0;
X	while ((n = readln (fd, ptr, len)) > 0) {
X		siz += n;
X		len -= n;
X		if (catlines && (n > 1) && (ptr[n-2] == '\\') && (ptr[n-1] == '\n')) {
X			ptr += (n - 2);
X			len += 2;
X			siz -= 2;
X		} else if ((ptr[n-1] == '\n') || (len <= 0))
X			break;
X		else
X			ptr += n;
X	}
X	if (conv_it && doconv && (siz > 0))
X		conv_charset (buf, siz);
X	return (siz);
X}
X
Xchar *
Xreadbuf (fd, len)
Xregister int fd;
Xregister int *len;
X{
X	static char	*buf = NULL;
X	static int	size = 0;
X	register char	*ptr;
X	register int	n, siz;
X
X	siz = 0;
X	ptr = buf;
X	do {
X		if (siz >= size) {
X			size += 256;
X			if (! (buf = realloc (buf, size + 8))) {
X				size = 0;
X				return (NULL);
X			}
X			ptr = buf + siz;
X		}
X		if ((n = readln (fd, ptr, size - siz)) > 0) {
X			ptr += n;
X			siz += n;
X			if (*(ptr - 1) == '\n') {
X				if (catlines && (n + siz > 1) && (*(ptr - 2) == '\\')) {
X					ptr -= 2;
X					n -= 2;
X					siz -= 2;
X				} else
X					break;
X			}
X		} else {
X			*ptr = '\0';
X			break;
X		}
X	} while (1);
X	if (len)
X		*len = siz;
X	if (siz) {
X		*ptr = '\0';
X		if (conv_it && doconv)
X			conv_charset (buf, siz);
X		return (buf);
X	} else
X		return (NULL);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/limit.c' ; then
  echo 'File INEWS/limit.c already exists, overwriting it'
  del 'INEWS/limit.c'
fi
echo Extracting \"'INEWS/limit.c'\"
sed "s/^X//" >'INEWS/limit.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	limit.c_v $
X * Revision 1.1  90/08/31  15:34:26  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: limit.c_v 1.1 90/08/31 15:34:26 cs Exp $";
X# endif		LINT
X# include	<modes.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern char	*strdup ();
X
Xcharc *
Xget_limit_newsgroups ()
X{
X	register int	fd;
X	register char	*buf;
X	int		n;
X	charc		*tmp, *lhead, *lprev;
X	char		*prefix;
X	char		*ptmp, *ctmp;
X
X	lhead = NULL;
X	lprev = NULL;
X	if ((fd = open (CHK_FILE, S_IREAD)) < 0)
X		return (NULL);
X	catlines = TRUE;
X	while (buf = readbuf (fd, & n)) {
X		if ((n == 1) || (buf[0] == '#'))
X			continue;
X		buf[n - 1] = '\0';
X		prefix = skipc (buf, '\0');
X		if (!dists) {
X			if (Stricmp (buf, DST_WORLD))
X				continue;
X		} else {
X			tmp = dists;
X			while (tmp)
X				if (Strieql (tmp->text, buf))
X					break;
X				else
X					tmp = tmp->next;
X			if (!tmp)
X				continue;
X		}
X		ptmp = prefix;
X		while (ctmp = skipc (ptmp, ',')) {
X			tmp = lhead;
X			while (tmp)
X				if (Strieql (tmp->text, ptmp))
X					break;
X				else
X					tmp = tmp->next;
X			if ((!tmp) && (tmp = (charc *) malloc (sizeof (charc))))
X				if (tmp->text = strdup (ptmp)) {
X					tmp->next = NULL;
X					if (!lprev)
X						lhead = tmp;
X					else
X						lprev->next = tmp;
X					lprev = tmp;
X				} else
X					free ((char *) tmp);
X			if (!ctmp[0])
X				break;
X			ptmp = ctmp;
X		}
X	}
X	catlines = FALSE;
X	close (fd);
X	return (lhead);
X}
X
Xint
Xcheck_limit (lm, s)
Xregister charc *lm;
Xregister char *s;
X{
X	if (!lm)
X		return (TRUE);
X	while (lm) {
X		if (lm -> text[0] == '!') {
X			if (_cmpnam (s, lm -> text + 1, strlen (lm -> text + 1)) == 0) {
X				lm = NULL;
X				break;
X			}
X		} else if (_cmpnam (s, lm->text, strlen (lm->text)) == 0)
X			break;
X		lm = lm->next;
X	}
X	return (lm ? TRUE : FALSE);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/list.c' ; then
  echo 'File INEWS/list.c already exists, overwriting it'
  del 'INEWS/list.c'
fi
echo Extracting \"'INEWS/list.c'\"
sed "s/^X//" >'INEWS/list.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	list.c_v $
X * Revision 1.1  91/05/22  13:35:52  ud
X * Initial revision
X * 
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: list.c_v 1.1 91/05/22 13:35:52 ud Exp $";
X# endif		LINT
X# include	<stdio.h>
X# include	"inews.h"
X
X# ifdef		IN_MEMORY
Xvoid
Xadd_list (l, s, n)
Xlist **l;
Xchar *s;
Xint n;
X{
X	list		*tmp;
X	register list	*run;
X
X	if (tmp = (list *) malloc (sizeof (list)))
X		if (tmp->text = malloc (n + 2)) {
X			strncpy (tmp->text, s, n);
X			tmp->text[n] = '\0';
X			tmp->len =
X			tmp->siz = n;
X			tmp->next = NULL;
X			if (!*l)
X				*l = tmp;
X			else {
X				for (run = *l; run->next; run = run->next)
X					;
X				run->next = tmp;
X			}
X		} else {
X			free ((char *) tmp);
X			tmp = NULL;
X		}
X	if (! tmp) {
X		do_log ("Out of memory in add_list ()\n");
X		do_exit (1);
X	}
X}
X
Xvoid
Xfree_list (l)
Xregister list *l;
X{
X	register list	*tmp;
X
X	while (l) {
X		tmp = l;
X		l = l->next;
X		free (tmp->text);
X		free ((char *) tmp);
X	}
X}
X
Xlist *
Xget_file (fn)
Xchar *fn;
X{
X	FILE	*fp;
X	char	buf[256];
X	int	n;
X	list	*l;
X
X	if (! (fp = fopen (fn, "r")))
X		return (NULL);
X	l = NULL;
X	while (fgets (buf, 256, fp))
X		add_list (&l, buf, strlen (buf));
X	fclose (fp);
X	return (l);
X}
X# endif		/* IN_MEMORY */
__END__OF__THIS__FILE__
if test -f 'INEWS/mail.c' ; then
  echo 'File INEWS/mail.c already exists, overwriting it'
  del 'INEWS/mail.c'
fi
echo Extracting \"'INEWS/mail.c'\"
sed "s/^X//" >'INEWS/mail.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	mail.c_v $
X * Revision 1.3  91/05/22  13:18:02  ud
X * Added in memory option
X * 
X * Revision 1.2  90/12/01  15:48:39  ud
X * A new switch had been added to allow sending a copy of a mail
X * to the local postmaster
X * 
X * Revision 1.1  90/08/31  15:34:29  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: mail.c_v 1.3 91/05/22 13:18:02 ud Exp $";
X# endif		LINT
X# include	<stdio.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern FILE	*xpopen ();
X
Xvoid
Xmail_to (to, reply_to, subj, subjv, fn, comment)
Xchar *to, *reply_to, *subj, *subjv;
X# ifndef	IN_MEMORY
Xchar *fn;
X# else		/* IN_MEMORY */
Xlist *fn;
X# endif		/* IN_MEMORY */
Xchar **comment;
X{
X	FILE	*pp;
X# ifndef	IN_MEMORY
X	FILE	*fp;
X# else		/* IN_MEMORY */
X	list	*ltmp;
X# endif		/* IN_MEMORY */
X	char	buf[80];
X	char	*cmd;
X	int	t;
X
X	if (!(cmd = malloc (strlen (to) + 50)))
X		return;
X# ifdef		COPY_TO_POSTMASTER
X	sprintf (cmd, "rmail postmaster '%s'", to);
X# else		/* COPY_TO_POSTMASTER */
X	sprintf (cmd, "rmail '%s'", to);
X# endif		/* COPY_TO_POSTMASTER */
X	if (!(pp = xpopen (cmd, "w"))) {
X		do_log ("FATAL: Can't fork '%s'\n", cmd);
X		return;
X	}
X	fprintf (pp, "From: %s@%s (News Subsystem)\n", news_owner, fhost);
X	fprintf (pp, "To: %s\n", to);
X# ifdef		COPY_TO_POSTMASTER
X	fprintf (pp, "Cc: postmaster@%s\n", fhost);
X# endif		/* COPY_TO_POSTMASTER */
X	if (reply_to)
X		fprintf (pp, "Reply-To: %s\n", reply_to);
X	else
X		fprintf (pp, "Reply-To: Postmaster@%s\n", fhost);
X	fprintf (pp, "Subject: %s %s\n", subj, subjv ? subjv : "");
X	fprintf (pp, "\n");
X	if (comment && comment[0]) {
X		for (t=0;comment[t];++t)
X			fputs (comment[t], pp);
X		fputs ("\n\n", pp);
X	}
X# ifndef	IN_MEMORY
X	if (fn && (fp = fopen (fn, "r"))) {
X		while (fgets (buf, 78, fp))
X			fputs (buf, pp);
X		fclose (fp);
X	}
X# else		/* IN_MEMORY */
X	for (ltmp = fn; ltmp; ltmp = ltmp->next)
X		fwrite (ltmp->text, sizeof (char), ltmp->len, pp);
X# endif		/* IN_MEMORY */
X	pclose (pp);
X	free (cmd);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/makh.c' ; then
  echo 'File INEWS/makh.c already exists, overwriting it'
  del 'INEWS/makh.c'
fi
echo Extracting \"'INEWS/makh.c'\"
sed "s/^X//" >'INEWS/makh.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	makh.c_v $
X * Revision 1.1  90/08/31  15:34:33  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: makh.c_v 1.1 90/08/31 15:34:33 cs Exp $";
X# endif		LINT
X# include	<time.h>
X# include	"inews.h"
X
Xextern char	*index ();
Xextern char	*malloc ();
Xextern char	*strdup ();
X
Xcharc *
Xmake_head (id)
Xint id;
X{
X	charc		*dest;
X	register char	*p1, *from;
X	time_t		tim;
X
X	if (!(dest = (charc *) malloc (sizeof (charc))))
X		return (NULL);
X	dest->next = NULL;
X	switch (id) {
X		case H_PATH:
X			if (!(from = find_address ())) {
X				do_log ("No Path: Field found!\n");
X				do_exit (1);
X			}
X			if (!(dest->text = malloc (strlen (from) + strlen (hlines[H_PATH] + 2) + 6))) {
X				do_log ("Unable to alloc while creating Path:\n");
X				do_exit (1);
X			}
X			strcpy (dest->text, hlines[H_PATH] + 2);
X			strcat (dest->text, " ");
X			strcat (dest->text, from);
X			free (from);
X			break;
X		case H_FROM:
X			if (!(from = find_from (FALSE))) {
X				do_log ("No From: Field found!\n");
X				do_exit (1);
X			}
X			if (!(dest->text = malloc (strlen (from) + strlen (hlines[H_FROM] + 2) + 6))) {
X				do_log ("Can't alloc memory when creating From: Field\n");
X				do_exit (1);
X			}
X			strcpy (dest->text, hlines[H_FROM] + 2);
X			strcat (dest->text, " ");
X			strcat (dest->text, from);
X			break;
X		case H_SUBJECT:
X			if (!(dest->text = strdup ("Subject: [none]"))) {
X				do_log ("Can't alloc memory in Field Subject:\n");
X				do_exit (1);
X			}
X			break;
X		case H_NEWSGROUPS:
X			do_log ("No Newsgroups: Field found!\n");
X			do_exit (1);
X			break;
X		case H_MESSAGE_ID:
X			p1 = get_msgid ();
X			if (!(dest->text = malloc (strlen (p1) + strlen (hlines[H_MESSAGE_ID] + 2) + 6))) {
X				do_log ("Can't alloc memory in Field Message-ID:\n");
X				do_exit (1);
X			}
X			strcpy (dest->text, hlines[H_MESSAGE_ID] + 2);
X			strcat (dest->text, " ");
X			strcat (dest->text, p1);
X			break;
X		case H_DATE:
X			if (!(dest->text = malloc (60))) {
X				do_log ("Can't alloc memory in Field Date\n");
X				do_exit (1);
X			}
X			strcpy (dest->text, hlines[H_DATE] + 2);
X			strcat (dest->text, " ");
X			time (&tim);
X			strcat (dest->text, ntime (&tim));
X			break;
X		case H_LINES:
X			if (!(dest->text = malloc (strlen (hlines[H_LINES]) + 20))) {
X				do_log ("Can't alloc memory in Lines: field.\n");
X				do_exit (1);
X			}
X			sprintf (dest->text, "%s %d", hlines[H_LINES] + 2, lines);
X			break;
X		default:
X			free ((char *) dest);
X			dest = NULL;
X			break;
X	}
X	return (dest);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/mcan.c' ; then
  echo 'File INEWS/mcan.c already exists, overwriting it'
  del 'INEWS/mcan.c'
fi
echo Extracting \"'INEWS/mcan.c'\"
sed "s/^X//" >'INEWS/mcan.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	mcan.c_v $
X * Revision 1.1  90/08/31  15:34:37  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: mcan.c_v 1.1 90/08/31 15:34:37 cs Exp $";
X# endif		LINT
X# include	<modes.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern char	*rindex ();
Xextern char	*strdup ();
X
Xint
Xmay_cancel (fn)
Xchar *fn;
X{
X	int	fd;
X	char	*buf;
X	char	*from, *sender, *reply;
X	char	*tfrom, *tsender;
X	char	*news, *newsorig, *ptr;
X	int	n;
X	int	ret;
X
X	if (!(buf = malloc (strlen (newsdir) + strlen (fn) + 8))) {
X		do_log ("FATAL: Can't alloc in may_cancel()\n");
X		do_exit (1);
X	}
X	strcpy (buf, newsdir);
X	strcat (buf, "/");
X	strcat (buf, fn);
X	fd = open (buf, S_IREAD);
X	free (buf);
X	if (fd < 0)
X		return (TRUE);
X	if (!(tfrom = find_address_hl (H_FROM)))
X		tfrom = find_address_hl (H_REPLY_TO);
X	tsender = find_address_hl (H_SENDER);
X	if ((!tfrom) && (!tsender)) {
X		close (fd);
X		do_log ("No from/reply-to/sender in cancel message\n");
X		return (FALSE);
X	}
X	if ((!tfrom) || (!(ptr = rindex (tfrom, '@')))) {
X		if (tsender && (ptr = rindex (tsender, '@')))
X			newsorig = tsender;
X	} else
X		newsorig = tfrom;
X	news = NULL;
X	if (ptr && (Strnieql (news_owner, newsorig, strlen (news_owner)) && newsorig[strlen (news_owner)] == '@'))
X		news = strdup (ptr + 1);
X	from = NULL;
X	reply = NULL;
X	sender = NULL;
X	conv_it = TRUE;
X	while (buf = readbuf (fd, & n)) {
X		if (n == 1)
X			break;
X		buf[n - 1] = '\0';
X		if ((!from) && (Strnieql (buf, hlines[H_FROM] + 2, strlen (hlines[H_FROM] + 2))))
X			from = extract_address (buf);
X		else if ((!reply) && (Strnieql (buf, hlines[H_REPLY_TO] + 2, strlen (hlines[H_REPLY_TO] + 2))))
X			reply = extract_address (buf);
X		else if ((!sender) && (Strnieql (buf, hlines[H_SENDER] + 2, strlen (hlines[H_SENDER] + 2))))
X			sender = extract_address (buf);
X	}
X	conv_it = FALSE;
X	close (fd);
X	if (reply)
X		if (!from)
X			from = reply;
X		else
X			free (reply);
X	ret = FALSE;
X	if (tsender && sender)
X		ret = Strieql (sender, tsender);
X	if ((!ret) && (tsender && from))
X		ret = Strieql (from, tsender);
X	if ((!ret) && (tfrom && sender))
X		ret = Strieql (sender, tfrom);
X	if ((!ret) && (tfrom && from))
X		ret = Strieql (from, tfrom);
X	if ((!ret) && news) {
X		if ((!sender) || (!(ptr = rindex (sender, '@'))))
X			if (from)
X				ptr = rindex (from, '@');
X		if (ptr)
X			ret = Strieql (news, ptr + 1);
X	}
X	if (from)
X		free (from);
X	if (tfrom)
X		free (tfrom);
X	if (sender)
X		free (sender);
X	if (tsender)
X		free (tsender);
X	if (news)
X		free (news);
X	return (ret);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/mhead.c' ; then
  echo 'File INEWS/mhead.c already exists, overwriting it'
  del 'INEWS/mhead.c'
fi
echo Extracting \"'INEWS/mhead.c'\"
sed "s/^X//" >'INEWS/mhead.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	mhead.c_v $
X * Revision 1.1  90/08/31  15:34:42  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: mhead.c_v 1.1 90/08/31 15:34:42 cs Exp $";
X# endif		LINT
X# include	<c8type.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern char	*strdup ();
X
Xcharc *
Xsplit_fields (s, lc)
Xchar *s;
Xint lc;
X{
X	charc		*top, *tmp, *act;
X	char		*buf;
X	register char	*sav, *ptr, *p;
X	int		len;
X
X	top = NULL;
X	act = NULL;
X	if (!(buf = strdup (s))) {
X		do_log ("Can't alloc memory in split_fields\n");
X		do_exit (1);
X	}
X	ptr = buf;
X	while (is8space (*ptr) || (*ptr == ','))
X		++ptr;
X	while (*ptr) {
X		sav = ptr;
X		while (*ptr && (!is8space (*ptr)) && (*ptr != ','))
X			++ptr;
X		if (*ptr) {
X			*ptr++ = '\0';
X			while (is8space (*ptr) || (*ptr == ','))
X				++ptr;
X		}
X		if (!sav[0])
X			continue;
X		if (!(tmp = (charc *) malloc (sizeof (charc)))) {
X			do_log ("Can't alloc memory during split_fields\n");
X			do_exit (1);
X		}
X		len = strlen (sav);
X		if (len < 10)
X			len = 10;
X		len += 2;
X		if (!(tmp->text = malloc (len))) {
X			do_log ("Can't alloc memory during split_fields\n");
X			do_exit (1);
X		} else
X			strcpy (tmp->text, sav);
X		p = tmp->text;
X		if (lc)
X			while (*p) {
X				*p = to8lower (*p);
X				++p;
X			}
X		tmp->nr = 0;
X		tmp->next = NULL;
X		if (!act)
X			top = tmp;
X		else
X			act->next = tmp;
X		act = tmp;
X	}
X	free (buf);
X	return (top);
X}
X
__END__OF__THIS__FILE__
if test -f 'INEWS/mid.c' ; then
  echo 'File INEWS/mid.c already exists, overwriting it'
  del 'INEWS/mid.c'
fi
echo Extracting \"'INEWS/mid.c'\"
sed "s/^X//" >'INEWS/mid.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	mid.c_v $
X * Revision 1.3  91/05/22  13:35:19  ud
X * Added short message-ids
X * 
X * Revision 1.2  91/01/02  21:23:12  ud
X * Added ndbm for history support
X * 
X * Revision 1.1  90/08/31  15:34:45  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: mid.c_v 1.3 91/05/22 13:35:19 ud Exp $";
X# endif		LINT
X# include	<c8type.h>
X# include	<modes.h>
X# include	<time.h>
X# include	"inews.h"
X# include	"hist.h"
X
X# define	SEQ		".seq"
X
Xextern char	*malloc ();
Xextern char	*strdup ();
X
Xstatic int	yetcreated = FALSE;
Xstatic char	msgid[128];
X
X# ifdef		SHORT_MSGID
Xstatic char	msgmap[] = {
X	'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',',
X	'-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8',
X	'9', ':', ';', '=', '?', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
X	'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
X	'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '^', '_', '`',
X	'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
X	'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
X	'y', 'z', '{', '|', '}', '~'
X};
X# endif		/* SHORT_MSGID */
X
Xchar *
Xget_msgid ()
X{
X	int		fd;
X	unsigned int	id;
X	register char	*ptr;
X
X	if (yetcreated)
X		return (msgid);
X	if (access (SEQ, 0) < 0) {
X		fd = create (SEQ, S_IWRITE, 03);
X		id = 0;
X	} else if ((fd = open (SEQ, S_IREAD | S_IWRITE)) != -1) {
X		if (read (fd, &id, sizeof (int)) != sizeof (int))
X			id = 0;
X		lseek (fd, 0, 0);
X	}
X	++id;
X	if (fd != -1) {
X		write (fd, &id, sizeof (int));
X		close (fd);
X	}
X	yetcreated = TRUE;
X# ifndef	SHORT_MSGID
X	sprintf (msgid, "<%d@%s>", id, fhost);
X# else		/* SHORT_MSGID */
X	ptr = msgid;
X	*ptr++ = '<';
X	while (id != 0) {
X		*ptr++ = msgmap[id % sizeof (msgmap)];
X		id /= sizeof (msgmap);
X	}
X	sprintf (ptr, "@%s>", fhost);
X# endif		/* SHORT_MSGID */
X	return (msgid);
X}
X
Xvoid
Xset_msgid (s)
Xchar *s;
X{
X	if (!yetcreated) {
X		strncpy (msgid, s, 120);
X		yetcreated = TRUE;
X	}
X}
X
Xvoid
Xclear_msgid ()
X{
X	yetcreated = FALSE;
X}
X
Xchar *
Xexists_message_id (id, tim)
Xchar *id;
Xtime_t *tim;
X{
X# ifndef	USE_NDBM
X	register char	*p1, *p2;
X	char		*buf;
X	int		fd;
X	char		*sav;
X	char		*fn;
X	char		*flag;
X	int		n;
X
X	if ((fd = open_hist (id, S_IREAD)) < 0)
X		return (NULL);
X	while (buf = readbuf (fd, & n)) {
X		buf[n-1] = '\0';
X		sav = skipc (buf, '\0');
X		flag = skipc (sav, '\0');
X		if (Mideql (sav, id)) {
X			fn = skipc (flag, '\0');
X			break;
X		}
X	}
X	close (fd);
X	if (n > 0) {
X		*tim = atol (buf);
X		skipc (fn, '\0');
X		p1 = buf;
X		p2 = fn;
X		while (*p2)
X			*p1++ = *p2++;
X		*p1 = '\0';
X		return (strdup (buf));
X	}
X	return (NULL);
X# else		/* USE_NDBM */
X	register char	*ptr;
X
X	if (!(db = open_hist (S_IREAD)))
X		return (NULL);
X	key.dptr = lower_mid (id);
X	key.dsize = strlen (id) + 1;
X	dat = dbm_fetch (db, key);
X	dbm_close (db);
X	if (dat.dptr == NULL)
X		return (NULL);
X	memcpy (&hist, dat.dptr, sizeof (history));
X	skipc (hist.fns, '\0');
X	*tim = hist.tim;
X	return (strdup (hist.fns));
X# endif		/* USE_NDBM */
X}
X
Xvoid
Xcheck_message_id (id)
Xchar *id;
X{
X	time_t	dummy;
X
X	if (exists_message_id (id, &dummy)) {
X		do_log ("Duplicated article received '%s'\n", id);
X		do_exit (0);
X	}
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/misc.c' ; then
  echo 'File INEWS/misc.c already exists, overwriting it'
  del 'INEWS/misc.c'
fi
echo Extracting \"'INEWS/misc.c'\"
sed "s/^X//" >'INEWS/misc.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	misc.c_v $
X * Revision 1.2  91/05/22  13:09:21  ud
X * Added 8 bit support and assembler routines
X * 
X * Revision 1.1  90/08/31  15:34:49  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: misc.c_v 1.2 91/05/22 13:09:21 ud Exp $";
X# endif		LINT
X# include	<c8type.h>
X# include	<modes.h>
X# include	<time.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern char	*strdup ();
X
Xstatic char	*months[] = {
X	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
X	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL
X};
X
X# ifndef	USE_ASM	
Xchar *
Xskipc (s, c)
Xregister char *s;
Xregister char c;
X{
X	if (c)
X		while (*s && (*s != c))
X			++s;
X	else
X		while (*s && (!is8space (*s)))
X			++s;
X	if (*s) {
X		*s++ = '\0';
X		while (is8space (*s))
X			++s;
X	}
X	return (s);
X}
X
Xchar *
Xskipn (s, c)
Xregister char *s;
Xregister char c;
X{
X	if (c)
X		while (*s && (*s != c))
X			++s;
X	else
X		while (*s && (!is8space (*s)))
X			++s;
X	if (*s) {
X		++s;
X		while (is8space (*s))
X			++s;
X	}
X	return (s);
X}
X# else		/* USE_ASM */
X# asm
Xxskip:
X	move.l	d0,a0
X	andi.l	#255,d1
X	tst.b	d1
X	bne.b	skip2
Xl1
X	tst.b	(a0)
X	beq.b	fin
X	move.b	(a0),d1
X	lea.l	_ch8codes(a6),a1
X	btst.b	#4,0(a1,d1)
X	bne.b	fin
X	adda.l	#1,a0
X	bra.b	l1
Xskip2
X	tst.b	(a0)
X	beq.b	fin
X	cmp.b	(a0),d1
X	beq.b	fin
X	adda.l	#1,a0
X	bra.b	skip2
Xfin
X	tst.b	(a0)
X	beq.s	finfin
X	tst.b	d2
X	beq.s	no_clr
X	clr.b	(a0)
Xno_clr
X	addq.l	#1,a0
Xfinfin
X	tst.b	(a0)
X	beq.b	lastfin
X	move.b	(a0),d2
X	lea.l	_ch8codes(a6),a1
X	btst.b	#4,0(a1,d2)
X	beq.b	lastfin
X	adda.l	#1,a0
X	bra.b	finfin
Xlastfin
X	move.l	a0,d0
X	rts
X*
Xskipc:
X	move.l	d2,-(sp)
X	move.l	#1,d2
Xdoit
X	bsr	xskip
X	move.l	(sp)+,d2
X	rts
Xskipn:
X	move.l	d2,-(sp)
X	clr.l	d2
X	bra	doit
X# endasm
X# endif		/* USE_ASM */
X
Xchar *
Xitoa (n)
Xint n;
X{
X	static char	nbuf[34];
X	register char	*p;
X	int		prefix;
X
X	p = nbuf + 32;
X	*p = '\0';
X	if (n == 0)
X		*--p = '0';
X	else {
X		if (n < 0) {
X			n = -n;
X			prefix = -1;
X		} else
X			prefix = 1;
X		while (n > 0) {
X			*--p = (n % 10) + '0';
X			n = n / 10;
X		}
X		if (prefix < 0)
X			*--p = '-';
X	}
X	return (p);
X}
X
Xvoid
Xfree_field (fld)
Xregister charc *fld;
X{
X	register charc	*tmp;
X
X	while (fld) {
X		tmp = fld->next;
X		free (fld->text);
X		free ((char *) fld);
X		fld = tmp;
X	}
X}
X
Xcharc *
Xcopy_field (fld)
Xregister charc *fld;
X{
X	register charc	*hd, *tmp, *cur;
X	register int	err;
X
X	cur = NULL;
X	err = 0;
X	while (fld) {
X		if (tmp = (charc *) malloc (sizeof (charc)))
X			if (tmp->text = strdup (fld->text)) {
X				tmp->nr = fld->nr;
X				tmp->next = NULL;
X				if (!cur)
X					hd = tmp;
X				else
X					cur->next = tmp;
X				cur = tmp;
X			} else {
X				++err;
X				break;
X			}
X		else {
X			++err;
X			break;
X		}
X		fld = fld->next;
X	}
X	if (err && hd) {
X		free_field (hd);
X		hd = NULL;
X	}
X	return (hd);
X}
X		
Xchar *
Xcatcharc (hd, sp)
Xcharc *hd;
Xchar *sp;
X{
X	register charc	*tmp;
X	register char	*p1, *p2;
X	char		*ptr;
X	int		siz;
X	register int	slen;
X
X	slen = strlen (sp);
X	tmp = hd;
X	siz = 0;
X	while (tmp) {
X		siz += strlen (tmp->text) + slen + 4;
X		tmp = tmp->next;
X	}
X	if (!(ptr = malloc (siz + 10)))
X		return (NULL);
X	p1 = ptr;
X	tmp = hd;
X	while (tmp) {
X		if (tmp != hd) {
X			p2 = sp;
X			while (*p2)
X				*p1++ = *p2++;
X		}
X		p2 = tmp->text;
X		while (*p2)
X			*p1++ = *p2++;
X		tmp = tmp->next;
X	}
X	*p1 = '\0';
X	return (ptr);
X}
X
Xchar *
Xget_realfilename (fn, fd)
Xchar *fn;
Xint *fd;
X{
X	char	*newfn;
X	int	len;
X	int	n;
X
X	if (!(newfn = malloc (512)))
X		return (NULL);
X	if ((*fd = open (fn, S_IREAD)) < 0) {
X		free (newfn);
X		return (NULL);
X	}
X	len = strlen (LINK_ID);
X	if (read (*fd, newfn, len) == len) {
X		if (Strneql (newfn, LINK_ID, len)) {
X			if ((n = readln (*fd, newfn, 500)) > 0) {
X				newfn[n - 1] = '\0';
X				close (*fd);
X				if ((*fd = open (newfn, S_IREAD)) < 0) {
X					free (newfn);
X					newfn = NULL;
X				}
X				return (newfn);
X			} else {
X				free (newfn);
X				close (*fd);
X				return (NULL);
X			}
X		} else {
X			lseek (*fd, 0, 0);
X			strcpy (newfn, fn);
X			return (newfn);
X		}
X	} else {
X		close (*fd);
X		free (newfn);
X		return (NULL);
X	}
X}
X
Xchar *
Xmake_realfilename (s, n, fd)
Xchar *s;
Xint n;
Xint *fd;
X{
X	char	*rfn, *fn;
X
X	if (!(rfn = malloc (strlen (s) + 40)))
X		return (NULL);
X	sprintf (rfn, "%s/%d", s, n);
X	make_fn (rfn);
X	fn = get_realfilename (rfn, fd);
X	free (rfn);
X	return (fn);
X}
X
Xchar *
Xntime (tim)
Xtime_t *tim;
X{
X	struct tm	*tt;
X	static char	tbuf[64];
X
X	if (tt = gmtime (tim)) {
X		sprintf (tbuf, "%d %s %04d %02d:%02d:%02d GMT",
X			tt->tm_mday,
X			months[tt->tm_mon],
X			tt->tm_year + 1900,
X			tt->tm_hour,
X			tt->tm_min,
X			tt->tm_sec);
X	} else
X		strcpy (tbuf, "");
X	return (tbuf);
X}
X
X# ifndef	SEND_WORLD
Xint
Xdist_is_world ()
X{
X	charc		*hd;
X	charc		*ptr;
X	register charc	*tmp;
X	int		ret;
X
X	ret = TRUE;
X	if (hd = get_header_line (H_DISTRIBUTION))
X		if (ptr = split_fields (hd->text)) {
X			ret = FALSE;
X			for (tmp = ptr; tmp; tmp = tmp->next)
X				if (Strieql (tmp->text, DST_WORLD)) {
X					ret = TRUE;
X					break;
X				}
X			free_field (ptr);
X		}
X	if (ret)
X		block_forward = TRUE;
X	return (ret);
X}
X# endif		/* SEND_WORLD */
X
X# ifdef		HASH_SEARCH
Xhash_t
Xcalc_hash (str, icase)
Xregister char *str;
Xregister int icase;
X{
X	register hash_t	ret;
X
X	ret = 0;
X	while (*str)
X		ret += (icase ? tolower (*str++) : *str++) & 0xff;
X	return (ret);
X}
X# endif		/* HASH_SEARCH */
__END__OF__THIS__FILE__
if test -f 'INEWS/mit.c' ; then
  echo 'File INEWS/mit.c already exists, overwriting it'
  del 'INEWS/mit.c'
fi
echo Extracting \"'INEWS/mit.c'\"
sed "s/^X//" >'INEWS/mit.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	mit.c_v $
X * Revision 1.1  90/08/31  15:34:54  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: mit.c_v 1.1 90/08/31 15:34:54 cs Exp $";
X# endif		LINT
X# include	"inews.h"
X
Xvoid
Xmail_it (rec)
Xchar *rec;
X{
X	mail_to (rec, NULL, "This is a moderated group", NULL, newstmp, NULL);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/oart.c' ; then
  echo 'File INEWS/oart.c already exists, overwriting it'
  del 'INEWS/oart.c'
fi
echo Extracting \"'INEWS/oart.c'\"
sed "s/^X//" >'INEWS/oart.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log$
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id$";
X# endif		LINT
X# include	<c8type.h>
X# include	<modes.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
X
Xstatic char	*nfn = NULL;
X
Xchar *
Xopen_article (fn, readit)
Xchar *fn;
Xint readit;
X{
X	register char	*p1, *p2;
X	register int	n;
X	int		fd;
X	char		buf[32];
X
X	if (! nfn)
X		if (! (nfn = malloc (1024)))
X			return (NULL);
X	for (p1 = fn, p2 = nfn, n = 0; *p1;)
X		if ((*p1 == '/') || (*p1 == '.')) {
X			*p2++ = '/';
X			++p1;
X			n = 0;
X		} else {
X			if ((! is8alnum (*p1)) && (! index ("$_.", *p1))) {
X				++p1;
X				*p2++ = '_';
X			} else
X				*p2++ = *p1++;
X			if (++n > 26)
X				while (*p1 && (*p1 != '/'))
X					++p1;
X		}
X	*p2 = '\0';
X	if (readit && ((fd = open (nfn, S_IREAD)) != -1)) {
X		n = strlen (LINK_ID);
X		if ((read (fd, buf, n) == n) && Strneql (buf, LINK_ID, n))
X			if ((n = read (fd, nfn, 1000)) > 0) {
X				nfn[n] = '\0';
X				if (access (nfn, 0) == -1)
X					n = -1;
X			} else
X				n = -1;
X		close (fd);
X		if (n < 0)
X			return (open_article (fn, FALSE));
X	}
X	return (nfn);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/ohist.c' ; then
  echo 'File INEWS/ohist.c already exists, overwriting it'
  del 'INEWS/ohist.c'
fi
echo Extracting \"'INEWS/ohist.c'\"
sed "s/^X//" >'INEWS/ohist.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	ohist.c_v $
X * Revision 1.4  91/05/22  13:07:32  ud
X * - Included assembler routines
X * - better ndbm support
X * 
X * Revision 1.3  91/01/02  21:24:47  ud
X * Added ndbm support for history, optional
X * 
X * Revision 1.2  90/12/01  15:45:16  ud
X * Changed generating of filenames for historyfiles to hashing mode
X * 
X * Revision 1.1  90/08/31  15:34:57  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: ohist.c_v 1.4 91/05/22 13:07:32 ud Exp $";
X# endif		LINT
X# include	<c8type.h>
X# include	<modes.h>
X# include	<direct.h>
X# include	"inews.h"
X# include	"hist.h"
X
X# ifndef	USE_ASM
Xint
XMideql (id1, id2)
Xregister char *id1, *id2;
X{
X	register int	is_local;
X
X	is_local = TRUE;
X	while (*id1 && *id2)
X		if (is_local ? (*id1 != *id2) : (to8lower (*id1) != to8lower (*id2)))
X			return (FALSE);
X		else {
X			if (*id1 == '@')
X				is_local = FALSE;
X			++id1;
X			++id2;
X		}
X	return (!(*id1 || *id2));
X}
X# else		/* USE_ASM */
X# asm
XMideql:
X	move.l	d2,-(sp)
X	move.l	d0,a0
X	move.l	d1,a1
X	moveq.l	#1,d0
Xloop
X	tst.b	(a0)
X	beq.b	fin
X	tst.b	(a1)
X	beq.b	fin
X	tst.b	d0
X	beq	no_sense
X	move.b	(a0),d1
X	cmp.b	(a1),d1
X	bne.b	fin
X	cmp.b	#$40,d1
X	bne.s	reloop
X	clr.l	d0
Xreloop
X	addq.l	#1,a0
X	addq.l	#1,a1
X	bra.b	loop
Xno_sense
X	move.b	(a0),d1
X	cmp.b	#$5a,d1
X	bgt.s	no1
X	cmp.b	#$41,d1
X	blt.s	no1
X	and.b	#$20,d1
Xno1
X	move.b	(a1),d2
X	cmp.b	#$5a,d2
X	bgt.s	no2
X	cmp.b	#$41,d2
X	blt.s	no2
X	and.b	#$20,d2
Xno2
X	cmp.b	d0,d1
X	beq.b	reloop
Xfin
X	move.l	#1,d0
X	move.b	(a0),d1
X	sub.b	(a1),d1
X	beq.s	Okay
X	clr.l	d0
XOkay
X	move.l	(sp)+,d2
X	rts
X# endasm
X# endif		/* USE_ASM */
X
X# ifndef	USE_NDBM
Xint
Xopen_hist (id, mode)
Xchar *id;
Xint mode;
X{
X	int			fd;
X	char			fn[80];
X	register int		is_local;
X	register char		*ptr;
X	register unsigned int	count;
X
X	ptr = id;
X	count = 0;
X	is_local = TRUE;
X	while (*ptr) {
X		count += (is_local ? *ptr : to8lower (*ptr)) & 0xff;
X		if (*ptr++ == '@')
X			is_local = FALSE;
X	}
X	sprintf (fn, HIST_FILE, count % HIST_MAXIMUM);
X	if ((fd = open (fn, mode)) < 0)
X		if (mode & S_IWRITE)
X			fd = create (fn, mode, 03);
X	return (fd);
X}
X# else		/* USE_NDBM */
Xchar *
Xlower_mid (id)
Xchar *id;
X{
X	static int	siz = 0;
X	static char	*buf = NULL;
X	int		len;
X	register char	*p1, *p2;
X	register int	is_local;
X
X	if ((len = strlen (id)) >= siz) {
X		siz = len + 32;
X		if (!(buf = realloc (buf, siz + 2)))
X			return (NULL);
X	}
X	is_local = TRUE;
X	p1 = id;
X	p2 = buf;
X	while (*p1) {
X		*p2++ = is_local ? *p1 : to8lower (*p1);
X		if (*p1++ == '@')
X			is_local = FALSE;
X	}
X	*p2 = '\0';
X	return (buf);
X}
X
Xvoid
Xfill_hist ()
X{
X	dat.dsize = strlen (hist.fns) + 1 + sizeof (int) + sizeof (time_t);
X	dat.dptr = (char *) &hist;
X}
X
Xstatic void
Xcheck_history (suffix)
Xchar *suffix;
X{
X	int		fd, fdo;
X	char		fn[40];
X	char		*buf;
X	int		n, siz;
X	struct fildes	fdes;
X
X	strcpy (fn, HISTORY);
X	strcat (fn, suffix);
X	if ((fd = open (fn, 0)) != -1) {
X		if (_gs_gfd (fd, &fdes, sizeof (struct fildes)) != -1) {
X			for (t = 0; t < 48; ++t)
X				if (! (fdes.fdseg[t].addr[0] ||
X				       fdes.fdseg[t].addr[0] ||
X				       fdes.fdseg[t].addr[0]))
X				       	break;
X			if (t > 43) {
X				do_log ("%s has %d file segments\n", fn, t);
X				if (rename (fn, TEMP_FILE) == 0) {
X					if ((fdo = create (fn, S_IWRITE | S_ISIZE, 013, _gs_size (fd)) != -1) {
X						siz = 5000;
X						do {
X							if (! (buf = malloc (siz + 32)))
X								siz -= 1000;
X						} while ((! buf) && (siz > 0));
X						if (! buf) {
X							buf = &c;
X							siz = 1;
X						}
X						while ((n = read (fd, buf, siz)) > 0)
X							write (fdo, buf, n);
X						close (fdo);
X						if (siz > 1)
X							free (buf);
X					} else
X						rename (TEMP_FILE, fn);
X				} else
X					do_log ("rename (%s, %s) failed\n", fn, TEMP_FILE);
X		}
X		close (fd);
X	}
X}
X
Xvoid
Xcheck_history_size ()
X{
X	check_history (DIREXT);
X	check_history (PAGEXT);
X}
X
XDBM *
Xopen_hist (mode)
Xint mode;
X{
X	return (dbm_open (HISTORY, mode, 013));
X}
X# endif		/* USE_NDBM */
__END__OF__THIS__FILE__
if test -f 'INEWS/pargs.c' ; then
  echo 'File INEWS/pargs.c already exists, overwriting it'
  del 'INEWS/pargs.c'
fi
echo Extracting \"'INEWS/pargs.c'\"
sed "s/^X//" >'INEWS/pargs.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	pargs.c_v $
X * Revision 1.3  91/05/22  13:10:38  ud
X * Added ndbm file checks
X * 
X * Revision 1.2  90/12/01  15:42:35  ud
X * Added new option for rebuildig history
X * Currently only for converting from old format to new
X * hashing format possible
X * 
X * Revision 1.1  90/08/31  15:35:01  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: pargs.c_v 1.3 91/05/22 13:10:38 ud Exp $";
X# endif		LINT
X# include	"inews.h"
X
Xextern char	*rindex ();
Xextern char	*strdup ();
X
Xstatic char	*help[] = {
X	"Syntax: inews [<opts>]\n",
X	"Function: stores and forwards news articles\n",
X	"Options:\n",
X	"     -a         runs in admin mode (execute control-messages)\n",
X	"     -e=<days>  removes all article that are longer than <days> on the machine\n",
X	"     -E=<days>  remove older entries from the history file (to use with `-e')\n",
X	"     -r         rebuilds the active file\n",
X	"     -H         rebuilds all history files (warning! slow!)\n",
X# ifdef		USE_NDBM
X	"     -C         check DBM history files for file segment list\n",
X# endif		/* USE_NDBM */
X	"     -h         create a new message (insert missing header lines)\n",
X	"     -t         enable translation of 8 bit chars even w/o `-h' option\n",
X	"     -D         enable auto.determination of distribution w/o `-h'\n",
X	"     -v         verbose mode, prints log messages on screen, too\n",
X	"     -c=<ctrl>  send <ctrl> as control message\n",
X	"     -g=<grps>  specify list of groups\n",
X	"     -d=<dist>  specify list of distribution(s)\n",
X	"\n",
X	"     -M=<msgid> retreives the filename for this message id and writes it\n",
X	"                to stdout (more -M's can be used to get more filenames).\n",
X	"     -R         respool droped articles\n",
X	"\n",
X	"     -m=<mode>  mode of user-interface (mode can be `read' or `write'\n",
X	"     -p=<rec>   if mode is <mail> these are the receivers\n",
X	NULL
X};
X
Xstatic void
Xusage ()
X{
X	register int	t;
X
X	for (t=0;help[t];++t)
X		writeln (2, help[t], strlen (help[t]));
X}
X
Xvoid
Xparse_args (ac, av)
Xint ac;
Xchar *av[];
X{
X	register int	t;
X	register char	*ptr;
X	charc		*tmp, *t2;
X	int		muid, ruid;
X	char		*expire, *exphist;
X	char		*ctrlmsg;
X	int		rebuild_active;
X	int		rebuild_history;
X	int		check_dbmsiz;
X	char		*srcfn;
X	charc		*retr_msgid;
X	int		mode;
X	int		rev_conv;
X	int		do_respool;
X
X	isadm = FALSE;
X	expire = NULL;
X	exphist = NULL;
X	ctrlmsg = NULL;
X	rebuild_active = FALSE;
X	rebuild_history = FALSE;
X	check_dbmsiz = FALSE;
X	retr_msgid = NULL;
X	if (ptr = rindex (av[0], '/'))
X		++ptr;
X	else
X		ptr = av[0];
X	mode = (! _strccmp (ptr, "mnews") ? M_READ : M_NONE);
X	doconv = FALSE;
X	conv_it = FALSE;
X	rev_conv = FALSE;
X	do_respool = FALSE;
X	srcfn = NULL;
X	crthd = FALSE;
X	ins_dist = FALSE;
X	for (t=1;t<ac;++t)
X		if (av[t][0] == '-') {
X			ptr = av[t] + 1;
X			while (*ptr) {
X				switch (*ptr) {
X					case 'v':
X						verbose = TRUE;
X 						break;
X					case 'h':
X						crthd = TRUE;
X						/* Fall through ... */
X					case 't':
X						doconv = TRUE;
X						break;
X					case 'D':
X						ins_dist = TRUE;
X						break;
X					case 'r':
X						rebuild_active = TRUE;
X						break;
X					case 'H':
X						rebuild_history = TRUE;
X						break;
X# ifdef		USE_NDBM
X					case 'C':
X						check_dbmsiz = TRUE;
X						break;
X# endif		/* USE_NDBM */
X					case 'e':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						expire = ptr;
X						while (*ptr)
X							++ptr;
X						break;
X					case 'E':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						exphist = ptr;
X						while (*ptr)
X							++ptr;
X						break;
X					case 'c':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						ctrlmsg = ptr;
X						while (*ptr)
X							++ptr;
X						break;
X					case 'g':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						tmp = split_fields (ptr, TRUE);
X						if (tmp) {
X							if (!ngs)
X								ngs = tmp;
X							else {
X								t2 = ngs;
X								while (t2->next)
X									t2 = t2->next;
X								t2->next = tmp;
X							}
X						}
X						while (*ptr)
X							++ptr;
X						break;
X					case 'd':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						tmp = split_fields (ptr, TRUE);
X						if (tmp) {
X							if (!dists)
X								dists = tmp;
X							else {
X								t2 = dists;
X								while (t2->next)
X									t2 = t2->next;
X								t2->next = tmp;
X							}
X						}
X						while (*ptr)
X							++ptr;
X						break;
X					case 'a':
X						break;
X					case 'M':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						if ((tmp = (charc *) malloc (sizeof (charc))) && (tmp->text = strdup (ptr))) {
X							tmp->next = NULL;
X							if (!retr_msgid)
X								retr_msgid = tmp;
X							else {
X								for (t2 = retr_msgid; t2->next; t2 = t2->next)
X									;
X								t2->next = tmp;
X							}
X						} else
X							exit (_errmsg (1, "Out of memory.\n"));
X						while (*ptr)
X							++ptr;
X						break;
X					case 'R':
X						do_respool = TRUE;
X						break;
X					case 'm':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						if (Strieql (ptr, "read"))
X							mode = M_READ;
X						else if (Strieql (ptr, "write"))
X							mode = M_WRITE;
X						else if (Strieql (ptr, "mail"))
X							mode = M_MAIL;
X						else
X							exit (_errmsg (1, "Unknown mode %s.\n", ptr));
X						while (*ptr)
X							++ptr;
X						break;
X					case 'p':
X						ptr += (*(ptr+1) == '=') ? 2 : 1;
X						tmp = split_fields (ptr, FALSE);
X						if (tmp) {
X							if (!recv)
X								recv= tmp;
X							else {
X								t2 = recv;
X								while (t2->next)
X									t2 = t2->next;
X								t2->next = tmp;
X							}
X						}
X						while (*ptr)
X							++ptr;
X						break;
X					case '?':
X					default:
X						usage ();
X						exit (*ptr == '?' ? 0 :
X							_errmsg (1, "Unknown option '%c'\n", *ptr));
X						break;
X				}
X				if (*ptr)
X					++ptr;
X			}
X		} else if (!srcfn)
X			srcfn = strdup (av[t]);
X
X	if (mode != M_NONE) {
X		doconv = TRUE;
X		rev_conv = TRUE;
X		verbose = TRUE;
X	}
X
X	setup_convtable (doconv, rev_conv);
X
X	muid = getmuid ();
X	ruid = getuid ();
X	isadm = (muid == ruid) || (ruid == 0);
X
X	if (mode != M_NONE) {
X		user_interface (mode, srcfn);
X		do_exit (0);
X	}
X
X	setuid (getmuid ());
X
X	if (retr_msgid) {
X		retreive_message_id (retr_msgid);
X		do_exit (0);
X	}
X
X	if (do_respool) {
X		if (do_init (FALSE) < 0)
X			exit (_errmsg (1, "Can't init in respool\n"));
X		respool (FALSE);
X		do_exit (0);
X	}
X	
X	if ((expire != NULL) || rebuild_active || rebuild_history || check_dbmsiz) {
X		if (!isadm)
X			exit (_errmsg (1, "Sorry, admin-mode requires %03d.%03d!\n", muid >> 16, muid & 0xffff));
X		do_admin ((expire != NULL ? TRUE : FALSE), expire, exphist, rebuild_active, rebuild_history, check_dbmsiz);
X		do_exit (0);
X	}
X	if (ctrlmsg) {
X		create_control_message (ctrlmsg, isadm);
X		do_exit (0);
X	}
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/pit.c' ; then
  echo 'File INEWS/pit.c already exists, overwriting it'
  del 'INEWS/pit.c'
fi
echo Extracting \"'INEWS/pit.c'\"
sed "s/^X//" >'INEWS/pit.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	pit.c_v $
X * Revision 1.1  90/08/31  15:35:06  cs
X * Initial revision
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: pit.c_v 1.1 90/08/31 15:35:06 cs Exp $";
X# endif		LINT
X# include	<stdio.h>
X# include	<errno.h>
X# include	"inews.h"
X
Xextern char	*malloc ();
Xextern char	*strdup ();
Xextern FILE	*xpopen ();
X
Xvoid
Xpipe_it (cmd)
Xchar *cmd;
X{
X	char	*rcmd;
X	char	*rfn;
X	FILE	*pp;
X	FILE	*fp;
X	char	*buf;
X	int	n;
X
X	if (!(buf = malloc (512))) {
X		do_log ("FATAL: Can't alloc for command %s\n", cmd);
X		return;
X	}
X	if (!(rcmd = strdup (cmd))) {
X		do_log ("FATAL: Can't alloc for command %s\n", cmd);
X		return;
X	}
X	if (!(rfn = malloc (strlen (newsdir) + strlen (realfile) + 6))) {
X		do_log ("FATAL: Can't malloc in pipe_it(%s)\n", cmd);
X		return;
X	}
X	sprintf (rfn, "%s/%s", newsdir, realfile);
X	if (!(fp = fopen (rfn, "r"))) {
X		do_log ("FATAL: Can't open %s\n", realfile);
X		return;
X	}
X	if (!(pp = xpopen (rcmd, "w"))) {
X		fclose (fp);
X		do_log ("FATAL: Can't fork command %s\n", rcmd);
X		return;
X	}
X	while (fgets (buf, 500, fp))
X		if (fputs (buf, pp) == -1) {
X			do_log ("Broken pipe for %s (%d)?\n", cmd, errno);
X			break;
X		}
X	fclose (fp);
X	if (n = pclose (pp))
X		do_log ("Pclose(%s) returned %d\n", cmd, n);
X	free (rcmd);
X	free (buf);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/pmail.c' ; then
  echo 'File INEWS/pmail.c already exists, overwriting it'
  del 'INEWS/pmail.c'
fi
echo Extracting \"'INEWS/pmail.c'\"
sed "s/^X//" >'INEWS/pmail.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log:	pmail.c_v $
X * Revision 1.1  91/09/11  18:17:54  ud
X * Initial revision
X * 
X * 
X */
X# ifndef	LINT
Xstatic char rcsid[] = "$Id: pmail.c_v 1.1 91/09/11 18:17:54 ud Exp $";
X# endif		LINT
X# include	<stdio.h>
X# include	<c8type.h>
X# include	"inews.h"
X
X# ifdef		CAN_MAIL
Xextern char	*index ();
Xextern char	*malloc ();
Xextern char	*rindex ();
Xextern FILE	*xpopen ();
X
Xstatic struct {
X	char	*text;
X	int	len;
X} pattern[] = {
X	"To: ",		4,
X	"Cc: ",		4,
X	"Bcc: ",	5,
X	NULL,		0
X};
X
Xvoid
Xsend_private_mail ()
X{
X	register charc	*tmp;
X	register int	t;
X	charc		*rec;
X	charc		*cur, *prev;
X	charc		*path;
X	char		*pt;
X	int		len;
X	char		*ptr, *tptr;
X	char		*quote;
X# ifdef		IN_MEMORY
X	list		*ltmp;
X# else		/* IN_MEMORY */
X	int		ch;
X	FILE		*fp;
X# endif		/* IN_MEMORY */
X	FILE		*pp;
X
X	if (! crthd)
X		return;
X
X	tmp = head;
X	prev = NULL;
X	rec = NULL;
X	for (tmp = head; tmp; tmp = tmp -> next)
X		for (t = 0; pattern[t].text; ++t)
X			if (Strnieql (pattern[t].text, tmp -> text, pattern[t].len)) {
X				ptr = skip_field (tmp -> text);
X				if (! (cur = split_fields (ptr, FALSE)))
X					break;
X				if (! prev)
X					rec = cur;
X				else
X					prev -> next = cur;
X				while (cur -> next)
X					cur = cur -> next;
X				prev = cur;
X			}
X	if (! rec)
X		return;
X	len = strlen (MAILCMD) + 4;
X	for (tmp = rec; tmp; tmp = tmp -> next)
X		len += strlen (tmp -> text) + 5;
X	if (! (ptr = malloc (len))) {
X		free_field (rec);
X		return;
X	}
X	strcpy (ptr, MAILCMD);
X	for (tmp = rec; tmp; tmp = tmp -> next) {
X		if (tptr = index (tmp -> text, '<')) {
X			strcpy (tmp -> text, tptr + 1);
X			if (tptr = index (tmp -> text, '>'))
X				*tptr = '\0';
X		} else if (tmp -> text[0] == '(') {
X			if (tptr = rindex (tmp -> text, ')')) {
X				++tptr;
X				while (is8space (*tptr))
X					++tptr;
X				strcpy (tmp -> text, tptr);
X			}
X		} else {
X			tptr = tmp -> text;
X			while (*tptr && (! is8space (*tptr)))
X				++tptr;
X			*tptr = '\0';
X		}
X		if (tmp -> text[0]) {
X			if (index (tmp -> text, '\''))
X				quote = "\"";
X			else
X				quote = "'";
X			strcat (ptr, " ");
X			strcat (ptr, quote);
X			strcat (ptr, tmp -> text);
X			strcat (ptr, quote);
X		}
X	}
X	do_log ("Mail using `%s'\n", ptr);
X	if (pp = xpopen (ptr, "w")) {
X		for (tmp = head; tmp; tmp = tmp -> next)
X			if (Strnicmp (tmp -> text, pattern[2].text, pattern[2].len))
X				fprintf (pp, "%s\n", tmp -> text);
X		putc ('\n', pp);
X# ifdef		IN_MEMORY
X		for (ltmp = newstmp; ltmp; ltmp = ltmp->next)
X			fputs (ltmp -> text, pp);
X# else		/* IN_MEMORY */
X		if (fp = fopen (newstmp, "r")) {
X			while ((ch = getc (fp)) != EOF)
X				putc (ch, pp);
X			fclose (fp);
X		}
X# endif		/* IN_MEMORY */
X		pclose (pp);
X	}
X	free (ptr);
X	free_field (rec);
X}
X# endif		/* CAN_MAIL */
__END__OF__THIS__FILE__
exit 0
: end of shell archive

-- 
Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
Xref: sparky de.comp.sources.os9:10 comp.os.os9:1552