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: spop.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 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 /* hack */
|
|
121 #define adios my_adios
|
|
122 static localmail(), arginit();
|
|
123 static int lose(), copyfile();
|
|
124 static void adios();
|
|
125 /* */
|
|
126
|
|
127 /* ARGSUSED */
|
|
128
|
|
129 main (argc, argv, envp)
|
|
130 int argc;
|
|
131 char **argv,
|
|
132 **envp;
|
|
133 {
|
|
134 int fd;
|
|
135 char tmpfil[BUFSIZ];
|
|
136
|
|
137 #ifdef LOCALE
|
|
138 setlocale(LC_ALL, "");
|
|
139 #endif
|
|
140 #ifdef JAPAN
|
|
141 ml_init();
|
|
142 #endif /* JAPAN */
|
|
143 #ifdef MHMTS
|
|
144 if (argc != 5)
|
|
145 adios (EX_USAGE, NULL, "you lose really big");
|
|
146 #endif MHMTS
|
|
147 arginit (argv);
|
|
148
|
|
149 fflush (stdout);
|
|
150 discard (stdout); /* XXX: reference discard to help loader */
|
|
151
|
|
152 fd = copyfile (fileno (stdin), tmpfil);
|
|
153 (void) unlink (tmpfil);
|
|
154
|
|
155 localmail (fd);
|
|
156 #ifdef DISTRIBUTE
|
|
157 distribute (fd);
|
|
158 notify (fd);
|
|
159 #endif DISTRIBUTE
|
|
160
|
|
161 exit (EX_OK);
|
|
162 }
|
|
163
|
|
164 /* */
|
|
165
|
|
166 static localmail (fd)
|
|
167 int fd;
|
|
168 {
|
|
169 int i,
|
|
170 md;
|
|
171 register struct bboard *bp;
|
|
172
|
|
173 for (i = 0; bp = bb[i]; i++)
|
|
174 if (bp -> bb_file && *bp -> bb_file) {
|
|
175 (void) lseek (fd, (off_t)0, 0);
|
|
176 #ifndef SPOP
|
|
177 if ((md = mbx_open (bp -> bb_file, bb_uid, bb_gid, BBMODE))
|
|
178 #else SPOP
|
|
179 if ((md = mbx_open (bp -> bb_file, bb_uid, bb_gid, POMODE))
|
|
180 #endif SPOP
|
|
181 == NOTOK) {
|
|
182 (void) lose ("unable to open %s", bp -> bb_file);
|
|
183 continue;
|
|
184 }
|
|
185 #ifndef SPOP
|
|
186 if (mbx_init (bp) != NOTOK)
|
|
187 #endif not SPOP
|
|
188 (void) mbx_copy (bp -> bb_file, md, fd, 1, bb_head, 0);
|
|
189 (void) mbx_close (bp -> bb_file, md);
|
|
190 }
|
|
191 }
|
|
192
|
|
193 /* */
|
|
194
|
|
195 #ifndef SPOP
|
|
196 static int mbx_init (bp)
|
|
197 register struct bboard *bp;
|
|
198 {
|
|
199 int fd,
|
|
200 clear;
|
|
201 register struct bboard *ip;
|
|
202 register FILE *fp;
|
|
203
|
|
204 if ((fd = mbx_Xopen (bp -> bb_info, bb_uid, bb_gid, BBMODE, &clear))
|
|
205 == NOTOK)
|
|
206 return lose ("unable to lock and open %s", bp -> bb_info);
|
|
207 if ((fp = fdopen (fd, "w")) == NULL) {
|
|
208 (void) mbx_close (bp -> bb_info, fd);
|
|
209 return lose ("unable to fdopen %s", bp -> bb_info);
|
|
210 }
|
|
211
|
|
212 if ((ip = getbbnam (bp -> bb_name)) == NULL) {
|
|
213 (void) lkfclose (fp, bp -> bb_info);
|
|
214 return lose ("unable to get information on BBoard %s", bp -> bb_name);
|
|
215 }
|
|
216 (void) strcpy (bb_time, dtimenow ());
|
|
217 (void) sprintf (bb_head, "BBoard-ID: %d\nBB-Posted: %s\n",
|
|
218 bp -> bb_maxima = ++ip -> bb_maxima, bb_time);
|
|
219
|
|
220 fprintf (fp, "%d\n%s\n", bp -> bb_maxima, bb_time);
|
|
221 (void) lkfclose (fp, bp -> bb_info);
|
|
222
|
|
223 return OK;
|
|
224 }
|
|
225 #endif not SPOP
|
|
226
|
|
227 /* */
|
|
228
|
|
229 #ifdef DISTRIBUTE
|
|
230 static distribute (fd)
|
|
231 int fd;
|
|
232 {
|
|
233 int i;
|
|
234 register struct bboard *bp;
|
|
235
|
|
236 for (i = 0; bp = bb[i]; i++)
|
|
237 if (bp -> bb_dist && *bp -> bb_dist)
|
|
238 break;
|
|
239 if (bp == NULL)
|
|
240 return;
|
|
241
|
|
242 if (dst_init () == NOTOK) {
|
|
243 dst_lose ();
|
|
244 return;
|
|
245 }
|
|
246 for (i = 0; bp = bb[i]; i++)
|
|
247 if (bp -> bb_dist && *bp -> bb_dist)
|
|
248 if (dst_adrs (bp) == NOTOK) {
|
|
249 dst_lose ();
|
|
250 return;
|
|
251 }
|
|
252 if (dst_text (fd) == NOTOK || dst_end () == NOTOK)
|
|
253 dst_lose ();
|
|
254 }
|
|
255
|
|
256 /* */
|
|
257
|
|
258 static int dst_init ()
|
|
259 {
|
|
260 int retval;
|
|
261
|
|
262 if (rp_isbad (retval = sm_init (NULLCP, NULLCP, 0, 0, 0, 0, 0))
|
|
263 || rp_isbad (retval = sm_winit (S_MAIL, bb_from)))
|
|
264 return lose ("problem initializing SendMail; %s",
|
|
265 rp_string (retval));
|
|
266
|
|
267 return OK;
|
|
268 }
|
|
269
|
|
270 /* */
|
|
271
|
|
272 static int dst_adrs (bp)
|
|
273 register struct bboard *bp;
|
|
274 {
|
|
275 if (getbbdist (bp, dst_rcpt))
|
|
276 return lose ("getbbdist failed: %s", getbberr ());
|
|
277
|
|
278 return OK;
|
|
279 }
|
|
280
|
|
281 /* */
|
|
282
|
|
283 static int dst_rcpt (mbox, host)
|
|
284 register char *mbox,
|
|
285 *host;
|
|
286 {
|
|
287 int retval;
|
|
288
|
|
289 switch (retval = sm_wadr (mbox, host, NULLCP)) {
|
|
290 case RP_OK:
|
|
291 return OK;
|
|
292
|
|
293 case RP_NO:
|
|
294 case RP_USER:
|
|
295 (void) lose ("%s@%s: loses; %s", mbox, host, rp_string (retval));
|
|
296 return OK; /* fail-soft */
|
|
297
|
|
298 default:
|
|
299 return lose ("%s@%s: unexpected response; %s",
|
|
300 mbox, host, rp_string (retval));
|
|
301 }
|
|
302 }
|
|
303
|
|
304 /* */
|
|
305
|
|
306 static int dst_text (fd)
|
|
307 int fd;
|
|
308 {
|
|
309 int i,
|
|
310 retval;
|
|
311 char buffer[BUFSIZ];
|
|
312
|
|
313 if (rp_isbad (retval = sm_waend ()))
|
|
314 return lose ("problem ending addresses; %s", rp_string (retval));
|
|
315
|
|
316 (void) lseek (fd, (off_t)0, 0);
|
|
317 while ((i = read (fd, buffer, sizeof buffer)) > 0)
|
|
318 if (rp_isbad (retval = sm_wtxt (buffer, i)))
|
|
319 return lose ("problem writing text; %s", rp_string (retval));
|
|
320
|
|
321 return (i != NOTOK ? OK : lose ("error reading from file"));
|
|
322 }
|
|
323
|
|
324 /* */
|
|
325
|
|
326 static int dst_end ()
|
|
327 {
|
|
328 int retval;
|
|
329
|
|
330 switch (retval = sm_wtend ()) {
|
|
331 case RP_OK:
|
|
332 (void) sm_end (OK);
|
|
333 return OK;
|
|
334
|
|
335 case RP_NO:
|
|
336 case RP_NDEL:
|
|
337 return lose ("posting failed; %s", rp_string (retval));
|
|
338
|
|
339 default:
|
|
340 return lose ("unexpected response; %s", rp_string (retval));
|
|
341 }
|
|
342 }
|
|
343
|
|
344 /* */
|
|
345
|
|
346 static dst_lose ()
|
|
347 {
|
|
348 (void) sm_end (NOTOK);
|
|
349 }
|
|
350
|
|
351 /* */
|
|
352
|
|
353 /* VARARGS1 */
|
|
354
|
|
355 static int lose (fmt, a, b, c, d)
|
|
356 char *fmt,
|
|
357 *a,
|
|
358 *b,
|
|
359 *c,
|
|
360 *d;
|
|
361 {
|
|
362 int fd,
|
|
363 i;
|
|
364 char *bp,
|
|
365 buffer[BUFSIZ];
|
|
366
|
|
367 if (bb_fderr == NOTOK) {
|
|
368 if ((fd = open ("/dev/null", 0)) == NOTOK)
|
|
369 adios (EX_OSERR, "/dev/null", "unable to open");
|
|
370 bb_fderr = copyfile (fd, bb_rept);
|
|
371 }
|
|
372
|
|
373 (void) sprintf (bp = buffer, fmt, a, b, c, d);
|
|
374 bp += strlen (bp);
|
|
375 bp += strlen (strcpy(bp, "\n"));
|
|
376 i = bp - buffer;
|
|
377 if (write (bb_fderr, buffer, i) != i)
|
|
378 adios (EX_IOERR, bb_rept, "error writing");
|
|
379
|
|
380 return NOTOK;
|
|
381 }
|
|
382
|
|
383 /* */
|
|
384
|
|
385 static notify (fd)
|
|
386 int fd;
|
|
387 {
|
|
388 int i;
|
|
389 char buffer[BUFSIZ];
|
|
390
|
|
391 if (bb_fderr == NOTOK)
|
|
392 return;
|
|
393
|
|
394 if (rp_isbad (sm_init (NULLCP, NULLCP, 0, 0, 0, 0, 0))
|
|
395 || rp_isbad (sm_winit (S_MAIL, bb_from)))
|
|
396 goto sm_err;
|
|
397
|
|
398 switch (sm_wadr (bb_from, NULLCP, NULLCP)) {
|
|
399 case RP_OK:
|
|
400 for (i = 0; bb[i]; i++) {
|
|
401 (void) sprintf (buffer, "local-%s-request", bb[i] -> bb_name);
|
|
402 (void) sm_wadr (buffer, LocalName (), NULLCP);
|
|
403 }
|
|
404 break;
|
|
405
|
|
406 default:
|
|
407 goto sm_err;
|
|
408 }
|
|
409
|
|
410 if (rp_isbad (sm_waend ()))
|
|
411 goto sm_err;
|
|
412
|
|
413 (void) sprintf (buffer,
|
|
414 "Date: %s\nFrom: %s\nTo: %s\nSubject: BBoards Failure\n\n",
|
|
415 dtimenow (), bb_from, bb_from);
|
|
416 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
417 goto sm_err;
|
|
418
|
|
419 for (i = 0; bb[i]; i++) {
|
|
420 (void) sprintf (buffer, "BBoard %s\n", bb[i] -> bb_name);
|
|
421 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
422 goto sm_err;
|
|
423 }
|
|
424
|
|
425 (void) lseek (bb_fderr, (off_t)0, 0);
|
|
426 while ((i = read (bb_fderr, buffer, sizeof buffer)) > 0)
|
|
427 if (rp_isbad (sm_wtxt (buffer, i)))
|
|
428 goto sm_err;
|
|
429
|
|
430 (void) strcpy (buffer, "\n------- Forwarded Message\n\n");
|
|
431 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))) || encap (fd) == NOTOK)
|
|
432 goto sm_err;
|
|
433 (void) strcpy (buffer, "\n------- End of Forwarded Message\n\n");
|
|
434 if (rp_isbad (sm_wtxt (buffer, strlen (buffer))))
|
|
435 goto sm_err;
|
|
436
|
|
437 switch (sm_wtend ()) {
|
|
438 case RP_OK:
|
|
439 (void) unlink (bb_rept);
|
|
440 (void) sm_end (OK);
|
|
441 return;
|
|
442
|
|
443 default:
|
|
444 sm_err: ;
|
|
445 adios (EX_UNAVAILABLE, NULLCP,
|
|
446 "failed and unable to post advisory, see %s for details",
|
|
447 bb_rept);
|
|
448 }
|
|
449 }
|
|
450
|
|
451 /* */
|
|
452
|
|
453 /* very similar to sbr/cpydgst.c */
|
|
454
|
|
455 #define S1 0
|
|
456 #define S2 1
|
|
457
|
|
458 #define output(c) if (bp >= dp) flush (), *bp++ = c; else *bp++ = c
|
|
459 #define flush() if ((j = bp - outbuf) \
|
|
460 && rp_isbad (sm_wtxt (outbuf, j))) \
|
|
461 return NOTOK; \
|
|
462 else \
|
|
463 bp = outbuf
|
|
464
|
|
465 static int encap (fd)
|
|
466 register int fd;
|
|
467 {
|
|
468 register int i,
|
|
469 state;
|
|
470 register char *cp,
|
|
471 *ep;
|
|
472 char buffer[BUFSIZ];
|
|
473 register int j;
|
|
474 register char *bp,
|
|
475 *dp;
|
|
476 char outbuf[BUFSIZ];
|
|
477
|
|
478 (void) lseek (fd, (off_t)0, 0);
|
|
479
|
|
480 dp = (bp = outbuf) + sizeof outbuf;
|
|
481 for (state = S1; (i = read (fd, buffer, sizeof buffer)) > 0;)
|
|
482 for (ep = (cp = buffer) + i; cp < ep; cp++) {
|
|
483 if (*cp == '\0')
|
|
484 continue;
|
|
485 switch (state) {
|
|
486 case S1:
|
|
487 if (*cp == '-') {
|
|
488 output ('-');
|
|
489 output (' ');
|
|
490 }
|
|
491 state = S2; /* fall */
|
|
492
|
|
493 case S2:
|
|
494 output (*cp);
|
|
495 if (*cp == '\n')
|
|
496 state = S1;
|
|
497 break;
|
|
498 }
|
|
499 }
|
|
500
|
|
501 if (i == NOTOK)
|
|
502 return NOTOK;
|
|
503 flush ();
|
|
504
|
|
505 return OK;
|
|
506 }
|
|
507 #endif DISTRIBUTE
|
|
508
|
|
509 /* */
|
|
510
|
|
511 #ifndef DISTRIBUTE
|
|
512 /* VARARGS1 */
|
|
513
|
|
514 static int lose (fmt, a, b, c, d)
|
|
515 char *fmt,
|
|
516 *a,
|
|
517 *b,
|
|
518 *c,
|
|
519 *d;
|
|
520 {
|
|
521 adios (EX_UNAVAILABLE, NULLCP, fmt, a, b, c, d);/* NOTREACHED */
|
|
522 }
|
|
523 #endif not DISTRIBUTE
|
|
524
|
|
525 /* */
|
|
526
|
|
527 static arginit (vec)
|
|
528 register char **vec;
|
|
529 {
|
|
530 register int i;
|
|
531 #ifdef MHMTS
|
|
532 register char *ap;
|
|
533 #endif MHMTS
|
|
534 char addr[BUFSIZ];
|
|
535 register struct bboard *bp;
|
|
536 register struct passwd *pw;
|
|
537
|
|
538 invo_name = r1bindex (*vec++, '/');
|
|
539 if (strlen(invo_name) > NAMESZ) {
|
|
540 fprintf(stderr, "%s: argv[0] too long\n", invo_name);
|
|
541 exit(1);
|
|
542 }
|
|
543 m_foil (NULLCP);
|
|
544 mts_init (invo_name);
|
|
545
|
|
546 #ifndef SPOP
|
|
547 if ((pw = getpwnam (BBOARDS)) == NULL)
|
|
548 adios (EX_OSFILE, NULLCP, "no entry for ~%s", BBOARDS);
|
|
549 #else SPOP
|
|
550 if ((pw = getpwnam (POPUID)) == NULL || !setpwinfo (pw, POPDB, 1))
|
|
551 adios (EX_OSFILE, NULLCP, "%s", pw ? getbberr () : "POP user-id unknown");
|
|
552 #endif SPOP
|
|
553
|
|
554 if (pw -> pw_uid != geteuid ())
|
|
555 #ifndef SPOP
|
|
556 adios (EX_OSERR, NULLCP, "not running setuid to %s", BBOARDS);
|
|
557 #else SPOP
|
|
558 adios (EX_OSERR, NULLCP, "not running setuid to %s", POPUID);
|
|
559 #endif SPOP
|
|
560
|
|
561 bb_uid = pw -> pw_uid;
|
|
562 bb_gid = pw -> pw_gid;
|
|
563 #ifndef SPOP
|
|
564 (void) strcpy (bb_from, adrsprintf (pw -> pw_name, LocalName ()));
|
|
565 (void) strcpy (bb_home, pw -> pw_dir);
|
|
566 #endif not SPOP
|
|
567
|
|
568 #ifdef MHMTS
|
|
569 vec += 3;
|
|
570 #endif MHMTS
|
|
571 if (*vec == NULL)
|
|
572 adios (EX_USAGE, NULLCP, "usage: %s %s [%s ...]",
|
|
573 invo_name, ENTITY, ENTITY);
|
|
574
|
|
575 for (i = 0; *vec; vec++) {
|
|
576 if (strlen(*vec) >= BUFSIZ / 4)
|
|
577 adios (NULLCP, "argument too long");
|
|
578 #ifdef MHMTS
|
|
579 if (ap = index (*vec, '.'))
|
|
580 *vec = ++ap;
|
|
581 #endif MHMTS
|
|
582 make_lower (addr, *vec);
|
|
583
|
|
584 if ((bp = getbbnam (addr)) == NULL
|
|
585 && (bp = getbbaka (addr)) == NULL)
|
|
586 adios (EX_NOUSER, NULLCP, "no such %s as %s", ENTITY, *vec);
|
|
587 if ((bb[i++] = getbbcpy (bp)) == NULL)
|
|
588 adios (EX_UNAVAILABLE, NULLCP, "insufficient memory on %s", *vec);
|
|
589
|
|
590 if (i >= NBB - 1)
|
|
591 adios (EX_USAGE, NULLCP, "too many %ss, starting with %s",
|
|
592 ENTITY, *vec);
|
|
593 }
|
|
594 bb[i] = NULL;
|
|
595
|
|
596 (void) umask (0022);
|
|
597
|
|
598 bb_fderr = NOTOK;
|
|
599 }
|
|
600
|
|
601 /* */
|
|
602
|
|
603 static int copyfile (qd, tmpfil)
|
|
604 int qd;
|
|
605 register char *tmpfil;
|
|
606 {
|
|
607 int i,
|
|
608 fd;
|
|
609 char buffer[BUFSIZ];
|
|
610
|
|
611 (void) strcpy (tmpfil, m_tmpfil (invo_name));
|
|
612 if ((fd = creat (tmpfil, 0600)) == NOTOK)
|
|
613 adios (EX_CANTCREAT, tmpfil, "unable to create");
|
|
614 (void) close (fd);
|
|
615 if ((fd = open (tmpfil, 2)) == NOTOK)
|
|
616 adios (EX_NOINPUT, tmpfil, "unable to re-open");
|
|
617
|
|
618 (void) lseek (qd, (off_t)0, 0);
|
|
619 while ((i = read (qd, buffer, sizeof buffer)) > 0)
|
|
620 if (write (fd, buffer, i) != i)
|
|
621 adios (EX_IOERR, tmpfil, "error writing");
|
|
622 if (i == NOTOK)
|
|
623 adios (EX_IOERR, "input", "error reading");
|
|
624
|
|
625 (void) lseek (fd, (off_t)0, 0);
|
|
626
|
|
627 return fd;
|
|
628 }
|
|
629
|
|
630 /* */
|
|
631
|
|
632 /* VARARGS3 */
|
|
633
|
|
634 #ifdef MHMTS
|
|
635 /* ARGSUSED */
|
|
636 #endif MHMTS
|
|
637
|
|
638 static void adios (code, what, fmt, a, b, c, d, e, f)
|
|
639 int code;
|
|
640 char *what,
|
|
641 *fmt,
|
|
642 *a,
|
|
643 *b,
|
|
644 *c,
|
|
645 *d,
|
|
646 *e,
|
|
647 *f;
|
|
648 {
|
|
649 advise (what, fmt, a, b, c, d, e, f);
|
|
650 #ifdef SENDMTS
|
|
651 done (code);
|
|
652 #endif SENDMTS
|
|
653 #ifdef MHMTS
|
|
654 done (1);
|
|
655 #endif MHMTS
|
|
656 }
|