xref: /illumos-gate/usr/src/cmd/bnu/versys.c (revision fc910014e8a32a65612105835a10995f2c13d942)
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 #include "uucp.h"
31 
32 extern int getsysline();
33 extern void sysreset();
34 
35 /*
36  * verify system name
37  * input:
38  *	name	-> system name (char name[NAMESIZE])
39  * returns:
40  *	0	-> success
41  *	FAIL	-> failure
42  */
43 int
44 versys(name)
45 char *name;
46 {
47 	register char *iptr;
48 	char line[BUFSIZ];
49 	extern char *aliasFind();
50 	char	*prev;
51 
52 	if (name == 0 || *name == 0)
53 		return(FAIL);
54 
55 	prev = _uu_setlocale(LC_ALL, "C");
56 	if ((iptr = aliasFind(name)) != NULL) {
57 		/* overwrite the original name with the real name */
58 		strncpy(name, iptr, MAXBASENAME);
59 		name[MAXBASENAME] = '\0';
60 	}
61 
62 	if (EQUALS(name, Myname)) {
63 		(void) _uu_resetlocale(LC_ALL, prev);
64 		return(0);
65 	}
66 
67 	while (getsysline(line, sizeof(line))) {
68 		if((line[0] == '#') || (line[0] == ' ') || (line[0] == '\t') ||
69 			(line[0] == '\n'))
70 			continue;
71 
72 		if ((iptr=strpbrk(line, " \t")) == NULL)
73 		    continue;	/* why? */
74 		*iptr = '\0';
75 		if (EQUALS(name, line)) {
76 			sysreset();
77 			(void) _uu_resetlocale(LC_ALL, prev);
78 			return(0);
79 		}
80 	}
81 	sysreset();
82 	(void) _uu_resetlocale(LC_ALL, prev);
83 	return(FAIL);
84 }
85