added session manager and support for an external login system
[TransparentIRC.git] / src / overall.h
1 /* overall.h - TransparentIRC 0.1
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 TRANSIRC_VERSION "0.1"
23 #define VERSION_PATCHLEVEL 0
24
25 #define IO_READ_BUFLEN 1024
26 #define IO_MAX_TIMEOUT 10
27 #define LINELEN 512
28 #define CMDLEN 512
29 #define MAXNUMPARAMS 200
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <ctype.h>
35 #ifdef WIN32
36 #include <windows.h>
37 #include <winsock2.h>
38 #include <malloc.h>
39 #else
40 #include <features.h>
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <netinet/in.h>
44 #include <netinet/tcp.h>
45 #include <arpa/inet.h>
46 #include <netdb.h>
47 #include <sys/wait.h>
48 #include <errno.h>
49 #endif
50 #include <unistd.h>
51 #include <getopt.h>
52 #include <stdarg.h>
53 #include <sys/time.h>
54 #include <time.h>
55 #include <signal.h>
56
57 #if __GNUC__
58 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
59 #else
60 #define PRINTF_LIKE(M,N)
61 #endif
62
63 #if __GNUC__ >= 2
64 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
65 #elif defined(S_SPLINT_S)
66 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
67 #define const /*@observer@*/ /*@temp@*/
68 #else
69 #define UNUSED_ARG(ARG) ARG
70 #endif
71
72 #define STRINGIFY_(x) #x
73 #define STRINGIFY(x) STRINGIFY_(x)
74  
75 #if defined(__GNUC__)
76 #if defined(__GNUC_PATCHLEVEL__)
77 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
78 #else
79 #define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
80 #endif
81 #elif defined (__IMAGECRAFT__)
82 #define COMPILER "ICCAVR"
83 #else
84 #define COMPILER "Unknown"
85 #endif
86
87 #define timeval_is_bigger(x,y) ((x->tv_sec > y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec > y->tv_usec))
88 #define timeval_is_smaler(x,y) ((x->tv_sec < y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec < y->tv_usec))
89
90 #endif