try more files when trying to expand a cell name

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11544 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2002-11-26 17:11:58 +00:00
parent 83a9e52059
commit e181dcb248

View File

@@ -77,28 +77,43 @@ krb5_ccache id;
#endif #endif
static const char * static const char *
expand_cell_name(const char *cell) expand_one_file(FILE *f, const char *cell)
{ {
FILE *f; static char buf[1024];
static char buf[128];
char *p; char *p;
f = fopen(_PATH_CELLSERVDB, "r");
if(f == NULL)
return cell;
while (fgets (buf, sizeof(buf), f) != NULL) { while (fgets (buf, sizeof(buf), f) != NULL) {
if(buf[0] == '>') { if(buf[0] == '>') {
for(p = buf; *p && !isspace((unsigned char)*p) && *p != '#'; p++) for(p = buf; *p && !isspace((unsigned char)*p) && *p != '#'; p++)
; ;
*p = '\0'; *p = '\0';
if(strstr(buf, cell)){ if(strncmp(buf + 1, cell, strlen(cell)) == 0)
fclose(f);
return buf + 1; return buf + 1;
} }
buf[0] = '\0';
} }
buf[0] = 0; return NULL;
} }
static const char *
expand_cell_name(const char *cell)
{
FILE *f;
const char *c;
const char **fn, *files[] = { _PATH_CELLSERVDB,
_PATH_ARLA_CELLSERVDB,
_PATH_OPENAFS_DEBIAN_CELLSERVDB,
_PATH_ARLA_DEBIAN_CELLSERVDB,
NULL };
for(fn = files; *fn; fn++) {
f = fopen(*fn, "r");
if(f == NULL)
continue;
c = expand_one_file(f, cell);
fclose(f); fclose(f);
if(c)
return c;
}
return cell; return cell;
} }