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.1 by greg, Tue Sep 8 09:08:02 1992 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 NIX
11 > #include <stdio.h>
12 > #include <stdlib.h>
13 > #include <string.h>
14  
15 < #ifdef MSDOS
15 > #ifdef _WIN32
16 >  #include <io.h>
17  
18 < #define DIRSEP          '\\'
19 < #define PATHSEP         ';'
20 < #define TEMPLATE        "c:\\tmp\\rtXXXXXX"
21 < #define TEMPLEN         15
22 < #define ULIBVAR         "RAYPATH"
23 < #ifndef DEFPATH
24 < #define DEFPATH         ";\\ray\\lib"
25 < #endif
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 < #endif
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 TEMPLATE        "/tmp/rtXXXXXX"
55 < #define TEMPLEN         13
56 < #define ULIBVAR         "RAYPATH"
57 < #ifndef DEFPATH
58 < #define DEFPATH         ";/ray/lib"
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 >  #ifdef AMIGA
61 >
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
98  
99 + #ifndef ISDIRSEP
100 +  #define ISDIRSEP(c)   ((c)==DIRSEP)
101   #endif
102 + #ifndef CASEDIRSEP
103 +  #define CASEDIRSEP    case DIRSEP
104 + #endif
105  
36 #else
106  
107 < #define DIRSEP          '/'
108 < #define PATHSEP         ':'
109 < #define TEMPLATE        "/tmp/rtXXXXXX"
41 < #define TEMPLEN         13
42 < #define ULIBVAR         "RAYPATH"
43 < #ifndef DEFPATH
44 < #define DEFPATH         ":/usr/local/lib/ray"
45 < #endif
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  
49 extern char  *mktemp(), *getenv();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines