added thread count to cmd_netinfo
[NeonServV5.git] / src / main.h
1 /* main.h - NeonServ v5.3
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 #ifndef _main_h
18 #define _main_h
19 #include "../config.h"
20
21 #define NEONSERV_VERSION "5.3"
22 #define VERSION_PATCHLEVEL 543
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <ctype.h>
28 #ifdef WIN32
29 #include <windows.h>
30 #include <winsock2.h>
31 #include <malloc.h>
32 #else
33 #include <sys/types.h>
34 #include <sys/socket.h>
35 #include <netinet/in.h>
36 #include <netinet/tcp.h>
37 #include <arpa/inet.h>
38 #include <netdb.h>
39 #include <sys/wait.h>
40 #endif
41 #include <unistd.h>
42 #include <stdarg.h>
43 #include <sys/time.h>
44 #include <time.h>
45 #ifdef HAVE_THREADS
46 #include <pthread.h>
47 #include <sys/syscall.h>
48 #define THREAD_MUTEX_INIT(var) { \
49     pthread_mutexattr_t mutex_attr; \
50     pthread_mutexattr_init(&mutex_attr);\
51     pthread_mutexattr_setkind_np(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);\
52     pthread_mutex_init(&var, mutex_attr); \
53 }
54 #define SYNCHRONIZE(var) pthread_mutex_lock(&var)
55 #define DESYNCHRONIZE(var) pthread_mutex_unlock(&var)
56 #else
57 #define THREAD_MUTEX_INIT(var)
58 #define SYNCHRONIZE(var)
59 #define DESYNCHRONIZE(var)
60 #endif
61
62 #if __GNUC__
63 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
64 #else
65 #define PRINTF_LIKE(M,N)
66 #endif
67
68 #if __GNUC__ >= 2
69 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
70 #elif defined(S_SPLINT_S)
71 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
72 #define const /*@observer@*/ /*@temp@*/
73 #else
74 #define UNUSED_ARG(ARG) ARG
75 #endif
76
77 #define STRINGIFY_(x) #x
78 #define STRINGIFY(x) STRINGIFY_(x)
79  
80 #if defined(__GNUC__)
81 #if defined(__GNUC_PATCHLEVEL__)
82 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
83 #else
84 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
85 #endif
86 #elif defined (__IMAGECRAFT__)
87 #define COMPILER "ICCAVR"
88 #else
89 #define COMPILER "Unknown"
90 #endif
91
92 #define SOCKET_SELECT_TIME    1
93 #define SOCKET_RECONNECT_TIME 20
94
95 #define NICKLEN         30
96 #define USERLEN         10
97 #define AUTHLEN         32
98 #define HOSTLEN         63
99 #define REALLEN         50
100 #define TOPICLEN        500
101 #define CHANNELLEN      200
102 #define MAXLEN          512
103 #define TRIGGERLEN      50
104 #define MAXNUMPARAMS    200 /* maximum number of parameters in one line */
105 #define MAXLANGUAGES    5
106 #define MAXMODES        6
107 #define INVITE_TIMEOUT  30
108 #define BOTWAR_DETECTION_TIME 7
109 #define BOTWAR_DETECTION_EVENTS 6
110 #define REWHO_TIMEOUT   10 /* wait 10 seconds before WHO an unauthed user again */
111
112 //valid nick chars
113 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^-_`"
114 //the first char is a little bit different
115 //                              0        1         2         3         4         5          6
116 //                              1234567890123456789012345678901234567890123456789012345678 9012   62
117 #define VALID_NICK_CHARS_FIRST "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~[\\]^_`"
118 #define VALID_NICK_CHARS_FIRST_LEN 62
119
120 #define TEMPUSER_LIST_INDEX VALID_NICK_CHARS_FIRST_LEN
121
122 extern time_t start_time;
123 extern int statistics_enabled;
124 #ifdef HAVE_THREADS
125 extern int running_threads;
126 #endif
127
128 int stricmp (const char *s1, const char *s2);
129 int stricmplen (const char *s1, const char *s2, int len);
130
131 void restart_bot(int do_hard_restart);
132 void stop_bot();
133 void reload_config();
134
135 void statistics_update();
136
137 #endif