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