1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * SPDX-License-Identifier: MPL-2.0
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9  *
10  * See the COPYRIGHT file distributed with this work for additional
11  * information regarding copyright ownership.
12  */
13 
14 #ifndef ISC_STDIO_H
15 #define ISC_STDIO_H 1
16 
17 /*! \file isc/stdio.h */
18 
19 /*%
20  * These functions are wrappers around the corresponding stdio functions.
21  *
22  * They return a detailed error code in the form of an an isc_result_t.  ANSI C
23  * does not guarantee that stdio functions set errno, hence these functions
24  * must use platform dependent methods (e.g., the POSIX errno) to construct the
25  * error code.
26  */
27 
28 #include <stdio.h>
29 
30 #include <isc/lang.h>
31 #include <isc/result.h>
32 
33 ISC_LANG_BEGINDECLS
34 
35 /*% Open */
36 isc_result_t
37 isc_stdio_open(const char *filename, const char *mode, FILE **fp);
38 
39 /*% Close */
40 isc_result_t
41 isc_stdio_close(FILE *f);
42 
43 /*% Seek */
44 isc_result_t
45 isc_stdio_seek(FILE *f, off_t offset, int whence);
46 
47 /*% Tell */
48 isc_result_t
49 isc_stdio_tell(FILE *f, off_t *offsetp);
50 
51 /*% Read */
52 isc_result_t
53 isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret);
54 
55 /*% Write */
56 isc_result_t
57 isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
58 		size_t *nret);
59 
60 /*% Flush */
61 isc_result_t
62 isc_stdio_flush(FILE *f);
63 
64 isc_result_t
65 isc_stdio_sync(FILE *f);
66 /*%<
67  * Invoke fsync() on the file descriptor underlying an stdio stream, or an
68  * equivalent system-dependent operation.  Note that this function has no
69  * direct counterpart in the stdio library.
70  */
71 
72 ISC_LANG_ENDDECLS
73 
74 #endif /* ISC_STDIO_H */
75