2 * Copyright (C) 2004, 2007, 2011 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: stdio.c,v 1.8.814.2 2011-03-05 23:52:09 tbox Exp $ */
25 #include <isc/stdio.h>
28 #include "errno2result.h"
31 isc_stdio_open(const char *filename, const char *mode, FILE **fp) {
34 f = fopen(filename, mode);
36 return (isc__errno2result(errno));
38 return (ISC_R_SUCCESS);
42 isc_stdio_close(FILE *f) {
47 return (ISC_R_SUCCESS);
49 return (isc__errno2result(errno));
53 isc_stdio_seek(FILE *f, long offset, int whence) {
56 r = fseek(f, offset, whence);
58 return (ISC_R_SUCCESS);
60 return (isc__errno2result(errno));
64 isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) {
65 isc_result_t result = ISC_R_SUCCESS;
69 r = fread(ptr, size, nmemb, f);
74 result = isc__errno2result(errno);
82 isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
85 isc_result_t result = ISC_R_SUCCESS;
89 r = fwrite(ptr, size, nmemb, f);
91 result = isc__errno2result(errno);
98 isc_stdio_flush(FILE *f) {
103 return (ISC_R_SUCCESS);
105 return (isc__errno2result(errno));
109 isc_stdio_sync(FILE *f) {
112 r = fsync(fileno(f));
114 return (ISC_R_SUCCESS);
116 return (isc__errno2result(errno));