-static char *findhashcachefile(int filldef)
-{
- static char ret[128];
- char *hcname;
-
- if(getenv("HOME") != NULL)
- {
- snprintf(ret, sizeof(ret), "%s/.dc-hashcache", getenv("HOME"));
- if(!access(ret, R_OK))
- return(ret);
- }
- if((hcname = icswcstombs(confgetstr("cli", "hashcache"), NULL, NULL)) == NULL)
- {
- flog(LOG_WARNING, "could not convert hash cache name into local charset: %s", strerror(errno));
- return(NULL);
- }
- if(strchr(hcname, '/') != NULL)
- {
- if(!access(hcname, R_OK))
- {
- strcpy(ret, hcname);
- return(ret);
- }
- } else {
- snprintf(ret, sizeof(ret), "/etc/%s", hcname);
- if(!access(ret, R_OK))
- return(ret);
- snprintf(ret, sizeof(ret), "/usr/etc/%s", hcname);
- if(!access(ret, R_OK))
- return(ret);
- snprintf(ret, sizeof(ret), "/usr/local/etc/%s", hcname);
- if(!access(ret, R_OK))
- return(ret);
- }
- if(filldef)
- {
- if(getenv("HOME") != NULL)
- snprintf(ret, sizeof(ret), "%s/.dc-hashcache", getenv("HOME"));
- else
- snprintf(ret, sizeof(ret), "/etc/%s", hcname);
- return(ret);
- } else {
- return(NULL);
- }
-}
-