Thread View: de.comp.sources.os9
1 messages
1 total messages
Started by Frank Kaefer
Wed, 23 Dec 1992 19:41
MNews Prerelease Part03/09
Author: Frank Kaefer
Date: Wed, 23 Dec 1992 19:41
Date: Wed, 23 Dec 1992 19:41
2321 lines
57672 bytes
57672 bytes
Submitted-by: Ulrich Dessauer <ud@Nightmare.ddt.sub.org>
Archive-name: mnews/part03
: ----- Cut here ----- Cut here ----- Cut here ----- Cut here -----
: Use sh filename to extract shell archive
: This shell archive contains following files:
: 'INEWS/csme.c 515 bytes'
: 'INEWS/cssys.c 1918 bytes'
: 'INEWS/csuu.c 1242 bytes'
: 'INEWS/csver.c 1398 bytes'
: 'INEWS/ctrl.c 3060 bytes'
: 'INEWS/dbg.c 1599 bytes'
: 'INEWS/ddst.c 1571 bytes'
: 'INEWS/delh.c 768 bytes'
: 'INEWS/exp.c 8032 bytes'
: 'INEWS/ext.h 2171 bytes'
: 'INEWS/fcan.c 2345 bytes'
: 'INEWS/ffrom.c 1922 bytes'
: 'INEWS/ffup.c 1692 bytes'
: 'INEWS/getd.c 1029 bytes'
: 'INEWS/gfh.c 290 bytes'
: 'INEWS/ghead.c 487 bytes'
: 'INEWS/hact 69 bytes'
: 'INEWS/hash.c 435 bytes'
: 'INEWS/hist.h 873 bytes'
: 'INEWS/ihead.c 947 bytes'
: 'INEWS/inews.c 1823 bytes'
: 'INEWS/inews.h 11606 bytes'
:
if test -f 'INEWS/csme.c' ; then
echo 'File INEWS/csme.c already exists, overwriting it'
del 'INEWS/csme.c'
fi
echo Extracting \"'INEWS/csme.c'\"
sed "s/^X//" >'INEWS/csme.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: csme.c_v $
X * Revision 1.1 91/12/26 13:47:10 ud
X * Initial revision
X *
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: csme.c_v 1.1 91/12/26 13:47:10 ud Exp $";
X# endif LINT
X# include <c8type.h>
X# include "inews.h"
X
Xextern char *index ();
Xextern char *strdup ();
X
Xvoid
Xsend_me ()
X{
X char *ptr;
X charc *tmp;
X
X if (! ngs)
X return;
X ptr = ngs -> text;
X if (Strnicmp (ptr, "to.", 3))
X return;
X ptr += 3;
X if (Strieql (ptr, hostname) || Strieql (ptr, fhost)) {
X /* Handle sendme */
X return;
X }
X}
X
__END__OF__THIS__FILE__
if test -f 'INEWS/cssys.c' ; then
echo 'File INEWS/cssys.c already exists, overwriting it'
del 'INEWS/cssys.c'
fi
echo Extracting \"'INEWS/cssys.c'\"
sed "s/^X//" >'INEWS/cssys.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: cssys.c_v $
X * Revision 1.1 90/08/31 15:33:03 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: cssys.c_v 1.1 90/08/31 15:33:03 cs Exp $";
X# endif LINT
X# include "inews.h"
X
Xextern char *index ();
Xextern char *strdup ();
X
Xchar *
Xget_path (tmp)
Xcharc *tmp;
X{
X char *path;
X
X if ((path = index (tmp->text, '!')) || (path = index (tmp->text, ':')))
X ++path;
X else
X path = tmp->text;
X return (path);
X}
X
Xvoid
Xsendsys ()
X{
X char *from, *reply_to;
X char *comment[16];
X charc *tmp;
X# ifdef IN_MEMORY
X list *ltmp;
X# endif /* IN_MEMORY */
X
X if (!(from = find_from_addr (TRUE)))
X if (!(from = strdup (news_owner)))
X return;
X
X reply_to = NULL;
X
X# ifndef SEND_WORLD
X if (dist_is_world ()) {
X reply_to = from;
X if (! (from = strdup (news_owner))) {
X free (reply_to);
X return;
X }
X }
X# endif /* SEND_WORLD */
X
X do_log ("Received Sendsys Control Message from %s\n", from);
X comment[0] = "Dear Sender!\n";
X comment[1] = "You requested our `sys'-file, it is appended to this message\n";
X comment[2] = "This `sys'-file is currently running on ";
X comment[3] = fhost;
X comment[4] = ".\n";
X comment[5] = "** Note: This `sys'-format isn't compatible to this of BNews or CNews, so\n",
X comment[6] = " if you have have got some problems, be free and send a mail\n";
X comment[7] = " to postmaster@";
X comment[8] = fhost;
X comment[9] = ".\n";
X if (tmp = get_header_line (H_PATH)) {
X comment[10] = "The Path to here is: '";
X comment[11] = get_path (tmp);
X comment[12] = "'.\n";
X comment[13] = NULL;
X } else
X comment[10] = NULL;
X# ifndef IN_MEMORY
X mail_to (from, reply_to, "Request of sys-file from site", fhost, SYS_FILE, comment);
X# else /* IN_MEMORY */
X if (ltmp = get_file (SYS_FILE)) {
X mail_to (from, reply_to, "Request of sys-file from site", fhost, ltmp, comment);
X free_list (ltmp);
X }
X# endif /* IN_MEMORY */
X free (from);
X if (reply_to)
X free (reply_to);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/csuu.c' ; then
echo 'File INEWS/csuu.c already exists, overwriting it'
del 'INEWS/csuu.c'
fi
echo Extracting \"'INEWS/csuu.c'\"
sed "s/^X//" >'INEWS/csuu.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: csuu.c_v $
X * Revision 1.1 90/08/31 15:33:07 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: csuu.c_v 1.1 90/08/31 15:33:07 cs Exp $";
X# endif LINT
X# include "inews.h"
X
Xextern char *strdup ();
X
Xvoid
Xsenduuname ()
X{
X char *from, *reply_to;
X char *comment[10];
X charc *tmp;
X# ifdef IN_MEMORY
X list *ltmp;
X# endif /* IN_MEMORY */
X
X if (!(from = find_from_addr (TRUE)))
X if (!(from = strdup (news_owner)))
X return;
X
X reply_to = NULL;
X# ifndef SEND_WORLD
X if (dist_is_world ()) {
X reply_to = from;
X if (! (from = strdup (news_owner))) {
X free (reply_to);
X return;
X }
X }
X# endif /* SEND_WORLD */
X
X do_log ("Received Senduuname Control Message from %s\n", from);
X if (tmp = get_header_line (H_PATH)) {
X comment[0] = "The Path to here is: '";
X comment[1] = get_path (tmp);
X comment[2] = "'.\n";
X comment[3] = NULL;
X } else
X comment[0] = NULL;
X# ifndef IN_MEMORY
X mail_to (from, reply_to, "Request of uuname from site", fhost, UUNAME_FILE, comment);
X# else /* IN_MEMORY */
X if (ltmp = get_file (UUNAME_FILE)) {
X mail_to (from, reply_to, "Request of uuname from site", fhost, ltmp, comment);
X free_list (ltmp);
X }
X# endif /* IN_MEMORY */
X free (from);
X if (reply_to)
X free (reply_to);
X}
X
__END__OF__THIS__FILE__
if test -f 'INEWS/csver.c' ; then
echo 'File INEWS/csver.c already exists, overwriting it'
del 'INEWS/csver.c'
fi
echo Extracting \"'INEWS/csver.c'\"
sed "s/^X//" >'INEWS/csver.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: csver.c_v $
X * Revision 1.2 91/12/26 14:00:58 ud
X * Added RCS-ID as part of the version control message
X *
X * Revision 1.1 90/08/31 15:33:10 cs
X * Initial revision
X *
X */
Xstatic char rcsid[] = "$Id: csver.c_v 1.2 91/12/26 14:00:58 ud Exp $";
X
X# include "inews.h"
X
Xextern char *strdup ();
X
Xvoid
Xsendversion ()
X{
X char *from, *reply_to;
X char buf[128];
X char *comment[12];
X charc *tmp;
X
X if (!(from = find_from_addr (TRUE)))
X if (!(from = strdup (news_owner)))
X return;
X
X reply_to = NULL;
X# ifndef SEND_WORLD
X if (dist_is_world ()) {
X reply_to = from;
X if (! (from = strdup (news_owner))) {
X free (reply_to);
X return;
X }
X }
X# endif /* SEND_WORLD */
X
X do_log ("Received Sendversion Control Message from %s\n", from);
X# ifndef PATCHLEVEL
X sprintf (buf, VERSIONSTR, VERSION);
X# else PATCHLEVEL
X sprintf (buf, VERSIONSTR, VERSION, PATCHLEVEL);
X# endif PATCHLEVEL
X comment[0] = "Our current running version on '";
X comment[1] = fhost;
X comment[2] = "' is\n";
X comment[3] = buf;
X comment[4] = ".\n";
X comment[5] = "\tRCS: ";
X comment[6] = rcsid;
X comment[7] = "\n";
X if (tmp = get_header_line (H_PATH)) {
X comment[8] = "The Path to here is: '";
X comment[9] = get_path (tmp);
X comment[10] = "'.\n";
X comment[11] = NULL;
X } else
X comment[8] = NULL;
X mail_to (from, reply_to, "Current News-Version", buf, NULL, comment);
X free (from);
X if (reply_to)
X free (reply_to);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/ctrl.c' ; then
echo 'File INEWS/ctrl.c already exists, overwriting it'
del 'INEWS/ctrl.c'
fi
echo Extracting \"'INEWS/ctrl.c'\"
sed "s/^X//" >'INEWS/ctrl.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ctrl.c_v $
X * Revision 1.2 91/12/26 13:34:13 ud
X * Tried to insert `sendme', but didn't work as expected
X *
X * Revision 1.1 90/08/31 15:33:14 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ctrl.c_v 1.2 91/12/26 13:34:13 ud Exp $";
X# endif LINT
X# include "inews.h"
X
Xextern char *rindex ();
Xextern char *strdup ();
X
Xstatic void
Xdo_control (msg)
Xchar *msg;
X{
X register int t;
X char *rmsg;
X charc *tmp;
X char *opts;
X char *ptr;
X
X if (!(rmsg = strdup (msg))) {
X do_log ("FATAL: Failed during Control-Message\n");
X do_exit (1);
X }
X opts = skipc (rmsg, '\0');
X for (t=0;ctrlcodes[t];++t)
X if (Strieql (ctrlcodes[t], rmsg))
X break;
X if (!ctrlcodes[t]) {
X do_log ("FATAL: Unknown Controlmessage: %s (%s) --> article\n", rmsg, opts);
X tmp = ngs;
X while (tmp) {
X if ((ptr = rindex (tmp->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
X *ptr = '\0';
X tmp = tmp->next;
X }
X return;
X }
X do_log ("Received Control Message: %s\n", msg);
X if (!(isctrl = (charc *) malloc (sizeof (charc)))) {
X do_log ("FATAL: Can't alloc isctrl!\n");
X do_exit (1);
X }
X isctrl -> text = NULL;
X switch (t) {
X case CC_CANCEL:
X case CC_IHAVE:
X case CC_NEWGROUP:
X case CC_RMGROUP:
X case CC_SENDSYS:
X case CC_SENDUUNAME:
X case CC_VERSION:
X case CC_CHECKGROUPS:
X isctrl -> text = strdup (NG_CONTROL);
X break;
X case CC_SENDME:
X if (ngs)
X isctrl -> text = strdup (ngs -> text);
X else
X do_log ("No newsgroups: for sendme\n");
X break;
X }
X
X if (! isctrl -> text)
X do_exit (1);
X
X isctrl->next = NULL;
X if (!ngs) {
X if (!(ngs = (charc *) malloc (sizeof (charc)))) {
X do_log ("FATAL: Failed during Control-Message\n");
X do_exit (1);
X }
X if (!(ngs->text = strdup (NG_CONTROL))) {
X do_log ("FATAL: Failed during Control-Message\n");
X do_exit (1);
X }
X ngs->next = NULL;
X } else {
X tmp = ngs;
X while (tmp) {
X if ((ptr = rindex (tmp->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
X *ptr = '\0';
X tmp = tmp->next;
X }
X }
X if (t != CC_CANCEL)
X if (!get_header_line (H_APPROVED)) {
X do_log ("No Approved: Line for %s found\n", rmsg);
X do_exit (1);
X }
X switch (t) {
X case CC_CANCEL:
X cancel_msg (opts);
X break;
X case CC_IHAVE:
X do_log ("Unsopported control-message: %s\n", rmsg);
X do_exit (0);
X break;
X case CC_SENDME:
X send_me ();
X break;
X case CC_NEWGROUP:
X newgroup (opts);
X break;
X case CC_RMGROUP:
X rmgroup (opts);
X break;
X case CC_SENDSYS:
X sendsys ();
X break;
X case CC_SENDUUNAME:
X senduuname ();
X break;
X case CC_VERSION:
X sendversion ();
X break;
X case CC_CHECKGROUPS:
X checkgroups ();
X break;
X }
X}
X
Xvoid
Xcheck_control ()
X{
X register charc *tmp;
X char *ptr;
X
X if (tmp = get_header_line (H_CONTROL))
X ptr = skip_field (tmp->text);
X else if (ngs) {
X tmp = ngs;
X while (tmp)
X if ((ptr = rindex (ngs->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
X break;
X else
X tmp = tmp->next;
X ptr = NULL;
X if (tmp)
X if (tmp = get_header_line (H_SUBJECT))
X ptr = skip_field (tmp->text);
X } else
X ptr = NULL;
X if (ptr)
X do_control (ptr);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/dbg.c' ; then
echo 'File INEWS/dbg.c already exists, overwriting it'
del 'INEWS/dbg.c'
fi
echo Extracting \"'INEWS/dbg.c'\"
sed "s/^X//" >'INEWS/dbg.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: dbg.c_v $
X * Revision 1.1 91/05/22 13:38:16 ud
X * Initial revision
X *
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: dbg.c_v 1.1 91/05/22 13:38:16 ud Exp $";
X# endif LINT
X# include <stdio.h>
X# include "inews.h"
X# include "hist.h"
X
Xvoid
Xdump_charc (e)
Xregister charc *e;
X{
X for (; e; e = e->next)
X printf ("text=\"%s\", nr=%d\n", e->text, e->nr);
X}
X
Xvoid
Xdump_sys (e)
Xregister sys *e;
X{
X register int t;
X
X for (; e; e = e->next) {
X printf ("site=\"%s\"\n", e->site);
X if (e->wsites)
X for (t = 0; e->wsites[t]; ++t)
X printf ("\twsites[%d]=\"%s\"\n", t, e->wsites[t]);
X printf ("\tfwd=%d\n", e->fwd);
X if (e->grps && e->inv) {
X printf ("\tinv");
X for (t = 0; e->grps[t]; ++t)
X printf (", [%d]=%s", t, e->inv[t] ? "true" : "false");
X printf ("\n");
X }
X if (e->dist)
X for (t = 0; e->dist[t]; ++t)
X printf ("\tdist[%d]=\"%s\"\n", t, e->dist[t]);
X if (e->cmd)
X printf ("\tcmd=\"%s\"\n", e->cmd);
X }
X}
X
Xvoid
Xdump_active (e)
Xregister active *e;
X{
X register int t;
X
X for (; e; e = e->next) {
X printf ("grp=\"%s\", flag=%d, low=%d, high=%d, pos=%d, changed= %d, aflag='%c%c' kblimit=%d\n",
X e->grp, e->flag, e->low, e->high, e->pos,
X e->changed, e->aflag[0], e->aflag[1],
X e -> kblimit);
X if (e->moderator && e->moderator[0])
X for (t = 0; e->moderator[t]; ++t)
X printf ("\tmoderator[%d]=\"%s\"\n", t, e->moderator[t]);
X }
X}
X
Xvoid
Xdump_archive (e)
Xregister archive *e;
X{
X for (; e; e = e->next)
X printf ("grp=\"%s\", len=%d, dest=\"%s\", prefix=\"%s\"\n",
X e->grp, e->len,
X e->dest ? e->dest : "(none)",
X e->prefix ? e->prefix : "(none)");
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/ddst.c' ; then
echo 'File INEWS/ddst.c already exists, overwriting it'
del 'INEWS/ddst.c'
fi
echo Extracting \"'INEWS/ddst.c'\"
sed "s/^X//" >'INEWS/ddst.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ddst.c_v $
X * Revision 1.1 90/08/31 15:33:19 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ddst.c_v 1.1 90/08/31 15:33:19 cs Exp $";
X# endif LINT
X# include <c8type.h>
X# include <modes.h>
X# include "inews.h"
X
Xextern char *malloc ();
X
Xvoid
Xmake_default_dists ()
X{
X register char *ptr;
X regexp *reg;
X char *buf;
X char *grp;
X char *dst;
X char *cmt;
X int fd, n;
X charc *t1, *t2;
X charc *tmp, *append;
X
X if (!ngs)
X return;
X if ((fd = open (DIST_FILE, S_IREAD)) < 0)
X return;
X catlines = TRUE;
X while (buf = readbuf (fd, & n)) {
X if ((n < 2) || (buf[0] == '#'))
X continue;
X buf[n - 1] = '\0';
X grp = buf;
X dst = skipc (buf, '\0');
X cmt = skipc (dst, '\0');
X if (!(reg = regcomp (grp)))
X continue;
X ptr = grp;
X while (*ptr) {
X *ptr = to8lower (*ptr);
X ++ptr;
X }
X t1 = ngs;
X while (t1)
X if (regexec (reg, t1->text))
X break;
X else
X t1 = t1->next;
X free ((char *) reg);
X if (t1 && (tmp = split_fields (dst, TRUE))) {
X t2 = dists;
X while (t2) {
X t1 = tmp;
X while (t1) {
X if (Streql (t2->text, t1->text))
X t1->text[0] = '\0';
X t1 = t1->next;
X }
X t2 = t2->next;
X }
X append = dists;
X if (append)
X while (append->next)
X append = append->next;
X t1 = tmp;
X while (t1) {
X t2 = t1->next;
X if (t1->text[0] == '\0') {
X free (t1->text);
X free ((char *) t1);
X } else {
X if (append)
X append->next = t1;
X else
X dists = t1;
X append = t1;
X append->next = NULL;
X }
X t1 = t2;
X }
X }
X }
X catlines = FALSE;
X close (fd);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/delh.c' ; then
echo 'File INEWS/delh.c already exists, overwriting it'
del 'INEWS/delh.c'
fi
echo Extracting \"'INEWS/delh.c'\"
sed "s/^X//" >'INEWS/delh.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: delh.c_v $
X * Revision 1.1 90/08/31 15:33:23 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: delh.c_v 1.1 90/08/31 15:33:23 cs Exp $";
X# endif LINT
X# include "inews.h"
X
Xvoid
Xdelete_header (id)
Xregister int id;
X{
X register charc *tmp, *t2;
X
X if ((id < 0) || (id > HEADER_MAX))
X return;
X tmp = head;
X t2 = NULL;
X while (tmp)
X if (Strnieql (tmp->text, hlines[id] + 2, strlen (hlines[id] + 2))) {
X if (t2)
X t2->next = tmp->next;
X else
X head = head->next;
X free (tmp->text);
X free ((char *) tmp);
X tmp = head;
X } else {
X t2 = tmp;
X tmp = tmp->next;
X }
X}
X
Xvoid
Xdel_obsolete_header ()
X{
X register int t;
X
X for (t=0;hlines[t];++t) {
X if (hlines[t][0] != '2')
X continue;
X delete_header (t);
X }
X}
X
__END__OF__THIS__FILE__
if test -f 'INEWS/exp.c' ; then
echo 'File INEWS/exp.c already exists, overwriting it'
del 'INEWS/exp.c'
fi
echo Extracting \"'INEWS/exp.c'\"
sed "s/^X//" >'INEWS/exp.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: exp.c_v $
X * Revision 1.5 91/05/22 13:27:47 ud
X * Correct expire of a list of newsgroups (now working)
X * Allows other inews' running while in expire (this isn't the best
X * solution, but better than nothing: Every inews fails when locking
X * for lck.inews and saves the articles in a seperate directory; after
X * each file (in non ndbm mode) and at the end of expire, inews scans
X * this directory and feed them to itself)
X *
X * Revision 1.4 91/01/02 21:28:02 ud
X * Added ndbm support for history
X *
X * Revision 1.3 90/12/01 15:52:35 ud
X * Cleaned up a bit; make expire compatible to ols news
X * version
X *
X * Revision 1.2 90/10/26 14:19:14 ud
X * Added archive stuff; only working with expire and a given list
X * of newsgourps to expire
X *
X * Revision 1.1 90/08/31 15:33:26 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: exp.c_v 1.5 91/05/22 13:27:47 ud Exp $";
X# endif LINT
X# include <c8type.h>
X# include <time.h>
X# include <modes.h>
X# include <dir.h>
X# include "inews.h"
X# include "hist.h"
X
X/*
X * Important! This file must start
X * with a digit!
X */
X# define EXP_TMP "1_working_file"
X
X# define DO_WRITE (1<<0)
X# define DO_DELETE (1<<1)
X# define DO_ARCHIVE (1<<2)
X
Xextern char *malloc ();
Xextern char *rindex ();
Xextern char *strdup ();
X
Xstatic int deleted, checked, archived;
Xstatic charc *rngs;
Xstatic archive *arc, *tarc;
X
Xstatic void
Xsetup_rngs ()
X{
X register charc *act, *cur;
X register active *ta;
X charc *tmp;
X register char *p;
X int isok;
X
X if (!hact)
X if (read_active () < 0)
X do_exit (_errmsg (1, "Can't read active-file for expire\n"));
X for (act = ngs; act; act = act->next)
X act->nr = strlen (act->text);
X for (ta = hact; ta; ta = ta->next) {
X act = ngs;
X isok = FALSE;
X for (act = ngs; act; act = act->next)
X if (act->text[0] == '!') {
X if (_cmpnam (ta->grp, act->text + 1, act->nr - 1) == 0) {
X act = NULL;
X isok = FALSE;
X break;
X }
X } else if (_cmpnam (ta->grp, act->text, act->nr) == 0)
X isok = TRUE;
X if (isok && (tmp = (charc *) malloc (sizeof (charc))))
X if (tmp->text = strdup (ta->grp)) {
X tmp->nr = 0;
X p = tmp->text;
X while (*p)
X if (((!is8alnum (*p)) || (!is8ascii (*p))) && (*p != '.'))
X *p++ = '_';
X else
X ++p;
X tmp->next = NULL;
X if (!rngs)
X rngs = tmp;
X else
X cur->next = tmp;
X cur = tmp;
X } else
X free ((char *) tmp);
X }
X}
X
Xstatic int
Xto_expire (tima, timh, buf)
Xtime_t tima, timh;
Xchar *buf;
X{
X register charc *tmp;
X char **ags;
X register int t;
X char *ptr, *sav;
X char artstate;
X char *lbuf;
X char *gpn;
X int status;
X int exptim;
X
X tarc = NULL;
X exptim = atoi (buf);
X if (tima < exptim)
X status = DO_WRITE;
X else
X status = DO_DELETE;
X if (timh < exptim)
X status |= DO_WRITE;
X if (!(ngs || arc))
X return (status);
X ptr = skipn (buf, '\0');
X ptr = skipn (ptr, '\0');
X artstate = *ptr;
X if (artstate == ART_EXPIRED)
X status &= (~DO_DELETE);
X sav = skipn (ptr, '\0');
X
X if (!(lbuf = strdup (sav)))
X return (status & (~DO_DELETE));
X if (getargs (lbuf, &ags) < 0) {
X free (lbuf);
X return (status & (~DO_DELETE));
X }
X for (t=0;ags[t];++t) {
X if (!(gpn = strdup (ags[t]))) {
X status &= (~DO_DELETE);
X break;
X }
X if (ptr = rindex (gpn, '/')) {
X *ptr = '\0';
X ptr = gpn;
X while (*ptr)
X if (*ptr == '/')
X *ptr++ = '.';
X else
X ++ptr;
X }
X if (ngs) {
X tmp = rngs;
X while (tmp)
X if (_cmpnam (gpn, tmp->text, strlen (tmp->text)) == 0)
X break;
X else
X tmp = tmp->next;
X if (!tmp) {
X status &= (~DO_DELETE);
X if (artstate == ART_EXISTS)
X status |= DO_WRITE;
X }
X }
X if (arc) {
X tarc = arc;
X while (tarc)
X if (_cmpnam (gpn, tarc->grp, tarc->len) == 0) {
X status |= DO_ARCHIVE;
X break;
X } else
X tarc = tarc->next;
X }
X free (gpn);
X }
X free ((char *) ags);
X free (lbuf);
X if ((!(status & DO_DELETE)) && (status & DO_ARCHIVE))
X status &= (~DO_ARCHIVE);
X return (status);
X}
X
Xstatic void
Xexpire (fn, diffa, diffh, buf)
Xchar *fn;
Xint diffa, diffh;
Xchar *buf;
X{
X int fdi, fdo;
X int n;
X time_t tima, timh;
X char *ptr, *delnam;
X char *sav;
X int st;
X
X time (&tima);
X timh = tima;
X tima -= diffa;
X timh -= diffh;
X# ifndef USE_NDBM
X if ((fdi = open (fn, S_IREAD)) < 0) {
X do_log ("Can't open %s while in expire\n", fn);
X return;
X }
X unlink (EXP_TMP);
X if ((fdo = create (EXP_TMP, S_IWRITE | S_ISIZE, 03, _gs_size (fdi))) < 0) {
X do_log ("Can't create %s in expire\n", EXP_TMP);
X close (fdi);
X return;
X }
X while (buf = readbuf (fdi, & n)) { /* } */
X buf[n - 1] = '\0';
X# else /* USE_NDBM */
X for (key = dbm_firstkey (db); key.dptr; key = dbm_nextkey (db)) {
X dat = dbm_fetch (db, key);
X memcpy (&hist, dat.dptr, sizeof (history));
X sprintf (buf, "%d %s %c %s",
X hist.tim,
X key.dptr,
X (char) hist.flag,
X hist.fns);
X# endif /* USE_NDBM */
X ++checked;
X st = to_expire (tima, timh, buf);
X if (st & DO_DELETE) {
X# ifndef USE_NDBM
X if (st & DO_WRITE)
X sav = strdup (buf);
X else
X sav = NULL;
X# endif /* USE_NDBM */
X ptr = skipc (buf, '\0');
X ptr = skipc (ptr, '\0');
X if (*ptr != ART_EXPIRED) {
X ptr = skipc (ptr, '\0');
X ++deleted;
X while (*ptr) {
X delnam = ptr;
X ptr = skipc (ptr, '\0');
X if (tarc) {
X ++archived;
X do_archive (delnam, tarc);
X tarc = NULL;
X }
X unlink_in_newsdir_file (delnam);
X }
X }
X# ifndef USE_NDBM
X if (sav) {
X strcpy (buf, sav);
X ptr = skipn (buf, '\0');
X ptr = skipn (ptr, '\0');
X *ptr = ART_EXPIRED;
X free (sav);
X } else
X st = 0;
X# else /* USE_NDBM */
X hist.flag = ART_EXPIRED;
X# endif /* USE_NDBM */
X }
X# ifndef USE_NDBM
X if (st & DO_WRITE) {
X buf[n - 1] = '\n';
X write (fdo, buf, n);
X }
X# else /* USE_NDBM */
X if (st & DO_WRITE) {
X fill_hist ();
X dbm_store (db, key, dat, DBM_REPLACE);
X } else
X dbm_delete (db, key);
X# endif /* USE_NDBM */
X }
X# ifndef USE_NDBM
X close (fdi);
X n = _gs_size (fdo);
X close (fdo);
X unlink (fn);
X if (n == 0)
X unlink (EXP_TMP);
X else
X rename (EXP_TMP, fn);
X# endif /* USE_NDBM */
X}
X
Xvoid
Xdo_expire (delart, delhist)
Xchar *delart, *delhist;
X{
X# ifndef USE_NDBM
X charc *etmp, *hexp, *e2;
X DIR *dp;
X struct direct *ent;
X int tout;
X# endif /* USE_NDBM */
X char *buf;
X int diffart, diffhist;
X
X if (!(buf = malloc (2048)))
X do_exit (_errmsg (1, "Can't alloc memory\n"));
X diffart = atoi (delart) * 24 * 60 * 60;
X if (delhist)
X diffhist = atoi (delhist) * 24 * 60 * 60;
X else
X diffhist = diffart;
X checked = 0;
X deleted = 0;
X archived = 0;
X rngs = NULL;
X if (ngs) {
X setup_rngs ();
X if (!rngs)
X return;
X }
X arc = setup_archive ();
X# ifndef USE_NDBM
X hexp = NULL;
X e2 = NULL;
X if (!(dp = opendir (HIST_DIR)))
X do_exit (_errmsg (1, "Can't open %s\n", HIST_DIR));
X while (ent = readdir (dp)) {
X if (ent->d_name[0] == '.')
X continue;
X
X /*
X * No valid history file may start with
X * a digit!
X */
X if (isdigit (ent->d_name[0]))
X continue;
X
X if (!(etmp = (charc *) malloc (sizeof (charc))))
X do_exit (_errmsg (1, "Can't alloc during dir-reading\n"));
X if (!(etmp->text = strdup (ent->d_name)))
X do_exit (_errmsg (1, "Can't alloc during dir-reading\n"));
X etmp->next = NULL;
X if (!hexp)
X hexp = etmp;
X else
X e2->next = etmp;
X e2 = etmp;
X }
X closedir (dp);
X if (chdir (HIST_DIR) < 0)
X do_exit (_errmsg (1, "Can't chdir to %s\n", HIST_DIR));
X etmp = hexp;
X while (etmp) {
X expire (etmp->text, diffart, diffhist, buf);
X etmp = etmp->next;
X nunlock ();
X respool (FALSE);
X while (tout-- > 100)
X if (nlock () != -1)
X break;
X if (tout <= 0)
X break;
X else if ((chdir (newslib) < 0) || (chdir (HIST_DIR) < 0))
X break;
X }
X# else /* USE_NDBM */
X if (!(db = open_hist (S_IREAD | S_IWRITE)))
X do_exit (_errmsg (1, "Can't open %s.\n", HISTORY));
X expire (NULL, diffart, diffhist, buf);
X dbm_close (db);
X# endif /* USE_NDBM */
X do_log ("Expire: %d articles checked, %d deleted, %d archived.\n", checked, deleted, archived);
X if (rngs)
X free_field (rngs);
X free_archive (arc);
X if (chdir (newslib) < 0)
X do_exit (_errmsg (1, "Can't chdir to %s\n", newslib));
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/ext.h' ; then
echo 'File INEWS/ext.h already exists, overwriting it'
del 'INEWS/ext.h'
fi
echo Extracting \"'INEWS/ext.h'\"
sed "s/^X//" >'INEWS/ext.h' <<'__END__OF__THIS__FILE__'
X/*
X *
X * $Log: ext.h_v $
X * Initial revision
X * Revision 1.1 90/08/31 15:33:31 cs
X */
Xextern void cancel_msg ();
Xextern void check_control ();
Xextern void check_message_id ();
Xextern void checkgroups ();
Xextern void del_obsolete_header ();
Xextern void delete_dup_charc ();
Xextern void do_archive ();
Xextern void do_control ();
Xextern void do_exit ();
Xextern void do_expire ();
Xextern void do_log ();
Xextern void free_archive ();
X# ifdef IN_MEMORY
Xextern void free_list ();
X# endif /* IN_MEMORY */
X# ifdef CANCEL_SEND_CONTROL
Xextern void force_cancel ();
X# endif /* CANCEL_SEND_CONTROL */
Xextern void handle_special ();
Xextern void mail_it ();
Xextern void mail_to ();
Xextern void make_fn ();
Xextern void newgroup ();
Xextern void parse_args ();
Xextern void pipe_it ();
Xextern void rebuild_active_file ();
Xextern void rmgroup ();
Xextern void sendsys ();
Xextern void senduuname ();
Xextern void sendversion ();
Xextern void set_msgid ();
Xextern void sort_active ();
Xextern void special_header ();
Xextern void test_systems ();
Xextern void unlink_in_newsdir_dir ();
Xextern void write_it ();
Xextern char *catcharc ();
Xextern char *create_fn ();
Xextern char *exists_message_id ();
Xextern char *extract_address ();
Xextern char *find_address ();
Xextern char *find_address_hl ();
Xextern char *find_followup_to ();
Xextern char *find_from ();
Xextern char *find_from_addr ();
Xextern char *get_msgid ();
Xextern char *get_path ();
Xextern char *get_realfilename ();
Xextern char *input_line ();
X# ifdef USE_NDBM
Xextern char *lower_mid ();
X# endif /* USE_NDBM */
Xextern char *make_own_address ();
Xextern char *make_realfilename ();
Xextern char *ntime ();
Xextern char *readbuf ();
Xextern char *skipc ();
Xextern char *skipn ();
Xextern char *update_lists ();
Xextern char do_command ();
Xextern char extra_menu ();
X# ifdef HASH_SEARCH
Xextern hash_t calc_hash ();
Xextern active *find_active ();
X# endif /* HASH_SEARCH */
Xextern charc *copy_field ();
Xextern charc *get_header_line ();
Xextern charc *get_limit_newsgroups ();
Xextern charc *make_head ();
Xextern charc *split_fields ();
Xextern archive *setup_archive ();
X# ifdef IN_MEMORY
Xextern list *get_file ();
X# endif /* IN_MEMORY */
__END__OF__THIS__FILE__
if test -f 'INEWS/fcan.c' ; then
echo 'File INEWS/fcan.c already exists, overwriting it'
del 'INEWS/fcan.c'
fi
echo Extracting \"'INEWS/fcan.c'\"
sed "s/^X//" >'INEWS/fcan.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log$
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id$";
X# endif LINT
X# include <stdio.h>
X# include <time.h>
X# include "inews.h"
X
X# ifdef CANCEL_SEND_CONTROL
Xextern char *malloc ();
Xextern FILE *xpopen ();
X
Xvoid
Xforce_cancel (msg)
Xchar *msg;
X{
X charc *tmp;
X FILE *pp;
X int t;
X char *ptr;
X char *buf;
X char *name;
X time_t tim;
X
X block_forward = TRUE;
X if (! (buf = malloc (512))) {
X do_log ("FATAL: malloc in force_cancel()\n");
X do_exit (0);
X }
X nunlock ();
X if (! (pp = xpopen (INEWS, "w"))) {
X free (buf);
X do_exit (0);
X }
X for (t = 0; hlines[t]; ++t) {
X ptr = buf;
X switch (t) {
X case H_PATH:
X sprintf (buf, "%s %s",
X hlines[H_PATH] + 2, news_owner);
X break;
X case H_FROM:
X if (! (name = find_from (FALSE)))
X name = news_owner;
X sprintf (buf, "%s %s",
X hlines[H_FROM] + 2, name);
X break;
X case H_NEWSGROUPS:
X if (tmp = get_header_line (H_NEWSGROUPS))
X sprintf (buf, "%s %s",
X hlines[H_NEWSGROUPS] + 2,
X skip_field (tmp -> text));
X else
X ptr = NULL;
X break;
X case H_TO:
X sprintf (buf, "%s Postmaster@%s",
X hlines[H_TO] + 2,
X fhost);
X break;
X case H_SUBJECT:
X case H_CONTROL:
X if (tmp = get_header_line (H_MESSAGE_ID))
X sprintf (buf, "%s %s %s",
X hlines[t] + 2,
X ctrlcodes[CC_CANCEL],
X skip_field (tmp -> text));
X else
X ptr = NULL;
X break;
X case H_MESSAGE_ID:
X if (tmp = get_header_line (H_MESSAGE_ID))
X sprintf (buf, "%s C%s",
X hlines[H_MESSAGE_ID] + 2,
X skip_field (tmp -> text));
X else
X ptr = NULL;
X break;
X case H_DISTRIBUTION:
X if (tmp = get_header_line (H_DISTRIBUTION))
X strcpy (buf, tmp -> text);
X else
X ptr = NULL;
X break;
X case H_DATE:
X time (&tim);
X sprintf (buf, "%s %s",
X hlines[H_DATE] + 2,
X ntime (&tim));
X break;
X case H_ORGANIZATION:
X sprintf (buf, "%s News-Cancel Service",
X hlines[H_ORGANIZATION] + 2);
X break;
X case H_APPROVED:
X if (! (name = find_from (FALSE)))
X name = news_owner;
X sprintf (buf, "%s %s",
X hlines[H_APPROVED] + 2,
X name);
X break;
X case H_LINES:
X sprintf (buf, "%s 0",
X hlines[H_LINES] + 2);
X break;
X default:
X ptr = NULL;
X break;
X }
X if (ptr)
X fprintf (pp, "%s\n", buf);
X }
X pclose (pp);
X free (buf);
X do_exit (0);
X}
X# endif /* CANCEL_SEND_CONTROL */
X
__END__OF__THIS__FILE__
if test -f 'INEWS/ffrom.c' ; then
echo 'File INEWS/ffrom.c already exists, overwriting it'
del 'INEWS/ffrom.c'
fi
echo Extracting \"'INEWS/ffrom.c'\"
sed "s/^X//" >'INEWS/ffrom.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ffrom.c_v $
X * Revision 1.1 90/08/31 15:33:35 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ffrom.c_v 1.1 90/08/31 15:33:35 cs Exp $";
X# endif LINT
X# include <c8type.h>
X# include "inews.h"
X
Xextern char *index ();
Xextern char *malloc ();
X
Xchar *
Xfind_from (use_reply_first)
Xint use_reply_first;
X{
X charc *tmp;
X char *from;
X
X if (use_reply_first) {
X if (!(tmp = get_header_line (H_REPLY_TO)))
X tmp = get_header_line (H_FROM);
X } else
X if (!(tmp = get_header_line (H_FROM)))
X tmp = get_header_line (H_REPLY_TO);
X if (!tmp)
X if (!(tmp = get_header_line (H_SENDER)))
X return (NULL);
X from = skip_field (tmp->text);
X return (from);
X}
X
Xchar *
Xextract_address (s)
Xchar *s;
X{
X char *ad;
X char *from;
X register char *p1, *p2;
X
X if (!(ad = malloc (strlen (s) + 10)))
X return (NULL);
X p1 = skip_field (s);
X if (*p1 == '(') {
X while (*p1 && (*p1 != ')'))
X ++p1;
X if (*p1)
X ++p1;
X while (is8space (*p1))
X ++p1;
X }
X if (!*p1) {
X free (ad);
X return (NULL);
X }
X p2 = ad;
X from = p1;
X if (p1 = index (from, '<')) {
X ++p1;
X while (*p1 && (*p1 != '>'))
X *p2++ = *p1++;
X } else {
X p1 = from;
X while (*p1 && (!is8space (*p1)))
X *p2++ = *p1++;
X }
X *p2 = '\0';
X return (ad);
X}
X
Xchar *
Xfind_address_hl (id)
Xint id;
X{
X charc *tmp;
X char *ad;
X
X if (!(tmp = get_header_line (id)))
X return (NULL);
X ad = extract_address (tmp->text);
X return (ad);
X}
X
Xchar *
Xfind_address ()
X{
X char *ad;
X
X if (!(ad = find_address_hl (H_FROM)))
X ad = find_address_hl (H_SENDER);
X return (ad);
X}
X
Xchar *
Xfind_from_addr (use_reply_first)
Xint use_reply_first;
X{
X charc *tmp;
X char *from;
X
X if (use_reply_first) {
X if (!(tmp = get_header_line (H_REPLY_TO)))
X tmp = get_header_line (H_FROM);
X } else
X if (!(tmp = get_header_line (H_FROM)))
X tmp = get_header_line (H_REPLY_TO);
X if (!tmp)
X if (!(tmp = get_header_line (H_SENDER)))
X return (NULL);
X return (extract_address (tmp->text));
X}
X
X
__END__OF__THIS__FILE__
if test -f 'INEWS/ffup.c' ; then
echo 'File INEWS/ffup.c already exists, overwriting it'
del 'INEWS/ffup.c'
fi
echo Extracting \"'INEWS/ffup.c'\"
sed "s/^X//" >'INEWS/ffup.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ffup.c_v $
X * Revision 1.1 91/02/03 15:35:12 ud
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ffup.c_v 1.1 91/02/03 15:35:12 ud Exp $";
X# endif LINT
X# include <modes.h>
X# include "inews.h"
X
Xextern char *malloc ();
Xextern char *strdup ();
X
Xchar *
Xfind_followup_to (list)
Xcharc *list;
X{
X char *buf;
X int fd;
X int n;
X char *fup;
X char *res;
X charc *fhead, *tmp, *cur;
X register charc *srch;
X
X if ((fd = open (FOLLOW_FILE, S_IREAD)) < 0)
X return (NULL);
X if (!(list = copy_field (list))) {
X close (fd);
X return (NULL);
X }
X for (srch = list; srch; srch = srch->next)
X srch->nr = strlen (srch->text);
X fhead = NULL;
X cur = NULL;
X catlines = TRUE;
X while (buf = readbuf (fd, & n)) {
X buf[n - 1] = '\0';
X if ((buf[0] == '#') || (n == 1))
X continue;
X fup = skipc (buf, '\0');
X if (!(*fup && *buf))
X continue;
X for (srch = list; srch; srch = srch->next)
X if (srch->text[0] && (_cmpnam (buf, srch->text, srch->nr) != -1))
X break;
X if (srch) {
X if (tmp = (charc *) malloc (sizeof (charc)))
X if (tmp->text = strdup (fup)) {
X tmp->next = NULL;
X if (!cur)
X fhead = tmp;
X else
X cur->next = tmp;
X cur = tmp;
X } else
X free ((char *) tmp);
X srch->text[0] = '\0';
X }
X }
X catlines = FALSE;
X close (fd);
X if (fhead) {
X for (cur = fhead; cur->next; cur = cur->next)
X ;
X for (tmp = list; tmp;) {
X srch = tmp;
X tmp = tmp->next;
X if (srch->text[0]) {
X cur->next = srch;
X srch->next = NULL;
X cur = srch;
X } else {
X free (srch->text);
X free ((char *) srch);
X }
X }
X delete_dup_charc (fhead);
X res = catcharc (fhead, ",");
X free_field (fhead);
X } else
X res = NULL;
X return (res);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/getd.c' ; then
echo 'File INEWS/getd.c already exists, overwriting it'
del 'INEWS/getd.c'
fi
echo Extracting \"'INEWS/getd.c'\"
sed "s/^X//" >'INEWS/getd.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: getd.c_v $
X * Revision 1.1 90/08/31 15:33:39 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: getd.c_v 1.1 90/08/31 15:33:39 cs Exp $";
X# endif LINT
X# include <modes.h>
X# include "inews.h"
X
Xextern char *malloc ();
X
Xvoid
Xget_dists_and_ngs (fn)
Xchar *fn;
X{
X char *buf;
X char *tmp;
X int n;
X int fd;
X
X if (dists && ngs)
X return;
X if (!(buf = malloc (512)))
X return;
X strcpy (buf, newsdir);
X strcat (buf, "/");
X strcat (buf, fn);
X if ((fd = open (buf, S_IREAD)) < 0) {
X free (buf);
X return;
X }
X while ((n = readln (fd, buf, 500)) > 1) {
X buf[n - 1] = '\0';
X if ((!dists) && (Strnieql (buf, hlines[H_DISTRIBUTION] + 2, strlen (hlines[H_DISTRIBUTION] + 2)))) {
X tmp = skip_field (buf);
X dists = split_fields (tmp, TRUE);
X if (dists && ngs)
X break;
X } else if ((!ngs) && (Strnieql (buf, hlines[H_NEWSGROUPS] + 2, strlen (hlines[H_NEWSGROUPS] + 2)))) {
X tmp = skip_field (buf);
X ngs = split_fields (tmp, TRUE);
X if (dists && ngs)
X break;
X }
X }
X close (fd);
X free (buf);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/gfh.c' ; then
echo 'File INEWS/gfh.c already exists, overwriting it'
del 'INEWS/gfh.c'
fi
echo Extracting \"'INEWS/gfh.c'\"
sed "s/^X//" >'INEWS/gfh.c' <<'__END__OF__THIS__FILE__'
X/*
X * Extra sourcefile for this function, because it should be
X * easiely changeable (should be moved to os9lib.l)
X */
X# ifdef NEED_GETFULLHOSTNAME
Xchar *
Xgetfullhostname (buf, len)
Xchar *buf;
Xint len;
X{
X return (info_str ("fullhost", buf, len - 1));
X}
X# endif /* NEED_GETFULLHOSTNAME */
__END__OF__THIS__FILE__
if test -f 'INEWS/ghead.c' ; then
echo 'File INEWS/ghead.c already exists, overwriting it'
del 'INEWS/ghead.c'
fi
echo Extracting \"'INEWS/ghead.c'\"
sed "s/^X//" >'INEWS/ghead.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ghead.c_v $
X * Revision 1.1 90/08/31 15:33:43 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ghead.c_v 1.1 90/08/31 15:33:43 cs Exp $";
X# endif LINT
X# include "inews.h"
X
Xcharc *
Xget_header_line (id)
Xregister int id;
X{
X register charc *tmp;
X
X if ((id < 0) || (id > HEADER_MAX))
X return (NULL);
X tmp = head;
X while (tmp)
X if (Strnieql (tmp->text, hlines[id] + 2, strlen (hlines[id] + 2)))
X break;
X else
X tmp = tmp->next;
X return (tmp);
X}
X
X
__END__OF__THIS__FILE__
if test -f 'INEWS/hact' ; then
echo 'File INEWS/hact already exists, overwriting it'
del 'INEWS/hact'
fi
echo Extracting \"'INEWS/hact'\"
sed "s/^X//" >'INEWS/hact' <<'__END__OF__THIS__FILE__'
Xachk.c
Xwact.c
Xcnew.c
Xbuild.c
Xract.c
Xapp.c
Xsinfo.c
Xexp.c
Xcchk.c
Xcrm.c
__END__OF__THIS__FILE__
if test -f 'INEWS/hash.c' ; then
echo 'File INEWS/hash.c already exists, overwriting it'
del 'INEWS/hash.c'
fi
echo Extracting \"'INEWS/hash.c'\"
sed "s/^X//" >'INEWS/hash.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log$
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id$";
X# endif LINT
X# include "inews.h"
X# ifdef HASH_SEARCH
X
Xactive *
Xfind_active (grp)
Xregister char *grp;
X{
X register hash_t id;
X register active *run;
X
X id = calc_hash (grp, TRUE);
X run = hashact[id % HASH_ACTIVE];
X while (run)
X if ((run -> id == id) && Strieql (grp, run -> grp))
X return (run);
X else
X run = run -> hnext;
X return (NULL);
X}
X# endif /* HASH_SEARCH */
__END__OF__THIS__FILE__
if test -f 'INEWS/hist.h' ; then
echo 'File INEWS/hist.h already exists, overwriting it'
del 'INEWS/hist.h'
fi
echo Extracting \"'INEWS/hist.h'\"
sed "s/^X//" >'INEWS/hist.h' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: hist.h_v $
X * Revision 1.1 91/01/02 21:33:07 ud
X * Initial revision
X *
X */
X/*
X * Flags in history file
X */
X# define ART_EXISTS '1'
X# define ART_EXPIRED '0'
X
X# ifndef USE_NDBM
X# define HIST_FILE "HISTORY/history.%04d"
X# define HIST_DIR "HISTORY"
X
X/*
X * The maximum value for the hash-algorithm
X * should be a prim-number
X * This is equal to the number of creating
X * history-files
X * Possible values are: 19, 23, 29, 37, 43, 59, 73, 97
X * and a lot of others (these are only some suggenstions!)
X */
X# define HIST_MAXIMUM 37
X
X# else /* USE_NDBM */
X
X# include <ndbm.h>
X
X# ifndef CLK_TCK
X# include <time.h>
X# endif /* CLK_TCK */
X
X# define HISTORY "HistoryDBM"
X
Xtypedef struct _history {
X time_t tim;
X int flag;
X char fns[1024];
X} history;
X
Xextern DBM *open_hist ();
X
XEXTERN datum key, dat;
XEXTERN history *hptr, hist;
XEXTERN DBM *db;
X# endif /* USE_NDBM */
__END__OF__THIS__FILE__
if test -f 'INEWS/ihead.c' ; then
echo 'File INEWS/ihead.c already exists, overwriting it'
del 'INEWS/ihead.c'
fi
echo Extracting \"'INEWS/ihead.c'\"
sed "s/^X//" >'INEWS/ihead.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: ihead.c_v $
X * Revision 1.1 90/08/31 15:33:46 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: ihead.c_v 1.1 90/08/31 15:33:46 cs Exp $";
X# endif LINT
X# include "inews.h"
X
Xextern char *malloc ();
X
Xint
Xinsert_header (id, s, replace_it)
Xint id;
Xchar *s;
Xint replace_it;
X{
X char *buf;
X charc *tmp;
X register charc *t2;
X
X if ((id < 0) || (id > HEADER_MAX))
X return (-1);
X if (!(buf = malloc (strlen (hlines[id] + 2) + strlen (s) + 6)))
X return (-1);
X strcpy (buf, hlines[id] + 2);
X strcat (buf, " ");
X strcat (buf, s);
X if (tmp = get_header_line (id)) {
X if (replace_it) {
X free (tmp->text);
X tmp->text = buf;
X } else
X free (buf);
X } else {
X if (!(tmp = (charc *) malloc (sizeof (charc)))) {
X free (buf);
X return (-1);
X }
X tmp->text = buf;
X tmp->next = NULL;
X if (!head)
X head = tmp;
X else {
X t2 = head;
X while (t2->next)
X t2 = t2->next;
X t2->next = tmp;
X }
X }
X return (0);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/inews.c' ; then
echo 'File INEWS/inews.c already exists, overwriting it'
del 'INEWS/inews.c'
fi
echo Extracting \"'INEWS/inews.c'\"
sed "s/^X//" >'INEWS/inews.c' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: inews.c_v $
X * Revision 1.3 91/12/26 13:41:06 ud
X * insert a new locking mechanism with events; not yet tested
X *
X * Revision 1.2 91/05/22 13:20:01 ud
X * Added storing of articles in a seperate sub directory if lck.inews
X * can't be locked
X *
X * Revision 1.1 90/08/31 15:33:49 cs
X * Initial revision
X *
X */
X# ifndef LINT
Xstatic char rcsid[] = "$Id: inews.c_v 1.3 91/12/26 13:41:06 ud Exp $";
Xstatic char copyright[] = "Copyright (C) 1989, 1990 by Ulrich Dessauer, Germering, Germany.\n";
X# endif LINT
X# include <signal.h>
X# define EXTERN
X# include "inews.h"
X# include "hist.h"
X# ifdef EVENT_LOCK
X# include "lock.h"
X# endif /* EVENT_LOCK */
X
Xint
Xhandler (sig)
Xint sig;
X{
X switch (sig) {
X case SIGHUP:
X break;
X# ifdef EVENT_LOCK
X case SIGALRM:
X _got_alarm = TRUE;
X break;
X# endif /* EVENT_LOCK */
X default:
X# ifdef EVENT_LOCK
X do_unlock ("*");
X# endif /* EVENT_LOCK */
X exit (sig);
X break;
X }
X}
X
Xint
Xmain (argc, argv)
Xint argc;
Xchar *argv[];
X{
X int n;
X
X zero_out ();
X parse_args (argc, argv);
X intercept (handler);
X if ((n = do_init (TRUE)) < 0) {
X if ((n != -2) || (do_store () < 0)) {
X do_log ("Failed in do_init()\n");
X do_exit (1);
X }
X do_exit (0);
X }
X if (read_active () < 0) {
X do_log ("Failed in read_active()\n");
X do_exit (1);
X }
X if (read_sys () < 0) {
X do_log ("Failed in read_sys()\n");
X do_exit (1);
X }
X if (read_header (0) < 0) {
X do_log ("Failed in read_header()\n");
X do_exit (1);
X }
X if (check_active () < 0) {
X do_log ("Failed in check_active()\n");
X do_exit (1);
X }
X if (write_groups () < 0) {
X do_log ("Failed in write_groups()\n");
X do_exit (1);
X }
X if (process_sys () < 0) {
X do_log ("Failed in process_sys()\n");
X do_exit (1);
X }
X if (restore_active () < 0) {
X do_log ("Failed in restore_active()\n");
X do_exit (1);
X }
X do_exit (0);
X}
__END__OF__THIS__FILE__
if test -f 'INEWS/inews.h' ; then
echo 'File INEWS/inews.h already exists, overwriting it'
del 'INEWS/inews.h'
fi
echo Extracting \"'INEWS/inews.h'\"
sed "s/^X//" >'INEWS/inews.h' <<'__END__OF__THIS__FILE__'
X/*
X * $Log: inews.h_v $
X * Revision 1.4 91/05/22 13:33:16 ud
X * Added defines for Newsgroups file, Temp.file
X * Added define for Supersedes: field
X *
X * Revision 1.3 91/01/02 21:29:38 ud
X * Removed the defines for history management and put them in a own
X * include file, hist.h
X *
X * Revision 1.2 90/12/01 15:40:13 ud
X * Added struct for archiving news
X * Changed history relevant entries for hashing
X *
X * Revision 1.1 90/08/31 15:34:00 cs
X * Initial revision
X *
X */
X/*
X * Format of the sys-file
X * <site>{/sites(,sites)}{>fflag(s)}:<groups>:<dist>{:<cmd>}
X * <site> ::= the name of the site to forward this news
X * (check against member in the Path: field)
X * <sites> ::= this optional list of sites are to be not part of
X * the Path: otherwise they are not forwarded
X * <fflags> ::= Flags to be prefixed to the filename in the file
X * in the batchdirectory
X * <groups> ::= A list of to be send newsgroups for this site
X * <dist> ::= List of distributions for this site, !dist is
X * allowed to disable a distributin
X * <cmd> ::= Command to be executed, if not default is used
X * (default is storing all filenames in a file with
X * the filename equal to the sitename in a batch-
X * directory)
X */
X/*
X * Format of the history-file:
X * <number> <msg-id> <flag> <filename> {<filename>}
X * number ::= return value of time()
X * msg-id ::= the messageid of that article
X * flag ::= "0" | "1" ; "1" it article still exists, "0" if only
X * to be checked as duplicate articels
X * filename ::= filename of article and all "pseudo"-links
X */
X/*
X * Format of the active-file:
X * <grp>:<low> <high> <aflag>{ <moderator>}
X * <grp> ::= The name of the group
X * <low> ::= the low mark (the number of the oldest article)
X * <high> ::= the high mark (the newest article on the system)
X * <aflag> ::= Moderatorflag (n = not mod., y = is mod.) or ignore
X * <moderator> ::= The Name of the Moderators
X */
X/*
X * Format of the .newsrc File:
X * <flag><grp>:<low>:<high>:{<unread>}
X * <flag> ::= the group is unsubscribed
X * <grp> ::= the name of the group
X * <low> ::= All articles lower than this are obsolete (incl. this)
X * <high> ::= All articles higher than this are new
X * <unread> ::= A list of unread articles in this group
X */
X/*
X * Format of the Distributions File:
X * <group> <dist>{,<dist>} [<comment>]
X * <group> ::= A regular expression for the desired group
X * <dist> ::= A default distribution on this group
X * <comment> ::= A comment describing this newsgroup (opt.)
X */
X/*
X * Format of Archive FIle:
X * <group> <directory> {<prefix>}
X * <group> ::= The newsgroup to be archived (wildcard allowed)
X * <directory> ::= A valid absolute path to a directory where to this
X * gorup should be archived
X * <prefix> ::= Optional prefix to be placed before the unique
X * number in the destination directory
X */
X# include <regexp.h>
X# include "news.h"
X# include "patchlevel.h"
X
X/*
X * Some standard defienes
X */
X# ifndef NULL
X# define NULL 0
X# endif NULL
X
X/*
X * Current version
X */
X# define VERSION "1.03"
X# ifndef PATCHLEVEL
X# define VERSIONSTR "MNews (minimal News system for OSK) V %s"
X# else PATCHLEVEL
X# define VERSIONSTR "MNews (minimal News system for OSK) V %s (PL %d)"
X# endif PATCHLEVEL
X
X/*
X * Default directories
X */
X# define NEWS_BATCH MNEWS_BATCHDIR
X# define NEWS_DIR MNEWS_NEWSDIR
X# define NEWS_LIB MNEWS_NEWSLIB
X# define NEWS_TSPOOL MNEWS_TSPOOLDIR
X
X/*
X * Some Filenames
X */
X# define ACTIVE_FILE "Active"
X# define ACT_BAK_FILE "Active.bak"
X# define SYS_FILE "Sys"
X# define DIST_FILE "Distributions"
X# define CHK_FILE "Checkgroups"
X# define ALIAS_FILE "Aliases"
X# define LOG_FILE "logfile"
X# define UUNAME_FILE "send_uuname"
X# define ARCHIVE_FILE "Archive"
X# define FOLLOW_FILE "Followup"
X
X# define NEWSGROUPS_FILE "Newsgroups"
X
X# define TEMP_FILE "$$$temp_file$$$"
X
X# define EDITOR "me"
X
X/*
X * Access mode for the path for makdir()
X */
X# define ACCESS_PATH 3
X
X/*
X * Lock entry, only one program should run which changes
X * files relating to inews
X */
X# define NEWS_LOCK "lck.inews"
X
X/*
X * this specifies the time how long to wait for a lock
X * -1 means wait forever, 0 means don't wait and every
X * positiv number is the wait value in seconds
X */
X# define LOCK_TIMEOUT 6
X
X/*
X * Flags in the Active file (Types of moderation, ignore ng. etc.)
X */
X# define M_NOT_MOD 'n'
X# define M_MOD 'y'
X# define M_IGNORE 'i'
X# define M_USE 'u'
X# define M_READONLY 'r'
X
X/*
X * Some special Newsgroups & Distribution & etc.
X */
X# define NG_JUNK "junk"
X# define NG_CONTROL "control"
X
X# define DST_LOCAL "local"
X# define DST_WORLD "world"
X
X# define CTRL_POSTFIX ".ctl"
X
X/*
X * Lines in header
X */
X# define H_PATH 0
X# define H_FROM 1
X# define H_REPLY_TO 2
X# define H_NEWSGROUPS 3
X# define H_TO 4
X# define H_CC 5
X# define H_SUBJECT 6
X# define H_FOLLOWUP_TO 7
X# define H_MESSAGE_ID 8
X# define H_DISTRIBUTION 9
X# define H_DATE 10
X# define H_SENDER 11
X# define H_REFERENCES 12
X# define H_ORGANIZATION 13
X# define H_KEYWORDS 14
X# define H_SUMMARY 15
X# define H_EXPIRES 16
X# define H_SUPERSEDES 17
X# define H_CONTROL 18
X# define H_APPROVED 19
X# define H_LINES 20
X# define H_XREF 21
X# define H_POSTED 22
X
X# define HEADER_MAX 22
X
X# define S_PATH 0
X# define S_NEWSGROUPS 1
X# define S_TO 2
X# define S_SUBJECT 3
X# define S_FOLLOWUP_TO 4
X# define S_MESSAGE_ID 5
X# define S_DISTRIBUTION 6
X# define S_REFERENCES 7
X# define S_SUPERSEDES 8
X
X# define SPECIAL_MAX 8
X
X/*
X * Possible Control Messages
X */
X# define CC_CANCEL 0
X# define CC_IHAVE 1
X# define CC_SENDME 2
X# define CC_NEWGROUP 3
X# define CC_RMGROUP 4
X# define CC_SENDSYS 5
X# define CC_SENDUUNAME 6
X# define CC_VERSION 7
X# define CC_CHECKGROUPS 8
X
X/*
X * Possible modes for the user-interface
X */
X# define M_NONE 0
X# define M_READ 1
X# define M_WRITE 2
X# define M_MAIL 3
X
X/*
X * Some macros...
X */
X# define Write(s) writeln(1,s,strlen(s))
X# define skip_field(s) skipn ((s), ':')
X# define is_part_of_hostname(c) ((c) && (is8alnum (c) || index ("-+._", (c))))
X
X/*
X * This keeps the header
X */
Xtypedef struct _charc {
X char *text; /* any kind of text */
X int nr; /* Number, e.g. Filename for NG */
X struct _charc *next;
X} charc;
X
X/*
X * This hold every line of the sys-File
X */
Xtypedef struct _sys {
X char *site; /* Destination site */
X char **wsites; /* don't forward news with this sitenames
X in the Path: */
X char *fflags; /* flags for the batchfile */
X int fwd; /* if this article should go to sys */
X regexp **grps; /* The desired group in reg.exp. */
X int *inv; /* if the matching ng should NOT xmit */
X char **dist; /* The distributions for this site */
X char *cmd; /* the command to pipe to for this site */
X struct _sys *next;
X} sys;
X
X/*
X * The active File
X */
Xtypedef struct _active {
X char *grp; /* group name */
X int flag; /* flag for checkgroups etc. */
X int low; /* the lowest current number */
X int high; /* the highest current number */
X int pos; /* position of low/high in file */
X int changed; /* if this entry had been changed */
X char aflag[10]; /* active flag, moderated or ignore */
X int kblimit; /* maximum size of an article to be for-
X warded */
X char **moderator; /* the name(s) (accounts of the
X moderators */
X# ifdef HASH_SEARCH
X hash_t id; /* the hashed version of the groupname */
X struct _active *hnext; /* next entry in the hashline */
X# endif /* HASH_SEARCH */
X struct _active *next;
X} active;
X
X/*
X * To manage archive during expire
X */
Xtypedef struct _archive {
X char *grp; /* the name of the group as a wildcard */
X int len; /* strlen (archive->grp) */
X char *dest; /* the destination directiory */
X char *prefix; /* if there should be a prefix in the
X destination filename */
X struct _archive *next;
X} archive;
X
X/*
X * This structure is used to keep track of groups in the
X * Newsgroupsfile and not to delete old groups, if they
X * are not in the new checkgroups message
X */
Xtypedef struct _cgroup {
X char *group; /* name of the group */
X char seperate; /* the seperate character between
X group and comment (mostly space or
X tab) */
X char *comment; /* comment to the gorup */
X struct _cgroup
X *next;
X} cgroup;
X
X# include "ext.h"
X
X# ifndef EXTERN
X# define EXTERN extern
Xextern char *hlines[];
Xextern char *slines[];
Xextern char *ctrlcodes[];
X# else EXTERN
Xchar *hlines[] = {
X /* first character is 0, 1 or 2, 0 if the line must be present in
X the header, 1 if this line may be there 2 if it have to be deleted */
X "0 Path:",
X "0 From:",
X "1 Reply-To:",
X "0 Newsgroups:",
X "2 To:",
X "2 Cc:",
X "0 Subject:",
X "1 Followup-To:",
X "0 Message-ID:",
X "1 Distribution:",
X "0 Date:",
X "1 Sender:",
X "1 References:",
X "1 Organization:",
X "1 Keywords:",
X "1 Summary:",
X "1 Expires:",
X "1 Supersedes:",
X "1 Control:",
X "1 Approved:",
X "0 Lines:",
X "2 Xref:",
X "1 Posted:",
X NULL
X};
X
Xchar *slines[] = {
X "Path:",
X "Newsgroups:",
X "To:",
X "Subject:",
X "Followup-To:",
X "Message-Id:",
X "Distribution:",
X "References:",
X "Supersedes:",
X NULL
X};
X
Xchar *ctrlcodes[] = {
X "cancel",
X "ihave",
X "sendme",
X "newgroup",
X "rmgroup",
X "sendsys",
X "senduuname",
X "version",
X "checkgroups",
X NULL
X};
X# endif EXTERN
X
XEXTERN charc *ngs; /* the newsgroups of this article */
XEXTERN charc *dists; /* the distribuitons of this article */
XEXTERN charc *head; /* the headerlines */
XEXTERN sys *hsys; /* the sys-file entries */
XEXTERN active *hact; /* the active file */
X# ifdef HASH_SEARCH
XEXTERN active **hashact; /* the hashtable for the active file */
X# endif /* HASH_SEARCH */
XEXTERN int act_rewrite; /* active file needs complete written */
X
XEXTERN int artsize; /* the size of the article */
X
XEXTERN int block_forward; /* if forwarding of this article should
X be blocked */
X
XEXTERN charc *recv; /* list of receiver for mailing */
X
XEXTERN char *hostname; /* The hostname of this system */
XEXTERN char *fhost; /* Fullhostname (including domain) */
XEXTERN char *news_owner; /* the owner of the newssystem */
X
XEXTERN char *batchdir; /* Directory where batchfiles lives */
XEXTERN char *newsdir; /* Directory for the news themselves */
XEXTERN char *newslib; /* Directory for the news files */
XEXTERN char *newstspool; /* Directory for temp.spooled files */
X
XEXTERN int crthd; /* create missing header lines */
XEXTERN int doconv; /* if a character translation should
X take place */
XEXTERN int ins_dist; /* If the automatic determination of
X the distributions (if none present)
X should switched on w/o crthd */
X
X# ifndef IN_MEMORY
XEXTERN char newstmp[40 + sizeof (TEMPDIR)];
X /* The temp.filename of the body */
X# else /* IN_MEMORY */
XEXTERN list *newstmp; /* the body in memory */
X# endif /* IN_MEMORY */
X
XEXTERN charc *isctrl; /* if this is a Ctrl-Msg */
XEXTERN int lines; /* lines in the message */
XEXTERN char *realfile; /* the filename of the real article */
XEXTERN int catlines; /* if TRUE, readin cats lines finished
X with a backslash with the next line */
XEXTERN int conv_it; /* if TRUE, readin converts a character
X set it possible/neccessary */
XEXTERN int isadm; /* if caller is news.admin */
XEXTERN int verbose; /* if log messages should appear on scr */
XEXTERN char *user; /* the name of the user */
XEXTERN char *home; /* the homedirectory of current user */
X
XEXTERN void (*local_term) ();
X /* if a subsystem of the newssystem
X needs it own cleanup */
__END__OF__THIS__FILE__
exit 0
: end of shell archive
--
Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads