file.c revision a548a3c20cf520a61b7e6c6332de51bae2314e45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: file.c,v 1.37 2001/07/16 17:26:44 gson Exp $ */
#include <config.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h> /* Required for utimes on some platforms. */
#include <unistd.h> /* Required for mkstemp on NetBSD. */
#include "errno2result.h"
/*
* XXXDCL As the API for accessing file statistics undoubtedly gets expanded,
* it might be good to provide a mechanism that allows for the results
* of a previous stat() to be used again without having to do another stat,
* such as perl's mechanism of using "_" in place of a file name to indicate
* that the results of the last stat should be used. But then you get into
* annoying MP issues. BTW, Win32 has stat().
*/
static isc_result_t
return (result);
}
if (result == ISC_R_SUCCESS)
/*
* XXXDCL some operating systems provide nanoseconds, too,
*/
return (result);
}
/*
* tv_sec is at least a 32 bit quantity on all platforms we're
* dealing with, but it is signed on most (all?) of them,
* so we need to make sure the high bit isn't set. This unfortunately
* loses when either:
* * tv_sec becomes a signed 64 bit integer but long is 32 bits
* and isc_time_seconds > LONG_MAX, or
* * isc_time_seconds is changed to be > 32 bits but long is 32 bits
* and isc_time_seconds has at least 33 significant bits.
*/
/*
* Here is the real check for the high bit being set.
*/
return (ISC_R_RANGE);
/*
* isc_time_nanoseconds guarantees a value that divided by 1000 will
* fit into the minimum possible size tv_usec field. Unfortunately,
* we don't know what that type is so can't cast directly ... but
* we can at least cast to signed so the IRIX compiler shuts up.
*/
return (isc__errno2result(errno));
return (ISC_R_SUCCESS);
}
}
char *s;
if (s != NULL)
templet = s + 1;
if (s != NULL) {
return (ISC_R_NOSPACE);
} else {
return (ISC_R_NOSPACE);
}
return (ISC_R_SUCCESS);
}
int fd = -1;
int res = 0;
if (fd == -1) {
}
if (result == ISC_R_SUCCESS) {
if (res != 0) {
}
}
if (fd != -1)
return (result);
}
int fd;
FILE *f;
/*
* Win32 does not have mkstemp.
*/
if (fd == -1)
if (result == ISC_R_SUCCESS) {
if (f == NULL) {
} else
*fp = f;
}
return (result);
}
isc_file_remove(const char *filename) {
int r;
if (r == 0)
return (ISC_R_SUCCESS);
else
return (isc__errno2result(errno));
}
int r;
if (r == 0)
return (ISC_R_SUCCESS);
else
return (isc__errno2result(errno));
}
isc_file_exists(const char *pathname) {
}
isc_file_isabsolute(const char *filename) {
}
isc_file_iscurrentdir(const char *filename) {
}
const char *
isc_file_basename(const char *filename) {
char *s;
if (s == NULL)
return (filename);
return (s + 1);
}
const char *base;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}