1 /* overall.h - NeonServ v5.4
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "../config.h"
22 #define NEONSERV_VERSION "5.4"
23 #define VERSION_PATCHLEVEL 657
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <netinet/tcp.h>
39 #include <arpa/inet.h>
50 //some winnt machines do already have a SYNCHRONIZE macro defined...
56 #define pthread_self_tid() pthread_self().p
58 #define pthread_self_tid() pthread_self()
60 #define THREAD_MUTEX_INIT(var) { \
61 pthread_mutexattr_t mutex_attr; \
62 pthread_mutexattr_init(&mutex_attr);\
63 pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);\
64 pthread_mutex_init(&var, &mutex_attr); \
66 #define THREAD_MUTEX_INIT_TYPE(var, type) { \
67 pthread_mutexattr_t mutex_attr; \
68 pthread_mutexattr_init(&mutex_attr);\
69 pthread_mutexattr_settype(&mutex_attr, type);\
70 pthread_mutex_init(&var, &mutex_attr); \
72 #define SYNCHRONIZE(var) pthread_mutex_lock(&var)
73 #define SET_SYNCHRONIZE(var) pthread_mutex_trylock(&var)
74 #define DESYNCHRONIZE(var) pthread_mutex_unlock(&var)
76 #define THREAD_MUTEX_INIT(var)
77 #define SYNCHRONIZE(var)
78 #define DESYNCHRONIZE(var)
82 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
84 #define PRINTF_LIKE(M,N)
88 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
89 #elif defined(S_SPLINT_S)
90 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
91 #define const /*@observer@*/ /*@temp@*/
93 #define UNUSED_ARG(ARG) ARG
96 #define STRINGIFY_(x) #x
97 #define STRINGIFY(x) STRINGIFY_(x)
100 #if defined(__GNUC_PATCHLEVEL__)
101 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
103 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
105 #elif defined (__IMAGECRAFT__)
106 #define COMPILER "ICCAVR"
108 #define COMPILER "Unknown"
111 #ifdef ENABLE_MEMORY_DEBUG
112 #include "memoryDebug.h"
115 #define PID_FILE "neonserv.pid"
116 #define CONF_FILE "neonserv.conf"
117 #define LOG_FILE "neonserv.log"
119 #define SOCKET_SELECT_TIME 1
120 #define SOCKET_RECONNECT_TIME 20
128 #define CHANNELLEN 200
130 #define MAXLOGLEN 1024
131 #define TRIGGERLEN 50
132 #define MAXNUMPARAMS 200 /* maximum number of parameters in one line */
133 #define MAXLANGUAGES 5
135 #define INVITE_TIMEOUT 30
136 #define BOTWAR_DETECTION_TIME 7
137 #define BOTWAR_DETECTION_EVENTS 6
138 #define REWHO_TIMEOUT 10 /* wait 10 seconds before WHO an unauthed user again */
139 #define TICKS_PER_SECOND 10
142 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^-_`"
143 //the first char is a little bit different
145 // 1234567890123456789012345678901234567890123456789012345678 9012 62
146 #define VALID_NICK_CHARS_FIRST "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~[\\]^_`"
147 #define VALID_NICK_CHARS_FIRST_LEN 62
149 #define TEMPUSER_LIST_INDEX VALID_NICK_CHARS_FIRST_LEN
151 #define LOGLEVEL_INFO 0x01
152 #define LOGLEVEL_ERROR 0x02
153 #define LOGLEVEL_RAW 0x04
154 #define LOGLEVEL_MYSQL 0x08
156 #define timeval_is_bigger(x,y) ((x.tv_sec > y.tv_sec) || (x.tv_sec == y.tv_sec && x.tv_usec > y.tv_usec))
158 #define perror(errmsg) (putlog(LOGLEVEL_ERROR, "ERROR (%s:%d) %s", __FILE__, __LINE__, errmsg))
160 #define MODSTATE_RELOAD 0x01
161 #define MODSTATE_STARTSTOP 0x02
162 #define MODSTATE_REBIND 0x03