file.c revision 77685300d90f3072f2b8249f4237a7e4c574ec0f
/*
* Copyright (C) 2000 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.
*/
#include <config.h>
#include <errno.h>
#include <stdlib.h>
#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.
*/
(long)isc_time_seconds(time);
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) {
return (ISC_R_NOSPACE);
} else {
return (ISC_R_NOSPACE);
}
return (ISC_R_SUCCESS);
}
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));
}