libctdb: reorganize headers: remove ctdb.h, add ctdb_client.h and ctdb_protocol.h
[rusty/ctdb.git] / include / includes.h
1 #define HAVE_UNIXSOCKET 1
2
3 #include "replace.h"
4 #include "talloc.h"
5 #include "system/wait.h"
6 #include "system/network.h"
7 #include "tdb.h"
8 #include "idtree.h"
9 #include "ctdb_client.h"
10
11 typedef bool BOOL;
12
13 #define True 1
14 #define False 0
15
16 extern int LogLevel;
17 extern int this_log_level;
18
19 enum debug_level { 
20         DEBUG_EMERG   = -3, 
21         DEBUG_ALERT   = -2, 
22         DEBUG_CRIT    = -1,
23         DEBUG_ERR     =  0,
24         DEBUG_WARNING =  1,
25         DEBUG_NOTICE  =  2,     
26         DEBUG_INFO    =  3,
27         DEBUG_DEBUG   =  4,
28 };
29
30 #define DEBUGLVL(lvl) ((lvl) <= LogLevel)
31 #define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) < DEBUG_DEBUG) { log_ringbuffer x; } if ((lvl) <= LogLevel) { do_debug x; }} while (0)
32 #define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug_add x; }} while (0)
33
34 #define _PUBLIC_
35 #define _NORETURN_
36 #define _PURE_
37
38 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
39
40 #ifndef discard_const
41 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
42 #endif
43
44 struct timeval timeval_zero(void);
45 bool timeval_is_zero(const struct timeval *tv);
46 struct timeval timeval_current(void);
47 struct timeval timeval_set(uint32_t secs, uint32_t usecs);
48 int timeval_compare(const struct timeval *tv1, const struct timeval *tv2);
49 struct timeval timeval_until(const struct timeval *tv1,
50                              const struct timeval *tv2);
51 _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs);
52 double timeval_elapsed(struct timeval *tv);
53 double timeval_delta(struct timeval *tv2, struct timeval *tv);
54 char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx);
55 char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
56 _PUBLIC_ const char **str_list_add(const char **list, const char *s);
57 _PUBLIC_ int set_blocking(int fd, BOOL set);
58
59 #include "lib/util/debug.h"
60 #include "lib/util/util.h"