annotate 3rdparty/packages/uucpbb/src/postnews.c @ 2106:c4c7facbd082

Fixed up some warnings
author boisy
date Sat, 07 Oct 2006 12:11:22 +0000
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 /* postnews.c This is main program for sending Usenet news.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
2 Copyright (C) 1990, 1993 Rick Adams and Bob Billson
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 /* Options:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
26
5ba8e711a1a3 source added
boisy
parents:
diff changeset
27 -f <file>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
28 -n <newsgroup>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
29 -S <system>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
30 -s <subject>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
31 -i <reference-ID>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
32 -a <reference-article>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
33 -t (force /t2 "dumb" windowing codes)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
34 -x <debug_level>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
35 */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
36
5ba8e711a1a3 source added
boisy
parents:
diff changeset
37 #define MAIN
5ba8e711a1a3 source added
boisy
parents:
diff changeset
38
5ba8e711a1a3 source added
boisy
parents:
diff changeset
39 #include "uucp.h"
5ba8e711a1a3 source added
boisy
parents:
diff changeset
40 #include <time.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
41 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
42 #include <utime.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
43 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
44 #include <signal.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
45 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
46 #include <os9.h>
5ba8e711a1a3 source added
boisy
parents:
diff changeset
47 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
48
5ba8e711a1a3 source added
boisy
parents:
diff changeset
49 extern QQ unsigned myuid;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
50 extern QQ char sepsym, quotechar;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
51 extern QQ char *nodename, *sitename, *name, *newshost, *organization;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
52 extern char user[], temp[];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
53
5ba8e711a1a3 source added
boisy
parents:
diff changeset
54 #ifndef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
55 QQ flag t2flag = FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
56 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
57 QQ FILE *log;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
58 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
59 QQ flag usedotilde;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
60 static char *dotilde = "dotilde";
5ba8e711a1a3 source added
boisy
parents:
diff changeset
61 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
62 QQ char *got_escape = "<ESC> hit...exiting";
5ba8e711a1a3 source added
boisy
parents:
diff changeset
63 QQ int debuglvl = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
64 static char value[100];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
65 char sysname[20], artfile[100], newsgroup[1024], subject[128];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
66 char reference[256],article[100], distrib[50], localgroup[256];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
67 char tempfile[100]; /* moved from postgroup() so interrupt() */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
68 /* can clean up -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
69
2106
c4c7facbd082 Fixed up some warnings
boisy
parents: 1772
diff changeset
70 int main(argc, argv)
1772
5ba8e711a1a3 source added
boisy
parents:
diff changeset
71 int argc;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
72 char *argv[];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
73 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
74 int option, interrupt();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
75 register char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
76 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
77 struct registers regs;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
78 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
79 *sysname = *artfile = *newsgroup = *subject = *localgroup = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
80 *reference = *article = *tempfile = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
81 homedir = NULL;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
82 opterr = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
83 log = stderr; /* use stderr rather than uulog file --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
84
5ba8e711a1a3 source added
boisy
parents:
diff changeset
85 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
86 pflinit(); /* tell linker longs will be printed --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
87 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
88
5ba8e711a1a3 source added
boisy
parents:
diff changeset
89 /* handle keyboard interrupts */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
90 intercept (interrupt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
91
5ba8e711a1a3 source added
boisy
parents:
diff changeset
92 #ifdef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
93 init_term_cap();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
94 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
95
5ba8e711a1a3 source added
boisy
parents:
diff changeset
96 while ((option = getopt (argc, argv, "f:n:s:S:i:a:tx:")) != EOF)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
97 switch (option)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
98 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
99 case 'f':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
100 strcpy (artfile, optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
101 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
102
5ba8e711a1a3 source added
boisy
parents:
diff changeset
103 case 'n':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
104 strcat (strcat (newsgroup, optarg), " ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
105 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
106
5ba8e711a1a3 source added
boisy
parents:
diff changeset
107 case 's':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
108 strcpy (subject, optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
109 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
110
5ba8e711a1a3 source added
boisy
parents:
diff changeset
111 case 'S':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
112 strcpy (sysname, optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
113 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
114
5ba8e711a1a3 source added
boisy
parents:
diff changeset
115 case 'i':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
116 strcpy (reference, optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
117 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
118
5ba8e711a1a3 source added
boisy
parents:
diff changeset
119 case 'a':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
120 strcpy (article, optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
121 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
122
5ba8e711a1a3 source added
boisy
parents:
diff changeset
123 case 't':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
124 #ifndef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
125 t2flag = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
126 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
127 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
128 case 'x':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
129 debuglvl = atoi (optarg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
130 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
131
5ba8e711a1a3 source added
boisy
parents:
diff changeset
132 case '?':
5ba8e711a1a3 source added
boisy
parents:
diff changeset
133 usage();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
134 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
135
5ba8e711a1a3 source added
boisy
parents:
diff changeset
136 default:
5ba8e711a1a3 source added
boisy
parents:
diff changeset
137 strcat (strcat (newsgroup, optarg), " ");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
138 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
139 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
140
5ba8e711a1a3 source added
boisy
parents:
diff changeset
141 /* elminated last blank in newsgroup list -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
142 newsgroup[strlen (newsgroup) - 1] = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
143
5ba8e711a1a3 source added
boisy
parents:
diff changeset
144 if (getparam() == FALSE)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
145 interrupt (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
146
5ba8e711a1a3 source added
boisy
parents:
diff changeset
147 userparam();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
148
5ba8e711a1a3 source added
boisy
parents:
diff changeset
149 if ((newsdir = getdirs ("newsdir")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
150 badparam ("newsdir");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
151
5ba8e711a1a3 source added
boisy
parents:
diff changeset
152 if ((spooldir = getdirs ("spooldir")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
153 badparam ("spooldir");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
154
5ba8e711a1a3 source added
boisy
parents:
diff changeset
155 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
156 if (nmlink (dotilde, 0, 0) == -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
157 if (nmload (dotilde, 0, 0) == -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
158 fatal ("can't load dotilde");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
159
5ba8e711a1a3 source added
boisy
parents:
diff changeset
160 usedotilde = TRUE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
161 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
162
5ba8e711a1a3 source added
boisy
parents:
diff changeset
163 #ifndef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
164 if (!t2flag)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
165 t2flag = t2test();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
166 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
167 /* figure out path to article being replied to, if any */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
168 if (*article != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
169 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
170 sprintf (temp, "%s/%s/%s", newsdir, newsgroup, article);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
171
5ba8e711a1a3 source added
boisy
parents:
diff changeset
172 while ((p = strchr (temp, '.')) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
173 *p = '/';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
174
5ba8e711a1a3 source added
boisy
parents:
diff changeset
175 strcpy (article, temp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
176 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
177
5ba8e711a1a3 source added
boisy
parents:
diff changeset
178 /* use default newsfeed host is -S wasn't on command line -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
179 if (*sysname == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
180 if (*newshost != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
181 strcpy (sysname, newshost);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
182 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
183 getsys (sysname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
184
5ba8e711a1a3 source added
boisy
parents:
diff changeset
185 /* get user name */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
186 if (*user == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
187 fatal ("user not in password file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
188
5ba8e711a1a3 source added
boisy
parents:
diff changeset
189 /* post article to newsgroup */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
190 postgroup (sysname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
191 interrupt (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
192 }
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 /* postgroup --queue article for remote news delivery */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
197
5ba8e711a1a3 source added
boisy
parents:
diff changeset
198 int postgroup (system)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
199 char *system;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
200 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
201 static char line[128], filename[50];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
202 static char cname[15], xname[14], dname[14], jname[14];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
203 char seq[5];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
204 FILE *file, *qfile, *sigfile;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
205 char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
206 long nseq;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
207 int result;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
208 flag localonly;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
209
5ba8e711a1a3 source added
boisy
parents:
diff changeset
210 /* open prepared article, if any */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
211 if (*artfile != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
212 if ((file = fopen (artfile, "r")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
213 fatal ("can't open article file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
214
5ba8e711a1a3 source added
boisy
parents:
diff changeset
215 /* Become super user so we can go to proper spool file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
216 asetuid (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
217 sprintf (temp, "%s/%s", spooldir, system);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
218
5ba8e711a1a3 source added
boisy
parents:
diff changeset
219 if (chdir (temp) == -1)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
220 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
221 char tmp[100];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
222
5ba8e711a1a3 source added
boisy
parents:
diff changeset
223 sprintf (tmp, "can't change to spool directory: %s\n", temp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
224 fatal (tmp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
225 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
226 asetuid (myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
227
5ba8e711a1a3 source added
boisy
parents:
diff changeset
228 /* Get unique message ID number. Moved here to speed things up a bit.
5ba8e711a1a3 source added
boisy
parents:
diff changeset
229 When we return our user ID will be restored. --REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
230
5ba8e711a1a3 source added
boisy
parents:
diff changeset
231 nseq = getseq (NEWSEQ);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
232
5ba8e711a1a3 source added
boisy
parents:
diff changeset
233 /* figure out all the spool file names */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
234 strcpy (seq, genseq() );
5ba8e711a1a3 source added
boisy
parents:
diff changeset
235
5ba8e711a1a3 source added
boisy
parents:
diff changeset
236 /* D.sysnameXXXX filename (article data file) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
237 sprintf (dname, "D.%.7s%s", nodename, seq);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
238
5ba8e711a1a3 source added
boisy
parents:
diff changeset
239 /* D.sysnameXXXX file (job file) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
240 sprintf (jname, "D.%.7s%s", system, seq);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
241
5ba8e711a1a3 source added
boisy
parents:
diff changeset
242 /* C.sysnameCXXXX (control file) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
243 sprintf (cname, "C.%.7sC%s", system, seq);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
244
5ba8e711a1a3 source added
boisy
parents:
diff changeset
245 /* X.sysnameXXXX (execute file) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
246 sprintf (xname, "X.%.7s%s", system, seq);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
247
5ba8e711a1a3 source added
boisy
parents:
diff changeset
248 /* open article data file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
249 maketemp (tempfile, '1', FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
250
5ba8e711a1a3 source added
boisy
parents:
diff changeset
251 /* change id so we can open a file -- BAS */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
252 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
253 asetuid (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
254
5ba8e711a1a3 source added
boisy
parents:
diff changeset
255 if ((qfile = fopen (tempfile, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
256 fatal ("can't open article data file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
257
5ba8e711a1a3 source added
boisy
parents:
diff changeset
258 fixperms (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
259 asetuid (myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
260
5ba8e711a1a3 source added
boisy
parents:
diff changeset
261 /* Path: ccentral!rickadams */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
262 fprintf (qfile, "Path: %s!%s\n", nodename, user);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
263
5ba8e711a1a3 source added
boisy
parents:
diff changeset
264 /* From: rickadams@ccentral.UUCP (The OTHER Rick Adams) */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
265 sprintf (line, "From: %s%c%s%s%s%s\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
266 sepsym != '!' ? user : sitename,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
267 sepsym,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
268 sepsym != '!' ? sitename : user,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
269 *name != '\0' ? " (" : "",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
270 *name != '\0' ? name : "",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
271 *name != '\0' ? ")" : "");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
272
5ba8e711a1a3 source added
boisy
parents:
diff changeset
273 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
274 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
275
5ba8e711a1a3 source added
boisy
parents:
diff changeset
276 /* Newsgroups: ca.test */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
277 if (*newsgroup == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
278 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
279 sprintf (filename, "%s/active", UUCPSYS);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
280 getvalue (qfile, "Newsgroups", filename);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
281 strcpy (newsgroup, value);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
282 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
283 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
284 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
285 sprintf (line, "Newsgroups: %s\n", newsgroup);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
286 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
287 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
288 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
289
5ba8e711a1a3 source added
boisy
parents:
diff changeset
290 /* Subject: test */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
291 if (*subject == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
292 getfield (qfile, "Subject", TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
293 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
294 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
295 sprintf (line, "Subject: %s\n", subject);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
296 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
297 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
298 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
299
5ba8e711a1a3 source added
boisy
parents:
diff changeset
300 /* Keywords: test */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
301 getfield (qfile, "Keywords", FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
302
5ba8e711a1a3 source added
boisy
parents:
diff changeset
303 /* Message-ID: <1@ccentral.UUCP> Changed -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
304 sprintf (line, "Message-ID: <%ld@%s>\n", nseq, sitename);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
305 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
306 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
307
5ba8e711a1a3 source added
boisy
parents:
diff changeset
308 /* Date: Tue, 12 Feb 91 10:57:45 -0800 Changed -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
309 strcat (strcpy (line, "Date: "), date822());
5ba8e711a1a3 source added
boisy
parents:
diff changeset
310 puts (line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
311 fprintf (qfile, "%s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
312
5ba8e711a1a3 source added
boisy
parents:
diff changeset
313 /* Reply-To: user@sitename Some news articles seem to have this */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
314 /* I don't know if it is done completely right. -- BAS */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
315
5ba8e711a1a3 source added
boisy
parents:
diff changeset
316 sprintf (line, "Reply-To: %s%c%s\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
317 sepsym != '!' ? user : sitename,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
318 sepsym,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
319 sepsym != '!' ? sitename : user);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
320
5ba8e711a1a3 source added
boisy
parents:
diff changeset
321 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
322 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
323
5ba8e711a1a3 source added
boisy
parents:
diff changeset
324 /* References: <1234@sitename.UUCP> Changed -- REB */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
325 if (*reference != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
326 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
327 sprintf (line, "References: %s\n", reference);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
328 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
329 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
330 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
331
5ba8e711a1a3 source added
boisy
parents:
diff changeset
332 /* Distribution: ca */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
333 if (!localcheck())
5ba8e711a1a3 source added
boisy
parents:
diff changeset
334 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
335 sprintf (filename, "%s/distributions", UUCPSYS);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
336 getvalue (qfile, "Distribution", filename);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
337 strcpy (distrib, value);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
338 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
339 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
340 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
341 /* local article */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
342 sprintf (line, "Distribution: local\n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
343 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
344 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
345 strcpy (distrib, "local");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
346 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
347
5ba8e711a1a3 source added
boisy
parents:
diff changeset
348 /* local distribution only? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
349 localonly = (strcmp (distrib, "local") == 0) ? TRUE : FALSE;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
350
5ba8e711a1a3 source added
boisy
parents:
diff changeset
351 /* Summary: This is a test message. */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
352 getfield (qfile, "Summary", FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
353
5ba8e711a1a3 source added
boisy
parents:
diff changeset
354 /* Organization: Color Central Software */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
355 if (*organization != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
356 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
357 sprintf (line, "Organization: %s\n", organization);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
358 fputs (line, stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
359 fputs (line, qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
360 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
361
5ba8e711a1a3 source added
boisy
parents:
diff changeset
362 /* body of message */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
363 putchar ('\n');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
364 putc ('\n', qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
365
5ba8e711a1a3 source added
boisy
parents:
diff changeset
366 if (*artfile != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
367 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
368 while (fgets (line, sizeof (line), file) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
369 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
370 if ((p = strchr (line, '\n')) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
371 *p = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
372
5ba8e711a1a3 source added
boisy
parents:
diff changeset
373 fprintf (qfile, "%s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
374 printf ("%s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
375 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
376 fclose (file);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
377 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
378 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
379 for (;;)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
380 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
381 /* end of input? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
382 if (fgets (line, sizeof (line), stdin) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
383 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
384
5ba8e711a1a3 source added
boisy
parents:
diff changeset
385 if (*line == '.' && *(line + 1) == '\n')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
386 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
387 CurUp();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
388 fputs (" \b", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
389 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
390 break;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
391 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
392 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
393 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
394 if (*line == '~')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
395 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
396 int tilde;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
397
5ba8e711a1a3 source added
boisy
parents:
diff changeset
398 fclose (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
399 line[strlen (line) - 1] = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
400
5ba8e711a1a3 source added
boisy
parents:
diff changeset
401 sprintf (temp,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
402 "dotilde \"%s\" %d %d %c %s %s %s",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
403 #ifndef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
404 line, t2flag, myuid, quotechar, tempfile,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
405 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
406 line, 0, myuid, quotechar, tempfile,
5ba8e711a1a3 source added
boisy
parents:
diff changeset
407 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
408 homedir, article);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
409
5ba8e711a1a3 source added
boisy
parents:
diff changeset
410 asetuid (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
411 tilde = docmd_na (temp);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
412
5ba8e711a1a3 source added
boisy
parents:
diff changeset
413 if (tilde == SIGINT || tilde == SIGQUIT
5ba8e711a1a3 source added
boisy
parents:
diff changeset
414 || tilde == ABORT)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
415 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
416 interrupt (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
417 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
418
5ba8e711a1a3 source added
boisy
parents:
diff changeset
419 if ((qfile = fopen (tempfile, "a")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
420 fatal ("can't reopen article file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
421
5ba8e711a1a3 source added
boisy
parents:
diff changeset
422 fixperms (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
423 asetuid (myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
424 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
425 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
426 fprintf (qfile, "%s", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
427 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
428 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
429
5ba8e711a1a3 source added
boisy
parents:
diff changeset
430 /* append signature file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
431 #ifdef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
432 sprintf (line, "%s/.signature", homedir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
433 #else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
434 sprintf (line, "%s/%s/signature", homedir, uudir);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
435 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
436
5ba8e711a1a3 source added
boisy
parents:
diff changeset
437 if ((sigfile = fopen (line, "r")) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
438 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
439 fprintf (qfile, "-- \n");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
440 puts ("--");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
441
5ba8e711a1a3 source added
boisy
parents:
diff changeset
442 while (fgets (line, sizeof (line), sigfile) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
443 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
444 if ((p = strchr (line, '\n')) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
445 *p = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
446
5ba8e711a1a3 source added
boisy
parents:
diff changeset
447 fprintf (qfile, "%s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
448 printf ("%s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
449 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
450 fclose (sigfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
451 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
452
5ba8e711a1a3 source added
boisy
parents:
diff changeset
453 /* close article file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
454 fclose (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
455
5ba8e711a1a3 source added
boisy
parents:
diff changeset
456 /* transfer article file to queued data file and replace CRs with LFs */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
457 asetuid (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
458 filemovl (tempfile, dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
459 *tempfile = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
460 fputs ("\n\nposting your article...locally...", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
461 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
462
5ba8e711a1a3 source added
boisy
parents:
diff changeset
463 /* post article locally */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
464 sprintf (line, "rnews -x%d -n%s %s", debuglvl, newsgroup, dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
465
5ba8e711a1a3 source added
boisy
parents:
diff changeset
466 if ((result = docmd_na (line)) != 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
467 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
468 unlink (dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
469 interrupt (result);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
470 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
471
5ba8e711a1a3 source added
boisy
parents:
diff changeset
472 /* local article only? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
473 if (localonly)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
474 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
475 asetuid (0); /* so we can delete the file -- BAS */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
476 unlink (dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
477 asetuid (myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
478 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
479 return (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
480 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
481
5ba8e711a1a3 source added
boisy
parents:
diff changeset
482 fputs ("and to the net...", stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
483 fflush (stdout);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
484
5ba8e711a1a3 source added
boisy
parents:
diff changeset
485 /* write job file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
486 asetuid (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
487
5ba8e711a1a3 source added
boisy
parents:
diff changeset
488 if ((qfile = fopen (jname, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
489 fatal ("can't create job file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
490
5ba8e711a1a3 source added
boisy
parents:
diff changeset
491 fixperms (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
492 chown (jname, myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
493
5ba8e711a1a3 source added
boisy
parents:
diff changeset
494 fprintf (qfile, "U %s %s\x0a", user, nodename);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
495 fprintf (qfile, "F %s\x0a", dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
496 fprintf (qfile, "I %s\x0a", dname);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
497 fputs ("C rnews \x0a", qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
498 fclose( qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
499
5ba8e711a1a3 source added
boisy
parents:
diff changeset
500 /* write control file */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
501 if ((qfile = fopen (cname, "w")) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
502 fatal ("can't create control file");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
503
5ba8e711a1a3 source added
boisy
parents:
diff changeset
504 fixperms (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
505 chown (cname, myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
506
5ba8e711a1a3 source added
boisy
parents:
diff changeset
507 fprintf (qfile, "S %s %s %s - %s 0666 %s\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
508 dname, dname, user, dname, user);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
509
5ba8e711a1a3 source added
boisy
parents:
diff changeset
510 fprintf (qfile, "S %s %s %s - %s 0666 %s\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
511 jname, xname, user, jname, user);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
512
5ba8e711a1a3 source added
boisy
parents:
diff changeset
513 fclose (qfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
514 asetuid (myuid);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
515 cls();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
516 return (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
517 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
518
5ba8e711a1a3 source added
boisy
parents:
diff changeset
519
5ba8e711a1a3 source added
boisy
parents:
diff changeset
520
5ba8e711a1a3 source added
boisy
parents:
diff changeset
521 int getvalue (file, prompt, filename)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
522 FILE *file;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
523 char *prompt, *filename;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
524 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
525 char line[100];
5ba8e711a1a3 source added
boisy
parents:
diff changeset
526 flag status;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
527 FILE *file2;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
528 char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
529
5ba8e711a1a3 source added
boisy
parents:
diff changeset
530 do
5ba8e711a1a3 source added
boisy
parents:
diff changeset
531 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
532 /* get value */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
533 do
5ba8e711a1a3 source added
boisy
parents:
diff changeset
534 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
535 printf ("%s: ", prompt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
536
5ba8e711a1a3 source added
boisy
parents:
diff changeset
537 if (mfgets (value, sizeof (value), stdin) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
538 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
539 errno = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
540 fatal (got_escape);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
541 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
542
5ba8e711a1a3 source added
boisy
parents:
diff changeset
543 if (*value == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
544 printf ("\nThe \"%s\" field is required.\n\n", prompt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
545 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
546 while (*value == '\0');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
547
5ba8e711a1a3 source added
boisy
parents:
diff changeset
548 status = findent (value, filename, line, sizeof(line));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
549
5ba8e711a1a3 source added
boisy
parents:
diff changeset
550 if (!status)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
551 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
552 /* dump out valid values */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
553 printf ("\nInvalid -- valid values for \"%s\" are:\n", prompt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
554
5ba8e711a1a3 source added
boisy
parents:
diff changeset
555 if ((file2 = fopen (filename, "r")) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
556 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
557 while (mfgets (line, sizeof (line), file2) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
558 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
559 if ((p = strchr (line, ' ')) != NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
560 *p = '\0';
5ba8e711a1a3 source added
boisy
parents:
diff changeset
561
5ba8e711a1a3 source added
boisy
parents:
diff changeset
562 printf (" %s\n", line);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
563 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
564 fclose (file);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
565 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
566 putchar ('\n');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
567 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
568 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
569 while (!status);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
570
5ba8e711a1a3 source added
boisy
parents:
diff changeset
571 fprintf (file, "%s: %s\n", prompt, value);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
572 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
573
5ba8e711a1a3 source added
boisy
parents:
diff changeset
574
5ba8e711a1a3 source added
boisy
parents:
diff changeset
575
5ba8e711a1a3 source added
boisy
parents:
diff changeset
576 int getfield (file, prompt, needthis)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
577 FILE *file;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
578 char *prompt;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
579 flag needthis; /* field required? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
580 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
581 register char *p;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
582
5ba8e711a1a3 source added
boisy
parents:
diff changeset
583 p = value;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
584 do
5ba8e711a1a3 source added
boisy
parents:
diff changeset
585 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
586 printf ("%s: ", prompt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
587
5ba8e711a1a3 source added
boisy
parents:
diff changeset
588 if (mfgets (p, sizeof (value), stdin) == NULL)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
589 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
590 errno = 0;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
591 fatal (got_escape);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
592 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
593
5ba8e711a1a3 source added
boisy
parents:
diff changeset
594 if (needthis && *p == '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
595 printf ("\nThe \"%s\" field is required.\n\n", prompt);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
596
5ba8e711a1a3 source added
boisy
parents:
diff changeset
597 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
598 while (needthis && *p == '\0');
5ba8e711a1a3 source added
boisy
parents:
diff changeset
599
5ba8e711a1a3 source added
boisy
parents:
diff changeset
600 fprintf (file, "%s: %s\n", prompt, p);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
601 return (strlen (p));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
602 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
603
5ba8e711a1a3 source added
boisy
parents:
diff changeset
604
5ba8e711a1a3 source added
boisy
parents:
diff changeset
605
5ba8e711a1a3 source added
boisy
parents:
diff changeset
606 /* check to see if this is a local newsgroup */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
607
5ba8e711a1a3 source added
boisy
parents:
diff changeset
608 int localcheck()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
609 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
610 /* newsgroup begins with "nodename."? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
611 strcat (strcpy (temp, nodename), ".");
5ba8e711a1a3 source added
boisy
parents:
diff changeset
612
5ba8e711a1a3 source added
boisy
parents:
diff changeset
613 if (strncmp (newsgroup, temp, strlen (temp)) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
614 return (TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
615
5ba8e711a1a3 source added
boisy
parents:
diff changeset
616 /* newsgroup begins with "local." or "general."? */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
617 if (strncmp (newsgroup, "local.", 6) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
618 return (TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
619 else if (strncmp (newsgroup, "general.", 8) == 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
620 return (TRUE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
621 else
5ba8e711a1a3 source added
boisy
parents:
diff changeset
622 return (FALSE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
623 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
624
5ba8e711a1a3 source added
boisy
parents:
diff changeset
625
5ba8e711a1a3 source added
boisy
parents:
diff changeset
626
5ba8e711a1a3 source added
boisy
parents:
diff changeset
627 int fatal (msg)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
628 char *msg;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
629 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
630 fprintf (stderr, "\npostnews: %s", msg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
631
5ba8e711a1a3 source added
boisy
parents:
diff changeset
632 if (errno != 0)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
633 fprintf (stderr, "...error %d", errno);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
634
5ba8e711a1a3 source added
boisy
parents:
diff changeset
635 putc ('\n', stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
636 interrupt (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
637 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
638
5ba8e711a1a3 source added
boisy
parents:
diff changeset
639
5ba8e711a1a3 source added
boisy
parents:
diff changeset
640
5ba8e711a1a3 source added
boisy
parents:
diff changeset
641 int badparam (msg)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
642 char *msg;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
643 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
644 fprintf (stderr, "postnews: %s not in Parameters\n", msg);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
645 interrupt (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
646 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
647
5ba8e711a1a3 source added
boisy
parents:
diff changeset
648
5ba8e711a1a3 source added
boisy
parents:
diff changeset
649
5ba8e711a1a3 source added
boisy
parents:
diff changeset
650 /* deal with interruptions */
5ba8e711a1a3 source added
boisy
parents:
diff changeset
651
5ba8e711a1a3 source added
boisy
parents:
diff changeset
652 int interrupt (sig)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
653 int sig;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
654 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
655 if (*tempfile != '\0')
5ba8e711a1a3 source added
boisy
parents:
diff changeset
656 unlink (tempfile);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
657 #ifndef _OSK
5ba8e711a1a3 source added
boisy
parents:
diff changeset
658 if (usedotilde)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
659 munload (dotilde, 0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
660 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
661 exit (sig);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
662 }
5ba8e711a1a3 source added
boisy
parents:
diff changeset
663
5ba8e711a1a3 source added
boisy
parents:
diff changeset
664
5ba8e711a1a3 source added
boisy
parents:
diff changeset
665
5ba8e711a1a3 source added
boisy
parents:
diff changeset
666 int usage()
5ba8e711a1a3 source added
boisy
parents:
diff changeset
667 {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
668 char *stredetab();
5ba8e711a1a3 source added
boisy
parents:
diff changeset
669 register char **ptr;
5ba8e711a1a3 source added
boisy
parents:
diff changeset
670 static char *help[] = {
5ba8e711a1a3 source added
boisy
parents:
diff changeset
671 "postnews\t post news to Usenet",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
672 " ",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
673 "Usage: postnews [options]",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
674 "\t Options:",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
675 "\t\t-f <file>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
676 "\t\t-n <newsgroup>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
677 "\t\t-S <system>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
678 "\t\t-s <subject>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
679 "\t\t-i <reference-ID>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
680 "\t\t-a <reference-article>",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
681 #ifndef TERMCAP
5ba8e711a1a3 source added
boisy
parents:
diff changeset
682 "\t\t-t (force /t2 \"dumb\" windowing codes)",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
683 #endif
5ba8e711a1a3 source added
boisy
parents:
diff changeset
684 NULL
5ba8e711a1a3 source added
boisy
parents:
diff changeset
685 };
5ba8e711a1a3 source added
boisy
parents:
diff changeset
686
5ba8e711a1a3 source added
boisy
parents:
diff changeset
687 putc ('\n', stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
688 for (ptr = help; *ptr != NULL; ++ptr)
5ba8e711a1a3 source added
boisy
parents:
diff changeset
689 fprintf (stderr, "%s\n", strdetab (strcpy (temp, *ptr), 6));
5ba8e711a1a3 source added
boisy
parents:
diff changeset
690
5ba8e711a1a3 source added
boisy
parents:
diff changeset
691 fprintf (stderr, "\nv%s (%s) This is free software released under the GNU General Public\n",
5ba8e711a1a3 source added
boisy
parents:
diff changeset
692 version, VERDATE);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
693 fputs ("License. Please send suggestions/bug reports to: bob@kc2wz.bubble.org\n", stderr);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
694 exit (0);
5ba8e711a1a3 source added
boisy
parents:
diff changeset
695 }