1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
7  *
8  * See the COPYRIGHT file distributed with this work for additional
9  * information regarding copyright ownership.
10  */
11 
12 
13 #ifndef ISC_STDIO_H
14 #define ISC_STDIO_H 1
15 
16 /*! \file isc/stdio.h */
17 
18 /*%
19  * These functions are wrappers around the corresponding stdio functions.
20  *
21  * They return a detailed error code in the form of an an isc_result_t.  ANSI C
22  * does not guarantee that stdio functions set errno, hence these functions
23  * must use platform dependent methods (e.g., the POSIX errno) to construct the
24  * error code.
25  */
26 
27 #include <stdio.h>
28 
29 #include <isc/lang.h>
30 #include <isc/result.h>
31 
32 ISC_LANG_BEGINDECLS
33 
34 /*% Open */
35 isc_result_t
36 isc_stdio_open(const char *filename, const char *mode, FILE **fp);
37 
38 /*% Close */
39 isc_result_t
40 isc_stdio_close(FILE *f);
41 
42 /*% Seek */
43 isc_result_t
44 isc_stdio_seek(FILE *f, off_t offset, int whence);
45 
46 /*% Tell */
47 isc_result_t
48 isc_stdio_tell(FILE *f, off_t *offsetp);
49 
50 /*% Read */
51 isc_result_t
52 isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f,
53 	       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