ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fropen.c
Revision: 2.7
Committed: Wed Mar 1 10:40:17 1995 UTC (29 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.6: +1 -1 lines
Log Message:
changed fropen() call to frlibopen()

File Contents

# Content
1 /* Copyright (c) 1992 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Find and open a Radiance library file.
9 */
10
11 #include <stdio.h>
12
13 #include "paths.h"
14
15
16 FILE *
17 frlibopen(fname) /* find file and open for reading */
18 register char *fname;
19 {
20 extern char *strcpy(), *getlibpath();
21 FILE *fp;
22 char pname[MAXPATH];
23 register char *sp, *cp;
24
25 if (fname == NULL)
26 return(NULL);
27
28 if (ISDIRSEP(fname[0]) || fname[0] == '.') /* absolute path */
29 return(fopen(fname, "r"));
30 /* check search path */
31 sp = getlibpath();
32 do {
33 cp = pname;
34 while (*sp && (*cp = *sp++) != PATHSEP)
35 cp++;
36 if (cp > pname && !ISDIRSEP(cp[-1]))
37 *cp++ = DIRSEP;
38 strcpy(cp, fname);
39 if ((fp = fopen(pname, "r")) != NULL)
40 return(fp); /* got it! */
41 } while (*sp);
42 /* not found */
43 return(NULL);
44 }