2012-05-17 20:14:22 +01:00
|
|
|
#ifndef __UTIL_H
|
|
|
|
#define __UTIL_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
void error_init();
|
|
|
|
|
2012-05-29 00:59:12 +01:00
|
|
|
void error(int consult_errno, int close_socket, pthread_mutex_t* unlock, const char* format, ...);
|
2012-05-17 20:14:22 +01:00
|
|
|
|
|
|
|
void* xrealloc(void* ptr, size_t size);
|
|
|
|
|
|
|
|
void* xmalloc(size_t size);
|
|
|
|
|
2012-05-31 13:31:22 +01:00
|
|
|
void set_debug(int value);
|
|
|
|
#ifdef DEBUG
|
|
|
|
void debug(const char*msg, ...);
|
2012-05-17 20:14:22 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CLIENT_ERROR(msg, ...) \
|
2012-05-29 00:59:12 +01:00
|
|
|
error(0, client->socket, &client->serve->l_io, msg, ##__VA_ARGS__)
|
2012-05-17 20:14:22 +01:00
|
|
|
#define CLIENT_ERROR_ON_FAILURE(test, msg, ...) \
|
2012-05-29 00:59:12 +01:00
|
|
|
if (test < 0) { error(1, client->socket, &client->serve->l_io, msg, ##__VA_ARGS__); }
|
2012-05-20 14:38:46 +01:00
|
|
|
|
2012-05-17 20:14:22 +01:00
|
|
|
#define SERVER_ERROR(msg, ...) \
|
2012-05-29 00:59:12 +01:00
|
|
|
error(0, 0, NULL, msg, ##__VA_ARGS__)
|
2012-05-17 20:14:22 +01:00
|
|
|
#define SERVER_ERROR_ON_FAILURE(test, msg, ...) \
|
2012-05-29 00:59:12 +01:00
|
|
|
if (test < 0) { error(1, 0, NULL, msg, ##__VA_ARGS__); }
|
2012-05-17 20:14:22 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|