View | Details | Raw Unified | Return to bug 69551
Collapse All | Expand All

(-)s-news/Makefile (+1 lines)
Lines 7-12 Link Here
7
7
8
PORTNAME=	s-news
8
PORTNAME=	s-news
9
PORTVERSION=	0.1.11
9
PORTVERSION=	0.1.11
10
PORTREVISION=	1
10
CATEGORIES=	news
11
CATEGORIES=	news
11
MASTER_SITES=	http://www.lost.org.uk/
12
MASTER_SITES=	http://www.lost.org.uk/
12
13
(-)s-news/files/patch-active (+5 lines)
Line 0 Link Here
1
--- data/active	1998-09-06 14:11:15.000000000 +0100
2
+++ data/active	2002-09-08 12:51:26.000000000 +0100
3
@@ -1 +1,2 @@
4
 junk 0 1 y
5
+control.cancel 0 1 y
(-)s-news/files/patch-config.h.in (+12 lines)
Line 0 Link Here
1
--- config.h.in	2002-05-18 20:22:50.000000000 +0100
2
+++ config.h.in	2002-10-12 19:23:12.000000000 +0100
3
@@ -55,6 +55,9 @@
4
 /* Define if you have the <malloc.h> header file. */
5
 #undef HAVE_MALLOC_H
6
 
7
+/* Define if you have the <sys/file.h> header file.  */
8
+#undef HAVE_SYS_FILE_H
9
+
10
 /* Define if you have the <memory.h> header file. */
11
 #undef HAVE_MEMORY_H
12
 
(-)s-news/files/patch-configure (+11 lines)
Line 0 Link Here
1
--- configure	2002-05-18 20:25:00.000000000 +0100
2
+++ configure	2002-10-12 19:23:12.000000000 +0100
3
@@ -2370,7 +2370,7 @@
4
 
5
 fi
6
 
7
-for ac_header in fcntl.h limits.h malloc.h syslog.h unistd.h
8
+for ac_header in fcntl.h limits.h malloc.h syslog.h unistd.h sys/file.h
9
 do
10
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
11
 echo "$as_me:2376: checking for $ac_header" >&5
(-)s-news/files/patch-newfeed.in (-3 / +7 lines)
Lines 1-6 Link Here
1
--- newfeed.in.old	Thu Jul 15 16:31:44 2004
1
--- newfeed.in.orig	Sat Jun 29 21:29:49 2002
2
+++ newfeed.in	Thu Jul 15 16:33:15 2004
2
+++ newfeed.in	Sun Jul 25 04:40:59 2004
3
@@ -52,7 +52,7 @@
3
@@ -52,9 +52,11 @@
4
 	umask $UMASK
4
 	umask $UMASK
5
 fi
5
 fi
6
 
6
 
Lines 8-11 Link Here
8
+if mkdir -p $SUCKDIR/$host
8
+if mkdir -p $SUCKDIR/$host
9
 then
9
 then
10
 	echo junk >$SUCKDIR/$host/active-ignore
10
 	echo junk >$SUCKDIR/$host/active-ignore
11
+	# Uncomment the following line if you don't want cancel messages to propagate
12
+	#echo control.cancel >>$SUCKDIR/$host/active-ignore
11
 	mkdir $SUCKDIR/$host/incoming
13
 	mkdir $SUCKDIR/$host/incoming
14
 
15
 	for opt in $options
(-)s-news/files/patch-nntpd.c (+247 lines)
Line 0 Link Here
1
--- nntpd.c	Sat May 18 20:21:56 2002
2
+++ nntpd.c	Wed Aug 21 22:09:46 2002
3
@@ -2,6 +2,7 @@
4
  *  S-News version 0.1.9 - A Simple News Server
5
  *  Copyright (C) 1998 Christopher John Purnell
6
  *                     cjp@lost.org.uk
7
+ *  XPAT support added in 2002 by Tony Houghton <tony@realh.co.uk>
8
  *
9
  *  This program is free software; you can redistribute it and/or modify
10
  *  it under the terms of the GNU General Public License as published by
11
@@ -106,6 +107,7 @@
12
 static void do_listgroup(char *);
13
 static void do_xover(char *);
14
 static void do_xhdr(char *);
15
+static void do_xpat(char *);
16
 static void do_xpath(char *);
17
 static void do_ihave(char *);
18
 static void do_post(char *);
19
@@ -239,6 +241,10 @@
20
 		{
21
 			do_xhdr(arg);
22
 		}
23
+		else if (!strcasecmp(line,"xpat"))
24
+		{
25
+			do_xpat(arg);
26
+		}
27
 		else if (!strcasecmp(line,"xover"))
28
 		{
29
 			do_xover(arg);
30
@@ -811,10 +817,11 @@
31
 	printf(".\r\n");
32
 }
33
 
34
+static char *xhdr_h[7] = { "Subject","From","Date","Message-ID",
35
+		      "References","Bytes","Lines" };
36
+
37
 static void do_xhdr(char *arg)
38
 {
39
-	static char *h[7] = { "Subject","From","Date","Message-ID",
40
-			      "References","Bytes","Lines" };
41
 	char *fmt,*cp;
42
 	unsigned char c;
43
 	int i;
44
@@ -835,7 +842,7 @@
45
 	i = -1; fmt = "%u \r\n";
46
 	for (u=0; u<7; ++u)
47
 	{
48
-		if (!strcasecmp(arg,h[u]))
49
+		if (!strcasecmp(arg,xhdr_h[u]))
50
 		{
51
 			fmt = ((i=u) < 5) ? "%u %s\r\n" : "%u %u\r\n";
52
 		}
53
@@ -1118,6 +1125,7 @@
54
 		printf("ARTICLE   HEAD      BODY      STAT\r\n");
55
 		printf("GROUP     LIST      NEXT      LAST\r\n");
56
 		printf("LISTGROUP XHDR      XOVER     XPATH\r\n");
57
+		printf("XPAT      ");
58
 	}
59
 	if (canpost)
60
 	{
61
@@ -1127,7 +1135,7 @@
62
 	{
63
 		printf("IHAVE     ");
64
 	}
65
-	printf("HELP      QUIT\r\n.\r\n");
66
+	printf("\r\nHELP      QUIT\r\n.\r\n");
67
 }
68
 
69
 static int match_pat(char *pat,char *str)
70
@@ -1533,3 +1541,177 @@
71
 
72
 	return str;
73
 }
74
+
75
+static int match_pattern(const char *pat,const char *str)
76
+{
77
+	char c;
78
+
79
+	while ((c = *(pat++)))
80
+	{
81
+		switch (c)
82
+		{
83
+		case '*':
84
+			if (!*pat)
85
+				return (1);
86
+			while (*str)
87
+			{
88
+				if (match_pattern(pat,str))
89
+					return (1);
90
+				++str;
91
+			}
92
+			break;
93
+		case '?':
94
+			if (!*str)
95
+				return (0);
96
+			break;
97
+		case '[':
98
+			if (*str)
99
+			{
100
+				unsigned char rev,mat=0,l=0,h,u=*str;
101
+
102
+				if ((rev = (*pat=='^'?1:0)))
103
+					pat++;
104
+				if ((c=*pat)) do
105
+				{
106
+					pat++;
107
+					if (c=='-' && l && (h=*pat) && h!=']')
108
+					{
109
+						pat++;
110
+						if (u>=l && u<=h) mat=1;
111
+						l = 0;
112
+					}
113
+					else
114
+					{
115
+						if (u==c) mat=1;
116
+						l = c;
117
+					}
118
+				}
119
+				while ((c=*pat) && c!=']');
120
+				if (c)
121
+					++pat;
122
+				if (mat==rev)
123
+					return (0);
124
+			}
125
+			else
126
+				return (0);
127
+			break;
128
+		default:
129
+			if (*str!=c)
130
+				return (0);
131
+			break;
132
+		}
133
+		++str;
134
+	}
135
+
136
+	return (!*str);
137
+}
138
+
139
+static void do_xpat(char *arg)
140
+{
141
+	char *cp;
142
+	unsigned char c;
143
+	int i;
144
+	unsigned u,l;
145
+	char const **patterns = NULL;
146
+	size_t pat_size = 0;
147
+	size_t npats = 0;
148
+
149
+	if (check_read()) return;
150
+
151
+	if (!grp)
152
+	{
153
+		printf("412 no newsgroup has been selected\r\n");
154
+		return;
155
+	}
156
+
157
+	cp = arg;
158
+	while ((c=*(cp)) && !isspace(c)) cp++;
159
+	if (*cp) *(cp++) = '\0';
160
+
161
+	i = -1;
162
+	for (u=0; u<7; ++u)
163
+	{
164
+		if (!strcasecmp(arg,xhdr_h[u]))
165
+		{
166
+		//	fmt = ((i=u) < 5) ? "%u %s\r\n" : "%u %u\r\n";
167
+			i = u;
168
+		}
169
+	}
170
+	if (i == -1)
171
+	{
172
+		printf("501 header not in index\r\n");
173
+		return;
174
+	}
175
+
176
+	while ((c=*(cp)) && isspace(c)) cp++;
177
+	if (*cp)
178
+	{
179
+		u = strtoul(cp,&cp,10);
180
+		if (*cp == '-')
181
+		{
182
+			if (*(++cp)) l = strtoul(cp,&cp,10);
183
+			else l = grp->last;
184
+		}
185
+		else l = u;
186
+	}
187
+	else u = l = art;
188
+
189
+	if (!u)
190
+	{
191
+		printf("420 no article has been selected\r\n");
192
+		return;
193
+	}
194
+
195
+	patterns = malloc(sizeof(char const *));
196
+	pat_size = 1;
197
+	do
198
+	{
199
+		while (*cp && isspace(*cp)) ++cp;
200
+		if (*cp)
201
+		{
202
+			if (npats + 1 > pat_size)
203
+			{
204
+				patterns = realloc(patterns, (pat_size *= 2) *
205
+						sizeof(const char *));
206
+			}
207
+			patterns[npats++] = cp;
208
+			while (*cp && !isspace(*cp)) ++cp;
209
+			if (*cp) *(cp++) = 0;
210
+		}
211
+	} while (*cp);
212
+	if (!npats)
213
+	{
214
+		free(patterns);
215
+		printf("501 command syntax error\r\n");
216
+	}
217
+
218
+	printf("221 Header follows\r\n");
219
+	
220
+	while (u <= l)
221
+	{
222
+		struct overview *o;
223
+
224
+		if ((o = find_overview(u)))
225
+		{
226
+			size_t pat;
227
+			char matchnum[12];
228
+			char *match = i < 5 ? (&o->subject)[i] :
229
+				(sprintf(matchnum, "%u", ((unsigned *)
230
+							  (&o->subject))[i]),
231
+				 matchnum);
232
+
233
+			for (pat = 0; pat < npats; ++pat)
234
+			{
235
+				if (match_pattern(patterns[pat], match))
236
+				{
237
+					printf("%u %s\r\n", u, match);
238
+				}
239
+			}
240
+		}
241
+		++u;
242
+	}
243
+
244
+	printf(".\r\n");
245
+	free(patterns);
246
+}
247
+
(-)s-news/files/patch-qnews.c (+95 lines)
Line 0 Link Here
1
--- qnews.c	2002-05-18 20:21:42.000000000 +0100
2
+++ qnews.c	2002-10-12 19:23:55.000000000 +0100
3
@@ -2,6 +2,8 @@
4
  *  S-News version 0.1.9 - A Simple News Server
5
  *  Copyright (C) 1998 Christopher John Purnell
6
  *                     cjp@lost.org.uk
7
+ *  flock modification (c) 2002 Tony Houghton
8
+ *  		       tony@realh.co.uk
9
  *
10
  *  This program is free software; you can redistribute it and/or modify
11
  *  it under the terms of the GNU General Public License as published by
12
@@ -22,7 +24,13 @@
13
 #include "config.h"
14
 #endif
15
 
16
+#include <sys/types.h>
17
 #include <sys/stat.h>
18
+#ifdef HAVE_SYS_FILE_H
19
+#include <sys/file.h>
20
+#endif
21
+#include <fcntl.h>
22
+
23
 #ifdef HAVE_UNISTD_H
24
 #include <unistd.h>
25
 #endif
26
@@ -79,15 +87,37 @@
27
 			if (match_group(ptr->value,line,end))
28
 			{
29
 				FILE *fp;
30
+			#ifdef HAVE_SYS_FILE_H
31
+				int fd;
32
+			#endif
33
 
34
 				sprintf(file,CONFDIR"/suck/%s/outgoing",
35
-					ptr->name);
36
+				    ptr->name);
37
 
38
-				if (!(fp = fopen(file,"a")))
39
+			#ifdef HAVE_SYS_FILE_H
40
+				if ((fd = open(file,O_WRONLY|O_APPEND|O_CREAT,
41
+						0644)) == -1)
42
 				{
43
-					perror(file);
44
-					return (1);
45
+				    perror(file);
46
+				    return (1);
47
+				}
48
+				if (flock(fd,LOCK_EX) == -1)
49
+				{
50
+				    perror(file);
51
+				    return (1);
52
+				}
53
+				if (!(fp = fdopen(fd,"a")))
54
+				{
55
+				    perror(file);
56
+				    return (1);
57
 				}
58
+			#else
59
+                                if (!(fp = fopen(file,"a")))
60
+                                {
61
+                                        perror(file);
62
+                                        return (1);
63
+                                }
64
+			#endif
65
 
66
 				if (fputs(line,fp) < 0 ||
67
 				    fputc('\n',fp) < 0)
68
@@ -103,6 +133,9 @@
69
 					return (1);
70
 				}
71
 
72
+				/* By commenting this break we can post to
73
+				 * multiple servers instead of stopping after
74
+				 * first match*/
75
 				break;
76
 			}
77
 		}
78
@@ -204,7 +237,7 @@
79
 				return (0);
80
 			break;
81
 		case '[':
82
-			if (str>=end)
83
+			if (str<end)
84
 			{
85
 				unsigned char rev,mat=0,l=0,h,u=*str;
86
 
87
@@ -229,6 +262,8 @@
88
 				if (mat==rev)
89
 					return (0);
90
 			}
91
+			else
92
+				return (0);
93
 			break;
94
 		default:
95
 			if (str>=end || *str!=c)
(-)s-news/files/patch-rnews.c (+453 lines)
Line 0 Link Here
1
--- rnews.c	2002-05-18 20:21:26.000000000 +0100
2
+++ rnews.c	2002-09-08 12:50:41.000000000 +0100
3
@@ -2,6 +2,8 @@
4
  *  S-News version 0.1.9 - A Simple News Server
5
  *  Copyright (C) 1998 Christopher John Purnell
6
  *                     cjp@lost.org.uk
7
+ *  Supersedes/cancel modifications (C) 2002 Tony Houghton
8
+ *  		       tony@realh.co.uk
9
  *
10
  *  This program is free software; you can redistribute it and/or modify
11
  *  it under the terms of the GNU General Public License as published by
12
@@ -50,6 +52,8 @@
13
 
14
 #include "snews.h"
15
 
16
+#define DEBLOG(a) /* fprintf a */
17
+
18
 struct header
19
 {
20
 	struct header *next;
21
@@ -78,14 +82,23 @@
22
 static FILE *open_lock(char *);
23
 static int file_name(struct header *,char *,unsigned);
24
 static GDBM_FILE open_history(char *,int);
25
+static int read_string(FILE *,char *,unsigned);
26
+static void delete_msg(const char *);
27
+static int whole_string(struct header_pointer *,char *,unsigned);
28
+static int read_line(FILE *,char *,unsigned);
29
+static int isolate_addr(char *);
30
 
31
 static char *progname;
32
 static char fqdn[BUFLEN];
33
 static char msgid[BUFLEN];
34
 static char article[BUFLEN];
35
+static char vsender[BUFLEN];
36
+static char cancel[BUFLEN];
37
 static char queue=0,approved=0;
38
+static int cancel_only;
39
 
40
 struct header junk = { 0, "junk", 0 };
41
+struct header control_cancel = { 0, "control.cancel", 0 };
42
 
43
 int main(int argc,char **argv)
44
 {
45
@@ -95,6 +108,16 @@
46
 
47
 	set_ug_id();
48
 
49
+	/* For logging, remove this in release */
50
+	/*
51
+	i = open("/var/log/news/rnews", O_WRONLY|O_CREAT|O_APPEND, 0644);
52
+	if (i)
53
+	{
54
+	    close(2);
55
+	    dup2(i, 2);
56
+	}
57
+	*/
58
+
59
 	progname = argv[0];
60
 
61
 	if (get_fqdn())
62
@@ -116,12 +139,18 @@
63
 		return (1);
64
 	}
65
 
66
+	cancel[0] = 0;
67
+	vsender[0] = 0;
68
+	cancel_only = 0;
69
+
70
 	if (!(hdr = read_header()))
71
 		return (1);
72
 
73
 	if (!(ngrp = parse_header(hdr)))
74
 		return (1);
75
 
76
+	DEBLOG((stderr, "Message-ID: %s\n", msgid));
77
+
78
 	if (!(fp = open_lock(CONFDIR"/active.n")))
79
 	{
80
 		perror(progname);
81
@@ -130,8 +159,16 @@
82
 	
83
 	if (!(i = chk_article(msgid)))
84
 	{
85
-		if (!(ngrp = update_active(CONFDIR"/active",CONFDIR"/active.n",
86
-					  fp,ngrp)))
87
+		DEBLOG((stderr, "chk_article OK\n"));
88
+		if (cancel_only)
89
+		{
90
+			ngrp = update_active(CONFDIR"/active",
91
+					     CONFDIR"/active.n",
92
+					     fp,&control_cancel);
93
+			DEBLOG((stderr, "cancel_only, ngrp = %d\n", ngrp));
94
+		}
95
+		else if (!(ngrp = update_active(CONFDIR"/active",
96
+			    CONFDIR"/active.n",fp,ngrp)))
97
 		{
98
 			rewind(fp);
99
 			if (ftruncate(fileno(fp),0))
100
@@ -144,8 +181,11 @@
101
 		i = !ngrp;
102
 	}
103
 
104
+	DEBLOG((stderr, "After chk_article and update_active, result = %d (0 is good)\n", i));
105
+
106
 	if (fclose(fp) || i || write_article(hdr,ngrp))
107
 	{
108
+		DEBLOG((stderr, "fclose || i || write_article failed\n"));
109
 		unlink(CONFDIR"/active.n");
110
 		return (1);
111
 	}
112
@@ -158,6 +198,9 @@
113
 		return (1);
114
 	}
115
 
116
+	if (cancel[0])
117
+		delete_msg(cancel);
118
+
119
 	if (!queue) return (0);
120
 
121
 	execl(QNEWSPATH,QNEWSARG0,article,0);
122
@@ -301,11 +344,79 @@
123
 			{
124
 				approved=1;
125
 			}
126
+			else if (!strncasecmp(hdr->line,"Sender:",7))
127
+			{
128
+				hp.hdr = hdr;
129
+				hp.ptr = hdr->line+7;
130
+				if (whole_string(&hp,vsender,BUFLEN)<=0)
131
+				{
132
+					fprintf(stderr,"%s: bad Sender\n",
133
+						progname);
134
+					return (0);
135
+				}
136
+				DEBLOG((stderr, "Found Sender: %s\n", vsender));
137
+			}
138
+			else if (!vsender[0] && !strncasecmp(hdr->line,"From:",5))
139
+			{
140
+				hp.hdr = hdr;
141
+				hp.ptr = hdr->line+5;
142
+				if (whole_string(&hp,vsender,BUFLEN)<=0)
143
+				{
144
+					fprintf(stderr,"%s: bad From\n",
145
+						progname);
146
+					return (0);
147
+				}
148
+				DEBLOG((stderr, "Found From: %s\n", vsender));
149
+			}
150
+			else if (!strncasecmp(hdr->line,"Supersedes:",11))
151
+			{
152
+				hp.hdr = hdr;
153
+				hp.ptr = hdr->line+11;
154
+				if (whole_string(&hp,cancel,BUFLEN)<=0)
155
+				{
156
+					fprintf(stderr,"%s: bad Supersedes\n",
157
+						progname);
158
+					return (0);
159
+				}
160
+				DEBLOG((stderr, "Found Supersedes: %s\n", cancel));
161
+			}
162
+			else if (!strncasecmp(hdr->line,"Control: cancel",15))
163
+			{
164
+				hp.hdr = hdr;
165
+				hp.ptr = hdr->line+15;
166
+				if (whole_string(&hp,cancel,BUFLEN)<=0)
167
+				{
168
+					fprintf(stderr,"%s: bad cancel\n",
169
+						progname);
170
+					return (0);
171
+				}
172
+				DEBLOG((stderr, "Found cancel: %s\n", cancel));
173
+				cancel_only = 1;
174
+			}
175
+			else if (!strncasecmp(hdr->line,"Also-Control: cancel",20))
176
+			{
177
+				hp.hdr = hdr;
178
+				hp.ptr = hdr->line+20;
179
+				if (whole_string(&hp,cancel,BUFLEN)<=0)
180
+				{
181
+					fprintf(stderr,"%s: bad cancel\n",
182
+						progname);
183
+					return (0);
184
+				}
185
+				DEBLOG((stderr, "Found also-cancel: %s\n", cancel));
186
+			}
187
 
188
 		}
189
 		hdr = hdr->next;
190
 	}
191
 
192
+	if (vsender[0])
193
+	{
194
+		int ires=isolate_addr(vsender);
195
+		DEBLOG((stderr,"vsender address = %s (result %d)\n",
196
+					vsender,ires));
197
+	}
198
+	
199
 	return (*msgid?ret:0);
200
 }
201
 
202
@@ -597,7 +708,10 @@
203
 	int ret;
204
 
205
 	if (!(dbf = open_history(CONFDIR"/history",GDBM_READER)))
206
+	{
207
+		DEBLOG((stderr, "chk_article: Couldn't open history\n"));
208
 		return (1);
209
+	}
210
 
211
 	key.dsize = strlen(key.dptr = id) + 1;
212
 
213
@@ -605,6 +719,7 @@
214
 
215
 	gdbm_close(dbf);
216
 
217
+	DEBLOG((stderr, "chk_article: %s exists: %d\n", id, ret));
218
 	return (ret);
219
 }
220
 
221
@@ -642,3 +757,232 @@
222
 	}
223
 	return (dbf);
224
 }
225
+
226
+/* Added by Tony Houghton <tony@realh.co.uk>, mostly copied from expire.c */
227
+
228
+static void delete_msg(const char *msgid)
229
+{
230
+	char buf[BUFLEN];
231
+	char sender[BUFLEN];
232
+	struct stat st;
233
+	FILE *fp;
234
+	GDBM_FILE dbf;
235
+	datum key,value;
236
+	char *file;
237
+
238
+	DEBLOG((stderr, "Deleting %s\n", msgid));
239
+	if (!(dbf = open_history(CONFDIR"/history",GDBM_READER)))
240
+		return;
241
+	key.dsize = strlen(key.dptr = (char *) msgid) + 1;
242
+	value = gdbm_fetch(dbf, key);
243
+	if ((file = value.dptr) == NULL)
244
+		return;
245
+	DEBLOG((stderr, "Filename is %s\n", file));
246
+	
247
+	if (!(fp = fopen(file,"r")))
248
+	{
249
+		if (errno != ENOENT)
250
+			perror(file);
251
+		free(file);
252
+		return;
253
+	}
254
+
255
+	if (fstat(fileno(fp),&st))
256
+	{
257
+		perror(file);
258
+		free(file);
259
+		return;
260
+	}
261
+
262
+	sender[0] = 0;
263
+	while (fgets(buf,6,fp))
264
+	{
265
+		if (!sender[0] && !strcasecmp(buf,"From:"))
266
+		{
267
+			if (read_line(fp,sender,BUFLEN) <= 0)
268
+			{
269
+				fclose(fp);
270
+				fprintf(stderr,"%s: bad From header\n",file);
271
+				free(file);
272
+				return;
273
+			}
274
+			DEBLOG((stderr, "From: %s\n", sender));
275
+		}
276
+		else if (!strcasecmp(buf,"Sende") && fgetc(fp) == 'r' &&
277
+			fgetc(fp) == ':')
278
+		{
279
+			if (read_line(fp,sender,BUFLEN) <= 0)
280
+			{
281
+				fclose(fp);
282
+				fprintf(stderr,"%s: bad Sender\n",file);
283
+				free(file);
284
+				return;
285
+			}
286
+			DEBLOG((stderr, "Sender: %s\n", sender));
287
+		}
288
+		else if (buf[0] == '\n')
289
+			break;
290
+	}
291
+	rewind(fp);
292
+	if (isolate_addr(sender) == -1)
293
+	{
294
+		fprintf(stderr,"Invalid sender, can't cancel\n");
295
+		free(file);
296
+		fclose(fp);
297
+		return;
298
+	}
299
+	DEBLOG((stderr,"Sender address = %s\n",sender));
300
+
301
+	if (strcasecmp(sender,vsender))
302
+	{
303
+		fprintf(stderr,"Wrong sender, can't cancel\n");
304
+		free(file);
305
+		fclose(fp);
306
+		return;
307
+	}
308
+
309
+	while (fgets(buf,6,fp))
310
+	{
311
+		char *cp;
312
+		int c;
313
+
314
+		if (strcasecmp(buf,"Xref:"))
315
+		{
316
+			if ((cp = strchr(buf,'\n')))
317
+			{
318
+				if (cp == buf) break;
319
+			}
320
+			else
321
+			{
322
+				while ((c = fgetc(fp)) != EOF && c != '\n');
323
+				if (c == EOF) break;
324
+			}
325
+		}
326
+		else
327
+		{
328
+			if ((read_string(fp,buf,BUFLEN) <= 0) ||
329
+			    strcasecmp(buf,fqdn))
330
+			{
331
+				fclose(fp);
332
+				fprintf(stderr,"%s: bad Xref line\n",file);
333
+				free(file);
334
+				return;
335
+			}
336
+
337
+			while ((c = read_string(fp,buf,BUFLEN)))
338
+			{
339
+				if (c < 0)
340
+				{
341
+					fclose(fp);
342
+					fprintf(stderr,"%s: bad Xref line\n",
343
+						file);
344
+					free(file);
345
+					return;
346
+				}
347
+
348
+				cp = buf;
349
+				while ((c = *cp))
350
+				{
351
+					if (c == '.' || c ==':')
352
+						*cp = '/';
353
+					++cp;
354
+				}
355
+
356
+				if (strcmp(file,buf) &&
357
+				    unlink(buf) && errno != ENOENT)
358
+				{
359
+					perror(buf);
360
+					fclose(fp);
361
+					free(file);
362
+					return;
363
+				}
364
+			}
365
+
366
+			break;
367
+		}
368
+	}
369
+	if (ferror(fp))
370
+	{
371
+		perror(file);
372
+		free(file);
373
+		fclose(fp);
374
+		return;
375
+	}
376
+
377
+	fclose(fp);
378
+	if (unlink(file))
379
+		perror(file);
380
+	free(file);
381
+}
382
+
383
+static int read_string(FILE *fp,char *str,unsigned len)
384
+{
385
+	int c;
386
+	unsigned i=0;
387
+
388
+	while ((c = fgetc(fp)) != EOF && c != '\n' && isspace(c));
389
+
390
+	while (c != EOF && !isspace(c))
391
+	{
392
+		str[i]=c;
393
+		if (++i>=len) return (-1);
394
+		c = fgetc(fp);
395
+	}
396
+	str[i]='\0';
397
+
398
+	return (i);
399
+}
400
+
401
+static int whole_string(struct header_pointer *hp,char *str,unsigned len)
402
+{
403
+        unsigned i=0;
404
+	unsigned char c;
405
+
406
+        while ((c = next_char(hp)) && isspace(c));
407
+
408
+        while (c && c != '\n')
409
+        {
410
+                str[i]=c;
411
+                if (++i>=len) return (-1);
412
+                c = next_char(hp);
413
+        }
414
+	str[i]='\0';
415
+
416
+        return (i);
417
+}
418
+ 
419
+static int read_line(FILE *fp,char *str,unsigned len)
420
+{
421
+	int c;
422
+	unsigned i=0;
423
+
424
+	while ((c = fgetc(fp)) != EOF && c != '\n' && isspace(c));
425
+
426
+	while (c != EOF && c != '\n')
427
+	{
428
+		str[i]=c;
429
+		if (++i>=len) return (-1);
430
+		c = fgetc(fp);
431
+	}
432
+	str[i]='\0';
433
+
434
+	return (i);
435
+}
436
+
437
+static int isolate_addr(char *str)
438
+{
439
+    char *at;
440
+    unsigned len;
441
+
442
+    if (!(at=strchr(str,'@')))
443
+	    return -1;
444
+    while (at != str && !isspace(*(at-1)) && *(at-1) != '<')
445
+	    --at;
446
+    for (len = 0;
447
+	 len <= strlen(at) && !isspace(at[len]) && at[len] !='>';
448
+	 ++len);
449
+    memmove(str,at,len);
450
+    str[len]=0;
451
+    return 0;
452
+}
453
+

Return to bug 69551