1 /* main.h - NeonServ v5.3
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/>.
19 #include "../config.h"
21 #define NEONSERV_VERSION "5.3"
22 #define VERSION_PATCHLEVEL 543
34 #include <sys/types.h>
35 #include <sys/socket.h>
36 #include <netinet/in.h>
37 #include <netinet/tcp.h>
38 #include <arpa/inet.h>
50 #define pthread_self_tid() pthread_self().p
52 #define pthread_self_tid() pthread_self()
54 #define THREAD_MUTEX_INIT(var) { \
55 pthread_mutexattr_t mutex_attr; \
56 pthread_mutexattr_init(&mutex_attr);\
57 pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);\
58 pthread_mutex_init(&var, &mutex_attr); \
60 #define THREAD_MUTEX_INIT_TYPE(var, type) { \
61 pthread_mutexattr_t mutex_attr; \
62 pthread_mutexattr_init(&mutex_attr);\
63 pthread_mutexattr_settype(&mutex_attr, type);\
64 pthread_mutex_init(&var, &mutex_attr); \
66 #define SYNCHRONIZE(var) pthread_mutex_lock(&var)
67 #define SET_SYNCHRONIZE(var) pthread_mutex_trylock(&var)
68 #define DESYNCHRONIZE(var) pthread_mutex_unlock(&var)
70 #define THREAD_MUTEX_INIT(var)
71 #define SYNCHRONIZE(var)
72 #define DESYNCHRONIZE(var)
76 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
78 #define PRINTF_LIKE(M,N)
82 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
83 #elif defined(S_SPLINT_S)
84 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
85 #define const /*@observer@*/ /*@temp@*/
87 #define UNUSED_ARG(ARG) ARG
90 #define STRINGIFY_(x) #x
91 #define STRINGIFY(x) STRINGIFY_(x)
94 #if defined(__GNUC_PATCHLEVEL__)
95 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
97 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
99 #elif defined (__IMAGECRAFT__)
100 #define COMPILER "ICCAVR"
102 #define COMPILER "Unknown"
105 #ifdef ENABLE_MEMORY_DEBUG
106 #include "memoryDebug.h"
109 #define PID_FILE "neonserv.pid"
110 #define CONF_FILE "neonserv.conf"
111 #define LOG_FILE "neonserv.log"
113 #define SOCKET_SELECT_TIME 1
114 #define SOCKET_RECONNECT_TIME 20
122 #define CHANNELLEN 200
124 #define MAXLOGLEN 1024
125 #define TRIGGERLEN 50
126 #define MAXNUMPARAMS 200 /* maximum number of parameters in one line */
127 #define MAXLANGUAGES 5
129 #define INVITE_TIMEOUT 30
130 #define BOTWAR_DETECTION_TIME 7
131 #define BOTWAR_DETECTION_EVENTS 6
132 #define REWHO_TIMEOUT 10 /* wait 10 seconds before WHO an unauthed user again */
133 #define TICKS_PER_SECOND 10
136 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^-_`"
137 //the first char is a little bit different
139 // 1234567890123456789012345678901234567890123456789012345678 9012 62
140 #define VALID_NICK_CHARS_FIRST "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~[\\]^_`"
141 #define VALID_NICK_CHARS_FIRST_LEN 62
143 #define TEMPUSER_LIST_INDEX VALID_NICK_CHARS_FIRST_LEN
145 #define LOGLEVEL_INFO 0x01
146 #define LOGLEVEL_ERROR 0x02
147 #define LOGLEVEL_RAW 0x04
148 #define LOGLEVEL_MYSQL 0x08
150 #define timeval_is_bigger(x,y) ((x.tv_sec > y.tv_sec) || (x.tv_sec == y.tv_sec && x.tv_usec > y.tv_usec))
152 extern time_t start_time;
153 extern int statistics_enabled;
155 extern int running_threads;
156 extern pthread_mutex_t cache_sync;
157 extern pthread_mutex_t whohandler_sync, whohandler_mass_sync;
159 int getCurrentThreadID();
164 int stricmp (const char *s1, const char *s2);
165 int stricmplen (const char *s1, const char *s2, int len);
167 void restart_process();
169 void restart_bot(int do_hard_restart);
171 void reload_config();
173 void statistics_update();
175 void putlog(int loglevel, const char *text, ...) PRINTF_LIKE(2, 3);
177 #define perror(errmsg) (putlog(LOGLEVEL_ERROR, "ERROR (%s:%d) %s", __FILE__, __LINE__, errmsg))