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
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.
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]
23 * Copyright (c) 1986-1992 by Sun Microsystems Inc.
28 #include <rpcsvc/yp_prot.h>
29 #include <rpcsvc/ypclnt.h>
34 /* number of nickname file entries arbitrarily limited */
36 static char NICKFILE
[] = "/var/yp/nicknames";
37 static char *transtable
[MAXMAPS
];
40 * This will read nicknames from file /var/yp/nicknames
41 * and print it out or save it for future use.
49 char nickbuf
[2*YPMAXMAP
+3], nickname
[YPMAXMAP
+1], mapname
[YPMAXMAP
+1];
51 if ((nickp
= fopen(NICKFILE
, "r")) == NULL
) {
52 (void) fprintf(stderr
, "nickname file %s does not exist\n",
56 while (fgets(nickbuf
, YPMAXMAP
, nickp
) != NULL
) {
57 if (strchr(nickbuf
, '\n') == NULL
) {
58 (void) fprintf(stderr
,
59 "garbled nickname file %s\n", NICKFILE
);
62 (void) memset(nickname
, 0, YPMAXMAP
+1);
63 (void) memset(mapname
, 0, YPMAXMAP
+1);
64 if (sscanf(nickbuf
, "%s %s\n", nickname
, mapname
) != 2) {
65 (void) fprintf(stderr
,
66 "garbled nickname file %s\n", NICKFILE
);
70 transtable
[i
] = strdup(nickname
);
71 transtable
[i
+1] = strdup(mapname
);
75 printf("Use \"%s\"\tfor map \"%s\"\n",
83 * This will get the mapname for a given nickname from the file.
90 char nickbuf
[2*YPMAXMAP
+3], nickname
[YPMAXMAP
+1];
92 if ((nickp
= fopen(NICKFILE
, "r")) == NULL
)
94 while (fgets(nickbuf
, YPMAXMAP
, nickp
) != NULL
) {
95 if (strchr(nickbuf
, '\n') == NULL
) {
99 (void) memset(nickname
, 0, YPMAXMAP
+1);
100 (void) memset(map
, 0, YPMAXMAP
+1);
101 if (sscanf(nickbuf
, "%s %s\n", nickname
, map
) != 2) {
105 if (strcmp(nick
, nickname
) == 0) {