2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
17 struct bc_config *bc_globalConfig;
21 TrimLine(char *abuffer, afs_int32 *aport)
27 sscanf(abuffer, "%s %u", garb, aport);
28 while ((tc = *abuffer)) {
40 bc_open(struct bc_config *aconfig, char *aname, char *aext, char *amode)
45 strcpy(tpath, aconfig->path);
50 tf = fopen(tpath, amode);
55 bc_InitConfig(char *apath)
59 /* initialize global config structure */
60 tb = (struct bc_config *)malloc(sizeof(struct bc_config));
65 memset(tb, 0, sizeof(struct bc_config));
66 tb->path = strdup(apath);
72 /* now read the important config files; no file means empty list during system init */
78 HostAdd(struct bc_hostEntry **alist, char *aname, afs_int32 aport)
80 struct bc_hostEntry **tlast, *tentry;
83 /* check that the host address is real */
84 th = gethostbyname(aname);
88 /* check if this guy is already in the list */
89 for (tentry = *alist; tentry; tentry = tentry->next)
90 if (tentry->portOffset == aport)
93 /* add this guy to the end of the list */
95 for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast);
97 /* tlast now points to the next pointer (or head pointer) we should overwrite */
98 tentry = (struct bc_hostEntry *)malloc(sizeof(struct bc_hostEntry));
99 memset(tentry, 0, sizeof(*tentry));
100 tentry->name = strdup(aname);
102 tentry->next = (struct bc_hostEntry *)0;
103 tentry->addr.sin_family = AF_INET;
104 memcpy(&tentry->addr.sin_addr.s_addr, th->h_addr, sizeof(afs_int32));
105 tentry->addr.sin_port = 0;
106 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
107 tentry->addr.sin_len = sizeof(struct sockaddr_in);
109 tentry->portOffset = aport;
114 HostDelete(struct bc_hostEntry **alist, char *aname, afs_int32 aport)
116 struct bc_hostEntry **tlast, *tentry;
118 /* find guy to zap */
120 for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast)
121 if (strcmp(tentry->name, aname) == 0 && (aport == tentry->portOffset))
124 return ENOENT; /* failed to find it */
126 /* otherwise delete the entry from the list and free appropriate structures */
127 *tlast = tentry->next;
134 bc_AddTapeHost(struct bc_config *aconfig, char *aname, afs_int32 aport)
138 code = HostAdd(&aconfig->tapeHosts, aname, aport);
144 bc_DeleteTapeHost(struct bc_config *aconfig, char *aname, afs_int32 aport)
148 code = HostDelete(&aconfig->tapeHosts, aname, aport);