0
|
1 /* mts.c - definitions for the mail transport system */
|
|
2 #ifndef lint
|
12
|
3 static char ident[] = "@(#)$Id: mts.c,v 1.3 2006/12/05 18:18:14 kono Exp $";
|
0
|
4 #endif /* lint */
|
|
5
|
|
6 /* LINTLIBRARY */
|
|
7
|
|
8 #undef NETWORK
|
|
9 #if defined(BSD41A) || defined(BSD42) || defined(SOCKETS)
|
|
10 #define NETWORK
|
|
11 #endif
|
|
12
|
|
13 #include "../h/strings.h"
|
|
14 #include <ctype.h>
|
|
15 #include <stdio.h>
|
|
16 #include "mts.h"
|
|
17 #ifdef NETWORK
|
|
18 #if defined(BSD42) || defined(SOCKETS)
|
|
19 #include <netdb.h>
|
|
20 #endif
|
|
21 #else /* NETWORK */
|
|
22 #ifndef SYS5
|
|
23 #include <whoami.h>
|
|
24 #else
|
|
25 #include <sys/utsname.h>
|
|
26 #endif /* SYS5 */
|
|
27 #endif /* NETWORK */
|
|
28 #include <pwd.h>
|
|
29
|
|
30
|
|
31 #define NOTOK (-1)
|
|
32 #define OK 0
|
|
33
|
|
34 #define NULLCP ((char *) 0)
|
|
35
|
|
36 #include <errno.h>
|
|
37
|
|
38 static char *tailor_value ();
|
|
39
|
|
40
|
|
41 #if defined(SYS5) && !defined(_AIX)
|
|
42 #define index strchr
|
|
43 #define rindex strrchr
|
|
44 #endif /* SYS5 */
|
|
45
|
|
46 #if !defined(__STDC__) && !defined(_AIX) && !defined(_POSIX_SOURCE)
|
|
47 char *index (), *malloc (), *mktemp (), *rindex (), *strcpy ();
|
|
48
|
|
49 #ifdef SYS5
|
|
50 struct passwd *getpwuid ();
|
|
51 #endif
|
|
52 #endif /* !__STDC__ */
|
|
53
|
|
54 /* */
|
|
55
|
|
56 /*
|
|
57 *mmdfldir and *uucpldir are the maildrop directories. If maildrops
|
|
58 are kept in the user's home directory, then these should be empty
|
|
59 strings. In this case, the appropriate ...lfil array should contain
|
|
60 the name of the file in the user's home directory. Usually, this is
|
|
61 something like ".mail".
|
|
62 */
|
|
63
|
10
|
64 static char *mtstailor = "/usr/local/lib/mh/mtstailor";
|
0
|
65
|
|
66 static char *localname = "";
|
|
67 static char *localdomain = "";
|
|
68 static char *systemname = "";
|
|
69 #ifdef MF
|
|
70 static char *UUCPchan = "";
|
|
71 #endif /* MF */
|
|
72 char *mmdfldir = "/var/mail";
|
|
73 char *mmdflfil = "";
|
|
74 #ifdef MF
|
|
75 char *uucpldir = "/usr/spool/mail";
|
|
76 #else /* MF */
|
|
77 char *uucpldir = "";
|
|
78 #endif /* MF */
|
|
79 char *uucplfil = "";
|
|
80
|
|
81
|
|
82 char *mmdlm1 = "\001\001\001\001\n";
|
|
83 char *mmdlm2 = "\001\001\001\001\n";
|
|
84
|
|
85
|
|
86 static int MMailids = 0;
|
|
87 static char *mmailid = "0";
|
|
88
|
|
89
|
|
90 #ifdef MF
|
10
|
91 char *umincproc = "/usr/local/lib/mh/uminc";
|
0
|
92 #else /* MF */
|
|
93 char *umincproc = NULL;
|
|
94 #endif /* MF */
|
|
95
|
|
96
|
|
97 int lockstyle = LOK_UNIX;
|
|
98 static char *lkstyle = "0";
|
|
99 char *lockldir = "";
|
|
100
|
|
101 /* */
|
|
102
|
|
103 /* MTS specific variables */
|
|
104
|
|
105 #ifdef MHMTS
|
|
106 char *Mailqdir = "/usr/spool/netmail";
|
|
107 char *TMailqdir = "/usr/tmp";
|
|
108 int Syscpy = 1;
|
|
109 static char *syscpy = "1";
|
|
110 char *Overseer = "root";
|
|
111 char *Mailer = "root";
|
|
112 char *Fromtmp = "/tmp/rml.f.XXXXXX";
|
|
113 char *Msgtmp = "/tmp/rml.m.XXXXXX";
|
|
114 char *Errtmp = "/tmp/rml.e.XXXXXX";
|
|
115 int Tmpmode = 0600;
|
|
116 static char *tmpmode = "0600";
|
10
|
117 char *Okhosts = "/usr/local/lib/mh/Rmail.OkHosts";
|
|
118 char *Okdests = "/usr/local/lib/mh/Rmail.OkDests";
|
0
|
119 #endif /* MHMTS */
|
|
120
|
|
121 #ifdef MMDFMTS
|
|
122 #endif /* MMDFMTS */
|
|
123
|
|
124 #ifdef SENDMTS
|
10
|
125 char *hostable = "/usr/local/lib/mh/hosts";
|
|
126 char *sendmail = "/usr/lib/sendmail";
|
0
|
127 #endif /* SENDMTS */
|
|
128
|
|
129
|
|
130 /* SMTP/POP stuff */
|
|
131
|
|
132 char *clientname = (char *)0;
|
|
133 char *servers = "localhost \01localnet";
|
|
134 char *pophost = "";
|
|
135 #ifdef MH_PLUS
|
|
136 char *rpop_default = "";
|
|
137 #endif /* MH_PLUS */
|
|
138
|
|
139
|
|
140 /* BBoards-specific variables */
|
|
141
|
|
142 char *bb_domain = "";
|
|
143
|
|
144
|
|
145 /* POP BBoards-specific variables */
|
|
146
|
|
147 #if defined(BPOP) || defined(NNTP)
|
|
148 char *popbbhost = "";
|
|
149 #endif /* BPOP || NNTP */
|
|
150 #ifdef BPOP
|
|
151 char *popbbuser = "";
|
10
|
152 char *popbblist = "/usr/local/lib/mh/hosts.popbb";
|
0
|
153 #endif /* BPOP */
|
|
154
|
|
155
|
|
156 /* MailDelivery */
|
|
157
|
10
|
158 char *maildelivery = "/usr/local/lib/mh/maildelivery";
|
0
|
159
|
|
160
|
|
161 /* Aliasing Facility (doesn't belong here) */
|
|
162
|
|
163 int Everyone = NOTOK;
|
|
164 static char *everyone = "-1";
|
|
165 char *NoShell = "";
|
|
166
|
|
167 #ifdef MH_PLUS
|
|
168 int LocalUser = 0;
|
|
169 static char *localuser = "0";
|
|
170 #endif /* MH_PLUS */
|
|
171
|
|
172 /* */
|
|
173
|
10
|
174 /* customize the MTS settings for MH by reading /usr/local/lib/mh/mtstailor */
|
0
|
175
|
|
176 static struct bind {
|
|
177 char *keyword;
|
|
178 char **value;
|
|
179 } binds[] = {
|
|
180 "localname", &localname,
|
|
181 "localdomain", &localdomain,
|
|
182 "systemname", &systemname,
|
|
183 #ifdef MF
|
|
184 "uucpchan", &UUCPchan,
|
|
185 #endif /* MF */
|
|
186 "mmdfldir", &mmdfldir,
|
|
187 "mmdflfil", &mmdflfil,
|
|
188 "uucpldir", &uucpldir,
|
|
189 "uucplfil", &uucplfil,
|
|
190 "mmdelim1", &mmdlm1,
|
|
191 "mmdelim2", &mmdlm2,
|
|
192 "mmailid", &mmailid,
|
|
193 "umincproc", &umincproc,
|
|
194 "lockstyle", &lkstyle,
|
|
195 "lockldir", &lockldir,
|
|
196
|
|
197 #ifdef MHMTS
|
|
198 "mailqdir", &Mailqdir,
|
|
199 "tmailqdir", &TMailqdir,
|
|
200 "syscpy", &syscpy,
|
|
201 "overseer", &Overseer,
|
|
202 "mailer", &Mailer,
|
|
203 "fromtmp", &Fromtmp,
|
|
204 "msgtmp", &Msgtmp,
|
|
205 "errtmp", &Errtmp,
|
|
206 "tmpmode", &tmpmode,
|
|
207 "okhosts", &Okhosts,
|
|
208 "okdests", &Okdests,
|
|
209 #endif /* MHMTS */
|
|
210
|
|
211 #ifdef MMDFMTS
|
|
212 #endif /* MMDFMTS */
|
|
213
|
|
214 #ifdef SENDMTS
|
|
215 "hostable", &hostable,
|
|
216 "sendmail", &sendmail,
|
|
217 #endif /* SENDMTS */
|
|
218
|
|
219 "clientname", &clientname,
|
|
220 "servers", &servers,
|
|
221 "pophost", &pophost,
|
|
222 #ifdef MH_PLUS
|
|
223 "rpop", &rpop_default,
|
|
224 #endif /* MH_PLUS */
|
|
225
|
|
226 "bbdomain", &bb_domain,
|
|
227
|
|
228 #ifdef BPOP
|
|
229 "popbbhost", &popbbhost,
|
|
230 "popbbuser", &popbbuser,
|
|
231 "popbblist", &popbblist,
|
|
232 #endif /* BPOP */
|
|
233 #ifdef NNTP
|
|
234 "nntphost", &popbbhost,
|
|
235 #endif /* NNTP */
|
|
236
|
|
237 "maildelivery", &maildelivery,
|
|
238
|
|
239 "everyone", &everyone,
|
|
240 "noshell", &NoShell,
|
|
241
|
|
242 #ifdef MH_PLUS
|
|
243 "localuser", &localuser,
|
|
244 #endif /* MH_PLUS */
|
|
245
|
|
246 NULL
|
|
247 };
|
|
248
|
|
249 /* */
|
|
250
|
|
251 /* I'd like to use m_getfld() here, but not all programs loading mts.o may be
|
|
252 MH-style programs... */
|
|
253
|
|
254 /* ARGSUSED */
|
|
255
|
|
256 mts_init (name)
|
|
257 char *name;
|
|
258 {
|
|
259 register char *bp,
|
|
260 *cp;
|
|
261 char buffer[BUFSIZ];
|
|
262 register struct bind *b;
|
|
263 register FILE *fp;
|
|
264 static int inited = 0;
|
|
265
|
|
266 if (inited++ || (fp = fopen (mtstailor, "r")) == NULL)
|
|
267 return;
|
|
268
|
|
269 while (fgets (buffer, sizeof buffer, fp)) {
|
|
270 if ((cp = index (buffer, '\n')) == NULL)
|
|
271 break;
|
|
272 *cp = 0;
|
|
273 if (*buffer == '#' || *buffer == '\0')
|
|
274 continue;
|
|
275 if ((bp = index (buffer, ':')) == NULL)
|
|
276 break;
|
|
277 *bp++ = 0;
|
|
278 while (isspace (*bp))
|
|
279 *bp++ = 0;
|
|
280
|
|
281 for (b = binds; b -> keyword; b++)
|
|
282 if (strcmp (buffer, b -> keyword) == 0)
|
|
283 break;
|
|
284 if (b -> keyword && (cp = tailor_value (bp)))
|
|
285 *b -> value = cp;
|
|
286 }
|
|
287
|
|
288 (void) fclose (fp);
|
|
289
|
|
290 MMailids = atoi (mmailid);
|
|
291 if ((lockstyle = atoi (lkstyle)) < LOK_UNIX || lockstyle > LOK_MMDF)
|
|
292 lockstyle = LOK_UNIX;
|
|
293 #ifdef MHMTS
|
|
294 Syscpy = atoi (syscpy);
|
|
295 (void) sscanf (tmpmode, "0%o", &Tmpmode);
|
|
296 #endif /* MHMTS */
|
|
297 Everyone = atoi (everyone);
|
|
298 #ifdef MH_PLUS
|
|
299 LocalUser = atoi (localuser);
|
|
300 #endif /* MH_PLUS */
|
|
301 }
|
|
302
|
|
303 /* */
|
|
304
|
|
305 #define QUOTE '\\'
|
|
306
|
|
307 static char *tailor_value (s)
|
|
308 register char *s;
|
|
309 {
|
|
310 register int i,
|
|
311 r;
|
|
312 register char *bp;
|
|
313 char buffer[BUFSIZ];
|
|
314
|
|
315 for (bp = buffer; *s; bp++, s++)
|
|
316 if (*s != QUOTE)
|
|
317 *bp = *s;
|
|
318 else
|
|
319 switch (*++s) {
|
|
320 #define grot(y,z) case y: *bp = z; break;
|
|
321 grot ('b', '\b');
|
|
322 grot ('f', '\f');
|
|
323 grot ('n', '\n');
|
|
324 grot ('t', '\t');
|
|
325 #undef grot
|
|
326
|
|
327 case 0: s--;
|
|
328 case QUOTE:
|
|
329 *bp = QUOTE;
|
|
330 break;
|
|
331
|
|
332 default:
|
|
333 if (!isdigit (*s)) {
|
|
334 *bp++ = QUOTE;
|
|
335 *bp = *s;
|
|
336 }
|
|
337 r = *s != '0' ? 10 : 8;
|
|
338 for (i = 0; isdigit (*s); s++)
|
|
339 i = i * r + *s - '0';
|
|
340 s--;
|
|
341 *bp = toascii (i);
|
|
342 break;
|
|
343 }
|
|
344 *bp = 0;
|
|
345
|
|
346 bp = malloc ((unsigned) (strlen (buffer) + 1));
|
|
347 if (bp != NULL)
|
|
348 (void) strcpy (bp, buffer);
|
|
349
|
|
350 return bp;
|
|
351 }
|
|
352
|
|
353 /* */
|
|
354
|
|
355 struct hostent *mh_gethostbyname();
|
|
356
|
|
357 char *LocalName () {
|
|
358 #ifdef BSD41A
|
|
359 char *myname;
|
|
360 #endif /* BSD41A */
|
|
361 #if defined(BSD42) || defined(SOCKETS)
|
|
362 register struct hostent *hp;
|
|
363 #endif /* BSD42 or SOCKETS */
|
|
364 #if defined(SYS5) && !defined(NETWORK)
|
|
365 struct utsname name;
|
|
366 #endif /* SYS5 and not NETWORK */
|
|
367 static char buffer[BUFSIZ] = "";
|
|
368
|
|
369 if (buffer[0])
|
|
370 return buffer;
|
|
371
|
|
372 mts_init ("mts");
|
|
373 if (*localname)
|
|
374 strcpy (buffer, localname);
|
|
375 else {
|
|
376
|
|
377 #ifdef locname
|
|
378 (void) strcpy (buffer, locname);
|
|
379 #else /* not locname */
|
|
380 #ifdef NETWORK
|
|
381 #ifdef BSD41A
|
|
382 myname = "myname";
|
|
383 if (rhost (&myname) == -1)
|
|
384 (void) gethostname (buffer, sizeof buffer);
|
|
385 else {
|
|
386 (void) strcpy (buffer, myname);
|
|
387 free (myname);
|
|
388 }
|
|
389 #endif /* BSD41A */
|
|
390 #if defined(BSD42) || defined(SOCKETS)
|
|
391 (void) gethostname (buffer, sizeof buffer);
|
|
392 #ifndef BIND
|
|
393 sethostent (1);
|
|
394 #endif
|
|
395 if (hp = mh_gethostbyname (buffer))
|
|
396 (void) strcpy (buffer, hp -> h_name);
|
|
397 #endif /* BSD42 or SOCKETS */
|
|
398 #else /* not NETWORK */
|
|
399 #ifndef SYS5
|
|
400 (void) strcpy (buffer, SystemName ());
|
|
401 #else /* SYS5 */
|
|
402 (void) uname (&name);
|
|
403 (void) strcpy (buffer, name.nodename);
|
|
404 #endif /* SYS5 */
|
|
405 #endif /* not NETWORK */
|
|
406 #endif /* not locname */
|
|
407 }
|
|
408 if (*localdomain) {
|
|
409 strcat (buffer, ".");
|
|
410 strcat (buffer, localdomain);
|
|
411 }
|
|
412 return buffer;
|
|
413 }
|
|
414
|
|
415 /* */
|
|
416
|
|
417 char *SystemName () {
|
|
418 #if defined(SYS5) && !defined(NETWORK)
|
|
419 struct utsname name;
|
|
420 #endif /* SYS5 and not NETWORK */
|
|
421 static char buffer[BUFSIZ] = "";
|
|
422
|
|
423 if (buffer[0])
|
|
424 return buffer;
|
|
425
|
|
426 mts_init ("mts");
|
|
427 if (*systemname)
|
|
428 return strcpy (buffer, systemname);
|
|
429
|
|
430 #ifdef sysname
|
|
431 (void) strcpy (buffer, sysname);
|
|
432 #else /* sysname */
|
|
433 #if !defined(SYS5) || defined(NETWORK)
|
|
434 (void) gethostname (buffer, sizeof buffer);
|
|
435 #else /* SYS5 and not NETWORK */
|
|
436 #ifdef SYS5
|
|
437 (void) uname (&name);
|
|
438 (void) strcpy (buffer, name.nodename);
|
|
439 #endif /* SYS5 */
|
|
440 #endif /* SYS5 and not NETWORK */
|
|
441 #endif /* sysname */
|
|
442
|
|
443 return buffer;
|
|
444 }
|
|
445
|
|
446 /* */
|
|
447
|
|
448 char *UucpChan () {
|
|
449 #ifdef MF
|
|
450 static char buffer[BUFSIZ] = "";
|
|
451 #endif /* MF */
|
|
452
|
|
453 #ifndef MF
|
|
454 return NULL;
|
|
455 #else /* MF */
|
|
456 if (buffer[0])
|
|
457 return buffer;
|
|
458
|
|
459 mts_init ("mts");
|
|
460 if (*UUCPchan)
|
|
461 return strcpy (buffer, UUCPchan);
|
|
462
|
|
463 #ifdef uucpchan
|
|
464 (void) strcpy (buffer, uucpchan);
|
|
465 #else /* uucpchan */
|
|
466 (void) strcpy (buffer, "uucp");
|
|
467 #endif /* uucpchan */
|
|
468 return buffer;
|
|
469 #endif /* MF */
|
|
470 }
|
|
471
|
|
472 /* */
|
|
473
|
|
474 #ifdef ALTOS
|
|
475 gethostname (name, len)
|
|
476 register char *name;
|
|
477 register int len;
|
|
478 {
|
|
479 register char *cp;
|
|
480 register FILE *fp;
|
|
481
|
|
482 if (fp = fopen ("/etc/systemid", "r")) {
|
|
483 if (fgets (name, len, fp)) {
|
|
484 if (cp = index (name, '\n'))
|
|
485 *cp = 0;
|
|
486 (void) fclose (fp);
|
|
487 return OK;
|
|
488 }
|
|
489 (void) fclose (fp);
|
|
490 }
|
|
491 (void) strncpy (name, "altos", len);
|
|
492
|
|
493 return OK;
|
|
494 }
|
|
495 #endif /* ALTOS */
|
|
496
|
|
497 /* */
|
|
498
|
|
499 static char username[BUFSIZ];
|
|
500 static char fullname[BUFSIZ];
|
|
501
|
|
502
|
|
503 char *getusr () {
|
|
504 register char *cp,
|
|
505 *np;
|
|
506 #ifdef KPOP
|
|
507 int uid;
|
|
508 #endif /* KPOP */
|
|
509 register struct passwd *pw;
|
|
510
|
|
511 if (username[0])
|
|
512 return username;
|
|
513
|
|
514 #ifndef KPOP
|
|
515 #ifdef __CYGWIN32__
|
|
516 if ((cp = getenv ("USERNAME")) != NULL
|
|
517 && (pw = getpwnam (cp)) != NULL)
|
|
518 strcpy (username, cp);
|
|
519 else if ((pw = getpwuid (getuid ())) == NULL
|
|
520 || pw -> pw_name == NULL
|
|
521 || *pw -> pw_name == '\0') {
|
|
522 #else /* __CYGWIN32__ */
|
|
523 if ((pw = getpwuid (getuid ())) == NULL
|
|
524 || pw -> pw_name == NULL
|
|
525 || *pw -> pw_name == '\0') {
|
|
526 #endif /* __CYGWIN32__ */
|
|
527 #else /* KPOP */
|
|
528 uid = getuid ();
|
|
529 if (uid == geteuid () && (cp = getenv ("USER")) != NULL
|
|
530 && (pw = getpwnam (cp)) != NULL)
|
|
531 strcpy (username, cp);
|
|
532 else if ((pw = getpwuid (uid)) == NULL
|
|
533 || pw -> pw_name == NULL
|
|
534 || *pw -> pw_name == '\0') {
|
|
535 #endif /* KPOP */
|
|
536 (void) strcpy (username, "unknown");
|
|
537 (void) sprintf (fullname, "The Unknown User-ID (%d)", getuid ());
|
|
538 return username;
|
|
539 }
|
|
540
|
|
541 np = pw -> pw_gecos;
|
|
542 #ifndef GCOS_HACK
|
|
543 for (cp = fullname; *np && *np != (MMailids ? '<' : ','); *cp++ = *np++)
|
|
544 continue;
|
|
545 #else
|
|
546 for (cp = fullname; *np && *np != (MMailids ? '<' : ','); )
|
|
547 if (*np == '&') { /* blech! */
|
|
548 (void) strcpy(cp, pw -> pw_name);
|
|
549 *cp = toupper(*cp);
|
|
550 while (*cp)
|
|
551 cp++;
|
|
552 np++;
|
|
553 }
|
|
554 else
|
|
555 *cp++ = *np++;
|
|
556 #endif
|
|
557 *cp = '\0';
|
|
558 if (MMailids) {
|
|
559 if (*np)
|
|
560 np++;
|
|
561 for (cp = username; *np && *np != '>'; *cp++ = *np++)
|
|
562 continue;
|
|
563 *cp = '\0';
|
|
564 }
|
|
565 if (MMailids == 0 || *np == '\0')
|
|
566 (void) strcpy (username, pw -> pw_name);
|
|
567
|
|
568 if ((cp = getenv ("SIGNATURE")) && *cp) {
|
|
569 if (strlen(cp) > BUFSIZ / 4) {
|
|
570 fprintf(stderr, "SIGNATURE envariable too long\n");
|
|
571 exit(1);
|
|
572 }
|
|
573 (void) strcpy (fullname, cp);
|
|
574 }
|
|
575 if (index(fullname, '.')) { /* quote any .'s */
|
|
576 char tmp[BUFSIZ];
|
|
577 sprintf (tmp, "\"%s\"", fullname);/* should quote "'s too */
|
|
578 strcpy (fullname, tmp);
|
|
579 }
|
|
580
|
|
581 return username;
|
|
582 }
|
|
583
|
|
584
|
|
585 char *getfullname () {
|
|
586 if (username[0] == '\0')
|
|
587 (void) getusr ();
|
|
588
|
|
589 return fullname;
|
|
590 }
|
|
591
|
|
592 /* */
|
|
593
|
|
594 #ifdef SYS5
|
|
595 #ifndef notdef /* Supposedly this works, I prefer the
|
|
596 recursive solution... */
|
|
597
|
|
598 #include <fcntl.h>
|
|
599
|
|
600 int dup2 (d1, d2)
|
|
601 register int d1,
|
|
602 d2;
|
|
603 {
|
|
604 int d;
|
|
605
|
|
606 if (d1 == d2)
|
|
607 return OK;
|
|
608
|
|
609 (void) close (d2);
|
|
610 if ((d = fcntl (d1, F_DUPFD, d2)) == NOTOK)
|
|
611 return NOTOK;
|
|
612 if (d == d2)
|
|
613 return OK;
|
|
614
|
|
615 errno = 0;
|
|
616 return NOTOK;
|
|
617 }
|
|
618
|
|
619 #else /* notdef */
|
|
620 int dup2 (d1, d2)
|
|
621 register int d1,
|
|
622 d2;
|
|
623 {
|
|
624 if (d1 == d2)
|
|
625 return OK;
|
|
626
|
|
627 (void) close (d2);
|
|
628 return dup2aux (d1, d2);
|
|
629 }
|
|
630
|
|
631
|
|
632 static int dup2aux (d1, d2)
|
|
633 register int d1,
|
|
634 d2;
|
|
635 {
|
|
636 int d,
|
|
637 i,
|
|
638 eindex;
|
|
639
|
|
640 if ((d = dup (d1)) == NOTOK)
|
|
641 return NOTOK;
|
|
642 if (d == d2)
|
|
643 return OK;
|
|
644
|
|
645 i = dup2aux (d1, d2);
|
|
646 eindex = errno;
|
|
647 (void) close (d);
|
|
648 errno = eindex;
|
|
649 return i;
|
|
650 }
|
|
651 #endif /* notdef */
|
|
652 #endif /* SYS5 */
|
|
653
|
|
654 struct hostent *
|
|
655 mh_gethostbyname(name)
|
|
656 char *name;
|
|
657 {
|
|
658 struct hostent *xx;
|
|
659 #if (defined(SOLARIS) && SOLARIS < 20400) || (defined(sony_news) && defined(__svr4))
|
|
660 # if SOLARIS == 20300
|
|
661 static struct hostent hp;
|
|
662 static char buf[1000];
|
|
663 extern struct hostent *_switch_gethostbyname_r();
|
|
664
|
|
665 xx = _switch_gethostbyname_r(name, &hp, buf, sizeof(buf), &h_errno);
|
|
666 # else
|
|
667 extern struct hostent *__switch_gethostbyname();
|
|
668
|
|
669 xx = __switch_gethostbyname(name);
|
|
670 # endif /* Solaris 2.3 */
|
|
671 #else /* SOLARIS */
|
|
672
|
|
673 xx = gethostbyname(name);
|
|
674 #endif /* SOLARIS */
|
|
675
|
|
676 return xx;
|
|
677 }
|
|
678
|
|
679 #ifdef __CYGWIN32__
|
|
680 void sethostent(x)
|
|
681 int x;
|
|
682 {
|
|
683 }
|
|
684 #endif
|