1 /* $NetBSD: supcname.c,v 1.6 2002/07/10 20:19:45 wiz Exp $ */
4 * Copyright (c) 1992 Carnegie Mellon University
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 * Carnegie Mellon requests users of this software to return to
19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 * School of Computer Science
21 * Carnegie Mellon University
22 * Pittsburgh PA 15213-3890
24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes.
28 * sup client name server interface
29 **********************************************************************
31 * Revision 1.4 92/08/11 12:07:32 mrt
35 * 21-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
36 * Changed to no longer use a name server.
38 * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
39 * Changed getnams and added several new routines to change the
40 * way that sup finds nameservers. It now builds a tree of
41 * servers to check. It walks over the tree. At each node, it
42 * tries to contact the name server and get as many names
43 * resolved as it can. It stops after either all collections
44 * have host names, or if some collections don't have host names
45 * but either everyone doesn't know what they are, or after too
46 * many tries, none could be reached.
48 * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
49 * Split off from sup.c
51 **********************************************************************
55 #include "supextern.h"
57 extern COLLECTION
*firstC
; /* collection list pointer */
59 /*****************************************
60 *** G E T H O S T N A M E S ***
61 *****************************************/
64 * For each collection that doesn't have a host name specified, read
65 * the file server list for the name of the host for that collection.
66 * It's a fatal error if a collection has no file server.
73 char buf
[STRINGLENGTH
];
77 for (c
= firstC
; c
&& c
->Chtree
!= NULL
; c
= c
->Cnext
);
80 (void) sprintf(buf
, FILEHOSTS
, DEFDIR
);
83 logquit(1, "Can't open %s", buf
);
84 while ((p
= fgets(buf
, STRINGLENGTH
, f
)) != NULL
) {
85 if ((q
= strchr(p
, '\n')) != NULL
)
87 if (strchr("#;:", *p
))
89 q
= nxtarg(&p
, "= \t");
90 p
= skipover(p
, " \t");
93 p
= skipover(p
, " \t");
95 goaway("error in collection/host file");
97 if (strcmp(c
->Cname
, q
) == 0) {
99 q
= nxtarg(&p
, ", \t");
100 p
= skipover(p
, " \t");
103 p
= skipover(p
, " \t");
104 (void) Tinsert(&c
->Chtree
, q
, FALSE
);
105 } while (*p
!= '\0');
107 while ((c
= c
->Cnext
) != NULL
&& c
->Chtree
!= NULL
);
109 for (c
= firstC
; c
&& c
->Chtree
!= NULL
; c
= c
->Cnext
);
117 logerr("Host for collection %s not found", c
->Cname
);
118 while ((c
= c
->Cnext
) != NULL
&& c
->Chtree
!= NULL
);
120 logquit(1, "Hosts not found for all collections");