]>
jfr.im git - solanum.git/blob - libratbox/include/ratbox_lib.h
2 * $Id: ratbox_lib.h 26256 2008-12-10 04:05:26Z androsyn $
8 #include <librb-config.h>
17 #ifdef HAVE_LINUX_TCP_H
18 # include <linux/tcp.h>
23 #define alloca __builtin_alloca
27 # define alloca _alloca
35 # ifndef alloca /* predefined by HP cc +Olibcalls */
52 #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
53 # define __builtin_expect(x, expected_value) (x)
56 #define rb_likely(x) __builtin_expect(!!(x), 1)
57 #define rb_unlikely(x) __builtin_expect(!!(x), 0)
69 #define rb_likely(x) (x)
70 #define rb_unlikely(x) (x)
86 #define strerror(x) rb_strerror(x)
87 char *rb_strerror(int error
);
90 #define ENOBUFS WSAENOBUFS
91 #define EINPROGRESS WSAEINPROGRESS
92 #define EWOULDBLOCK WSAEWOULDBLOCK
93 #define EMSGSIZE WSAEMSGSIZE
94 #define EALREADY WSAEALREADY
95 #define EISCONN WSAEISCONN
96 #define EADDRINUSE WSAEADDRINUSE
97 #define EAFNOSUPPORT WSAEAFNOSUPPORT
99 #define pipe(x) _pipe(x, 1024, O_BINARY)
100 #define ioctl(x,y,z) ioctlsocket(x,y, (u_long *)z)
105 #define SIGKILL SIGTERM
117 #define slrb_assert(expr) do \
118 if(rb_unlikely(!(expr))) { \
120 "file: %s line: %d (%s): Assertion failed: (%s)", \
121 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
125 #define slrb_assert(expr) do \
126 if(rb_unlikely(!(expr))) { \
128 "file: %s line: %d: Assertion failed: (%s)", \
129 __FILE__, __LINE__, #expr); \
135 #define lrb_assert(expr) slrb_assert(expr)
137 #define lrb_assert(expr) do { slrb_assert(expr); assert(expr); } while(0)
140 #ifdef RB_SOCKADDR_HAS_SA_LEN
141 #define ss_len sa_len
144 #define GET_SS_FAMILY(x) (((const struct sockaddr *)(x))->sa_family)
145 #define SET_SS_FAMILY(x, y) ((((struct sockaddr *)(x))->sa_family) = y)
146 #ifdef RB_SOCKADDR_HAS_SA_LEN
147 #define SET_SS_LEN(x, y) do { \
148 struct sockaddr *storage; \
149 storage = ((struct sockaddr *)(x));\
150 storage->sa_len = (y); \
152 #define GET_SS_LEN(x) (((struct sockaddr *)(x))->sa_len)
153 #else /* !RB_SOCKADDR_HAS_SA_LEN */
154 #define SET_SS_LEN(x, y) (((struct sockaddr *)(x))->sa_family = ((struct sockaddr *)(x))->sa_family)
156 #define GET_SS_LEN(x) (((struct sockaddr *)(x))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
158 #define GET_SS_LEN(x) (((struct sockaddr *)(x))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : 0)
175 typedef void log_cb(const char *buffer
);
176 typedef void restart_cb(const char *buffer
);
177 typedef void die_cb(const char *buffer
);
179 char *rb_ctime(const time_t, char *, size_t);
180 char *rb_date(const time_t, char *, size_t);
181 void rb_lib_log(const char *, ...);
182 void rb_lib_restart(const char *, ...);
183 void rb_lib_die(const char *, ...);
184 void rb_set_time(void);
185 const char *rb_lib_version(void);
187 void rb_lib_init(log_cb
* xilog
, restart_cb
* irestart
, die_cb
* idie
, int closeall
, int maxfds
,
188 size_t dh_size
, size_t fd_heap_size
);
189 void rb_lib_loop(long delay
);
191 time_t rb_current_time(void);
192 const struct timeval
*rb_current_time_tv(void);
193 pid_t
rb_spawn_process(const char *, const char **);
195 char *rb_strtok_r(char *, const char *, char **);
197 int rb_gettimeofday(struct timeval
*, void *);
199 void rb_sleep(unsigned int seconds
, unsigned int useconds
);
200 char *rb_crypt(const char *, const char *);
202 unsigned char *rb_base64_encode(const unsigned char *str
, int length
);
203 unsigned char *rb_base64_decode(const unsigned char *str
, int length
, int *ret
);
204 int rb_kill(pid_t
, int);
205 char *rb_strerror(int);
207 int rb_setenv(const char *, const char *, int);
209 pid_t
rb_waitpid(pid_t pid
, int *status
, int options
);
210 pid_t
rb_getpid(void);
211 //unsigned int rb_geteuid(void);
214 #include <rb_tools.h>
215 #include <rb_memory.h>
216 #include <rb_commio.h>
217 #include <rb_balloc.h>
218 #include <rb_linebuf.h>
219 #include <rb_snprintf.h>
220 #include <rb_event.h>
221 #include <rb_helper.h>
222 #include <rb_rawbuf.h>
223 #include <rb_patricia.h>