Article View: news.software.readers
Article #23795Re: killing spam crossposts in slrn ?
From: Felix von Leitner
Date: Sat, 06 Jul 1996 00:00
Date: Sat, 06 Jul 1996 00:00
217 lines
5859 bytes
5859 bytes
-----BEGIN PGP SIGNED MESSAGE-----
On 6 Jul 1996 13:31:16 GMT, jamie <jamie@bozo.local.net> wrote:
> I had a patch for 8.8.2 that someone posted in here that handled
> crossposts without XOVER for me, but I lost it when I upgraded to
> 8.8.3
I was thw one who posted it. I ported it to 0.8.8.3 now and here it
comes again.
BTW: The alt.fan.warlord patch is integrated into the base slrn
distribution now. The PGP patch still works without modification. The
tilde patch had to be modified slightly, too. I will post it, too.
Felix
- --- slrn/src/killdupe.c.orig Sun Jun 30 16:40:37 1996
+++ slrn/src/killdupe.c Sun Jun 30 16:40:37 1996
@@ -0,0 +1,125 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+unsigned short hash(const char *c) {
+ unsigned i=0;
+ while (*c) {
+ i=(i*7+(int) *c) % 4096;
+ c++;
+ }
+ return i;
+}
+
+struct node {
+ char *key,*key2;
+ struct node *next;
+};
+
+static struct node *hashtab[4096];
+static struct node *newsgroups[4096];
+static int dontgrow=0;
+
+void dump_hash(struct node *ht[]) {
+ int i;
+ struct node *h;
+ for (i=0;i<4096;i++) {
+ h=ht[i];
+ while (h) {
+ printf("%s %s\n",h->key,h->key2);
+ h=h->next;
+ }
+ }
+}
+
+struct node *hash_there(struct node *ht[], const char *c) {
+ int h=hash(c);
+ struct node *n=ht[h];
+ while (n) {
+ if (strcmp(n->key,c) == 0) {
+ return n;
+ }
+ n=n->next;
+ }
+ return 0;
+}
+
+int hash_add(struct node *ht[], const char *c, const char *second) {
+ int h=hash(c);
+ struct node *n=ht[h];
+ while (n) {
+ if (strcmp(n->key,c) == 0) {
+ return 1;
+ }
+ n=n->next;
+ }
+ if (dontgrow) return 0;
+ n=malloc(sizeof(struct node));
+ if (n == NULL) {
+ dontgrow=1;
+ return 0;
+ }
+ n->next = ht[h];
+ n->key = malloc(strlen(c)+1);
+ if (n->key==NULL) {
+ dontgrow=1;
+ return 0;
+ }
+ strcpy(n->key,c);
+ if (second) {
+ n->key2 = malloc(strlen(second)+1);
+ if (n->key2==NULL) {
+ dontgrow=1;
+ return 0;
+ }
+ strcpy(n->key2,second);
+ }
+ ht[h]=n;
+ return 0;
+}
+
+void inithashtab() {
+ int i;
+ for (i=0;i<4096;i++) {
+ hashtab[i]=0;
+ newsgroups[i]=0;
+ }
+}
+
+char *there(const char *c) {
+ struct node *n=hash_there(hashtab,c);
+ if (n)
+ return n->key2;
+ else
+ return NULL;
+}
+
+void add(const char *c,const char *n) {
+ hash_add(hashtab,c,n);
+}
+
+char *alloc_newsgroup(const char *c) {
+ struct node *n=hash_there(newsgroups,c);
+ if (n) return n->key;
+ hash_add(newsgroups,c,NULL);
+ n=hash_there(newsgroups,c);
+ return n->key;
+}
+
+/*
+int main()
+{
+ char s[1024];
+ int i;
+ inithashtab();
+ while (gets(s)) {
+ i = there(s);
+ if (i) {
+ printf("Huh: %d %s\n",i,s);
+ } else {
+ i=add(s);
+ }
+ }
+ return 0;
+}
+*/
- --- slrn/src/killdupe.h.orig Sun Jun 30 16:40:37 1996
+++ slrn/src/killdupe.h Sun Jun 30 16:40:37 1996
@@ -0,0 +1,5 @@
+
+void inithashtab(); /* Initialize the msgid dupe killer */
+char *there(const char *c); /* return newsgroup where c was first sighted or NULL */
+void add(const char *c,const char *n); /* add c in newsgroup n. */
+char *alloc_newsgroup(const char *c); /* if given a newsgroup, return a pointer to a string where it will be stored, so that newsgroups don't need to be allocated 1000 times */
- --- slrn/src/modules.lis.orig Fri Jun 28 19:37:02 1996
+++ slrn/src/modules.lis Sun Jun 30 16:40:37 1996
@@ -10,4 +10,5 @@
uudecode
mime
menu
+killdupe
server
- --- slrn/src/score.c.orig Fri Jun 28 19:37:01 1996
+++ slrn/src/score.c Sun Jun 30 16:41:25 1996
@@ -14,6 +14,7 @@
#include "score.h"
#include "misc.h"
#include "server.h"
+#include "killdupe.h"
/* This file will implement article scoring for slrn. Basically the idea is
* that the user will provide a set of regular expressions that will act on
@@ -134,6 +135,12 @@
char *s = NULL;
int ival = 0;
+ if ((s=there(h->msgid))) { /* This article is a dupe. */
+ if (strcmp(s,newsgroup)) return (-9999);
+ /* Kill it if this wasn't the newsgroup were we saw it */
+ }
+ add(h->msgid,alloc_newsgroup(newsgroup));
+ s=NULL;
st = Score_Root;
while (st != NULL)
- --- slrn/src/slrn.c.orig Fri Jun 28 19:37:01 1996
+++ slrn/src/slrn.c Sun Jun 30 16:41:12 1996
@@ -48,6 +48,7 @@
#include "startup.h"
#include "art.h"
#include "score.h"
+#include "killdupe.h"
#ifdef __os2__
# define INCL_VIO
@@ -821,6 +822,7 @@
slrn_exit_error ("Unable to select object.");
}
+ inithashtab();
fprintf (stdout, "slrn %s\n", Slrn_Version);
if (dsc_flag && create_flag)
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1
iQCVAwUBMd74CB/Da1Yoy+f1AQFFsAP+JtfFW7D9D3SBZorfcrTKUA097INjD6Iu
h9Ge9Uawfdl005Noez+cbTYWX64BEoBp8wubd4Ift46MAviSqbMlRmYm2qSU2u/n
KP0aRNYfYfc4iPjHK6NWfoWSjW+/0eaAtXHiiK09RE62y1BR9F5YwAGD8SQEVsKf
XrPETMd6UDk=
=/14b
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<slrn4ttu09.2h5.leitner@xorn.prz.tu-berlin.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn4thkid.7ni.mike@apm0-39.realtime.net> <slrn4tiq52.eme.davis@aluche.mit.edu> <slrn4tsqq7.ad.jamie@bozo.local.net>Show Full Headers
Complete Article Headers
Message-ID: <slrn4ttu09.2h5.leitner@xorn.prz.tu-berlin.de> Subject: Re: killing spam crossposts in slrn ? Date: Sat, 06 Jul 1996 00:00:00 +0000 From: leitner@xorn.prz.tu-berlin.de (Felix von Leitner) References: <slrn4thkid.7ni.mike@apm0-39.realtime.net> <slrn4tiq52.eme.davis@aluche.mit.edu> <slrn4tsqq7.ad.jamie@bozo.local.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 164045884 Organization: Miscatonic University Reply-to: leitner@prz.tu-berlin.de Newsgroups: news.software.readers