4 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: stdio.c,v 1.8 2007/06/19 23:47:18 tbox Exp */
27 #include <isc/stdio.h>
29 #include "errno2result.h"
32 isc_stdio_open(const char *filename
, const char *mode
, FILE **fp
) {
35 f
= fopen(filename
, mode
);
37 return (isc__errno2result(errno
));
39 return (ISC_R_SUCCESS
);
43 isc_stdio_close(FILE *f
) {
48 return (ISC_R_SUCCESS
);
50 return (isc__errno2result(errno
));
54 isc_stdio_seek(FILE *f
, long offset
, int whence
) {
57 r
= fseek(f
, offset
, whence
);
59 return (ISC_R_SUCCESS
);
61 return (isc__errno2result(errno
));
65 isc_stdio_read(void *ptr
, size_t size
, size_t nmemb
, FILE *f
, size_t *nret
) {
66 isc_result_t result
= ISC_R_SUCCESS
;
70 r
= fread(ptr
, size
, nmemb
, f
);
75 result
= isc__errno2result(errno
);
83 isc_stdio_write(const void *ptr
, size_t size
, size_t nmemb
, FILE *f
,
86 isc_result_t result
= ISC_R_SUCCESS
;
90 r
= fwrite(ptr
, size
, nmemb
, f
);
92 result
= isc__errno2result(errno
);
99 isc_stdio_flush(FILE *f
) {
104 return (ISC_R_SUCCESS
);
106 return (isc__errno2result(errno
));
110 isc_stdio_sync(FILE *f
) {
113 r
= fsync(fileno(f
));
115 return (ISC_R_SUCCESS
);
117 return (isc__errno2result(errno
));