annotate 3rdparty/packages/uucpbb/src/openarts.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 /* openarts.c - Open a number of articles, if possible.
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 int debuglvl;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
30 char *fixgroupname();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
31
5ba8e711a1a3 source added
boisy
parents:
diff changeset
32
5ba8e711a1a3 source added
boisy
parents:
diff changeset
33 int openarts (g, gname)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
34 struct mbuf *g;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
35 char *gname;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
36 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
37 char lbuf[512], gpath[200];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
38 char *p, *ngroups, *np, *ncp;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
39 struct mbuf *gp;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
40 int havegroup = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
41
5ba8e711a1a3 source added
boisy
parents:
diff changeset
42 /* Allocate some space for the group name stuff */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
43 ngroups = (char *)malloc (strlen (gname) + 2);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
44
5ba8e711a1a3 source added
boisy
parents:
diff changeset
45 if (ngroups == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
46 fatal ("openarts(): can't malloc copy of newsgroup name");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
47
5ba8e711a1a3 source added
boisy
parents:
diff changeset
48 sprintf (ngroups, "%s\n", gname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
49 np = ngroups;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
50
5ba8e711a1a3 source added
boisy
parents:
diff changeset
51 /* Loop until we run out of given articles */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
52 while (*np != '\0' && *np != '\l' && *np != '\n')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
53 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
54 /* Search for the terminator or separator character */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
55 for (ncp = np;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
56 *ncp != ',' && *ncp != '\0' && *ncp != '\l' && *ncp != '\n';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
57 ncp++);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
58 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
59 *ncp = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
60 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
61
5ba8e711a1a3 source added
boisy
parents:
diff changeset
62 /* Loop through the groups that are at this particular site, see if
5ba8e711a1a3 source added
boisy
parents:
diff changeset
63 there is a match */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
64
5ba8e711a1a3 source added
boisy
parents:
diff changeset
65 for (gp = g; gp != NULL; gp = gp->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
66 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
67 if (debuglvl > 4)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
68 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
69 sprintf (lbuf, "Checking group '%s' and '%s'", np,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
70 ((struct groups *)gp->cbuf)->name);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
71 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
72 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
73
5ba8e711a1a3 source added
boisy
parents:
diff changeset
74 /* Ok, this group matched */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
75 if (strcmp(((struct groups *)gp->cbuf)->name, np) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
76 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
77 char *gname;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
78
5ba8e711a1a3 source added
boisy
parents:
diff changeset
79 gname = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
80 havegroup = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
81
5ba8e711a1a3 source added
boisy
parents:
diff changeset
82 if (chdir (newsdir) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
83 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
84 sprintf (lbuf, "Can't chdir to '%s'", newsdir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
85 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
86 return (ABORT);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
87 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
88
5ba8e711a1a3 source added
boisy
parents:
diff changeset
89 /* Make the directory path for this news group, if it
5ba8e711a1a3 source added
boisy
parents:
diff changeset
90 doesn't exist */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
91
5ba8e711a1a3 source added
boisy
parents:
diff changeset
92 gname = fixgroupname (np);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
93 makepath (gname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
94
5ba8e711a1a3 source added
boisy
parents:
diff changeset
95 if (gname != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
96 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
97 free (gname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
98 gname = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
99 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
100
5ba8e711a1a3 source added
boisy
parents:
diff changeset
101 /* Form this particular article. We should already be in
5ba8e711a1a3 source added
boisy
parents:
diff changeset
102 the correct newsgroup's directory. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
103
5ba8e711a1a3 source added
boisy
parents:
diff changeset
104 ((struct groups *)gp->cbuf)->max++;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
105 sprintf (gpath, "a%d", ((struct groups *)gp->cbuf)->max);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
106
5ba8e711a1a3 source added
boisy
parents:
diff changeset
107 if (debuglvl > 3)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
108 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
109 sprintf (lbuf, "Trying: '%s' in '%s'", gpath,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
110 ((struct groups *)gp->cbuf)->name);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
111 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
112 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
113
5ba8e711a1a3 source added
boisy
parents:
diff changeset
114 /* Try to open the article, this should truncate any files
5ba8e711a1a3 source added
boisy
parents:
diff changeset
115 that are the same name */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
116
5ba8e711a1a3 source added
boisy
parents:
diff changeset
117 if ((((struct groups *)gp->cbuf)->artfd
5ba8e711a1a3 source added
boisy
parents:
diff changeset
118 = fopen (gpath, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
119 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
120 sprintf (lbuf, "Couldn't open '%s', because %d",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
121 gpath, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
122 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
123 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
124 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
125 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
126 np = ncp + 1;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
127 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
128 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
129 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
130 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
131 np = ncp + 1;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
132 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
133
5ba8e711a1a3 source added
boisy
parents:
diff changeset
134 /* Ok, this article doesn't go to any of the groups at this site */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
135 if (!havegroup)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
136 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
137 if (debuglvl > 1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
138 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
139 log ("Article doesn't go to any news groups in active file.");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
140 log ("Junking it.");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
141 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
142
5ba8e711a1a3 source added
boisy
parents:
diff changeset
143 for (gp = g; gp != NULL; gp = gp->mbuf_next)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
144 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
145 if (strncmp (((struct groups *)gp->cbuf)->name, "junk" ,4) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
146 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
147 np = ((struct groups *)gp->cbuf)->name;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
148 if (chdir (newsdir) == ERROR)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
149 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
150 sprintf (lbuf, "Can't chdir to '%s'", newsdir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
151 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
152 return (ABORT);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
153 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
154 makepath (np);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
155 ((struct groups *)gp->cbuf)->max++;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
156 sprintf (gpath, "Z%d", ((struct groups *)gp->cbuf)->max);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
157
5ba8e711a1a3 source added
boisy
parents:
diff changeset
158 for (p = gpath; *p != '\0'; p++)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
159 if (*p == '.')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
160 *p='/';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
161
5ba8e711a1a3 source added
boisy
parents:
diff changeset
162 if (debuglvl > 3)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
163 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
164 sprintf (lbuf, "Trying: '%s' in '%s'",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
165 gpath, ((struct groups *)gp->cbuf)->name);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
166 log(lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
167 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
168
5ba8e711a1a3 source added
boisy
parents:
diff changeset
169 if ((((struct groups *)gp->cbuf)->artfd
5ba8e711a1a3 source added
boisy
parents:
diff changeset
170 = fopen (gpath, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
171 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
172 sprintf (lbuf, "Couldn't open '%s', because %d",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
173 gpath, errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
174 log (lbuf);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
175 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
176 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
177 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
178 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
179
5ba8e711a1a3 source added
boisy
parents:
diff changeset
180 /* This really indicates that there is a problem in the universe.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
181 Every site should have a 'junk' group */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
182
5ba8e711a1a3 source added
boisy
parents:
diff changeset
183 if (gp == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
184 if (debuglvl > 1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
185 log ("No junk group.....");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
186 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
187 free (ngroups);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
188 }