home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky de.comp.sources.os9:8 comp.os.os9:1550
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!sungy!stasys!stasys!not-for-mail
- From: frank.kaefer@stasys.sta.sub.org (Frank Kaefer)
- Newsgroups: de.comp.sources.os9,comp.os.os9
- Subject: MNews Prerelease Part02/09
- Message-ID: <1hafd5INNpsn@stasys.sta.sub.org>
- Date: 23 Dec 92 19:41:25 GMT
- Sender: news@stasys.sta.sub.org
- Followup-To: de.comp.sources.d
- Organization: Stasys News Server, Starnberg, Germany
- Lines: 1855
- Approved: frank.kaefer@stasys.sta.sub.org (Frank Kaefer)
- NNTP-Posting-Host: stasys.sta.sub.org
-
- Submitted-by: Ulrich Dessauer <ud@Nightmare.ddt.sub.org>
- Archive-name: mnews/part02
-
- : ----- Cut here ----- Cut here ----- Cut here ----- Cut here -----
- : Use sh filename to extract shell archive
- : This shell archive contains following files:
- : 'INEWS/RELS (Directory)'
- : 'INEWS/achk.c 5018 bytes'
- : 'INEWS/adm.c 740 bytes'
- : 'INEWS/alias.c 1678 bytes'
- : 'INEWS/app.c 3437 bytes'
- : 'INEWS/arc.c 3250 bytes'
- : 'INEWS/build.c 4973 bytes'
- : 'INEWS/ccan.c 2678 bytes'
- : 'INEWS/cchk.c 5484 bytes'
- : 'INEWS/cnew.c 3610 bytes'
- : 'INEWS/crct.c 2437 bytes'
- : 'INEWS/crm.c 1831 bytes'
- : 'INEWS/crth.c 2723 bytes'
- :
- if test -d 'INEWS/RELS' ; then
- echo 'Directory INEWS/RELS already exists'
- else
- echo Make directory \"'INEWS/RELS'\"
- makdir 'INEWS/RELS'
- fi
- if test -f 'INEWS/achk.c' ; then
- echo 'File INEWS/achk.c already exists, overwriting it'
- del 'INEWS/achk.c'
- fi
- echo Extracting \"'INEWS/achk.c'\"
- sed "s/^X//" >'INEWS/achk.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: achk.c_v $
- X * Revision 1.3 91/12/26 13:35:42 ud
- X * Added a feature to just forward articles with a maximum size
- X *
- X * Revision 1.2 91/05/22 13:11:51 ud
- X * Added better junk handling, added 2nd flag to skip newsgroups in active
- X * file (they are present, but have no spooldirectory)
- X *
- X * Revision 1.1 90/08/31 15:31:48 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: achk.c_v 1.3 91/12/26 13:35:42 ud Exp $";
- X# endif LINT
- X# include "inews.h"
- X
- Xextern char *malloc ();
- Xextern char *rindex ();
- X
- Xint
- Xcheck_active ()
- X{
- X register charc *act;
- X charc *prev;
- X charc *tmp, *t2;
- X int valid;
- X int isok;
- X register active *atmp;
- X char *junkbuf;
- X char *ptr;
- X char *comment[4];
- X int maxlimit;
- X int is_junked;
- X
- X act = isctrl ? isctrl : ngs;
- X t2 = NULL;
- X# ifdef NO_JUNK
- X valid = FALSE;
- X# else /* NO_JUNK */
- X valid = TRUE;
- X# endif /* NO_JUNK */
- X is_junked = 0;
- X maxlimit = -2;
- X while (act) {
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (act->text, atmp->grp))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (act -> text);
- X# endif /* HASH_SEARCH */
- X if (!atmp) {
- X if (junkbuf = malloc (strlen (act->text) + strlen (NG_JUNK) + 4)) {
- X strcpy (junkbuf, act->text);
- X strcat (junkbuf, ".");
- X strcat (junkbuf, NG_JUNK);
- X do {
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (atmp->grp, junkbuf))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (junkbuf);
- X# endif /* HASH_SEARCH */
- X if (!atmp) {
- X if (ptr = rindex (junkbuf, '.'))
- X *ptr = '_';
- X if (ptr = rindex (junkbuf, '.'))
- X strcpy (ptr + 1, NG_JUNK);
- X }
- X } while ((!atmp) && ptr);
- X if (!atmp) {
- X free (junkbuf);
- X junkbuf = NULL;
- X }
- X }
- X if (!junkbuf) {
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (atmp->grp, NG_JUNK))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (NG_JUNK);
- X# endif /* HASH_SEARCH */
- X }
- X if (atmp)
- X for (tmp = isctrl ? isctrl : ngs; tmp; tmp = tmp -> next)
- X if (tmp != act)
- X if (! strcmp (tmp -> text, atmp -> grp)) {
- X free (junkbuf);
- X junkbuf = NULL;
- X atmp = NULL;
- X break;
- X }
- X if (atmp && (valid || junkbuf)) {
- X do_log ("Newsgroup '%s' not in active, moved to %s\n", act->text, junkbuf ? junkbuf : NG_JUNK);
- X if (!isctrl) {
- X ++is_junked;
- X if (!junkbuf) {
- X strcpy (act->text, NG_JUNK);
- X valid = FALSE;
- X } else {
- X free (act->text);
- X act->text = junkbuf;
- X junkbuf = NULL;
- X }
- X } else if (junkbuf) {
- X free (junkbuf);
- X junkbuf = NULL;
- X }
- X } else
- X atmp = NULL;
- X }
- X isok = TRUE;
- X if (atmp) {
- X if (atmp->aflag[0] == M_MOD) {
- X if (!get_header_line (H_APPROVED))
- X isok = FALSE;
- X } else if (crthd && (atmp -> aflag[0] == M_READONLY))
- X isok = FALSE;
- X if (atmp->aflag[1] == M_IGNORE)
- X isok = FALSE;
- X }
- X if ((! atmp) || (! isok)) {
- X if (atmp && crthd && user && (atmp -> aflag[0] == M_READONLY)) {
- X comment[0] = "You tried to post to a group which is read-only\n";
- X comment[1] = "Your article follows:\n";
- X comment[2] = NULL;
- X mail_to (user, NULL, "This group is read-only: ", ngs -> text, newstmp, comment);
- X }
- X if (!isctrl) {
- X tmp = act;
- X act = act->next;
- X if (!t2)
- X ngs = ngs->next;
- X else
- X t2->next = act;
- X free (tmp->text);
- X free ((char *) tmp);
- X } else {
- X t2 = act;
- X act = act->next;
- X }
- X } else {
- X atmp->changed = TRUE;
- X atmp->high++;
- X if (maxlimit != -1)
- X if (atmp -> kblimit == -1)
- X maxlimit = -1;
- X else if ((maxlimit == -2) || (atmp -> kblimit < maxlimit))
- X maxlimit = atmp -> kblimit;
- X act->nr = atmp->high;
- X t2 = act;
- X act = act->next;
- X }
- X }
- X
- X if ((maxlimit >= 0) && ((maxlimit << 10) < artsize)) {
- X do_log ("Blocked due too large article (%d kBytes)\n", (artsize >> 10) + 1);
- X block_forward = TRUE;
- X }
- X
- X if ((!isctrl) && (!ngs)) {
- X do_log ("No more newsgroups after check_active(), aborted.\n");
- X do_exit (0);
- X }
- X
- X# ifndef NO_JUNK
- X if ((!isctrl) && (!valid)) {
- X# if 1
- X while (is_junked-- > 0) {
- X for (t2 = ngs; t2 -> next; t2 = t2 -> next)
- X ;
- X prev = NULL;
- X for (act = ngs; act; act = act -> next)
- X if (((ptr = rindex (act -> text, '.')) && Strieql (ptr + 1, NG_JUNK)) || Strieql (act -> text, NG_JUNK))
- X break;
- X else
- X prev = act;
- X if (act && (act != t2)) {
- X if (! prev)
- X ngs = ngs -> next;
- X else
- X prev -> next = act ->next;
- X act -> next = NULL;
- X t2 -> next = act;
- X }
- X }
- X# else
- X act = ngs;
- X t2 = NULL;
- X while (act)
- X if (Strieql (act->text, NG_JUNK))
- X break;
- X else {
- X t2 = act;
- X act = act->next;
- X }
- X if (act && act->next) {
- X if (t2)
- X t2->next = act->next;
- X else
- X ngs = ngs->next;
- X for (t2 = ngs; t2->next; t2 = t2->next)
- X ;
- X t2->next = act;
- X act->next = NULL;
- X }
- X# endif
- X }
- X# endif /* NO_JUNK */
- X
- X return (0);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/adm.c' ; then
- echo 'File INEWS/adm.c already exists, overwriting it'
- del 'INEWS/adm.c'
- fi
- echo Extracting \"'INEWS/adm.c'\"
- sed "s/^X//" >'INEWS/adm.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: adm.c_v $
- X * Revision 1.2 91/05/22 13:32:15 ud
- X * Added check_history_size() for ndbm files (--> file segment list)
- X *
- X * Revision 1.1 90/12/01 15:51:09 ud
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: adm.c_v 1.2 91/05/22 13:32:15 ud Exp $";
- X# endif LINT
- X# include "inews.h"
- X
- Xvoid
- Xdo_admin (doexp, delart, delhist, ra, rh, cd)
- Xint doexp;
- Xchar *delart, *delhist;
- Xint ra;
- Xint rh;
- Xint cd;
- X{
- X
- X if (do_init (TRUE) < 0)
- X exit (_errmsg (1, "Can't init in expire\n"));
- X if (doexp)
- X do_expire (delart, delhist);
- X if (ra)
- X rebuild_active_file ();
- X if (rh)
- X rebuild_history ();
- X# ifdef USE_NDBM
- X if (cd)
- X check_history_size ();
- X# endif /* USE_NDBM */
- X nunlock ();
- X respool (FALSE);
- X do_exit (0);
- X}
- X
- __END__OF__THIS__FILE__
- if test -f 'INEWS/alias.c' ; then
- echo 'File INEWS/alias.c already exists, overwriting it'
- del 'INEWS/alias.c'
- fi
- echo Extracting \"'INEWS/alias.c'\"
- sed "s/^X//" >'INEWS/alias.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: alias.c_v $
- X * Revision 1.1 90/08/31 15:31:51 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: alias.c_v 1.1 90/08/31 15:31:51 cs Exp $";
- X# endif LINT
- X# include <modes.h>
- X# include "inews.h"
- X
- Xextern char *malloc ();
- X
- Xvoid
- Xdelete_dup_charc (list)
- Xcharc *list;
- X{
- X register charc *cur, *prev, *tmp;
- X
- X if (!list)
- X return;
- X cur = list;
- X while (cur) {
- X prev = cur;
- X tmp = cur->next;
- X while (tmp)
- X if (Strieql (tmp->text, cur->text))
- X break;
- X else {
- X prev = tmp;
- X tmp = tmp->next;
- X }
- X if (tmp) {
- X prev->next = tmp->next;
- X free (tmp->text);
- X free ((char *) tmp);
- X } else
- X cur = cur->next;
- X }
- X}
- X
- Xint
- Xalias_newsgroups ()
- X{
- X char *buf;
- X int fd;
- X int n;
- X register charc *tmp, *prev;
- X char *new;
- X charc *newng, *app;
- X int didit;
- X
- X if (!ngs)
- X return (FALSE);
- X if ((fd = open (ALIAS_FILE, S_IREAD)) < 0)
- X return (FALSE);
- X didit = FALSE;
- X catlines = TRUE;
- X while (buf = readbuf (fd, & n)) {
- X if ((n == 1) || (buf[0] == '#'))
- X continue;
- X buf[n - 1] = '\0';
- X new = skipc (buf, '\0');
- X tmp = ngs;
- X prev = NULL;
- X while (tmp)
- X if (Strieql (tmp->text, buf))
- X break;
- X else {
- X prev = tmp;
- X tmp = tmp->next;
- X }
- X if (!tmp)
- X continue;
- X didit = TRUE;
- X if (!*new) {
- X if (prev)
- X prev->next = tmp->next;
- X else
- X ngs = ngs->next;
- X } else if (newng = split_fields (new, TRUE)) {
- X if (prev) {
- X prev->next = newng;
- X app = prev;
- X } else {
- X ngs = newng;
- X app = ngs;
- X }
- X while (app->next)
- X app = app->next;
- X app->next = tmp->next;
- X }
- X free (tmp->text);
- X free ((char *) tmp->text);
- X }
- X catlines = FALSE;
- X close (fd);
- X if (didit)
- X delete_dup_charc (ngs);
- X return (didit);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/app.c' ; then
- echo 'File INEWS/app.c already exists, overwriting it'
- del 'INEWS/app.c'
- fi
- echo Extracting \"'INEWS/app.c'\"
- sed "s/^X//" >'INEWS/app.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: app.c_v $
- X * Revision 1.1 90/08/31 15:31:55 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: app.c_v 1.1 90/08/31 15:31:55 cs Exp $";
- X# endif LINT
- X# include "inews.h"
- X
- Xextern char *malloc ();
- Xextern char *strdup ();
- X
- Xvoid
- Xcheck_approved ()
- X{
- X register int t;
- X register charc *t2;
- X register char *ptr;
- X char *recs;
- X register charc *tmp;
- X char *from, *sender;
- X active *atmp;
- X sys *stmp;
- X char *comment[10];
- X
- X tmp = ngs;
- X while (tmp) {
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (atmp->grp, tmp->text))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (tmp -> text);
- X# endif /* HASH_SEARCH */
- X if (atmp && (atmp->aflag[0] == M_MOD))
- X break;
- X tmp = tmp->next;
- X }
- X if ((!tmp) || (!atmp) || (!atmp->moderator))
- X return;
- X if (tmp = get_header_line (H_APPROVED))
- X return;
- X sender = find_address_hl (H_SENDER);
- X from = find_address_hl (H_FROM);
- X if (!(sender || from))
- X return;
- X if (atmp->moderator)
- X for (t=0;atmp->moderator[t];++t)
- X if (from && (Strieql (atmp->moderator[t], from)))
- X break;
- X else if (sender && (Strieql (atmp->moderator[t], sender)))
- X break;
- X if ((!atmp->moderator) || (!atmp->moderator[t])) {
- X do_log ("Article %s from wrong sender (%s, %s) in %s\n",
- X get_msgid (),
- X from ? from : "[no From]",
- X sender ? sender : "[no Sender]",
- X atmp->grp);
- X stmp = hsys;
- X while (stmp) {
- X stmp->fwd = FALSE;
- X stmp = stmp->next;
- X }
- X# ifdef NO_MAIL_TO_MODERATOR
- X if (recs = strdup (atmp->grp)) {
- X ptr = recs;
- X while (*ptr)
- X if (*ptr == '.')
- X *ptr++ = '-';
- X else
- X ++ptr;
- X comment[0] = "A message had been posted to the moderated group,\n";
- X comment[1] = "where you are listen as the moderator, the submitter was:\n";
- X comment[2] = sender ? sender : (from ? from : "[unknown]");
- X comment[3] = ". The submisson took place in '";
- X comment[4] = atmp->grp;
- X comment[5] = "'.\n";
- X comment[6] = "I hope you know how to handle this mail\n";
- X comment[7] = NULL;
- X mail_to (recs, from, "Non-approved article in moderated group by", from ? from : (sender ? sender : (from ? from : "[unknown]")), newstmp, comment);
- X }
- X# endif /* NO_MAIL_TO_MODERATOR */
- X comment[0] = "You tried to post a message in a moderated group,\n";
- X comment[1] = "Where you aren't the moderator; the group was '";
- X comment[2] = atmp->grp;
- X comment[3] = "'.\n";
- X# ifdef NO_MAIL_TO_MODERATOR
- X if (recs)
- X comment[4] = "Your article had been forwarded to the moderator.\n";
- X else
- X comment[4] = "Please send your article directly via mail to the moderator.\n";
- X# else /* NO_MAIL_TO_MODERATOR */
- X comment[4] = "If you wish to send this to the moderator, send it via mail\n";
- X# endif /* NO_MAIL_TO_MODERATOR */
- X comment[5] = NULL;
- X mail_to (from ? from : sender, NULL, "This is a moderated group!", NULL, recs ? NULL : newstmp, comment);
- X if (recs)
- X free (recs);
- X } else {
- X if (tmp = (charc *) malloc (sizeof (charc))) {
- X tmp->next = NULL;
- X if (tmp->text = malloc (strlen (atmp->moderator[t]) + strlen (hlines[H_APPROVED] + 2) + 6)) {
- X sprintf (tmp->text, "%s %s@%s",
- X hlines[H_APPROVED] + 2,
- X news_owner,
- X fhost);
- 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 sort_header (FALSE);
- X } else
- X free ((char *) tmp);
- X }
- X }
- X if (from)
- X free (from);
- X if (sender)
- X free (sender);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/arc.c' ; then
- echo 'File INEWS/arc.c already exists, overwriting it'
- del 'INEWS/arc.c'
- fi
- echo Extracting \"'INEWS/arc.c'\"
- sed "s/^X//" >'INEWS/arc.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: arc.c_v $
- X * Revision 1.1 90/10/26 14:20:31 ud
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: arc.c_v 1.1 90/10/26 14:20:31 ud Exp $";
- X# endif LINT
- X# include <modes.h>
- X# include <errno.h>
- X# include "inews.h"
- X
- Xextern char *malloc ();
- Xextern char *strdup ();
- X
- Xstatic void
- Xdo_copy (fdi, fdo)
- Xregister int fdi, fdo;
- X{
- X register int n;
- X register int size;
- X register char *buf;
- X register char smallbuf[128];
- X
- X size = 5000;
- X while (size >= 1000)
- X if (buf = malloc (size + 20))
- X break;
- X else
- X size -= 1000;
- X if (size < 1000) {
- X size = 100;
- X buf = smallbuf;
- X }
- X while ((n = read (fdi, buf, size)) > 0)
- X write (fdo, buf, n);
- X if (size > 100)
- X free (buf);
- X}
- X
- Xarchive *
- Xsetup_archive ()
- X{
- X int fd;
- X char *buf;
- X int n;
- X archive *ahead, *cur, *tmp;
- X char *group, *destination, *prefix;
- X
- X ahead = NULL;
- X if ((fd = open (ARCHIVE_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 group = buf;
- X destination = skipc (group, '\0');
- X prefix = skipc (destination, '\0');
- X if (tmp = (archive *) malloc (sizeof (archive)))
- X if (tmp->grp = strdup (group))
- X if (tmp->dest = strdup (destination)) {
- X tmp->len = strlen (tmp->grp);
- X if (prefix && *prefix)
- X tmp->prefix = strdup (prefix);
- X else
- X tmp->prefix = NULL;
- X tmp->next = NULL;
- X if (!ahead)
- X ahead = tmp;
- X else
- X cur->next = tmp;
- X cur = tmp;
- X } else {
- X free (tmp->grp);
- X free ((char *) tmp);
- X }
- X else
- X free ((char *) tmp);
- X }
- X catlines = FALSE;
- X close (fd);
- X return (ahead);
- X}
- X
- Xvoid
- Xfree_archive (ahead)
- Xarchive *ahead;
- X{
- X register archive *tmp, *cur;
- X
- X cur = ahead;
- X while (cur) {
- X tmp = cur;
- X cur = cur->next;
- X free (tmp->grp);
- X free (tmp->dest);
- X if (tmp->prefix)
- X free (tmp->prefix);
- X }
- X}
- X
- Xvoid
- Xdo_archive (fn, arc)
- Xchar *fn;
- Xarchive *arc;
- X{
- X char *fullfn;
- X char *destfn;
- X int fd, fdo;
- X int n;
- X int id;
- X
- X if (!(arc && fn))
- X return;
- X if (!(fullfn = create_fn (fn))) {
- X do_log ("FATAL: Can't create full-filename in do_archive().\n");
- X return;
- X }
- X if (!(destfn = malloc (strlen (arc->dest) + 40))) {
- X do_log ("FATAL: Can't malloc for dest in do_archive().\n");
- X free (fullfn);
- X return;
- X }
- X strcpy (destfn, arc->dest);
- X strcat (destfn, "/.seq");
- X do {
- X if ((fd = open (destfn, S_IREAD | S_IWRITE | S_ISHARE)) < 0) {
- X if (errno == E_PNNF) {
- X fd = create (destfn, S_IWRITE | S_ISHARE, 03);
- X id = 1;
- X }
- X } else {
- X read (fd, &id, sizeof (int));
- X lseek (fd, 0, 0);
- X }
- X if ((fd < 0) && (errno == E_SHARE))
- X sleep (1);
- X else
- X break;
- X } while (fd < 0);
- X if (fd != -1) {
- X n = id + 1;
- X write (fd, &n, sizeof (int));
- X close (fd);
- X }
- X if (arc->prefix && *arc->prefix)
- X sprintf (destfn, "%s/%s.%06d", arc->dest, arc->prefix, id);
- X else
- X sprintf (destfn, "%s/%06d", arc->dest, id);
- X if ((fd = open (fullfn, S_IREAD)) != -1) {
- X if ((fdo = create (destfn, S_IWRITE | S_ISIZE, 013, ((n = _gs_size (fd)) > 0) ? n : 4096)) != -1) {
- X do_copy (fd, fdo);
- X close (fdo);
- X } else
- X do_log ("Can't create %s for archive (%d).\n", destfn, errno);
- X close (fd);
- X } else
- X do_log ("Can't read %s for archive (%d).\n", fullfn, errno);
- X free (fullfn);
- X free (destfn);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/build.c' ; then
- echo 'File INEWS/build.c already exists, overwriting it'
- del 'INEWS/build.c'
- fi
- echo Extracting \"'INEWS/build.c'\"
- sed "s/^X//" >'INEWS/build.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: build.c_v $
- X * Revision 1.2 90/12/01 15:43:42 ud
- X * Added rebuild_history() to convert from old format to new
- X * hashing format; Rebuild from articles have to be done later
- X *
- X * Revision 1.1 90/08/31 15:31:59 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: build.c_v 1.2 90/12/01 15:43:42 ud Exp $";
- X# endif LINT
- X# include <stdio.h>
- X# include <c8type.h>
- X# include <modes.h>
- X# include <dir.h>
- X# include "inews.h"
- X# include "hist.h"
- X
- Xextern char *malloc ();
- Xextern char *strdup ();
- X
- Xstatic void
- Xbuild (at)
- Xactive *at;
- X{
- X int min, max, n;
- X DIR *dp;
- X struct direct *ent;
- X char *path;
- X
- X if (!(path = strdup (at->grp)))
- X return;
- X make_fn (path);
- X if (!(dp = opendir (path))) {
- X at->low = at->high;
- X free (path);
- X return;
- X }
- X min = -1;
- X max = -1;
- X while (ent = readdir (dp)) {
- X if (!is8digit (ent->d_name[0]))
- X continue;
- X n = atoi (ent->d_name);
- X if (min < 0) {
- X min = n;
- X max = n;
- X } else {
- X if (min > n)
- X min = n;
- X if (max < n)
- X max = n;
- X }
- X }
- X closedir (dp);
- X if (min < 0) {
- X min = at->high;
- X max = at->high;
- X }
- X if (max < min)
- X max = min;
- X do_log ("rebuild %s (%d, %d) --> (%d, %d)\n", at->grp,
- X at->low, at->high, min, max);
- X at->low = min;
- X at->high = max;
- X}
- X
- Xvoid
- Xrebuild_active_file ()
- X{
- X active *atmp;
- X charc *tmp;
- X
- X if ((! hact) && (read_active () < 0)) {
- X catlines = FALSE;
- X do_log ("Can't read active file in rebuild\n");
- X return;
- X }
- X act_rewrite = TRUE;
- X if (chdir (newsdir) < 0) {
- X do_log ("Can't chdir to %s in rebuild\n", newsdir);
- X return;
- X }
- X atmp = hact;
- X while (atmp) {
- X if (ngs) {
- X tmp = ngs;
- X while (tmp)
- X if (_cmpnam (atmp->grp, tmp->text, strlen (tmp->text)) == 0)
- X break;
- X else
- X tmp = tmp->next;
- X if (!tmp) {
- X atmp = atmp->next;
- X continue;
- X }
- X }
- X build (atmp);
- X atmp = atmp->next;
- X }
- X if (chdir (newslib) < 0) {
- X do_log ("Can't chdir to %s in rebuild\n", newsdir);
- X return;
- X }
- X if (restore_active () < 0) {
- X do_log ("Can't restore active file in rebuild\n");
- X return;
- X }
- X}
- X
- Xvoid
- Xrebuild_history ()
- X{
- X# ifndef USE_NDBM
- X int fd;
- X DIR *dp;
- X struct direct *ent;
- X charc *head, *cur, *tmp;
- X int err;
- X char *buf;
- X char *ptmp;
- X register char *ptr;
- X register int t;
- X char sav;
- X FILE *fp;
- X
- X if (!(buf = malloc (1024))) {
- X do_log ("Can't alloc in rebuild_history()\n");
- X return;
- X }
- X if (chdir (HIST_DIR) < 0) {
- X do_log ("Can't chdir to %s (errno %d\n", HIST_DIR, errno);
- X return;
- X }
- X head = NULL;
- X cur = NULL;
- X if (!(dp = opendir ("."))) {
- X do_log ("Can't read %s (errno %d)\n", HIST_DIR, errno);
- X chdir (newslib);
- X return;
- X }
- X err = 0;
- X while (ent = readdir (dp)) {
- X if ((ent->d_name[0] == '.') || isdigit (ent->d_name[0]))
- X continue;
- X if (!(tmp = (charc *) malloc (sizeof (charc)))) {
- X ++err;
- X break;
- X }
- X if (!(tmp->text = malloc (80))) {
- X free ((char *) tmp);
- X ++err;
- X break;
- X }
- X strcpy (tmp->text, ent->d_name);
- X tmp->next = NULL;
- X if (!cur)
- X head = tmp;
- X else
- X cur->next = tmp;
- X cur = tmp;
- X }
- X closedir (dp);
- X if (err) {
- X do_log ("Error during collecting history-files, aborted\n");
- X chdir (newslib);
- X return;
- X }
- X if (head) {
- X for (tmp = head, t = 0; tmp; tmp = tmp->next) {
- X sprintf (buf, "%06d_conv", t);
- X if (rename (tmp->text, buf) != 0) {
- X ++err;
- X break;
- X }
- X sprintf (tmp->text, "%s/%s", HIST_DIR, buf);
- X ++t;
- X }
- X if (chdir (newslib) < 0) {
- X do_log ("Can't chdir back to %s (%d)\n", newslib, errno);
- X return;
- X }
- X if (err) {
- X do_log ("Problems during renameing of files, aborted\n");
- X return;
- X }
- X for (tmp = head; tmp; tmp = tmp->next) {
- X if (!(fp = fopen (tmp->text, "r"))) {
- X ++err;
- X continue;
- X }
- X while (fgets (buf, 1000, fp)) {
- X ptmp = skipn (buf, '\0');
- X ptr = ptmp;
- X while (*ptr && (!is8space (*ptr)))
- X ++ptr;
- X if (!*ptr)
- X continue;
- X sav = *ptr;
- X *ptr = '\0';
- X if ((fd = open_hist (ptmp, S_IREAD | S_IWRITE)) != -1) {
- X if (lseek (fd, 0, 2) != -1) {
- X *ptr = sav;
- X do {
- X write (fd, buf, strlen (buf));
- X if (buf[strlen (buf) - 1] != '\n')
- X if (!fgets (buf, 1000, fp))
- X break;
- X } while (buf[strlen (buf) - 1] != '\n');
- X }
- X close (fd);
- X } else
- X ++err;
- X }
- X fclose (fp);
- X if (!err)
- X unlink (tmp->text);
- X }
- X if (err)
- X do_log ("Error during reformating old entries\n");
- X tmp = head;
- X while (tmp) {
- X cur = tmp;
- X tmp = tmp->next;
- X free (cur->text);
- X free ((char *) cur);
- X }
- X } else {
- X chdir (newslib);
- X do_log ("rebuild_history currently not implemented!\n");
- X }
- X if (chdir (HIST_DIR) < 0) {
- X do_log ("Fatal: Can't rechange to %s\n", HIST_DIR);
- X return;
- X }
- X if (!err)
- X if (dp = opendir (".")) {
- X while (ent = readdir (dp)) {
- X if ((ent->d_name[0] == '.') || is8digit (ent->d_name[0]))
- X continue;
- X sprintf (buf, "fsort %s", ent->d_name);
- X if (xshell (buf))
- X ++err;
- X }
- X closedir (dp);
- X }
- X free (buf);
- X# else /* USE_NDBM */
- X do_log ("rebuild_history for dbm currently not implemented!\n");
- X# endif /* USE_NDBM */
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/ccan.c' ; then
- echo 'File INEWS/ccan.c already exists, overwriting it'
- del 'INEWS/ccan.c'
- fi
- echo Extracting \"'INEWS/ccan.c'\"
- sed "s/^X//" >'INEWS/ccan.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: ccan.c_v $
- X * Revision 1.3 91/05/22 13:16:43 ud
- X * Seperate article delete function to be used by Supersedes:
- X *
- X * Revision 1.2 91/01/02 21:26:25 ud
- X * Added ndbm support for history
- X *
- X * Revision 1.1 90/08/31 15:32:03 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: ccan.c_v 1.3 91/05/22 13:16:43 ud Exp $";
- X# endif LINT
- X# include <modes.h>
- X# include "inews.h"
- X# include "hist.h"
- X
- Xextern char *malloc ();
- Xextern char *strdup ();
- X
- Xstatic int
- Xdo_cancel (fns, id, flag)
- Xregister char *fns;
- Xchar *id;
- Xchar flag;
- X{
- X register char *p;
- X char *tbuf;
- X int ok;
- X
- X if (! (fns = strdup (fns)))
- X return (TRUE);
- X tbuf = fns;
- X ok = TRUE;
- X do_log ("Delete '%s' (fns = %s)\n", id, fns);
- X p = skipc (fns, '\0');
- X if (may_cancel (fns)) {
- X if (flag != ART_EXPIRED)
- X while (*fns) {
- X if (unlink_in_newsdir_file (fns) == -1)
- X ok = FALSE;
- X fns = p;
- X p = skipc (fns, '\0');
- X }
- X } else {
- X ok = FALSE;
- X mail_to ("Postmaster", NULL, "Tries to cancel not-own article: ", find_from (FALSE), newstmp, NULL);
- X }
- X free (tbuf);
- X return (ok);
- X}
- X
- Xint
- Xdelete_msg (id)
- Xchar *id;
- X{
- X char *p, *fns;
- X char *flag;
- X int fd;
- X char *ptr, *sav;
- X char *buf;
- X char *savid;
- X int n;
- X int found;
- X
- X if (!(savid = strdup (id))) {
- X do_log ("FATAL: Can't alloc memory in delete_msg for id\n");
- X return (0);
- X }
- X# ifdef USE_NDBM
- X if (!(db = open_hist (S_IREAD | S_IWRITE))) {
- X free (savid);
- X do_log ("Can't open %s.\n", HISTORY);
- X return (0);
- X }
- X# endif /* USE_NDBM */
- X found = FALSE;
- X ptr = savid;
- X while (*ptr) {
- X sav = ptr;
- X ptr = skipc (ptr, '\0');
- X# ifndef USE_NDBM
- X if ((fd = open_hist (sav, S_IREAD)) != -1) {
- X while (buf = readbuf (fd, & n)) {
- X buf[n - 1] = '\0';
- X p = skipc (buf, '\0');
- X flag = skipc (p, '\0');
- X fns = skipc (flag, '\0');
- X if (Mideql (sav, p)) {
- X found = TRUE;
- X if (! do_cancel (fns, sav, flag[0]))
- X block_forward = TRUE;
- X break;
- X }
- X }
- X close (fd);
- X }
- X# else /* USE_NDBM */
- X key.dptr = lower_mid (sav);
- X key.dsize = strlen (sav) + 1;
- X dat = dbm_fetch (db, key);
- X if (dat.dptr) {
- X found = TRUE;
- X memcpy (&hist, dat.dptr, sizeof (history));
- X if (do_cancel (hist.fns, sav, (char) hist.flag)) {
- X memcpy (&hist, dat.dptr, sizeof (history));
- X hist.flag = ART_EXPIRED;
- X fill_hist ();
- X dbm_store (db, key, dat, DBM_REPLACE);
- X } else
- X block_forward = TRUE;
- X }
- X# endif /* USE_NDBM */
- X }
- X# ifdef USE_NDBM
- X dbm_close (db);
- X# endif /* USE_NDBM */
- X free (savid);
- X return (found);
- X}
- X
- Xvoid
- Xcancel_msg (id)
- Xchar *id;
- X{
- X if (!delete_msg (id)) {
- X do_log ("Receive Cancel for non existing article, ID = %s\n",
- X ((id && *id) ? id : "** lost! **"));
- X do_exit (0);
- X }
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/cchk.c' ; then
- echo 'File INEWS/cchk.c already exists, overwriting it'
- del 'INEWS/cchk.c'
- fi
- echo Extracting \"'INEWS/cchk.c'\"
- sed "s/^X//" >'INEWS/cchk.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: cchk.c_v $
- X * Revision 1.2 91/05/22 13:21:26 ud
- X * Added in memory option
- X * Stores now the checkgroups message in the Newsgroups file
- X *
- X * Revision 1.1 90/08/31 15:32:07 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: cchk.c_v 1.2 91/05/22 13:21:26 ud Exp $";
- X# endif LINT
- X# include <modes.h>
- X# include <c8type.h>
- X# include "inews.h"
- X
- Xextern char *malloc ();
- Xextern char *rindex ();
- Xextern char *strdup ();
- X
- Xstatic cgroup *
- Xadd_group (root, line)
- Xcgroup *root;
- Xchar *line;
- X{
- X cgroup *tmp;
- X register cgroup *run, *prev;
- X register char *ptr;
- X register int n;
- X
- X if (! (tmp = (cgroup *) malloc (sizeof (cgroup))))
- X return (root);
- X if (! (tmp -> group = strdup (line))) {
- X free ((char *) tmp);
- X return (root);
- X }
- X for (ptr = tmp -> group;*ptr && (! is8space (*ptr)); ++ptr)
- X ;
- X if (*ptr) {
- X tmp -> seperate = *ptr;
- X *ptr++ = '\0';
- X } else
- X tmp -> seperate = '\0';
- X tmp -> comment = ptr;
- X tmp -> next = NULL;
- X if (! root)
- X root = tmp;
- X else {
- X prev = NULL;
- X for (run = root; run; (prev = run), (run = run -> next)) {
- X n = strcmp (run -> group, tmp -> group);
- X if (n > 0) {
- X tmp -> next = run;
- X if (prev)
- X prev -> next = tmp;
- X else
- X root = tmp;
- X break;
- X } else if (n == 0) {
- X free (run -> group);
- X run -> group = tmp -> group;
- X run -> seperate = tmp -> seperate;
- X run -> comment = tmp -> comment;
- X free ((char *) tmp);
- X tmp = NULL;
- X break;
- X }
- X }
- X if ((! run) && prev)
- X prev -> next = tmp;
- X }
- X return (root);
- X}
- X
- Xvoid
- Xcheckgroups ()
- X{
- X int fd;
- X int fdt;
- X int fdn;
- X int n, t;
- X# ifndef IN_MEMORY
- X char fn[40 + sizeof (TEMPDIR)];
- X# else /* IN_MEMORY */
- X list *cgrp;
- X register list *ntmp;
- X# endif /* IN_MEMORY */
- X char *buf;
- X char *sav;
- X register char *ptr;
- X active *atmp;
- X charc *limit;
- X cgroup *croot, *crun, *cprev;
- X
- X if (!(buf = malloc (512))) {
- X do_log ("FATAL: Can't alloc in checkgroups\n");
- X do_exit (1);
- X }
- X# ifndef IN_MEMORY
- X if ((fd = open (newstmp, S_IREAD)) < 0) {
- X do_log ("FATAL: Can't open %s\n", newstmp);
- X do_exit (1);
- X }
- X sprintf (fn, "%s/inewstXXXXXX", TEMPDIR);
- X mktemp (fn);
- X if ((fdt = create (fn, S_IWRITE, 03)) < 0) {
- X do_log ("FATAL: Can't create tmpfile %s\n", fn);
- X close (fd);
- X do_exit (1);
- X }
- X# else /* IN_MEMORY */
- X cgrp = NULL;
- X# endif /* IN_MEMORY */
- X croot = NULL;
- X if ((fdn = open (NEWSGROUPS_FILE, S_IREAD)) != -1) {
- X while (ptr = readbuf (fdn, & n))
- X if ((n > 1) && (ptr[0] != '#')) {
- X if (ptr[n - 1] == '\n')
- X ptr[n - 1] = '\0';
- X else
- X ptr[n] = '\0';
- X croot = add_group (croot, ptr);
- X }
- X close (fdn);
- X }
- X limit = get_limit_newsgroups ();
- X atmp = hact;
- X while (atmp) {
- X atmp->flag = FALSE;
- X atmp = atmp->next;
- X }
- X strcpy (buf, "-tnx\n");
- X# ifndef IN_MEMORY
- X write (fdt, buf, strlen (buf));
- X n = _gs_size (fd);
- X# else /* IN_MEMORY */
- X add_list (&cgrp, buf, strlen (buf));
- X n = 0;
- X for (ntmp = newstmp; ntmp; ntmp = ntmp->next)
- X n += ntmp->len;
- X# endif /* IN_MEMORY */
- X strcpy (buf, "* Add missing newsgroups\n");
- X# ifndef IN_MEMORY
- X write (fdt, buf, strlen (buf));
- X while ((n = readin (fd, buf, 500)) > 0) { /* } */
- X# else /* IN_MEMORY */
- X add_list (&cgrp, buf, strlen (buf));
- X for (ntmp = newstmp; ntmp; ntmp = ntmp->next) {
- X strncpy (buf, ntmp->text, ((n = ntmp->len) > 500 ? 500 : n));
- X# endif /* IN_MEMORY */
- X if ((buf[0] == '#') || (buf[0] == '!') || (n == 1))
- X continue;
- X buf[n - 1] = '\0';
- X croot = add_group (croot, buf);
- X skipc (buf, '\0');
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (atmp->grp, buf))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (buf);
- X# endif /* HASH_SEARCH */
- X if (!atmp) {
- X if ((check_limit (limit, buf)) && (sav = strdup (buf))) {
- X sprintf (buf, "inews -v '-c=newgroup:%s' '-d=%s' </nil\n", sav, DST_LOCAL);
- X# ifndef IN_MEMORY
- X write (fdt, buf, strlen (buf));
- X# else /* IN_MEMORY */
- X add_list (&cgrp, buf, strlen (buf));
- X# endif /* IN_MEMORY */
- X free (sav);
- X }
- X } else
- X atmp->flag = TRUE;
- X }
- X strcpy (buf, "* Delete obsolete newsgrps\n");
- X# ifndef IN_MEMORY
- X write (fdt, buf, strlen (buf));
- X close (fd);
- X# else /* IN_MEMORY */
- X add_list (&cgrp, buf, strlen (buf));
- X# endif /* IN_MEMORY */
- X for (atmp = hact; atmp; atmp = atmp->next)
- X if ((!atmp->flag) && Stricmp (atmp->grp, NG_JUNK) && Stricmp (atmp->grp, NG_CONTROL) && check_limit (limit, atmp->grp))
- X if ((!(ptr = rindex (atmp->grp, '.'))) || Stricmp (ptr + 1, NG_JUNK)) {
- X sprintf (buf, "inews -v '-c=rmgroup:%s' </nil\n", atmp->grp);
- X# ifndef IN_MEMORY
- X write (fdt, buf, strlen (buf));
- X# else /* IN_MEMORY */
- X add_list (&cgrp, buf, strlen (buf));
- X# endif /* IN_MEMORY */
- X }
- X# ifndef IN_MEMORY
- X close (fdt);
- X mail_to (news_owner, NULL, "Control Message: Checkgroups", NULL, fn, NULL);
- X unlink (fn);
- X# else /* IN_MEMORY */
- X mail_to (news_owner, NULL, "Control Message: Checkgroups", NULL, cgrp, NULL);
- X free_list (cgrp);
- X# endif /* IN_MEMORY */
- X free (buf);
- X free_field (limit);
- X unlink (NEWSGROUPS_FILE);
- X if (croot && ((fdn = create (NEWSGROUPS_FILE, S_IWRITE | S_ISIZE, 013, n < 0 ? 4096 : n)) != -1)) {
- X for (crun = croot; crun;) {
- X if (crun -> seperate)
- X sprintf (buf, "%s%c%s\n",
- X crun -> group,
- X crun -> seperate,
- X crun -> comment);
- X else
- X sprintf (buf, "%s\n",
- X crun -> group);
- X n = strlen (buf);
- X if (write (fdn, buf, n) != n)
- X break;
- X cprev = crun;
- X crun = crun -> next;
- X free (cprev -> group);
- X free ((char *) cprev);
- X }
- X close (fdn);
- X }
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/cnew.c' ; then
- echo 'File INEWS/cnew.c already exists, overwriting it'
- del 'INEWS/cnew.c'
- fi
- echo Extracting \"'INEWS/cnew.c'\"
- sed "s/^X//" >'INEWS/cnew.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: cnew.c_v $
- X * Revision 1.2 91/05/22 13:13:48 ud
- X * Added auto newgroup
- X *
- X * Revision 1.1 90/08/31 15:32:11 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: cnew.c_v 1.2 91/05/22 13:13:48 ud Exp $";
- X# endif LINT
- X# include <c8type.h>
- X# include "inews.h"
- X
- Xextern char *index ();
- Xextern char *skipc ();
- Xextern char *strdup ();
- X
- Xvoid
- Xnewgroup (ng)
- Xchar *ng;
- X{
- X active *atmp, *aact;
- X char *ptr;
- X char *p;
- X int ismod;
- X int t;
- X
- X if (ptr = index (ng, ':')) {
- X *ptr++ = '\0';
- X while (is8space (*ptr))
- X ++ptr;
- X } else
- X ptr = skipc (ng, '\0');
- X ismod = (*ptr && Strnieql (ptr, "mod", 3));
- X# ifndef HASH_SEARCH
- X atmp = hact;
- X while (atmp)
- X if (Strieql (atmp->grp, ng))
- X break;
- X else
- X atmp = atmp->next;
- X# else /* HASH_SEARCH */
- X atmp = find_active (ng);
- X# endif /* HASH_SEARCH */
- X# ifndef AUTO_NEWGROUP
- X if (! isadm) {
- X if ((! atmp) || ((atmp -> aflag[0] == M_MOD) && (!ismod)) || ((atmp -> aflag[0] == M_NOT_MOD) && ismod)) {
- X char *tmp;
- X char *comment[6];
- X
- X comment[0] = "A newgroupmessage has arrived here, but you have disabled\n";
- X comment[1] = "the automatic creation of a newsgroup. So you have to\n";
- X comment[2] = "execute the following command as News Admin:\n";
- X if (atmp)
- X comment[3] = "The state of moderation had been changed\n";
- X else
- X comment[3] = "This newsgroup is completely new\n";
- X if (tmp = malloc (strlen (ng) + 128)) {
- X sprintf (tmp, "inews '-c=newgroup:%s%s' -d=local </nil\n", ng, ismod ? " moderated" : "");
- X comment[4] = tmp;
- X } else
- X comment[4] = "inews '-c=<newsgroup> [<moderated>]' -d=local </nil\n";
- X comment[5] = NULL;
- X mail_to (news_owner, NULL, "Control Message: newgroup", ng, NULL, comment);
- X if (tmp)
- X free (tmp);
- X }
- X return;
- X }
- X# endif /* AUTO_NEWGROUP */
- X if (atmp) {
- X do_log ("Got newgroup for existing group %s\n", atmp->grp);
- X if (atmp->aflag[1] == M_IGNORE)
- X atmp->aflag[1] = M_USE;
- X if ((atmp->aflag[0] == M_MOD) && (!ismod)) {
- X do_log ("Group status changed from moderated to unmoderated\n");
- X atmp->aflag[0] = M_NOT_MOD;
- X for (t=0;atmp->moderator[t];++t)
- X free (atmp->moderator[t]);
- X free ((char *) atmp->moderator);
- X atmp->moderator = NULL;
- X act_rewrite = TRUE;
- X } else if ((atmp->aflag[0] == M_NOT_MOD) && ismod) {
- X do_log ("Group status changed from unmoderated to moderated\n");
- X atmp->aflag[0] = M_MOD;
- X if (atmp->moderator = (char **) malloc (sizeof (char *) * 3))
- X atmp->moderator[0] = NULL;
- X else {
- X do_log ("FATAL: Can't alloc memory\n");
- X do_exit (1);
- X }
- X act_rewrite = TRUE;
- X }
- X return;
- X }
- X if (!(atmp = (active *) malloc (sizeof (active)))) {
- X do_log ("FATAL: Can't alloc for newgroup\n");
- X do_exit (1);
- X }
- X if (!(atmp->grp = strdup (ng))) {
- X do_log ("FATAL: Can't alloc for newgroup\n");
- X do_exit (1);
- X }
- X p = atmp->grp;
- X while (*p) {
- X *p = to8lower (*p);
- X ++p;
- X }
- X atmp->low = 0;
- X atmp->high = 0;
- X atmp->moderator = NULL;
- X if (ismod) {
- X atmp->aflag[0] = M_MOD;
- X if (!(atmp->moderator = (char **) malloc (sizeof (char *) * 3))) {
- X do_log ("FATAL: Can't alloc for newgroup\n");
- X do_exit (1);
- X }
- X atmp->moderator[0] = NULL;
- X } else
- X atmp->aflag[0] = M_NOT_MOD;
- X atmp->aflag[1] = M_USE;
- X atmp -> kblimit = -1;
- X atmp->next = NULL;
- X if (!hact)
- X hact = atmp;
- X else {
- X aact = hact;
- X while (aact->next)
- X aact = aact->next;
- X aact->next = atmp;
- X }
- X# ifdef HASH_SEARCH
- X atmp -> id = calc_hash (atmp -> grp, TRUE);
- X atmp -> hnext = hashact[atmp -> id % HASH_ACTIVE];
- X hashact[atmp -> id % HASH_ACTIVE] = atmp;
- X# endif /* HASH_SEARCH */
- X act_rewrite = TRUE;
- X do_log ("New newsgroup: %s\n", atmp->grp);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/crct.c' ; then
- echo 'File INEWS/crct.c already exists, overwriting it'
- del 'INEWS/crct.c'
- fi
- echo Extracting \"'INEWS/crct.c'\"
- sed "s/^X//" >'INEWS/crct.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: crct.c_v $
- X * Revision 1.1 90/08/31 15:32:51 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: crct.c_v 1.1 90/08/31 15:32:51 cs Exp $";
- X# endif LINT
- X# include <c8type.h>
- X# include <time.h>
- X# include "inews.h"
- X
- Xextern char *malloc ();
- Xextern char *strdup ();
- X
- Xstatic void
- Xmake_ctl_ngs (ng)
- Xchar *ng;
- X{
- X char *ptr;
- X register char *p;
- X
- X if (ngs)
- X return;
- X if (!(ptr = strdup (ng)))
- X return;
- X skipc (ptr, '\0');
- X p = ptr;
- X while (*p) {
- X *p = to8lower (*p);
- X ++p;
- X }
- X if (ngs = (charc *) malloc (sizeof (charc)))
- X if (ngs->text = malloc (strlen (ptr) + 10)) {
- X strcpy (ngs->text, ptr);
- X strcat (ngs->text, CTRL_POSTFIX);
- X ngs->next = NULL;
- X } else {
- X free ((char *) ngs);
- X ngs = NULL;
- X }
- X free (ptr);
- X}
- X
- Xvoid
- Xcreate_control_message (msg)
- Xchar *msg;
- X{
- X register int t;
- X char *fn;
- X char *opts, *pars;
- X time_t dummy;
- X
- X if (do_init (FALSE) < 0)
- X exit (_errmsg (1, "Can't initialize the mess\n"));
- X opts = skipc (msg, ':');
- X pars = skipc (opts, '\0');
- X for (t=0;ctrlcodes[t];++t)
- X if (Strieql (ctrlcodes[t], msg))
- X break;
- X if (!ctrlcodes[t])
- X do_exit (_errmsg (1, "Unknown controlmessage %s.\n", msg));
- X if (t != CC_CANCEL) {
- X if (!isadm)
- X do_exit (_errmsg (1, "You aren't allowed to send control messages\n"));
- X if (! dists) {
- X if (dists = (charc *) malloc (sizeof (charc)))
- X if (dists -> text = strdup (DST_LOCAL))
- X dists -> next = NULL;
- X else {
- X free ((char *) dists);
- X dists = NULL;
- X }
- X if (! dists)
- X do_exit (_errmsg (1, "Can't make distribution %s for %s\n",
- X DST_LOCAL, ctrlcodes[t]));
- X }
- X }
- X switch (t) {
- X case CC_CANCEL:
- X if (!*opts)
- X do_exit (_errmsg (1, "Which article you wish to cancel?\n"));
- X if (!(fn = exists_message_id (opts, &dummy)))
- X do_exit (_errmsg (1, "This article isn't written here\n"));
- X else {
- X get_dists_and_ngs (fn);
- X free (fn);
- X }
- X break;
- X case CC_IHAVE:
- X do_exit (_errmsg (1, "Sorry, this implementation doesn't support %s\n", msg));
- X break;
- X case CC_SENDME:
- X break;
- X case CC_NEWGROUP:
- X if (!*opts)
- X do_exit (_errmsg (1, "Which group do you want to make?\n"));
- X make_ctl_ngs (opts);
- X break;
- X case CC_RMGROUP:
- X if (!*opts)
- X do_exit (_errmsg (1, "Which group do you want to remove?\n"));
- X make_ctl_ngs (opts);
- X break;
- X case CC_SENDSYS:
- X case CC_SENDUUNAME:
- X case CC_VERSION:
- X case CC_CHECKGROUPS:
- X break;
- X }
- X send_control (msg, opts, pars);
- X do_exit (0);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/crm.c' ; then
- echo 'File INEWS/crm.c already exists, overwriting it'
- del 'INEWS/crm.c'
- fi
- echo Extracting \"'INEWS/crm.c'\"
- sed "s/^X//" >'INEWS/crm.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: crm.c_v $
- X * Revision 1.2 91/05/22 13:17:29 ud
- X * Added auto rmgroup
- X *
- X * Revision 1.1 90/08/31 15:32:55 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: crm.c_v 1.2 91/05/22 13:17:29 ud Exp $";
- X# endif LINT
- X# include "inews.h"
- X
- Xvoid
- Xrmgroup (ng)
- Xchar *ng;
- X{
- X active *atmp, *at;
- X int t;
- X# ifdef HASH_SEARCH
- X int idx;
- X active *tmp;
- X# endif /* HASH_SEARCH */
- X
- X atmp = hact;
- X at = NULL;
- X while (atmp)
- X if (Strieql (atmp->grp, ng))
- X break;
- X else {
- X at = atmp;
- X atmp = atmp->next;
- X }
- X# ifndef AUTO_RMGROUP
- X if (! isadm) {
- X
- X if (atmp) {
- X char *comment[7];
- X
- X comment[0] = "A rmgroup control message has arrived here, but you have\n";
- X comment[1] = "automatically remove of newsgroups disabled. So you have\n";
- X comment[2] = "to execute the following command by hand as News Admin:\n";
- X comment[3] = "inews '-c=rmgroup:";
- X comment[4] = ng;
- X comment[5] = "' -d=local </nil\n";
- X comment[6] = NULL;
- X mail_to (news_owner, NULL, "Control Message: rmgroup", ng, NULL, comment);
- X }
- X return;
- X }
- X# endif /* AUTO_RMGROUP */
- X
- X if (atmp) {
- X if (at)
- X at->next = atmp->next;
- X else
- X hact = hact->next;
- X make_fn (ng);
- X unlink_in_newsdir_dir (ng);
- X free (atmp->grp);
- X if (atmp->moderator) {
- X t = 0;
- X while (atmp->moderator[t]) {
- X free (atmp->moderator[t]);
- X ++t;
- X }
- X }
- X free ((char *) atmp->moderator);
- X# ifdef HASH_SEARCH
- X idx = atmp -> id % HASH_ACTIVE;
- X at = NULL;
- X for (tmp = hashact[idx]; tmp; )
- X if (tmp == atmp)
- X break;
- X else {
- X at = tmp;
- X tmp = tmp -> hnext;
- X }
- X if (tmp)
- X if (at)
- X at -> hnext = atmp -> hnext;
- X else
- X hashact[idx] = atmp -> next;
- X# endif /* HASH_SEARCH */
- X free ((char *) atmp);
- X act_rewrite = TRUE;
- X do_log ("Rmgroup: %s\n", ng);
- X } else
- X do_log ("Group %s doesn't exists (rmgroup)\n", ng);
- X}
- __END__OF__THIS__FILE__
- if test -f 'INEWS/crth.c' ; then
- echo 'File INEWS/crth.c already exists, overwriting it'
- del 'INEWS/crth.c'
- fi
- echo Extracting \"'INEWS/crth.c'\"
- sed "s/^X//" >'INEWS/crth.c' <<'__END__OF__THIS__FILE__'
- X/*
- X * $Log: crth.c_v $
- X * Revision 1.1 90/08/31 15:32:59 cs
- X * Initial revision
- X *
- X */
- X# ifndef LINT
- Xstatic char rcsid[] = "$Id: crth.c_v 1.1 90/08/31 15:32:59 cs Exp $";
- X# endif LINT
- X# include <time.h>
- X# include <pwd.h>
- X# include "inews.h"
- X
- Xextern char *getenv ();
- Xextern char *malloc ();
- X
- Xchar *
- Xmake_own_address (need_fullname)
- Xint need_fullname;
- X{
- X char *fullname;
- X struct passwd *pw;
- X struct gecos *gc;
- X char *buf;
- X
- X fullname = NULL;
- X if (need_fullname) {
- X setpwent ();
- X if ((pw = getpwnam (user)) && pw->pw_gecos && (gc = getgecos (pw->pw_gecos)) && (gc->fullname && *gc->fullname))
- X fullname = gc->fullname;
- X endpwent ();
- X }
- X if (!fullname)
- X if (!(fullname = getenv ("NAME")))
- X fullname = getenv ("FULLNAME");
- X if (buf = malloc (strlen (user) + strlen (fhost) + 4 + (fullname ? strlen (fullname) + 8 : 0))) {
- X strcpy (buf, user);
- X strcat (buf, "@");
- X strcat (buf, fhost);
- X if (fullname) {
- X strcat (buf, " (");
- X strcat (buf, fullname);
- X strcat (buf, ")");
- X }
- X }
- X return (buf);
- X}
- X
- Xint
- Xcreate_header (fornews, interactive)
- Xint fornews;
- Xint interactive;
- X{
- X char *buf;
- X time_t tim;
- X char *org;
- X char *tmp;
- X struct passwd *pw;
- X struct gecos *gc;
- X
- X if (!(buf = malloc (512)))
- X return (-1);
- X if (fornews)
- X insert_header (H_PATH, user, TRUE);
- X sprintf (buf, "%s@%s", user, fhost);
- X if (tmp = find_address_hl (H_FROM)) {
- X if (Stricmp (tmp, buf)) {
- X insert_header (H_REPLY_TO, tmp, interactive);
- X if (tmp = make_own_address (TRUE)) {
- X insert_header (H_SENDER, tmp, TRUE);
- X free (tmp);
- X } else
- X insert_header (H_SENDER, buf, TRUE);
- X }
- X free (tmp);
- X }
- X org = NULL;
- X setpwent ();
- X if ((pw = getpwnam (user)) && pw->pw_gecos && (gc = getgecos (pw->pw_gecos)) && (gc->fullname && *gc->fullname)) {
- X strcat (buf, " (");
- X strcat (buf, gc->fullname);
- X strcat (buf, ")");
- X if (gc->organization && *gc->organization)
- X org = gc->organization;
- X } else {
- X if (tmp = make_own_address (FALSE)) {
- X strcpy (buf, tmp);
- X free (tmp);
- X }
- X }
- X endpwent ();
- X insert_header (H_FROM, buf, interactive);
- X time (&tim);
- X strcpy (buf, ntime (&tim));
- X insert_header (H_DATE, buf, interactive);
- X if (!org)
- X org = getenv ("ORGANIZATION");
- X if (org)
- X insert_header (H_ORGANIZATION, org, interactive);
- X free (buf);
- X if (fornews) {
- X if (ngs && (tmp = catcharc (ngs, ","))) {
- X insert_header (H_NEWSGROUPS, tmp, interactive);
- X free (tmp);
- X }
- X if (dists && (tmp = catcharc (dists, ","))) {
- X insert_header (H_DISTRIBUTION, tmp, interactive);
- X free (tmp);
- X }
- X insert_header (H_POSTED, atime (&tim), interactive);
- X } else {
- X if (recv && (tmp = catcharc (recv, ", "))) {
- X insert_header (H_TO, tmp, interactive);
- X free (tmp);
- X }
- X }
- X if (interactive)
- X sort_header (FALSE);
- X return (0);
- X}
- __END__OF__THIS__FILE__
- exit 0
- : end of shell archive
-
- --
- Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
-