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