ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fropen.c
Revision: 2.16
Committed: Thu Dec 19 16:38:12 2013 UTC (10 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R2P1, rad5R3, HEAD
Changes since 2.15: +5 -4 lines
Log Message:
Changed rcalc and icalc to search RAYPATH for input *.cal files

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: fropen.c,v 2.15 2012/06/29 23:09:06 greg Exp $";
3 #endif
4 /*
5 * Find and open a Radiance library file.
6 *
7 * External symbols declared in rtio.h
8 */
9
10 #include "copyright.h"
11
12 #include <stdio.h>
13
14 #include "rtio.h"
15 #include "paths.h"
16
17
18 FILE *
19 frlibopen( /* find file and open for reading */
20 char *fname
21 )
22 {
23 FILE *fp;
24 char pname[PATH_MAX];
25 char *sp, *cp;
26
27 if (fname == NULL)
28 return(NULL);
29
30 if (ISABS(fname) || fname[0] == '.') /* absolute path */
31 return(fopen(fname, "r"));
32 /* check search path */
33 sp = getrlibpath();
34 do {
35 cp = pname;
36 while (*sp && (*cp = *sp++) != PATHSEP)
37 cp++;
38 if (cp > pname && !ISDIRSEP(cp[-1]))
39 *cp++ = DIRSEP;
40 strcpy(cp, fname);
41 if ((fp = fopen(pname, "r")) != NULL)
42 return(fp); /* got it! */
43 } while (*sp);
44 /* not found */
45 return(NULL);
46 }