ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fropen.c
(Generate patch)

Comparing ray/src/common/fropen.c (file contents):
Revision 2.3 by greg, Tue Jun 16 13:07:45 1992 UTC vs.
Revision 2.13 by schorsch, Thu Jul 17 09:21:29 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1990 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Find and open a Radiance library file.
6 + *
7 + *  External symbols declared in standard.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include <stdio.h>
13  
14 < #ifndef DEFPATH
15 < #define DEFPATH         ":/usr/local/lib/ray"
15 < #endif
16 < #ifndef ULIBVAR
17 < #define ULIBVAR         "RAYPATH"
18 < #endif
19 < #ifndef DIRSEP
20 < #define DIRSEP          '/'
21 < #endif
22 < #ifndef PATHSEP
23 < #define PATHSEP         ':'
24 < #endif
14 > #include "rtio.h"
15 > #include "paths.h"
16  
26 char  *libpath = NULL;          /* library search path */
17  
28
18   FILE *
19 < fropen(fname)                   /* find file and open for reading */
19 > frlibopen(fname)                /* find file and open for reading */
20   register char  *fname;
21   {
22 <        extern char  *strcpy(), *getenv();
22 >        extern char  *getrlibpath();
23          FILE  *fp;
24 <        char  pname[256];
24 >        char  pname[PATH_MAX];
25          register char  *sp, *cp;
26  
27          if (fname == NULL)
28                  return(NULL);
29  
30 <        if (fname[0] == DIRSEP || fname[0] == '.')      /* absolute path */
30 >        if (ISDIRSEP(fname[0]) || fname[0] == '.')      /* absolute path */
31                  return(fopen(fname, "r"));
43                
44        if (libpath == NULL) {                  /* get search path */
45                libpath = getenv(ULIBVAR);
46                if (libpath == NULL)
47                        libpath = DEFPATH;
48        }
32                                                  /* check search path */
33 <        sp = libpath;
33 >        sp = getrlibpath();
34          do {
35                  cp = pname;
36                  while (*sp && (*cp = *sp++) != PATHSEP)
37                          cp++;
38 <                if (cp > pname && cp[-1] != DIRSEP)
38 >                if (cp > pname && !ISDIRSEP(cp[-1]))
39                          *cp++ = DIRSEP;
40                  strcpy(cp, fname);
41                  if ((fp = fopen(pname, "r")) != NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines