3 * Routines for reading and writing files.
11 #include <stdio.h> /* for FILE typedef */
12 #include <stdint.h> /* for uint8_t, uint16_t, uint32_t */
16 /* Learn from "file" the largest line length (pointed to by "linemax_p"; length
17 * includes newline chars) and (pointed to by "n_lines_p" if it is not set to
18 * NULL) the number of lines (= number of newline chars).
20 * Returns 0 on success, 1 on error of fseek() (called to return to initial file
23 extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p,
24 uint16_t * n_lines_p);
28 /* These routines for reading values "x" from / writing values to "file" ensure a
29 * defined endianness and consistent error codes: return 0 on success and 1 on
30 * fgetc()/fputc() failure.
32 extern uint8_t read_uint8(FILE * file, uint8_t * x);
33 extern uint8_t read_uint16_bigendian(FILE * file, uint16_t * x);
34 extern uint8_t read_uint32_bigendian(FILE * file, uint32_t * x);
35 extern uint8_t write_uint8(uint8_t x, FILE * file);
36 extern uint8_t write_uint16_bigendian(uint16_t x, FILE * file);
37 extern uint8_t write_uint32_bigendian(uint32_t x, FILE * file);