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:
@@ -76,29 +76,44 @@ krb5_context context;
|
|||||||
krb5_ccache id;
|
krb5_ccache id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
expand_one_file(FILE *f, const char *cell)
|
||||||
|
{
|
||||||
|
static char buf[1024];
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
while (fgets (buf, sizeof(buf), f) != NULL) {
|
||||||
|
if(buf[0] == '>') {
|
||||||
|
for(p = buf; *p && !isspace((unsigned char)*p) && *p != '#'; p++)
|
||||||
|
;
|
||||||
|
*p = '\0';
|
||||||
|
if(strncmp(buf + 1, cell, strlen(cell)) == 0)
|
||||||
|
return buf + 1;
|
||||||
|
}
|
||||||
|
buf[0] = '\0';
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
expand_cell_name(const char *cell)
|
expand_cell_name(const char *cell)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
static char buf[128];
|
const char *c;
|
||||||
char *p;
|
const char **fn, *files[] = { _PATH_CELLSERVDB,
|
||||||
|
_PATH_ARLA_CELLSERVDB,
|
||||||
f = fopen(_PATH_CELLSERVDB, "r");
|
_PATH_OPENAFS_DEBIAN_CELLSERVDB,
|
||||||
if(f == NULL)
|
_PATH_ARLA_DEBIAN_CELLSERVDB,
|
||||||
return cell;
|
NULL };
|
||||||
while (fgets (buf, sizeof(buf), f) != NULL) {
|
for(fn = files; *fn; fn++) {
|
||||||
if(buf[0] == '>'){
|
f = fopen(*fn, "r");
|
||||||
for(p=buf; *p && !isspace((unsigned char)*p) && *p != '#'; p++)
|
if(f == NULL)
|
||||||
;
|
continue;
|
||||||
*p = '\0';
|
c = expand_one_file(f, cell);
|
||||||
if(strstr(buf, cell)){
|
fclose(f);
|
||||||
fclose(f);
|
if(c)
|
||||||
return buf + 1;
|
return c;
|
||||||
}
|
|
||||||
}
|
|
||||||
buf[0] = 0;
|
|
||||||
}
|
}
|
||||||
fclose(f);
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user