Add sys/types.h includes for OpenBSD.
[darkstat] / db.h
1 /* darkstat 3
2 *
3 * db.h: load and save in-memory database from/to file
4 * copyright (c) 2007 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
15 /* byteswap */
16 uint64_t hton64(const uint64_t ho);
17 uint64_t ntoh64(const uint64_t no);
18 void test_64order(void);
19
20 /* read helpers */
21 unsigned int xtell(const int fd);
22 int readn(const int fd, void *dest, const size_t len);
23 int read8(const int fd, uint8_t *dest);
24 int expect8(const int fd, uint8_t expecting);
25 int read16(const int fd, uint16_t *dest);
26 int read32(const int fd, uint32_t *dest);
27 int read64(const int fd, uint64_t *dest);
28 int readaddr_ipv4(const int fd, struct addr *dest);
29 int readaddr(const int fd, struct addr *dest);
30 int read_file_header(const int fd, const uint8_t expected[4]);
31
32 /* write helpers */
33 int writen(const int fd, const void *dest, const size_t len);
34 int write8(const int fd, const uint8_t i);
35 int write16(const int fd, const uint16_t i);
36 int write32(const int fd, const uint32_t i);
37 int write64(const int fd, const uint64_t i);
38 int writeaddr(const int fd, const struct addr *const a);
39
40 /* vim:set ts=3 sw=3 tw=78 et: */