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 <stdlib.h> |
12 |
> |
#include <string.h> |
13 |
> |
#ifdef _WIN32 |
14 |
> |
#include <io.h> |
15 |
> |
#else /* _WIN32 */ |
16 |
> |
#include <unistd.h> |
17 |
> |
#include <sys/param.h> |
18 |
> |
#endif /* _WIN32 */ |
19 |
|
|
20 |
< |
#ifdef MSDOS |
20 |
> |
#ifdef _WIN32 |
21 |
|
|
22 |
< |
#define DIRSEP '\\' |
23 |
< |
#define PATHSEP ';' |
24 |
< |
#define TEMPLATE "c:\\tmp\\rtXXXXXX" |
25 |
< |
#define TEMPLEN 15 |
26 |
< |
#define ULIBVAR "RAYPATH" |
27 |
< |
#ifndef DEFPATH |
28 |
< |
#define DEFPATH ";\\ray\\lib" |
29 |
< |
#endif |
22 |
> |
#define access _access |
23 |
> |
#define PATH_MAX _MAX_PATH |
24 |
> |
#define DIRSEP '/' |
25 |
> |
#define ISDIRSEP(c) ((c)=='/' || (c)=='\\') |
26 |
> |
#define ISABS(s) ((s)!=NULL \ |
27 |
> |
&& (s[0])!='\0' \ |
28 |
> |
&& ( ISDIRSEP(s[0]) \ |
29 |
> |
|| ( (s[1])!='\0' \ |
30 |
> |
&& (isupper(s[0])||islower(s[0])) \ |
31 |
> |
&& (s[1])==':'))) |
32 |
> |
#define CASEDIRSEP case '/': case '\\' |
33 |
> |
#define PATHSEP ';' |
34 |
> |
#define CURDIR '.' |
35 |
> |
#define MAXPATH 512 /* XXX obsoleted by posix PATH_MAX */ |
36 |
> |
#define DEFAULT_TEMPDIRS {"C:/TMP", "C:/TEMP", ".", NULL} |
37 |
> |
#define TEMPLATE "rtXXXXXX" |
38 |
> |
#define TEMPLEN 8 |
39 |
> |
#define ULIBVAR "RAYPATH" |
40 |
> |
#ifndef DEFPATH |
41 |
> |
#define DEFPATH ";c:/ray/lib" |
42 |
> |
#endif |
43 |
> |
/* <io.h> only does half the work for access() */ |
44 |
> |
#ifndef F_OK |
45 |
> |
#define F_OK 00 |
46 |
> |
#define X_OK 01 |
47 |
> |
#define W_OK 02 |
48 |
> |
#define R_OK 04 |
49 |
> |
#endif |
50 |
> |
extern char *fixargv0(); |
51 |
|
|
52 |
< |
#endif |
53 |
< |
#ifdef AMIGA |
52 |
> |
#else |
53 |
> |
#ifndef PATH_MAX /* doesn't implement posix? */ |
54 |
> |
#define PATH_MAX 512 /* quite conservative (I think...) */ |
55 |
> |
#endif |
56 |
|
|
57 |
< |
#define DIRSEP '/' |
58 |
< |
#define PATHSEP ';' |
59 |
< |
#define TEMPLATE "/tmp/rtXXXXXX" |
60 |
< |
#define TEMPLEN 13 |
61 |
< |
#define ULIBVAR "RAYPATH" |
62 |
< |
#ifndef DEFPATH |
63 |
< |
#define DEFPATH ";/ray/lib" |
57 |
> |
#ifdef AMIGA |
58 |
> |
|
59 |
> |
#define DIRSEP '/' |
60 |
> |
#define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0]))) |
61 |
> |
#define PATHSEP ';' |
62 |
> |
#define CURDIR '.' |
63 |
> |
#define MAXPATH 128 |
64 |
> |
#define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL} |
65 |
> |
#define TEMPLATE "/tmp/rtXXXXXX" |
66 |
> |
#define TEMPLEN 13 |
67 |
> |
#define ULIBVAR "RAYPATH" |
68 |
> |
#ifndef DEFPATH |
69 |
> |
#define DEFPATH ";/ray/lib" |
70 |
> |
#endif |
71 |
> |
#define fixargv0(a0) (a0) |
72 |
> |
|
73 |
> |
#else |
74 |
> |
|
75 |
> |
#define DIRSEP '/' |
76 |
> |
#define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0]))) |
77 |
> |
#define PATHSEP ':' |
78 |
> |
#define CURDIR '.' |
79 |
> |
#define MAXPATH 256 |
80 |
> |
#define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL} |
81 |
> |
#define TEMPLATE "/usr/tmp/rtXXXXXX" |
82 |
> |
#define TEMPLEN 17 |
83 |
> |
#define ULIBVAR "RAYPATH" |
84 |
> |
#ifndef DEFPATH |
85 |
> |
#define DEFPATH ":/usr/local/lib/ray" |
86 |
> |
#endif |
87 |
> |
#define fixargv0(a0) (a0) |
88 |
> |
|
89 |
> |
#endif |
90 |
|
#endif |
91 |
|
|
92 |
+ |
#ifndef ISDIRSEP |
93 |
+ |
#define ISDIRSEP(c) ((c)==DIRSEP) |
94 |
|
#endif |
95 |
+ |
#ifndef CASEDIRSEP |
96 |
+ |
#define CASEDIRSEP case DIRSEP |
97 |
+ |
#endif |
98 |
|
|
99 |
< |
#else |
99 |
> |
extern char *mktemp(), *getenv(); |
100 |
|
|
101 |
< |
#define DIRSEP '/' |
102 |
< |
#define PATHSEP ':' |
103 |
< |
#define TEMPLATE "/tmp/rtXXXXXX" |
104 |
< |
#define TEMPLEN 13 |
105 |
< |
#define ULIBVAR "RAYPATH" |
43 |
< |
#ifndef DEFPATH |
44 |
< |
#define DEFPATH ":/usr/local/lib/ray" |
101 |
> |
#ifdef BSD |
102 |
> |
extern char *getwd(); |
103 |
> |
#else |
104 |
> |
extern char *getcwd(); |
105 |
> |
#define getwd(p) getcwd(p, sizeof(p)) |
106 |
|
#endif |
107 |
|
|
108 |
+ |
|
109 |
+ |
/* Find a writeable directory for temporary files */ |
110 |
+ |
/* If s is NULL, we return a static string */ |
111 |
+ |
extern char *temp_directory(char *s, size_t len); |
112 |
+ |
|
113 |
+ |
/* Compose a *currently* unique name within a temporary directory */ |
114 |
+ |
/* If s is NULL, we return a static string */ |
115 |
+ |
/* If templ is NULL, we take our default template */ |
116 |
+ |
/* WARNING: On Windows, there's a maximum of 27 unique names within |
117 |
+ |
one process for the same template. */ |
118 |
+ |
extern char *temp_filename(char *s, size_t len, char *templ); |
119 |
+ |
|
120 |
+ |
/* Same as above, but also open the file and return the descriptor */ |
121 |
+ |
/* This one is supposed to protect against race conditions on unix */ |
122 |
+ |
/* WARNING: On Windows, there's no protection against race conditions */ |
123 |
+ |
extern int temp_file(char *s, size_t len, char *templ); |
124 |
+ |
|
125 |
+ |
/* Concatenate two strings, leaving exactly one DIRSEP in between */ |
126 |
+ |
extern char *append_filepath(char *s1, char *s2, size_t len); |
127 |
+ |
|
128 |
+ |
|
129 |
+ |
#ifdef __cplusplus |
130 |
+ |
} |
131 |
|
#endif |
132 |
+ |
#endif /* _RAD_PATHS_H_ */ |
133 |
|
|
49 |
– |
extern char *mktemp(), *getenv(); |