home · contact · privacy
Built error checking into file reading/writing routines and calls of them.
[plomrogue] / src / readwrite.h
1 /* readwrite.h:
2  *
3  * Routines for reading/writing (multi-)byte data from/to files. They ensure a
4  * defined endianness.
5  */
6
7 #ifndef READWRITE_H
8 #define READWRITE_H
9
10
11
12 #include <stdio.h> /* for FILE typedef */
13 #include <stdint.h> /* for uint16_t, uint32_t */
14
15
16
17 /* Each function returns 0 on success and 1 on failure. "x" is the value to be
18  * written to "file" for write_* functions and for read_* functions the pointer
19  * to where the value read from "file" is to be written.
20  */
21 extern uint8_t read_uint8(FILE * file, uint8_t * x);
22 extern uint8_t read_uint16_bigendian(FILE * file, uint16_t * x);
23 extern uint8_t read_uint32_bigendian(FILE * file, uint32_t * x);
24 extern uint8_t write_uint8(uint8_t x, FILE * file);
25 extern uint8_t write_uint16_bigendian(uint16_t x, FILE * file);
26 extern uint8_t write_uint32_bigendian(uint32_t x, FILE * file);
27
28 #endif