mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
isc_file_{stdiofunc} -> isc_stdio_*
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <isc/file.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/net.h> /* Required for ntohl. */
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -95,8 +96,7 @@ rdata_covers(dns_rdata_t *rdata) {
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
dns_soa_getserial(dns_rdata_t *rdata)
|
||||
{
|
||||
dns_soa_getserial(dns_rdata_t *rdata) {
|
||||
INSIST(rdata->type == dns_rdatatype_soa);
|
||||
/*
|
||||
* Locate the serial number within the SOA RDATA based
|
||||
@@ -115,8 +115,7 @@ dns_soa_getserial(dns_rdata_t *rdata)
|
||||
}
|
||||
|
||||
void
|
||||
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata)
|
||||
{
|
||||
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata) {
|
||||
INSIST(rdata->type == dns_rdatatype_soa);
|
||||
INSIST(rdata->length > 20);
|
||||
encode_uint32(val, rdata->data + rdata->length - 20);
|
||||
@@ -907,7 +906,7 @@ journal_header_encode(journal_header_t *cooked, journal_rawheader_t *raw) {
|
||||
static isc_result_t
|
||||
journal_seek(dns_journal_t *j, isc_uint32_t offset) {
|
||||
isc_result_t result;
|
||||
result = isc_file_fseek(j->fp, (long) offset, SEEK_SET);
|
||||
result = isc_stdio_seek(j->fp, (long)offset, SEEK_SET);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: seek: %s", j->filename,
|
||||
@@ -922,7 +921,7 @@ static isc_result_t
|
||||
journal_read(dns_journal_t *j, void *mem, size_t nbytes) {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_file_fread(mem, 1, nbytes, j->fp, NULL);
|
||||
result = isc_stdio_read(mem, 1, nbytes, j->fp, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
if (result == ISC_R_EOF)
|
||||
return (ISC_R_NOMORE);
|
||||
@@ -939,7 +938,7 @@ static isc_result_t
|
||||
journal_write(dns_journal_t *j, void *mem, size_t nbytes) {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_file_fwrite(mem, 1, nbytes, j->fp, NULL);
|
||||
result = isc_stdio_write(mem, 1, nbytes, j->fp, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: write: %s",
|
||||
@@ -953,14 +952,14 @@ journal_write(dns_journal_t *j, void *mem, size_t nbytes) {
|
||||
static isc_result_t
|
||||
journal_fsync(dns_journal_t *j) {
|
||||
isc_result_t result;
|
||||
result = isc_file_fflush(j->fp);
|
||||
result = isc_stdio_flush(j->fp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: flush: %s",
|
||||
j->filename, isc_result_totext(result));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
result = isc_file_ffsync(j->fp);
|
||||
result = isc_stdio_sync(j->fp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: fsync: %s",
|
||||
@@ -1026,7 +1025,7 @@ journal_file_create(isc_mem_t *mctx, const char *filename) {
|
||||
|
||||
INSIST(sizeof(journal_rawheader_t) == JOURNAL_HEADER_SIZE);
|
||||
|
||||
result = isc_file_fopen(filename, "w", &fp);
|
||||
result = isc_stdio_open(filename, "w", &fp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: create: %s",
|
||||
@@ -1043,26 +1042,26 @@ journal_file_create(isc_mem_t *mctx, const char *filename) {
|
||||
|
||||
mem = isc_mem_get(mctx, size);
|
||||
if (mem == NULL) {
|
||||
(void)isc_file_fclose(fp);
|
||||
(void)isc_stdio_close(fp);
|
||||
(void)isc_file_remove(filename);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
memset(mem, 0, size);
|
||||
memcpy(mem, &rawheader, sizeof(rawheader));
|
||||
|
||||
result = isc_file_fwrite(mem, 1, (size_t) size, fp, NULL);
|
||||
result = isc_stdio_write(mem, 1, (size_t) size, fp, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: write: %s",
|
||||
filename, isc_result_totext(result));
|
||||
(void)isc_file_fclose(fp);
|
||||
(void)isc_stdio_close(fp);
|
||||
(void)isc_file_remove(filename);
|
||||
isc_mem_put(mctx, mem, size);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
isc_mem_put(mctx, mem, size);
|
||||
|
||||
result = isc_file_fclose(fp);
|
||||
result = isc_stdio_close(fp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"%s: close: %s",
|
||||
@@ -1094,8 +1093,7 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
|
||||
j->filename = filename;
|
||||
j->index = NULL;
|
||||
|
||||
/* XXX isc_file_fopen() may need "b" (binary) on some platforms */
|
||||
result = isc_file_fopen(j->filename, write ? "r+" : "r", &fp);
|
||||
result = isc_stdio_open(j->filename, write ? "rb+" : "rb", &fp);
|
||||
|
||||
if (result == ISC_R_FILENOTFOUND) {
|
||||
if (write) {
|
||||
@@ -1105,8 +1103,10 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
|
||||
"creating it",
|
||||
j->filename);
|
||||
CHECK(journal_file_create(mctx, filename));
|
||||
/* Retry. */
|
||||
result = isc_file_fopen(j->filename, "r+", &fp);
|
||||
/*
|
||||
* Retry.
|
||||
*/
|
||||
result = isc_stdio_open(j->filename, "rb+", &fp);
|
||||
} else {
|
||||
FAIL(ISC_R_NOTFOUND);
|
||||
}
|
||||
@@ -1199,7 +1199,7 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
|
||||
j->index = NULL;
|
||||
}
|
||||
if (j->fp != NULL)
|
||||
(void)isc_file_fclose(j->fp);
|
||||
(void)isc_stdio_close(j->fp);
|
||||
isc_mem_put(j->mctx, j, sizeof(*j));
|
||||
return (result);
|
||||
}
|
||||
@@ -1699,7 +1699,7 @@ dns_journal_destroy(dns_journal_t **journalp) {
|
||||
isc_mem_put(j->mctx, j->it.source.base, j->it.source.length);
|
||||
|
||||
if (j->fp != NULL)
|
||||
(void)isc_file_fclose(j->fp);
|
||||
(void)isc_stdio_close(j->fp);
|
||||
j->magic = 0;
|
||||
isc_mem_put(j->mctx, j, sizeof(*j));
|
||||
*journalp = NULL;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <isc/file.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -550,7 +551,6 @@ dump_rdataset(isc_mem_t *mctx, dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
{
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
size_t nwritten;
|
||||
|
||||
REQUIRE(buffer->length > 0);
|
||||
|
||||
@@ -603,15 +603,17 @@ dump_rdataset(isc_mem_t *mctx, dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/* Write the buffer contents to the master file. */
|
||||
/*
|
||||
* Write the buffer contents to the master file.
|
||||
*/
|
||||
isc_buffer_usedregion(buffer, &r);
|
||||
nwritten = fwrite(r.base, 1, (size_t) r.length, f);
|
||||
result = isc_stdio_write(r.base, 1, (size_t)r.length, f, NULL);
|
||||
|
||||
if (nwritten != (size_t) r.length) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"master file write failed: %s",
|
||||
strerror(errno));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
isc_result_totext(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -784,7 +786,7 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
FILE *f = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_file_fopen(filename, "w", &f);
|
||||
result = isc_stdio_open(filename, "w", &f);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR,
|
||||
@@ -795,7 +797,7 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
|
||||
result = dns_master_dumptostream(mctx, db, version, style, f);
|
||||
|
||||
result = isc_file_fclose(f);
|
||||
result = isc_stdio_close(f);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR,
|
||||
|
@@ -32,7 +32,7 @@ CWARNINGS =
|
||||
UNIXOBJS = @ISC_ISCIPV6_O@ \
|
||||
unix/app.@O@ unix/dir.@O@ unix/errno2result.@O@ unix/file.@O@ \
|
||||
unix/interfaceiter.@O@ unix/net.@O@ unix/socket.@O@ \
|
||||
unix/time.@O@ unix/stdtime.@O@
|
||||
unix/time.@O@ unix/stdio.@O@ unix/stdtime.@O@
|
||||
|
||||
|
||||
NLSOBJS = nls/msgcat.@O@
|
||||
|
@@ -29,7 +29,7 @@ HEADERS = assertions.h base64.h bitstring.h boolean.h buffer.h \
|
||||
mutexblock.h netaddr.h ondestroy.h platform.h \
|
||||
print.h quota.h random.h ratelimiter.h region.h \
|
||||
result.h resultclass.h rwlock.h serial.h sockaddr.h \
|
||||
socket.h string.h symtab.h task.h taskpool.h timer.h \
|
||||
socket.h stdio.h string.h symtab.h task.h taskpool.h timer.h \
|
||||
types.h util.h
|
||||
|
||||
SUBDIRS =
|
||||
|
@@ -148,45 +148,6 @@ isc_file_openunique(char *templet, FILE **fp);
|
||||
* Something totally unexpected happened.
|
||||
*/
|
||||
|
||||
|
||||
isc_result_t
|
||||
isc_file_fopen(const char *filename, const char *mode, FILE **fp);
|
||||
|
||||
isc_result_t
|
||||
isc_file_fclose(FILE *f);
|
||||
|
||||
isc_result_t
|
||||
isc_file_fseek(FILE *f, long offset, int whence);
|
||||
|
||||
isc_result_t
|
||||
isc_file_fread(void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
isc_result_t
|
||||
isc_file_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
isc_result_t
|
||||
isc_file_fflush(FILE *f);
|
||||
|
||||
/*
|
||||
* These functions are wrappers around the corresponding
|
||||
* stdio functions, returning a detailed error code in the
|
||||
* form of an an isc_result_t. ANSI C does not guarantee
|
||||
* that stdio functions set errno, hence these functions
|
||||
* must use platform dependent methods (e.g., the POSIX errno)
|
||||
* to construct the error code.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_ffsync(FILE *f);
|
||||
/*
|
||||
* Invoke fsync() on the file descriptor underlying
|
||||
* an stdio stream, or an equivalent system-dependent
|
||||
* operation. Note that this function has no direct
|
||||
* counterpart in the stdio library.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_remove(const char *filename);
|
||||
/*
|
||||
|
55
lib/isc/include/isc/stdio.h
Normal file
55
lib/isc/include/isc/stdio.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
|
||||
#include <isc/result.h>
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_open(const char *filename, const char *mode, FILE **fp);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_close(FILE *f);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_seek(FILE *f, long offset, int whence);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_flush(FILE *f);
|
||||
/*
|
||||
* These functions are wrappers around the corresponding stdio functions,
|
||||
* returning a detailed error code in the form of an an isc_result_t. ANSI C
|
||||
* does not guarantee that stdio functions set errno, hence these functions
|
||||
* must use platform dependent methods (e.g., the POSIX errno) to construct the
|
||||
* error code.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_sync(FILE *f);
|
||||
/*
|
||||
* Invoke fsync() on the file descriptor underlying an stdio stream, or an
|
||||
* equivalent system-dependent operation. Note that this function has no
|
||||
* direct counterpart in the stdio library.
|
||||
*/
|
@@ -24,6 +24,7 @@
|
||||
#include <isc/file.h>
|
||||
#include <isc/lex.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -220,7 +221,7 @@ isc_lex_openfile(isc_lex_t *lex, const char *filename) {
|
||||
|
||||
REQUIRE(VALID_LEX(lex));
|
||||
|
||||
result = isc_file_fopen(filename, "r", &stream);
|
||||
result = isc_stdio_open(filename, "r", &stream);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
|
@@ -29,12 +29,12 @@ CWARNINGS =
|
||||
# Alphabetically
|
||||
OBJS = @ISC_IPV6_O@ \
|
||||
app.@O@ dir.@O@ errno2result.@O@ file.@O@ interfaceiter.@O@ \
|
||||
net.@O@ socket.@O@ stdtime.@O@ time.@O@
|
||||
net.@O@ socket.@O@ stdio.@O@ stdtime.@O@ time.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = @ISC_IPV6_C@ \
|
||||
app.c dir.c errno2result.c file.c interfaceiter.c \
|
||||
net.c socket.c stdtime.c time.c
|
||||
net.c socket.c stdio.c stdtime.c time.c
|
||||
|
||||
SUBDIRS = include
|
||||
TARGETS = ${OBJS}
|
||||
|
@@ -125,93 +125,6 @@ isc_file_openunique(char *templet, FILE **fp) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fopen(const char *filename, const char *mode, FILE **fp) {
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, mode);
|
||||
if (f == NULL)
|
||||
return (isc__errno2result(errno));
|
||||
*fp = f;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fclose(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fclose(f);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fseek(FILE *f, long offset, int whence) {
|
||||
int r;
|
||||
|
||||
r = fseek(f, offset, whence);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fread(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
size_t r;
|
||||
|
||||
clearerr(f);
|
||||
r = fread(ptr, size, nmemb, f);
|
||||
if (r != nmemb) {
|
||||
if (feof(f))
|
||||
result = ISC_R_EOF;
|
||||
else
|
||||
result = isc__errno2result(errno);
|
||||
}
|
||||
if (nret != NULL)
|
||||
*nret = r;
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
size_t r;
|
||||
|
||||
clearerr(f);
|
||||
r = fwrite(ptr, size, nmemb, f);
|
||||
if (r != nmemb)
|
||||
result = isc__errno2result(errno);
|
||||
if (nret != NULL)
|
||||
*nret = r;
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_fflush(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fflush(f);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_ffsync(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fsync(fileno(f));
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_remove(const char *filename) {
|
||||
int r;
|
||||
|
115
lib/isc/unix/stdio.c
Normal file
115
lib/isc/unix/stdio.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 <unistd.h>
|
||||
|
||||
#include <isc/stdio.h>
|
||||
|
||||
#include "errno2result.h"
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_open(const char *filename, const char *mode, FILE **fp) {
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, mode);
|
||||
if (f == NULL)
|
||||
return (isc__errno2result(errno));
|
||||
*fp = f;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_close(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fclose(f);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_seek(FILE *f, long offset, int whence) {
|
||||
int r;
|
||||
|
||||
r = fseek(f, offset, whence);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
size_t r;
|
||||
|
||||
clearerr(f);
|
||||
r = fread(ptr, size, nmemb, f);
|
||||
if (r != nmemb) {
|
||||
if (feof(f))
|
||||
result = ISC_R_EOF;
|
||||
else
|
||||
result = isc__errno2result(errno);
|
||||
}
|
||||
if (nret != NULL)
|
||||
*nret = r;
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
size_t r;
|
||||
|
||||
clearerr(f);
|
||||
r = fwrite(ptr, size, nmemb, f);
|
||||
if (r != nmemb)
|
||||
result = isc__errno2result(errno);
|
||||
if (nret != NULL)
|
||||
*nret = r;
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_flush(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fflush(f);
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_sync(FILE *f) {
|
||||
int r;
|
||||
|
||||
r = fsync(fileno(f));
|
||||
if (r == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
@@ -727,6 +727,7 @@
|
||||
./lib/isc/unix/ipv6.c C 1999,2000
|
||||
./lib/isc/unix/net.c C 1999,2000
|
||||
./lib/isc/unix/socket.c C 1998,1999,2000
|
||||
./lib/isc/unix/stdio.c C 2000
|
||||
./lib/isc/unix/stdtime.c C 1999,2000
|
||||
./lib/isc/unix/time.c C 1998,1999,2000
|
||||
./lib/isc/version.c C 1998,1999,2000
|
||||
@@ -747,6 +748,7 @@
|
||||
./lib/isc/win32/include/isc/net.h C 1999,2000
|
||||
./lib/isc/win32/include/isc/netdb.h C 1999,2000
|
||||
./lib/isc/win32/include/isc/once.h C 1999,2000
|
||||
./lib/isc/win32/include/isc/stdio.h C 2000
|
||||
./lib/isc/win32/include/isc/stdtime.h C 1999,2000
|
||||
./lib/isc/win32/include/isc/thread.h C 1998,1999,2000
|
||||
./lib/isc/win32/include/isc/time.h C 1998,1999,2000
|
||||
|
Reference in New Issue
Block a user