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.9 by greg, Sat Feb 22 02:07:22 2003 UTC vs.
Revision 2.32 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 1 | Line 1
1 < /* RCSid: $Id$ */
1 > /* RCSid $Id$ */
2   /*
3   * Definitions for paths on different machines
4   */
5 + #ifndef _RAD_PATHS_H_
6 + #define _RAD_PATHS_H_
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
12 < * Redistribution and use in source and binary forms, with or without
13 < * modification, are permitted provided that the following conditions
14 < * are met:
15 < *
16 < * 1. Redistributions of source code must retain the above copyright
17 < *         notice, this list of conditions and the following disclaimer.
18 < *
19 < * 2. Redistributions in binary form must reproduce the above copyright
20 < *       notice, this list of conditions and the following disclaimer in
21 < *       the documentation and/or other materials provided with the
22 < *       distribution.
23 < *
24 < * 3. The end-user documentation included with the redistribution,
25 < *           if any, must include the following acknowledgment:
26 < *             "This product includes Radiance software
27 < *                 (http://radsite.lbl.gov/)
28 < *                 developed by the Lawrence Berkeley National Laboratory
29 < *               (http://www.lbl.gov/)."
30 < *       Alternately, this acknowledgment may appear in the software itself,
31 < *       if and wherever such third-party acknowledgments normally appear.
32 < *
33 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
34 < *       and "The Regents of the University of California" must
35 < *       not be used to endorse or promote products derived from this
36 < *       software without prior written permission. For written
37 < *       permission, please contact [email protected].
38 < *
39 < * 5. Products derived from this software may not be called "Radiance",
40 < *       nor may "Radiance" appear in their name, without prior written
41 < *       permission of Lawrence Berkeley National Laboratory.
42 < *
43 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
44 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
47 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
50 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 < * SUCH DAMAGE.
55 < * ====================================================================
56 < *
57 < * This software consists of voluntary contributions made by many
58 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
59 < * information on Lawrence Berkeley National Laboratory, please see
60 < * <http://www.lbl.gov/>.
61 < */
8 > #include <stdio.h>
9 > #include <stdlib.h>
10 > #include <string.h>
11 > #include <fcntl.h>
12 > #include <sys/types.h>
13 > #include <sys/stat.h>
14  
15 < #ifdef MSDOS
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 CASEDIRSEP      case '/': case '\\'
24 < #define PATHSEP         ';'
25 < #define MAXPATH         128
26 < #define TEMPLATE        "rtXXXXXX"
27 < #define TEMPLEN         8
28 < #define ULIBVAR         "RAYPATH"
29 < #ifndef DEFPATH
30 < #define DEFPATH         ";c:/ray/lib"
31 < #endif
32 < 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 1 /* 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 PATHSEP         ';'
75 < #define MAXPATH         128
76 < #define TEMPLATE        "/tmp/rtXXXXXX"
77 < #define TEMPLEN         13
78 < #define ULIBVAR         "RAYPATH"
79 < #ifndef DEFPATH
88 < #define DEFPATH         ";/ray/lib"
89 < #endif
90 < #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 PATHSEP         ':'
85 < #define MAXPATH         256
86 < #define TEMPLATE        "/usr/tmp/rtXXXXXX"
87 < #define TEMPLEN         17
88 < #define ULIBVAR         "RAYPATH"
89 < #ifndef DEFPATH
90 < #define DEFPATH         ":/usr/local/lib/ray"
91 < #endif
92 < #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  
96 +  #else
97 +
98 +    /* posix */
99 +
100 +        /* this is defined as _PATH_DEVNULL in /usr/include/paths.h on Linux */
101 +        #define NULL_DEVICE     "/dev/null"
102 +    #define DIRSEP              '/'
103 +    #define ISABS(s)            ISDIRSEP((s)[0])
104 +    #define PATHSEP             ':'
105 +        #define CURDIR          '.'
106 +    #define DEFAULT_TEMPDIRS    {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL}
107 +    #define TEMPLATE            "/tmp/rtXXXXXX"
108 +    #define TEMPLEN             13
109 +    #define ULIBVAR             "RAYPATH"
110 +    #ifndef DEFPATH
111 +      #define DEFPATH           ":/usr/local/lib/ray"
112 +    #endif
113 +    #define SPECIALS            " \t\n'\"()${}*?[];|&"
114 +    #define QUOTCHAR            '\''
115 +    #define ALTQUOT             '"'
116 +
117 +  #endif
118   #endif
106 #endif
119  
120   #ifndef ISDIRSEP
121 < #define ISDIRSEP(c)     ((c)==DIRSEP)
121 >  #define ISDIRSEP(c)   ((c)==DIRSEP)
122   #endif
123   #ifndef CASEDIRSEP
124 < #define CASEDIRSEP      case DIRSEP
124 >  #define CASEDIRSEP    case DIRSEP
125   #endif
126  
127 < extern char  *mktemp(), *getenv();
127 > #ifdef __cplusplus
128 > extern "C" {
129 > #endif
130  
131 < #ifdef BSD
132 < extern char  *getwd();
133 < #else
120 < extern char  *getcwd();
121 < #define  getwd(p)       getcwd(p, sizeof(p))
131 > #if defined(_WIN32) || defined(_WIN64)
132 >  extern FILE *win_popen(char *command, char *type);
133 >  extern int win_pclose(FILE *p);
134   #endif
135 +
136 + /* Set global progname and return path-free version of argv[0] */
137 + extern char  *fixargv0(char *arg0);
138 + extern char  *progname;
139 +
140 + /* Check if any of the characters in str2 are found in str1 */
141 + extern int matchany(const char *str1, const char *str2);
142 +
143 + /* Convert a set of arguments into a command line for pipe() or system() */
144 + extern char *convert_commandline(char *cmd, const int len, char *av[]);
145 +
146 + /* Find a writeable directory for temporary files */
147 + /* If s is NULL, we return a static string */
148 + extern char *temp_directory(char *s, size_t len);
149 +
150 + /* Compose a *currently* unique name within a temporary directory */
151 + /* If s is NULL, we return a static string */
152 + /* If templ is NULL, we take our default template */
153 + /* WARNING: On Windows, there's a maximum of 27 unique names within
154 +            one process for the same template. */
155 + extern char *temp_filename(char *s, size_t len, char *templ);
156 +
157 + /* Same as above, but also open the file and return the descriptor */
158 + /* This one is supposed to protect against race conditions on unix */
159 + /* WARNING: On Windows, there's no protection against race conditions */
160 + extern int temp_fd(char *s, size_t len, char *templ);
161 +
162 + /* Same as above, but return a file pointer instead of a descriptor */
163 + extern FILE *temp_fp(char *s, size_t len, char *templ);
164 +
165 + /* Concatenate two strings, leaving exactly one DIRSEP in between */
166 + extern char *append_filepath(char *s1, char *s2, size_t len);
167 +
168 +
169 + #ifdef __cplusplus
170 + }
171 + #endif
172 + #endif /* _RAD_PATHS_H_ */
173 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines