Update portability notes.
[darkstat] / db.h
1 /* darkstat 3
2 *
3 * db.h: load and save in-memory database from/to file
4 * copyright (c) 2007-2012 Ben Stewart, Emil Mikulic.
5 */
6
7 #include <sys/types.h> /* for size_t */
8 #include <stdint.h> /* for uint64_t */
9
10 struct addr;
11
12 void db_import(const char *filename);
13 void db_export(const char *filename);
14 void test_64order(void);
15
16 /* read helpers */
17 unsigned int xtell(const int fd);
18 int readn(const int fd, void *dest, const size_t len);
19 int read8(const int fd, uint8_t *dest);
20 int expect8(const int fd, uint8_t expecting);
21 int read16(const int fd, uint16_t *dest);
22 int read32(const int fd, uint32_t *dest);
23 int read64(const int fd, uint64_t *dest);
24 int readaddr_ipv4(const int fd, struct addr *dest);
25 int readaddr(const int fd, struct addr *dest);
26 int read_file_header(const int fd, const uint8_t expected[4]);
27
28 /* write helpers */
29 int writen(const int fd, const void *dest, const size_t len);
30 int write8(const int fd, const uint8_t i);
31 int write16(const int fd, const uint16_t i);
32 int write32(const int fd, const uint32_t i);
33 int write64(const int fd, const uint64_t i);
34 int writeaddr(const int fd, const struct addr *const a);
35
36 /* vim:set ts=3 sw=3 tw=78 et: */