0
|
1 #ifndef SPOP
|
|
2 /* sbboards.c - MH style mailer to write to a ZOTnet BBoard */
|
|
3 #else SPOP
|
|
4 /* spop.c - MH style mailer to write to a POP subscriber */
|
|
5 #endif SPOP
|
|
6 #ifndef lint
|
12
|
7 static char ident[] = "@(#)$Id: sbboards.c,v 1.1.1.1 2005/04/18 14:46:07 kono Exp $";
|
0
|
8 #endif lint
|
|
9
|
|
10 #ifndef SPOP
|
|
11
|
|
12 /* This program acts like the MMDF ch_bboards channel: it does local
|
|
13 delivery to a ZOTnet BBoard and/or addition re-distribution to other
|
|
14 recipients of the BBoard. This program can function both as a SendMail
|
|
15 mailer and an MH .mh_receive file, depending on whether SENDMTS or
|
|
16 MHMTS is set. Currently, the MHMTS version of this program does not do
|
|
17 re-distribution.
|
|
18
|
|
19 This program should be used ONLY if you have "bboards on" set in your
|
|
20 MH configuration, and if you have "mts sendmail" or "mts mh" set as well.
|
|
21 */
|
|
22
|
|
23 #else SPOP
|
|
24
|
|
25 /* This program acts like the MMDF-II ch_pop channel: it does local
|
|
26 delivery for non-local users. These users are known as POP subscribers
|
|
27 and use the Post Office Protocol with a POP server in order to access
|
|
28 their maildrop.
|
|
29 */
|
|
30
|
|
31 #endif SPOP
|
|
32
|
|
33 #undef DISTRIBUTE
|
|
34 #ifdef SENDMTS
|
|
35 #ifndef SPOP
|
|
36 #define DISTRIBUTE
|
|
37 #endif not SPOP
|
|
38 #endif SENDMTS
|
|
39
|
|
40 #include "../h/mh.h"
|
|
41 #ifndef SPOP
|
|
42 #include "../h/addrsbr.h"
|
|
43 #endif not SPOP
|
|
44 #include "../h/dropsbr.h"
|
|
45 #include "../zotnet/bboards.h"
|
|
46 #include "../zotnet/tws.h"
|
|
47 #include <stdio.h>
|
|
48 #include "../zotnet/mts.h"
|
|
49 #include <pwd.h>
|
|
50 #ifndef SYS5
|
|
51 #include <sysexits.h>
|
|
52 #else SYS5
|
|
53 #define EX_CANTCREAT 1
|
|
54 #define EX_IOERR 1
|
|
55 #define EX_NOINPUT 1
|
|
56 #define EX_NOUSER 1
|
|
57 #define EX_OK 0
|
|
58 #define EX_OSERR 1
|
|
59 #define EX_OSFILE 1
|
|
60 #define EX_UNAVAILABLE 1
|
|
61 #define EX_USAGE 1
|
|
62 #endif SYS5
|
|
63 #ifdef DISTRIBUTE
|
|
64 #include "../mts/sendmail/smail.h"
|
|
65 #endif DISTRIBUTE
|
|
66 #ifdef LOCALE
|
|
67 #include <locale.h>
|
|
68 #endif
|
|
69 #ifdef linux
|
|
70 #include <sys/types.h>
|
|
71 #endif
|
|
72 #if defined(UNISTD) && !defined(sgi)
|
|
73 #include <unistd.h>
|
|
74 #endif
|
|
75
|
|
76 #define NBB 100
|
|
77
|
|
78 #ifndef SPOP
|
|
79 #define ENTITY "bboard"
|
|
80 #else SPOP
|
|
81 #define ENTITY "subscriber"
|
|
82 #endif SPOP
|
|
83
|
|
84 /* */
|
|
85
|
|
86 static int bb_fderr;
|
|
87
|
|
88 static int bb_uid;
|
|
89 static int bb_gid;
|
|
90
|
|
91 static int dst_rcpt ();
|
|
92
|
|
93
|
|
94 #ifndef SPOP
|
|
95 static char bb_from[BUFSIZ];
|
|
96 static char bb_head[BUFSIZ];
|
|
97 static char bb_home[BUFSIZ];
|
|
98 static char bb_time[BUFSIZ];
|
|
99 #ifdef DISTRIBUTE
|
|
100 static char bb_rept[BUFSIZ];
|
|
101 #endif DISTRIBUTE
|
|
102 #else SPOP
|
|
103 #define bb_head NULLCP
|
|
104 #endif SPOP
|
|
105
|
|
106 static struct bboard *bb[NBB];
|
|
107
|
|
108 #if defined(UNISTD) && !defined(sgi)
|
|
109 #include <unistd.h>
|
|
110 #else
|
|
111 off_t lseek ();
|
|
112 #endif
|
|
113
|
|
114 #ifndef __STDC__
|
|
115 #ifdef SYS5
|
|
116 struct passwd *getpwnam ();
|
|
117 #endif /* SYS5 */
|
|
118 #endif
|
|
119
|
|
120 #ifndef SPOP
|
|
121 static int mbx_init();
|
|
122 #endif
|
|
123 #ifdef DISTRIBUTE
|
|
124 static int distribute(), notify(), encap(),
|
|
125 dst_init(), dst_text(),
|
|
126 dst_end(), dst_lose(), dst_adrs();
|
|
127 #endif
|
|
128
|
|
129 /* hack */
|
|
130 #define adios my_adios
|
|
131 static localmail(), arginit();
|
|
132 static int lose(), copyfile();
|
|
133 static void adios();
|
|
134 /* */
|
|
135
|
|
136 /* ARGSUSED */
|
|
137
|
|
138 main (argc, argv, envp)
|
|
139 int argc;
|
|
140 char **argv,
|
|
141 **envp;
|
|
142 {
|
|
143 int fd;
|
|
144 char tmpfil[BUFSIZ];
|
|
145
|
|
146 #ifdef LOCALE
|
|
147 setlocale(LC_ALL, "");
|
|
148 #endif
|
|
149 #ifdef JAPAN
|
|
150 ml_init();
|
|
151 #endif /* JAPAN */
|
|
152 #ifdef MHMTS
|
|
153 if (argc != 5)
|
|
154 adios (EX_USAGE, NULL, "you lose really big");
|
|
155 #endif MHMTS
|
|
156 arginit (argv);
|
|
157
|
|
158 fflush (stdout);
|
|
159 discard (stdout); /* XXX: reference discard to help loader */
|
|
160
|
|
161 fd = copyfile (fileno (stdin), tmpfil);
|
|
162 (void) unlink (tmpfil);
|
|
163
|
|
164 localmail (fd);
|
|
165 #ifdef DISTRIBUTE
|
|
166 distribute (fd);
|
|
167 notify (fd);
|
|
168 #endif DISTRIBUTE
|
|
169
|
|
170 exit (EX_OK);
|
|
171 }
|
|
172
|
|
173 /* */
|
|
174
|
|
175 static localmail (fd)
|
|
176 int fd;
|
|
177 {
|
|
178 int i,
|
|
179 md;
|
|
180 register struct bboard *bp;
|
|
181
|
|
182 for (i = 0; bp = bb[i]; i++)
|
|
183 if (bp -> bb_file && *bp -> bb_file) {
|
|
184 (void) lseek (fd, (off_t)0, 0);
|
|
185 #ifndef SPOP
|
|
186 if ((md = mbx_open (bp -> bb_file, bb_uid, bb_gid, BBMODE))
|
|
187 #else SPOP
|
|
188 if ((md = mbx_open (bp -> bb_file, bb_uid, bb_gid, POMODE))
|
|
189 #endif SPOP
|
|
190 == NOTOK) {
|
|
191 (void) lose ("unable to open %s", bp -> bb_file);
|
|
192 continue;
|
|
193 }
|
|
194 #ifndef SPOP
|
|
195 if (mbx_init (bp) != NOTOK)
|
|
196 #endif not SPOP
|
|
197 (void) mbx_copy (bp -> bb_file, md, fd, 1, bb_head, 0);
|
|
198 (void) mbx_close (bp -> bb_file, md);
|
|
199 }
|
|
200 }
|
|
201
|
|
202 /* */
|
|
203
|
|
204 #ifndef SPOP
|
|
205 static int mbx_init (bp)
|
|
206 register struct bboard *bp;
|
|
207 {
|
|
208 int fd,
|
|
209 clear;
|
|
210 register struct bboard *ip;
|
|
211 register FILE *fp;
|
|
212
|
|
213 if ((fd = mbx_Xopen (bp -> bb_info, bb_uid, bb_gid, BBMODE, &clear))
|
|
214 == NOTOK)
|
|
215 return lose ("unable to lock and open %s", bp -> bb_info);
|
|
216 if ((fp = fdopen (fd, "w")) == NULL) {
|
|
217 (void) mbx_close (bp -> bb_info, fd);
|
|
218 return lose ("unable to fdopen %s", bp -> bb_info);
|
|
219 }
|
|
220
|
|
221 if ((ip = getbbnam (bp -> bb_name)) == NULL) {
|
|
222 (void) lkfclose (fp, bp -> bb_info);
|
|
223 return lose ("unable to get information on BBoard %s", bp -> bb_name);
|
|
224 }
|
|
225 (void) strcpy (bb_time, dtimenow ());
|
|
226 (void) sprintf (bb_head, "BBoard-ID: %d\nBB-Posted: %s\n",
|
|
227 bp -> bb_maxima = ++ip -> bb_maxima, bb_time);
|
|
228
|
|
229 fprintf (fp, "%d\n%s\n", bp -> bb_maxima, bb_time);
|
|
230 (void) lkfclose (fp, bp -> bb_info);
|
|
231
|
|
232 return OK;
|
|
233 }
|
|
234 #endif not SPOP
|
|
235
|
|
236 /* */
|
|
237
|
|
238 #ifdef DISTRIBUTE
|
|
239 static distribute (fd)
|
|
240 int fd;
|
|
241 {
|
|
242 int i;
|
|
243 register struct bboard *bp;
|
|
244
|
|
245 for (i = 0; bp = bb[i]; i++)
|
|
246 if (bp -> bb_dist && *bp -> bb_dist)
|
|
247 break;
|
|
248 if (bp == NULL)
|
|
249 return;
|
|
250
|
|
251 if (dst_init () == NOTOK) {
|
|
252 dst_lose ();
|
|
253 return;
|
|
254 }
|
|
255 for (i = 0; bp = bb[i]; i++)
|
|
256 if (bp -> bb_dist && *bp -> bb_dist)
|
|
257 if (dst_adrs (bp) == NOTOK) {
|
|
258 dst_lose ();
|
|
259 return;
|
|
260 }
|
|
261 if (dst_text (fd) == NOTOK || dst_end () == NOTOK)
|
|
262 dst_lose ();
|
|
263 }
|
|
264
|
|
265 /* */
|
|
266
|
|
267 static int dst_init ()
|
|
268 {
|
|
269 int retval;
|
|
270
|
|
271 if (rp_isbad (retval = sm_init (NULLCP, NULLCP, 0, 0, 0, 0, 0))
|
|
272 || rp_isbad (retval = sm_winit (S_MAIL, bb_from)))
|
|
273 return lose ("problem initializing SendMail; %s",
|
|
274 rp_string (retval));
|
|
275
|
|
276 return OK;
|
|
277 }
|
|
278
|
|
279 /* */
|
|
280
|
|
281 static int dst_adrs (bp)
|
|
282 register struct bboard *bp;
|
|
283 {
|
|
284 if (getbbdist (bp, dst_rcpt))
|
|
285 return lose ("getbbdist failed: %s", getbberr ());
|
|
286
|
|
287 return OK;
|
|
288 }
|
|
289
|
|
290 /* */
|
|
291
|
|
292 static int dst_rcpt (mbox, host)
|
|
293 register char *mbox,
|
|
294 *host;
|
|
295 {
|
|
296 int retval;
|
|
297
|
|
298 switch (retval = sm_wadr (mbox, host, NULLCP)) {
|
|
299 case RP_OK:
|
|
300 return OK;
|
|
301
|
|
302 case RP_NO:
|
|
303 case RP_USER:
|
|
304 (void) lose ("%s@%s: loses; %s", mbox, host, rp_string (retval));
|
|
305 return OK; /* fail-soft */
|
|
306
|
|
307 default:
|
|
308 return lose ("%s@%s: unexpected response; %s",
|
|
309 mbox, host, rp_string (retval));
|
|
310 }
|
|
311 }
|
|
312
|
|
313 /* */
|
|
314
|
|
315 static int dst_text (fd)
|
|
316 int fd;
|
|
317 {
|
|
318 int i,
|
|
319 retval;
|
|
320 char buffer[BUFSIZ];
|
|
321
|
|
322 if (rp_isbad (retval = sm_waend ()))
|
|
323 return lose ("problem ending addresses; %s", rp_string (retval));
|
|
324
|
|
325 (void) lseek (fd, (off_t)0, 0);
|
|
326 while ((i = read (fd, buffer, sizeof buffer)) > 0)
|
|
327 if (rp_isbad (retval = sm_wtxt (buffer, i)))
|
|
328 return lose ("problem writing text; %s", rp_string (retval));
|
|
329
|
|
330 return (i != NOTOK ? OK : lose ("error reading from file"));
|
|
331 }
|
|
332
|
|
333 /* */
|
|
334
|
|
335 static int dst_end ()
|
|
336 {
|
|
337 int retval;
|
|
338
|
|
339 switch (retval = sm_wtend ()) {
|
|
340 case RP_OK:
|
|
341 (void) sm_end (OK);
|
|
342 return OK;
|
|
343
|
|
344 case RP_NO:
|
|
345 case RP_NDEL:
|
|
346 return lose ("posting failed; %s", rp_string (retval));
|
|
347
|
|
348 default:
|
|
349 return lose ("unexpected response; %s", rp_string (retval));
|
|
350 }
|
|
351 }
|
|
352
|
|
353 /* */
|
|
354
|
|
355 static dst_lose ()
|
|
356 {
|
|
357 (void) sm_end (NOTOK);
|
|
358 }
|
|
359
|
|
360 /* */
|
|
361
|
|
362 /* VARARGS1 */
|
|
363
|
|
364 static int lose (fmt, a, b, c, d)
|
|
365 char *fmt,
|
|
366 *a,
|
|
367 *b,
|
|
368 *c,
|
|
369 *d;
|
|
370 {
|
|
371 int fd,
|
|
372 i;
|
|
373 char *bp,
|
|
374 buffer[BUFSIZ];
|
|
375
|
|
376 if (bb_fderr == NOTOK) {
|
|
377 if ((fd = open ("/dev/null", 0)) == NOTOK)
|
|
378 adios (EX_OSERR, "/dev/null", "unable to open");
|
|
379 bb_fderr = copyfile (fd, bb_rept);
|
|
380 }
|
|
381
|
|
382 (void) sprintf (bp = buffer, fmt, a, b, c, d);
|
|
383 bp += strlen (bp);
|
|
384 bp += strlen (strcpy(bp, "\n"));
|
|
385 i = bp - buffer;
|
|
386 if (write (bb_fderr, buffer, i) != i)
|
|
387 adios (EX_IOERR, bb_rept, "error writing");
|
|
388
|
|
389 return NOTOK;
|
|
390 }
|
|
391
|
|
392 /* */
|
|
393
|
|
394 static notify (fd)
|
|
395 int fd;
|
|
396 {
|
|
397 int i;
|
|
398 char buffer[BUFSIZ];
|
|
399
|
|
400 if (bb_fderr == NOTOK)
|
|
401 return;
|
|
402
|
|
403 if (rp_isbad (sm_init (NULLCP, NULLCP, 0, 0, 0, 0, 0))
|
|
404 || rp_isbad (sm_winit (S_MAIL, bb_from)))
|
|
405 goto sm_err;
|
|
406
|
|
407 switch (sm_wadr (bb_from, NULLCP, NULLCP)) {
|
|
408 case RP_OK:
|
|
409 for (i = 0; bb[i]; i++) {
|
|
410 (void) sprintf (buffer, "local-%s-request", bb[i] -> bb_name);
|
|
411 (void) sm_wadr (buffer, LocalName (), NULLCP);
|
|
412 }
|
|
413 break;
|
|
414
|
|
415 default:
|
|
416 goto sm_err;
|
|
417 }
|
|
418
|
|
419 if (rp_isbad (sm_waend ()))
|
|
420 goto sm_err;
|
|
421
|
|
422 (void) sprintf (buffer,
|
|
423 "Date: %s\nFrom: %s\nTo: %s\nSubject: BBoards Failure\n\n",
|
|
424 dtimenow (), bb_from, bb_from);
|
|
425 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
426 goto sm_err;
|
|
427
|
|
428 for (i = 0; bb[i]; i++) {
|
|
429 (void) sprintf (buffer, "BBoard %s\n", bb[i] -> bb_name);
|
|
430 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
431 goto sm_err;
|
|
432 }
|
|
433
|
|
434 (void) lseek (bb_fderr, (off_t)0, 0);
|
|
435 while ((i = read (bb_fderr, buffer, sizeof buffer)) > 0)
|
|
436 if (rp_isbad (sm_wtxt (buffer, i)))
|
|
437 goto sm_err;
|
|
438
|
|
439 (void) strcpy (buffer, "\n------- Forwarded Message\n\n");
|
|
440 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))) || encap (fd) == NOTOK)
|
|
441 goto sm_err;
|
|
442 (void) strcpy (buffer, "\n------- End of Forwarded Message\n\n");
|
|
443 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
444 goto sm_err;
|
|
445
|
|
446 switch (sm_wtend ()) {
|
|
447 case RP_OK:
|
|
448 (void) unlink (bb_rept);
|
|
449 (void) sm_end (OK);
|
|
450 return;
|
|
451
|
|
452 default:
|
|
453 sm_err: ;
|
|
454 adios (EX_UNAVAILABLE, NULLCP,
|
|
455 "failed and unable to post advisory, see %s for details",
|
|
456 bb_rept);
|
|
457 }
|
|
458 }
|
|
459
|
|
460 /* */
|
|
461
|
|
462 /* very similar to sbr/cpydgst.c */
|
|
463
|
|
464 #define S1 0
|
|
465 #define S2 1
|
|
466
|
|
467 #define output(c) if (bp >= dp) flush (), *bp++ = c; else *bp++ = c
|
|
468 #define flush() if ((j = bp - outbuf) \
|
|
469 && rp_isbad (sm_wtxt (outbuf, j))) \
|
|
470 return NOTOK; \
|
|
471 else \
|
|
472 bp = outbuf
|
|
473
|
|
474 static int encap (fd)
|
|
475 register int fd;
|
|
476 {
|
|
477 register int i,
|
|
478 state;
|
|
479 register char *cp,
|
|
480 *ep;
|
|
481 char buffer[BUFSIZ];
|
|
482 register int j;
|
|
483 register char *bp,
|
|
484 *dp;
|
|
485 char outbuf[BUFSIZ];
|
|
486
|
|
487 (void) lseek (fd, (off_t)0, 0);
|
|
488
|
|
489 dp = (bp = outbuf) + sizeof outbuf;
|
|
490 for (state = S1; (i = read (fd, buffer, sizeof buffer)) > 0;)
|
|
491 for (ep = (cp = buffer) + i; cp < ep; cp++) {
|
|
492 if (*cp == '\0')
|
|
493 continue;
|
|
494 switch (state) {
|
|
495 case S1:
|
|
496 if (*cp == '-') {
|
|
497 output ('-');
|
|
498 output (' ');
|
|
499 }
|
|
500 state = S2; /* fall */
|
|
501
|
|
502 case S2:
|
|
503 output (*cp);
|
|
504 if (*cp == '\n')
|
|
505 state = S1;
|
|
506 break;
|
|
507 }
|
|
508 }
|
|
509
|
|
510 if (i == NOTOK)
|
|
511 return NOTOK;
|
|
512 flush ();
|
|
513
|
|
514 return OK;
|
|
515 }
|
|
516 #endif DISTRIBUTE
|
|
517
|
|
518 /* */
|
|
519
|
|
520 #ifndef DISTRIBUTE
|
|
521 /* VARARGS1 */
|
|
522
|
|
523 static int lose (fmt, a, b, c, d)
|
|
524 char *fmt,
|
|
525 *a,
|
|
526 *b,
|
|
527 *c,
|
|
528 *d;
|
|
529 {
|
|
530 adios (EX_UNAVAILABLE, NULLCP, fmt, a, b, c, d);/* NOTREACHED */
|
|
531 }
|
|
532 #endif not DISTRIBUTE
|
|
533
|
|
534 /* */
|
|
535
|
|
536 static arginit (vec)
|
|
537 register char **vec;
|
|
538 {
|
|
539 register int i;
|
|
540 #ifdef MHMTS
|
|
541 register char *ap;
|
|
542 #endif MHMTS
|
|
543 char addr[BUFSIZ];
|
|
544 register struct bboard *bp;
|
|
545 register struct passwd *pw;
|
|
546
|
|
547 invo_name = r1bindex (*vec++, '/');
|
|
548 if (strlen(invo_name) > NAMESZ) {
|
|
549 fprintf(stderr, "%s: argv[0] too long\n", invo_name);
|
|
550 exit(1);
|
|
551 }
|
|
552 m_foil (NULLCP);
|
|
553 mts_init (invo_name);
|
|
554
|
|
555 #ifndef SPOP
|
|
556 if ((pw = getpwnam (BBOARDS)) == NULL)
|
|
557 adios (EX_OSFILE, NULLCP, "no entry for ~%s", BBOARDS);
|
|
558 #else SPOP
|
|
559 if ((pw = getpwnam (POPUID)) == NULL || !setpwinfo (pw, POPDB, 1))
|
|
560 adios (EX_OSFILE, NULLCP, "%s", pw ? getbberr () : "POP user-id unknown");
|
|
561 #endif SPOP
|
|
562
|
|
563 if (pw -> pw_uid != geteuid ())
|
|
564 #ifndef SPOP
|
|
565 adios (EX_OSERR, NULLCP, "not running setuid to %s", BBOARDS);
|
|
566 #else SPOP
|
|
567 adios (EX_OSERR, NULLCP, "not running setuid to %s", POPUID);
|
|
568 #endif SPOP
|
|
569
|
|
570 bb_uid = pw -> pw_uid;
|
|
571 bb_gid = pw -> pw_gid;
|
|
572 #ifndef SPOP
|
|
573 (void) strcpy (bb_from, adrsprintf (pw -> pw_name, LocalName ()));
|
|
574 (void) strcpy (bb_home, pw -> pw_dir);
|
|
575 #endif not SPOP
|
|
576
|
|
577 #ifdef MHMTS
|
|
578 vec += 3;
|
|
579 #endif MHMTS
|
|
580 if (*vec == NULL)
|
|
581 adios (EX_USAGE, NULLCP, "usage: %s %s [%s ...]",
|
|
582 invo_name, ENTITY, ENTITY);
|
|
583
|
|
584 for (i = 0; *vec; vec++) {
|
|
585 if (strlen(*vec) >= BUFSIZ / 4)
|
|
586 adios (NULLCP, "argument too long");
|
|
587 #ifdef MHMTS
|
|
588 if (ap = index (*vec, '.'))
|
|
589 *vec = ++ap;
|
|
590 #endif MHMTS
|
|
591 make_lower (addr, *vec);
|
|
592
|
|
593 if ((bp = getbbnam (addr)) == NULL
|
|
594 && (bp = getbbaka (addr)) == NULL)
|
|
595 adios (EX_NOUSER, NULLCP, "no such %s as %s", ENTITY, *vec);
|
|
596 if ((bb[i++] = getbbcpy (bp)) == NULL)
|
|
597 adios (EX_UNAVAILABLE, NULLCP, "insufficient memory on %s", *vec);
|
|
598
|
|
599 if (i >= NBB - 1)
|
|
600 adios (EX_USAGE, NULLCP, "too many %ss, starting with %s",
|
|
601 ENTITY, *vec);
|
|
602 }
|
|
603 bb[i] = NULL;
|
|
604
|
|
605 (void) umask (0022);
|
|
606
|
|
607 bb_fderr = NOTOK;
|
|
608 }
|
|
609
|
|
610 /* */
|
|
611
|
|
612 static int copyfile (qd, tmpfil)
|
|
613 int qd;
|
|
614 register char *tmpfil;
|
|
615 {
|
|
616 int i,
|
|
617 fd;
|
|
618 char buffer[BUFSIZ];
|
|
619
|
|
620 (void) strcpy (tmpfil, m_tmpfil (invo_name));
|
|
621 if ((fd = creat (tmpfil, 0600)) == NOTOK)
|
|
622 adios (EX_CANTCREAT, tmpfil, "unable to create");
|
|
623 (void) close (fd);
|
|
624 if ((fd = open (tmpfil, 2)) == NOTOK)
|
|
625 adios (EX_NOINPUT, tmpfil, "unable to re-open");
|
|
626
|
|
627 (void) lseek (qd, (off_t)0, 0);
|
|
628 while ((i = read (qd, buffer, sizeof buffer)) > 0)
|
|
629 if (write (fd, buffer, i) != i)
|
|
630 adios (EX_IOERR, tmpfil, "error writing");
|
|
631 if (i == NOTOK)
|
|
632 adios (EX_IOERR, "input", "error reading");
|
|
633
|
|
634 (void) lseek (fd, (off_t)0, 0);
|
|
635
|
|
636 return fd;
|
|
637 }
|
|
638
|
|
639 /* */
|
|
640
|
|
641 /* VARARGS3 */
|
|
642
|
|
643 #ifdef MHMTS
|
|
644 /* ARGSUSED */
|
|
645 #endif MHMTS
|
|
646
|
|
647 static void adios (code, what, fmt, a, b, c, d, e, f)
|
|
648 int code;
|
|
649 char *what,
|
|
650 *fmt,
|
|
651 *a,
|
|
652 *b,
|
|
653 *c,
|
|
654 *d,
|
|
655 *e,
|
|
656 *f;
|
|
657 {
|
|
658 advise (what, fmt, a, b, c, d, e, f);
|
|
659 #ifdef SENDMTS
|
|
660 done (code);
|
|
661 #endif SENDMTS
|
|
662 #ifdef MHMTS
|
|
663 done (1);
|
|
664 #endif MHMTS
|
|
665 }
|