--- ray/src/common/fropen.c 1990/12/08 09:28:15 1.1 +++ ray/src/common/fropen.c 2003/06/30 14:59:11 2.11 @@ -1,52 +1,41 @@ -/* Copyright (c) 1990 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: fropen.c,v 2.11 2003/06/30 14:59:11 schorsch Exp $"; #endif - /* * Find and open a Radiance library file. + * + * External symbols declared in standard.h */ +#include "copyright.h" + #include -#ifndef DEFPATH -#define DEFPATH ":/usr/local/lib/ray" -#endif -#ifndef ULIBVAR -#define ULIBVAR "RAYPATH" -#endif +#include "paths.h" FILE * -fropen(fname) /* find file and open for reading */ +frlibopen(fname) /* find file and open for reading */ register char *fname; { - extern char *strcpy(), *getenv(); - static char *searchpath; + extern char *strcpy(), *getrlibpath(); FILE *fp; - char pname[256]; + char pname[PATH_MAX]; register char *sp, *cp; if (fname == NULL) return(NULL); - if (fname[0] == '/' || fname[0] == '.') /* absolute path */ + if (ISDIRSEP(fname[0]) || fname[0] == '.') /* absolute path */ return(fopen(fname, "r")); - - if (searchpath == NULL) { /* get search path */ - searchpath = getenv(ULIBVAR); - if (searchpath == NULL) - searchpath = DEFPATH; - } /* check search path */ - sp = searchpath; + sp = getrlibpath(); do { cp = pname; - while (*sp && (*cp = *sp++) != ':') + while (*sp && (*cp = *sp++) != PATHSEP) cp++; - if (cp > pname && cp[-1] != '/') - *cp++ = '/'; + if (cp > pname && !ISDIRSEP(cp[-1])) + *cp++ = DIRSEP; strcpy(cp, fname); if ((fp = fopen(pname, "r")) != NULL) return(fp); /* got it! */