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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines