8f3e68679a491f22288712de77c6cb1fd5c30181
[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 "hosts_db.h" /* addr46 */
8
9 void db_import(const char *filename);
10 void db_export(const char *filename);
11
12 /* byteswap */
13 uint64_t hton64(const uint64_t ho);
14 uint64_t ntoh64(const uint64_t no);
15 void test_64order(void);
16
17 /* read helpers */
18 unsigned int xtell(const int fd);
19 int readn(const int fd, void *dest, const size_t len);
20 int read8(const int fd, uint8_t *dest);
21 int expect8(const int fd, uint8_t expecting);
22 int read16(const int fd, uint16_t *dest);
23 int read32(const int fd, uint32_t *dest);
24 int readaddr(const int fd, struct addr46 *dest);
25 int read64(const int fd, uint64_t *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 writeaddr(const int fd, const struct addr46 *const addr);
34 int write64(const int fd, const uint64_t i);
35
36 /* vim:set ts=3 sw=3 tw=78 et: */