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

Comparing ray/src/common/paths.h (file contents):
Revision 2.8 by greg, Mon Jun 24 10:01:11 1996 UTC vs.
Revision 2.16 by schorsch, Mon Jun 30 14:59:11 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   * Definitions for paths on different machines
4   */
5 + #ifndef _RAD_PATHS_H_
6 + #define _RAD_PATHS_H_
7 + #ifdef __cplusplus
8 + extern "C" {
9 + #endif
10  
11 < #ifdef MSDOS
11 > #include <stdio.h>
12 > #include <stdlib.h>
13 > #include <string.h>
14  
15 < #define DIRSEP          '/'
16 < #define ISDIRSEP(c)     ((c)=='/' || (c)=='\\')
17 < #define CASEDIRSEP      case '/': case '\\'
18 < #define PATHSEP         ';'
19 < #define MAXPATH         128
20 < #define TEMPLATE        "rtXXXXXX"
21 < #define TEMPLEN         8
22 < #define ULIBVAR         "RAYPATH"
23 < #ifndef DEFPATH
24 < #define DEFPATH         ";c:/ray/lib"
25 < #endif
15 > #ifdef _WIN32
16 >  #include <io.h>
17 >
18 >  #define access _access
19 >  #define PATH_MAX _MAX_PATH
20 >  #define DIRSEP                '/'
21 >  #define ISDIRSEP(c)   ((c)=='/' || (c)=='\\')
22 >  #define ISABS(s)      ((s)!=NULL \
23 >                  && (s[0])!='\0' \
24 >          && (   ISDIRSEP(s[0]) \
25 >              || (   (s[1])!='\0' \
26 >                  && (isupper(s[0])||islower(s[0])) \
27 >                  && (s[1])==':')))
28 >  #define CASEDIRSEP    case '/': case '\\'
29 >  #define PATHSEP               ';'
30 >  #define CURDIR                '.'
31 >  /*#define MAXPATH             512*/ /* obsoleted by posix PATH_MAX */
32 >  #define DEFAULT_TEMPDIRS {"C:/TMP", "C:/TEMP", ".", NULL}
33 >  #define TEMPLATE      "rtXXXXXX"
34 >  #define TEMPLEN               8
35 >  #define ULIBVAR               "RAYPATH"
36 >  #ifndef DEFPATH
37 >    #define DEFPATH             ";c:/ray/lib"
38 >  #endif
39 >  /* <io.h> only does half the work for access() */
40 >  #ifndef F_OK
41 >    #define  F_OK 00
42 >    #define  X_OK 01
43 >    #define  W_OK 02
44 >    #define  R_OK 04
45 >  #endif
46   extern char  *fixargv0();
47  
48 < #else
49 < #ifdef AMIGA
48 > #else /* everything but Windows */
49 >  #include <unistd.h>
50 >  #include <sys/param.h>
51  
52 < #define DIRSEP          '/'
53 < #define PATHSEP         ';'
54 < #define MAXPATH         128
55 < #define TEMPLATE        "/tmp/rtXXXXXX"
56 < #define TEMPLEN         13
57 < #define ULIBVAR         "RAYPATH"
58 < #ifndef DEFPATH
34 < #define DEFPATH         ";/ray/lib"
35 < #endif
36 < #define  fixargv0(a0)   (a0)
52 >  #define RMAX_PATH_MAX 4096 /* our own maximum */
53 >  #ifndef PATH_MAX
54 >    #define PATH_MAX 512
55 >  #elif PATH_MAX > RMAX_PATH_MAX /* the OS is exaggerating */
56 >    #undef PATH_MAX
57 >    #define PATH_MAX RMAX_PATH_MAX
58 >  #endif
59  
60 < #else
60 >  #ifdef AMIGA
61  
62 < #define DIRSEP          '/'
63 < #define PATHSEP         ':'
64 < #define MAXPATH         256
65 < #define TEMPLATE        "/usr/tmp/rtXXXXXX"
66 < #define TEMPLEN         17
67 < #define ULIBVAR         "RAYPATH"
68 < #ifndef DEFPATH
69 < #define DEFPATH         ":/usr/local/lib/ray"
70 < #endif
71 < #define  fixargv0(a0)   (a0)
62 >    #define DIRSEP              '/'
63 >    #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0])))
64 >    #define PATHSEP             ';'
65 >        #define CURDIR          '.'
66 >    /*#define MAXPATH           128*/ /* obsoleted by posix PATH_MAX */
67 >    #define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
68 >    #define TEMPLATE    "/tmp/rtXXXXXX"
69 >    #define TEMPLEN             13
70 >    #define ULIBVAR             "RAYPATH"
71 >    #ifndef DEFPATH
72 >      #define DEFPATH           ";/ray/lib"
73 >    #endif
74 >    #define      fixargv0(a0)   (a0)
75  
76 +  #else
77 +
78 +    /* posix */
79 +
80 +        /* this is defined as _PATH_DEVNULL in /usr/include/paths.h on Linux */
81 +        #define NULL_DEVICE     "/dev/null"
82 +    #define DIRSEP              '/'
83 +    #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0])))
84 +    #define PATHSEP             ':'
85 +        #define CURDIR          '.'
86 +    /*#define MAXPATH           256*/ /* obsoleted by posix PATH_MAX */
87 +    #define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
88 +    #define TEMPLATE    "/usr/tmp/rtXXXXXX"
89 +    #define TEMPLEN             17
90 +    #define ULIBVAR             "RAYPATH"
91 +    #ifndef DEFPATH
92 +      #define DEFPATH           ":/usr/local/lib/ray"
93 +    #endif
94 +    #define      fixargv0(a0)   (a0)
95 +
96 +  #endif
97   #endif
52 #endif
98  
99   #ifndef ISDIRSEP
100 < #define ISDIRSEP(c)     ((c)==DIRSEP)
100 >  #define ISDIRSEP(c)   ((c)==DIRSEP)
101   #endif
102   #ifndef CASEDIRSEP
103 < #define CASEDIRSEP      case DIRSEP
103 >  #define CASEDIRSEP    case DIRSEP
104   #endif
105  
61 extern char  *mktemp(), *getenv();
106  
107 < #ifdef BSD
108 < extern char  *getwd();
109 < #else
110 < extern char  *getcwd();
111 < #define  getwd(p)       getcwd(p, sizeof(p))
107 > /* Find a writeable directory for temporary files */
108 > /* If s is NULL, we return a static string */
109 > extern char *temp_directory(char *s, size_t len);
110 >
111 > /* Compose a *currently* unique name within a temporary directory */
112 > /* If s is NULL, we return a static string */
113 > /* If templ is NULL, we take our default template */
114 > /* WARNING: On Windows, there's a maximum of 27 unique names within
115 >            one process for the same template. */
116 > extern char *temp_filename(char *s, size_t len, char *templ);
117 >
118 > /* Same as above, but also open the file and return the descriptor */
119 > /* This one is supposed to protect against race conditions on unix */
120 > /* WARNING: On Windows, there's no protection against race conditions */
121 > extern int temp_fd(char *s, size_t len, char *templ);
122 >
123 > /* Same as above, but return a file pointer instead of a descriptor */
124 > extern FILE *temp_fp(char *s, size_t len, char *templ);
125 >
126 > /* Concatenate two strings, leaving exactly one DIRSEP in between */
127 > extern char *append_filepath(char *s1, char *s2, size_t len);
128 >
129 >
130 > #ifdef __cplusplus
131 > }
132   #endif
133 + #endif /* _RAD_PATHS_H_ */
134 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines