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.13 by schorsch, Sun Jun 8 12:01:52 2003 UTC vs.
Revision 2.29 by greg, Mon May 8 16:58:52 2017 UTC

# Line 4 | Line 4
4   */
5   #ifndef _RAD_PATHS_H_
6   #define _RAD_PATHS_H_
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
7  
8 < #include "copyright.h"
12 <
8 > #include <stdio.h>
9   #include <stdlib.h>
10   #include <string.h>
11 < #ifdef _WIN32
12 < #include <io.h>
13 < #define access _access
18 < #define PATH_MAX _MAX_PATH
19 < #else /* _WIN32 */
20 < #include <unistd.h>
21 < #include <sys/param.h>
22 < #endif /* _WIN32 */
11 > #include <fcntl.h>
12 > #include <sys/types.h>
13 > #include <sys/stat.h>
14  
15 < #ifdef _WIN32
15 > #if defined(_WIN32) || defined(_WIN64)
16 >  #include <io.h>
17 >  #include <direct.h> /* getcwd(), chdir(), _mkdir(), etc. */
18 >  #define getcwd _getcwd
19 >  #define chdir _chdir
20  
21 < #define DIRSEP          '/'
22 < #define ISDIRSEP(c)     ((c)=='/' || (c)=='\\')
23 < #define ISABS(s)        ((s)!=NULL \
24 <        && (s[0])!='\0' \
25 <        && (   ISDIRSEP(s[0]) \
26 <            || (   (s[1])!='\0' \
27 <                && (isupper(s[0])||islower(s[0])) \
28 <                && (s[1])==':')))
29 < #define CASEDIRSEP      case '/': case '\\'
30 < #define PATHSEP         ';'
31 < #define MAXPATH         128
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  W_OK 02
43 < #define  R_OK 04
44 < #endif
45 < extern char  *fixargv0();
21 >  #define access                _access
22 >  #define mkdir(dirname,perms)  _mkdir(dirname)
23 >  /* The windows _popen with the native shell breaks '\\\n' escapes.
24 >   * RT_WINPROC (used by SCons) enables our replacement functions to fix that.
25 >   * XXX This should really not depend on the compiler used! */
26 >  #if defined(_MSC_VER) && !defined(RT_WINPROC)
27 >    #define popen(cmd,mode)     _popen(cmd,mode)
28 >    #define pclose(p)           _pclose(p)
29 >  #else
30 >    #define popen(cmd,mode)     win_popen(cmd,mode)
31 >    #define pclose(p)           win_pclose(p)
32 >  #endif
33 >  #define kill(pid,sig)         win_kill(pid,sig)
34 >  #define nice(inc)             win_nice(inc)
35 >  #define PATH_MAX              _MAX_PATH
36 >  #define NULL_DEVICE           "NUL"
37 >  #define DIRSEP                '/'
38 >  #define ISDIRSEP(c)           (((c)=='/') | ((c)=='\\'))
39 >  #define ISABS(s)              ( ISDIRSEP((s)[0]) \
40 >                || ( isupper((s)[0]) | islower((s)[0]) \
41 >                        && (s)[1]==':' && ISDIRSEP((s)[2]) ) )
42 >  #define CASEDIRSEP            case '/': case '\\'
43 >  #define PATHSEP               ';'
44 >  #define CURDIR                '.'
45 >  #define DEFAULT_TEMPDIRS      {"C:/TMP", "C:/TEMP", ".", NULL}
46 >  #define TEMPLATE              "rtXXXXXX"
47 >  #define TEMPLEN               8
48 >  #define ULIBVAR               "RAYPATH"
49 >  #ifndef DEFPATH
50 >    #define DEFPATH             ";c:/ray/lib"
51 >  #endif
52 >  #define SPECIALS              " \t\"$*?|"
53 >  #define QUOTCHAR              '"'
54 >  /* <io.h> only does half the work for access() */
55 >  #ifndef F_OK
56 >    #define  F_OK 00
57 >    #define  W_OK 02
58 >  #endif
59 >  #ifndef R_OK
60 >    #define X_OK 01
61 >    #define R_OK 04
62 >  #endif
63 >  /* to make the permissions user specific we'd need to use CreateFile() */
64 >  #ifndef S_IRUSR
65 >    #define S_IRUSR _S_IREAD
66 >    #define S_IWUSR _S_IWRITE
67 >  #endif
68  
69 < #else
70 < #ifdef AMIGA
69 > #else /* everything but Windows */
70 >  #include <unistd.h>
71 >  #include <sys/param.h>
72  
73 < #define DIRSEP          '/'
74 < #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0])))
75 < #define PATHSEP         ';'
76 < #define MAXPATH         128
77 < #define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
78 < #define TEMPLATE        "/tmp/rtXXXXXX"
79 < #define TEMPLEN         13
62 < #define ULIBVAR         "RAYPATH"
63 < #ifndef DEFPATH
64 < #define DEFPATH         ";/ray/lib"
65 < #endif
66 < #define  fixargv0(a0)   (a0)
73 >  #define RMAX_PATH_MAX 4096 /* our own maximum */
74 >  #ifndef PATH_MAX
75 >    #define PATH_MAX 512
76 >  #elif PATH_MAX > RMAX_PATH_MAX /* the OS is exaggerating */
77 >    #undef PATH_MAX
78 >    #define PATH_MAX RMAX_PATH_MAX
79 >  #endif
80  
81 < #else
81 >  #ifdef AMIGA
82  
83 < #define DIRSEP          '/'
84 < #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0])))
85 < #define PATHSEP         ':'
86 < #define MAXPATH         256
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)
83 >        #define NULL_DEVICE     "NIL:"
84 >    #define DIRSEP              '/'
85 >    #define ISABS(s)            ISDIRSEP((s)[0])
86 >    #define PATHSEP             ';'
87 >        #define CURDIR          '.'
88 >    #define DEFAULT_TEMPDIRS    {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
89 >    #define TEMPLATE            "/tmp/rtXXXXXX"
90 >    #define TEMPLEN             13
91 >    #define ULIBVAR             "RAYPATH"
92 >    #ifndef DEFPATH
93 >      #define DEFPATH           ";/ray/lib"
94 >    #endif
95 >    #define      fixargv0(a0)   (a0)
96  
97 +  #else
98 +
99 +    /* posix */
100 +
101 +        /* this is defined as _PATH_DEVNULL in /usr/include/paths.h on Linux */
102 +        #define NULL_DEVICE     "/dev/null"
103 +    #define DIRSEP              '/'
104 +    #define ISABS(s)            ISDIRSEP((s)[0])
105 +    #define PATHSEP             ':'
106 +        #define CURDIR          '.'
107 +    #define DEFAULT_TEMPDIRS    {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
108 +    #define TEMPLATE            "/tmp/rtXXXXXX"
109 +    #define TEMPLEN             17
110 +    #define ULIBVAR             "RAYPATH"
111 +    #ifndef DEFPATH
112 +      #define DEFPATH           ":/usr/local/lib/ray"
113 +    #endif
114 +    #define SPECIALS            " \t\n'\"()${}*?[];|&"
115 +    #define QUOTCHAR            '\''
116 +    #define ALTQUOT             '"'
117 +    #define      fixargv0(a0)   (a0)
118 +
119 +  #endif
120   #endif
84 #endif
121  
122   #ifndef ISDIRSEP
123 < #define ISDIRSEP(c)     ((c)==DIRSEP)
123 >  #define ISDIRSEP(c)   ((c)==DIRSEP)
124   #endif
125   #ifndef CASEDIRSEP
126 < #define CASEDIRSEP      case DIRSEP
126 >  #define CASEDIRSEP    case DIRSEP
127   #endif
128  
129 < extern char  *mktemp(), *getenv();
129 > #ifdef __cplusplus
130 > extern "C" {
131 > #endif
132  
133 < #ifdef BSD
134 < extern char  *getwd();
135 < #else
136 < extern char  *getcwd();
99 < #define  getwd(p)       getcwd(p, sizeof(p))
133 > #if defined(_WIN32) || defined(_WIN64)
134 >  extern FILE *win_popen(char *command, char *type);
135 >  extern int win_pclose(FILE *p);
136 >  extern char  *fixargv0(char *arg0);
137   #endif
138  
139 + /* Check if any of the characters in str2 are found in str1 */
140 + extern int matchany(const char *str1, const char *str2);
141  
142 + /* Convert a set of arguments into a command line for pipe() or system() */
143 + extern char *convert_commandline(char *cmd, const int len, char *av[]);
144 +
145   /* Find a writeable directory for temporary files */
146   /* If s is NULL, we return a static string */
147   extern char *temp_directory(char *s, size_t len);
# Line 114 | Line 156 | extern char *temp_filename(char *s, size_t len, char *
156   /* Same as above, but also open the file and return the descriptor */
157   /* This one is supposed to protect against race conditions on unix */
158   /* WARNING: On Windows, there's no protection against race conditions */
159 < extern int temp_file(char *s, size_t len, char *templ);
159 > extern int temp_fd(char *s, size_t len, char *templ);
160 >
161 > /* Same as above, but return a file pointer instead of a descriptor */
162 > extern FILE *temp_fp(char *s, size_t len, char *templ);
163  
164   /* Concatenate two strings, leaving exactly one DIRSEP in between */
165   extern char *append_filepath(char *s1, char *s2, size_t len);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines