added raw_ping and printf-like putsock
[NeonServV5.git] / main.h
1 #ifndef _main_h
2 #define _main_h
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <ctype.h>
8 #include <sys/types.h>
9 #include <sys/socket.h>
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
12 #include <unistd.h>
13 #include <netdb.h>
14
15 #if __GNUC__
16 #define PRINTF_LIKE(M,N) __attribute__((format (printf, M, N)))
17 #else
18 #define PRINTF_LIKE(M,N)
19 #endif
20
21 #if __GNUC__ >= 2
22 #define UNUSED_ARG(ARG) ARG __attribute__((unused))
23 #elif defined(S_SPLINT_S)
24 #define UNUSED_ARG(ARG) /*@unused@*/ ARG
25 #define const /*@observer@*/ /*@temp@*/
26 #else
27 #define UNUSED_ARG(ARG) ARG
28 #endif
29
30 int stricmp (const char *s1, const char *s2)
31 {
32    if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
33    if (s2 == NULL) return *s1;
34    char c1, c2;
35    while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
36    {
37      if (*s1 == '\0') break;
38      ++s1; ++s2;
39    }
40    return c1 - c2;
41 }
42
43
44 #define NICKLEN         30
45 #define USERLEN         10
46 #define HOSTLEN         63
47 #define REALLEN         50
48 #define TOPICLEN        500
49 #define CHANNELLEN      200
50 #define MAXLEN          512
51
52 //valid nick chars
53 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^_`"
54 //the first char is a little bit different
55 //                              0        1         2         3         4         5          6
56 //                              1234567890123456789012345678901234567890123456789012345678 9012   62
57 #define VALID_NICK_CHARS_FIRST "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~[\\]^_`"
58 #define VALID_NICK_CHARS_FIRST_LEN 62
59
60 #endif