1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 /* 32 * University Copyright- Copyright (c) 1982, 1986, 1988 33 * The Regents of the University of California 34 * All Rights Reserved 35 * 36 * University Acknowledgment- Portions of this document are derived from 37 * software developed by the University of California, Berkeley, and its 38 * contributors. 39 */ 40 41 /* 42 * mailx -- a modified version of a University of California at Berkeley 43 * mail program 44 * 45 * Code to figure out what host we are on. 46 */ 47 48 #include "rcv.h" 49 #include "configdefs.h" 50 #include <sys/utsname.h> 51 #include <locale.h> 52 53 #define MAILCNFG "/etc/mail/mailcnfg" 54 55 char host[64]; 56 char domain[128]; 57 /* 58 * Initialize the network name of the current host. 59 */ 60 void 61 inithost(void) 62 { 63 register struct netmach *np; 64 struct utsname name; 65 char *fp; 66 67 xsetenv(MAILCNFG); 68 if (fp = xgetenv("CLUSTER")) { 69 nstrcpy(host, sizeof (host), fp); 70 } else { 71 uname(&name); 72 nstrcpy(host, sizeof (host), name.nodename); 73 } 74 snprintf(domain, sizeof (domain), "%s%s", host, maildomain()); 75 for (np = netmach; np->nt_machine != 0; np++) 76 if (strcmp(np->nt_machine, EMPTY) == 0) 77 break; 78 if (np->nt_machine == 0) { 79 printf( 80 gettext("Cannot find empty slot for dynamic host entry\n")); 81 exit(1); 82 } 83 np->nt_machine = host; 84 np++; 85 np->nt_machine = domain; 86 if (debug) fprintf(stderr, "host '%s', domain '%s'\n", host, domain); 87 } 88