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