annotate 3rdparty/packages/uucpbb/src/procart.c @ 3140:03b580a02945

Allow CoCo3FPGA-specific build of superdesc.asm Added new conditional CC3FPGA and code to "level1/modules/superdesc.asm" to reflect changes needed to build the new SD card descriptors for the Coco3FPGA.
author Bill Pierce <merlinious999@gmail.com>
date Sat, 04 Feb 2017 11:06:26 +0100
parents 5ba8e711a1a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1772
5ba8e711a1a3 source added
boisy
parents:
diff changeset
1 /* procart.c - Process a single article into one or more news groups.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
2 Copyright (C) 1994 Brad Spencer
5ba8e711a1a3 source added
boisy
parents:
diff changeset
3
5ba8e711a1a3 source added
boisy
parents:
diff changeset
4 This file is part of the OS-9 UUCP package, UUCPbb.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
5
5ba8e711a1a3 source added
boisy
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify
5ba8e711a1a3 source added
boisy
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
5ba8e711a1a3 source added
boisy
parents:
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
5ba8e711a1a3 source added
boisy
parents:
diff changeset
9 (at your option) any later version.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
10
5ba8e711a1a3 source added
boisy
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
5ba8e711a1a3 source added
boisy
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5ba8e711a1a3 source added
boisy
parents:
diff changeset
14 GNU General Public License for more details.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
15
5ba8e711a1a3 source added
boisy
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
5ba8e711a1a3 source added
boisy
parents:
diff changeset
17 along with this program; if not, write to the Free Software
5ba8e711a1a3 source added
boisy
parents:
diff changeset
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
19
5ba8e711a1a3 source added
boisy
parents:
diff changeset
20 The author of UUCPbb, Bob Billson, can be contacted at:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
21 bob@kc2wz.bubble.org or uunet!kc2wz!bob or by snail mail:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
22 21 Bates Way, Westfield, NJ 07090
5ba8e711a1a3 source added
boisy
parents:
diff changeset
23 */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
24
5ba8e711a1a3 source added
boisy
parents:
diff changeset
25 #include "uucp.h"
5ba8e711a1a3 source added
boisy
parents:
diff changeset
26 #include "rnews.h"
5ba8e711a1a3 source added
boisy
parents:
diff changeset
27 #include "mbuf.h"
5ba8e711a1a3 source added
boisy
parents:
diff changeset
28
5ba8e711a1a3 source added
boisy
parents:
diff changeset
29 extern char *junk;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
30 extern char *space;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
31 struct mbuf *mwrite();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
32 extern int debuglvl;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
33
5ba8e711a1a3 source added
boisy
parents:
diff changeset
34 int free();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
35
5ba8e711a1a3 source added
boisy
parents:
diff changeset
36 int procart (fd, initalbuf, initng, gh, origlength)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
37 FILE *fd;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
38 char *initalbuf, *initng;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
39 struct mbuf *gh;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
40 long origlength;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
41 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
42 char lbuf[512];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
43 char *newsgroups = NULL, *refline = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
44 int gotgroup = FALSE, r;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
45 struct mbuf *mh = NULL, *mp = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
46 register struct mbuf *gg;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
47
5ba8e711a1a3 source added
boisy
parents:
diff changeset
48 /* A inital newsgroup may be forced onto this article */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
49 if (*initng != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
50 newsgroups = initng;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
51
5ba8e711a1a3 source added
boisy
parents:
diff changeset
52 mp = mwrite (mp, &mh, initalbuf, strlen (initalbuf) + 1);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
53
5ba8e711a1a3 source added
boisy
parents:
diff changeset
54 while (feof (fd) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
55 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
56 if (gotgroup == FALSE)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
57 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
58 getline (fd, initalbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
59
5ba8e711a1a3 source added
boisy
parents:
diff changeset
60 if (debuglvl > 8)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
61 lineis (lbuf, initalbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
62
5ba8e711a1a3 source added
boisy
parents:
diff changeset
63 mp = mwrite (mp, &mh, initalbuf, strlen (initalbuf) + 1);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
64
5ba8e711a1a3 source added
boisy
parents:
diff changeset
65 if (*initng == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
66 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
67 if (strncmp (mp->cbuf, "Newsgroups: ", 12) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
68 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
69 newsgroups = &mp->cbuf[12];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
70
5ba8e711a1a3 source added
boisy
parents:
diff changeset
71 if (debuglvl > 1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
72 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
73 sprintf (lbuf, "Newsgroup: %s", newsgroups);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
74 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
75 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
76
5ba8e711a1a3 source added
boisy
parents:
diff changeset
77 if (refline != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
78 gotgroup = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
79 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
80 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
81
5ba8e711a1a3 source added
boisy
parents:
diff changeset
82 /* Bob says that tabs need to be eaten from References: lines
5ba8e711a1a3 source added
boisy
parents:
diff changeset
83 */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
84 if (strncmp (mp->cbuf, "References: ", 12) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
85 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
86 refline = mp->cbuf;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
87 fixref (refline);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
88
5ba8e711a1a3 source added
boisy
parents:
diff changeset
89 if (debuglvl > 2)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
90 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
91 sprintf (lbuf, "Reference line is: '%s'", refline);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
92 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
93 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
94
5ba8e711a1a3 source added
boisy
parents:
diff changeset
95 if (newsgroups != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
96 gotgroup = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
97 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
98
5ba8e711a1a3 source added
boisy
parents:
diff changeset
99 if (mp->cbuf[0] == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
100 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
101 if (newsgroups == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
102 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
103 if (debuglvl > 1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
104 log ("No newsgroup given, junking article");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
105
5ba8e711a1a3 source added
boisy
parents:
diff changeset
106 newsgroups = junk;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
107 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
108 gotgroup = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
109 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
110 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
111 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
112 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
113 if (gotgroup == TRUE)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
114 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
115 openarts (gh, newsgroups);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
116
5ba8e711a1a3 source added
boisy
parents:
diff changeset
117 if (origlength != -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
118 if ((origlength - 1) > 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
119 extendfile (gh, origlength, lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
120
5ba8e711a1a3 source added
boisy
parents:
diff changeset
121 /* Write the inital few lines to the file(s) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
122 for (gg = gh; gg != NULL; gg = gg->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
123 if (((struct groups *)gg->cbuf)->artfd != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
124 for (mp = mh; mp != NULL; mp = mp->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
125 fprintf (((struct groups *)gg->cbuf)->artfd,"%s\n", mp->cbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
126
5ba8e711a1a3 source added
boisy
parents:
diff changeset
127 gotgroup++;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
128 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
129
5ba8e711a1a3 source added
boisy
parents:
diff changeset
130 if ((r = fread (initalbuf, 1, BIGBUF-1, fd)) < 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
131 log ("procart: read error");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
132
5ba8e711a1a3 source added
boisy
parents:
diff changeset
133 if (debuglvl > 8)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
134 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
135 sprintf (lbuf, "read: %d", r);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
136 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
137 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
138 crlf (initalbuf, r);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
139
5ba8e711a1a3 source added
boisy
parents:
diff changeset
140 /* Write a just-read block */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
141 for (gg = gh; gg != NULL; gg = gg->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
142 if (((struct groups *)gg->cbuf)->artfd != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
143 fwrite (initalbuf, 1, r,((struct groups *)gg->cbuf)->artfd);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
144 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
145 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
146
5ba8e711a1a3 source added
boisy
parents:
diff changeset
147 /* Close all the open files */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
148 for (gg = gh; gg != NULL; gg = gg->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
149 if (((struct groups *)gg->cbuf)->artfd != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
150 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
151 fclose (((struct groups *)gg->cbuf)->artfd);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
152 ((struct groups *)gg->cbuf)->artfd = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
153 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
154
5ba8e711a1a3 source added
boisy
parents:
diff changeset
155 /* free the mbuf list, use 'free' because the cbufs are simple */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
156 if (mh != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
157 mfree (mh, free);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
158 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
159
5ba8e711a1a3 source added
boisy
parents:
diff changeset
160
5ba8e711a1a3 source added
boisy
parents:
diff changeset
161
5ba8e711a1a3 source added
boisy
parents:
diff changeset
162 /* This next bit is a attempt to lessen the disk fragmentation that seems to
5ba8e711a1a3 source added
boisy
parents:
diff changeset
163 occur when spooling news. It seeks to the maximum length that a article
5ba8e711a1a3 source added
boisy
parents:
diff changeset
164 may be and then writes a byte. It then rewinds. Hopefully, contiguous
5ba8e711a1a3 source added
boisy
parents:
diff changeset
165 blocks will be allocated */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
166
5ba8e711a1a3 source added
boisy
parents:
diff changeset
167 int extendfile (gh, origlength, lbuf)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
168 struct mbuf *gh;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
169 long origlength;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
170 char lbuf[];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
171 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
172 register struct mbuf *gg;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
173
5ba8e711a1a3 source added
boisy
parents:
diff changeset
174 for (gg = gh; gg != NULL; gg = gg->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
175 if (((struct groups *)gg->cbuf)->artfd != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
176 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
177 if (lseek (fileno (((struct groups *)gg->cbuf)->artfd),
5ba8e711a1a3 source added
boisy
parents:
diff changeset
178 origlength-1, 0) == -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
179 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
180 sprintf (lbuf, "Couldn't seek %ld %d",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
181 origlength-1, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
182 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
183 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
184
5ba8e711a1a3 source added
boisy
parents:
diff changeset
185 write (fileno (((struct groups *)gg->cbuf)->artfd), space, 1);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
186
5ba8e711a1a3 source added
boisy
parents:
diff changeset
187 if (lseek (fileno (((struct groups *)gg->cbuf)->artfd), 0L, 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
188 == -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
189 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
190 sprintf (lbuf, "Couldn't seek back %ld %d",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
191 origlength, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
192 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
193 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
194 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
195 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
196
5ba8e711a1a3 source added
boisy
parents:
diff changeset
197
5ba8e711a1a3 source added
boisy
parents:
diff changeset
198
5ba8e711a1a3 source added
boisy
parents:
diff changeset
199 int lineis (lbuf, initalbuf)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
200 char lbuf[], *initalbuf;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
201 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
202 strncat (strcpy (lbuf, "LINE IS '"), initalbuf, 20);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
203 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
204 }