removed unused code in bots.c
[NeonServV5.git] / src / overall.h
1 /* overall.h - NeonServ v5.6
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
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.
8  * 
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.
13  * 
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/>. 
16  */
17
18 #ifndef _overall_h
19 #define _overall_h
20 #include "../config.h"
21
22 #define NEONSERV_VERSION "5.6"
23 #define VERSION_PATCHLEVEL 736
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <ctype.h>
29 #ifdef WIN32
30 #include <windows.h>
31 #include <winsock2.h>
32 #include <malloc.h>
33 #else
34 #include <features.h>
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>
40 #include <netdb.h>
41 #include <sys/wait.h>
42 #include <errno.h>
43 #endif
44 #include <unistd.h>
45 #include <getopt.h>
46 #include <stdarg.h>
47 #include <sys/time.h>
48 #include <time.h>
49 #include <signal.h>
50 #ifdef SYNCHRONIZE
51 //some winnt machines do already have a SYNCHRONIZE macro defined...
52 #undef SYNCHRONIZE
53 #endif
54 #ifdef HAVE_THREADS
55 #include <pthread.h>
56 #ifdef WIN32
57 #define pthread_self_tid() pthread_self().p
58 #else
59 #define pthread_self_tid() pthread_self()
60 #endif
61 #define THREAD_MUTEX_INIT(var) { \
62     pthread_mutexattr_t mutex_attr; \
63     pthread_mutexattr_init(&mutex_attr);\
64     pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);\
65     pthread_mutex_init(&var, &mutex_attr); \
66 }
67 #define THREAD_MUTEX_INIT_TYPE(var, type) { \
68     pthread_mutexattr_t mutex_attr; \
69     pthread_mutexattr_init(&mutex_attr);\
70     pthread_mutexattr_settype(&mutex_attr, type);\
71     pthread_mutex_init(&var, &mutex_attr); \
72 }
73 #define SYNCHRONIZE(var) pthread_mutex_lock(&var)
74 #define SET_SYNCHRONIZE(var) pthread_mutex_trylock(&var)
75 #define DESYNCHRONIZE(var) pthread_mutex_unlock(&var)
76 #else
77 #define THREAD_MUTEX_INIT(var)
78 #define SYNCHRONIZE(var)
79 #define DESYNCHRONIZE(var)
80 #endif
81
82 #if __GNUC__
83 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
84 #else
85 #define PRINTF_LIKE(M,N)
86 #endif
87
88 #if __GNUC__ >= 2
89 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
90 #elif defined(S_SPLINT_S)
91 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
92 #define const /*@observer@*/ /*@temp@*/
93 #else
94 #define UNUSED_ARG(ARG) ARG
95 #endif
96
97 #define STRINGIFY_(x) #x
98 #define STRINGIFY(x) STRINGIFY_(x)
99  
100 #if defined(__GNUC__)
101 #if defined(__GNUC_PATCHLEVEL__)
102 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
103 #else
104 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
105 #endif
106 #elif defined (__IMAGECRAFT__)
107 #define COMPILER "ICCAVR"
108 #else
109 #define COMPILER "Unknown"
110 #endif
111
112 #ifdef ENABLE_MEMORY_DEBUG
113 #include "memoryDebug.h"
114 #endif
115
116 #define PID_FILE "neonserv.pid"
117 #define CONF_FILE "neonserv.conf"
118 #define LOG_FILE "neonserv.log"
119
120 #define SOCKET_SELECT_TIME    1
121 #define SOCKET_RECONNECT_TIME 20
122
123 #define NICKLEN         30
124 #define USERLEN         10
125 #define AUTHLEN         32
126 #define HOSTLEN         63
127 #define REALLEN         50
128 #define TOPICLEN        500
129 #define CHANNELLEN      200
130 #define MAXLEN          512
131 #define MAXLOGLEN       1024
132 #define TRIGGERLEN      50
133 #define MAXNUMPARAMS    200 /* maximum number of parameters in one line */
134 #define MAXLANGUAGES    5
135 #define MAXMODES        6
136 #define INVITE_TIMEOUT  30
137 #define BOTWAR_DETECTION_TIME 7
138 #define BOTWAR_DETECTION_EVENTS 6
139 #define REWHO_TIMEOUT   10 /* wait 10 seconds before WHO an unauthed user again */
140 #define CLEAR_CACHE_INTERVAL 10
141
142 //valid nick chars
143 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^-_`"
144 //the first char is a little bit different
145 //                              0        1         2         3         4         5          6
146 //                              1234567890123456789012345678901234567890123456789012345678 9012   62
147 #define VALID_NICK_CHARS_FIRST "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~[\\]^_`"
148 #define VALID_NICK_CHARS_FIRST_LEN 62
149
150 #define TEMPUSER_LIST_INDEX VALID_NICK_CHARS_FIRST_LEN
151
152 #define LOGLEVEL_INFO  0x01
153 #define LOGLEVEL_ERROR 0x02
154 #define LOGLEVEL_RAW   0x04
155 #define LOGLEVEL_MYSQL 0x08
156
157 #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
159 #define perror(errmsg) (putlog(LOGLEVEL_ERROR, "ERROR (%s:%d) %s", __FILE__, __LINE__, errmsg))
160
161 #define MODSTATE_RELOAD    0x01
162 #define MODSTATE_STARTSTOP 0x02
163 #define MODSTATE_REBIND    0x03
164
165 #endif