unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

common.h (5440B)

      1 /************************************************************************
      2  *   Unreal Internet Relay Chat Daemon, include/common.h
      3  *   Copyright (C) 1990 Armin Gruner
      4  *
      5  *   This program is free software; you can redistribute it and/or modify
      6  *   it under the terms of the GNU General Public License as published by
      7  *   the Free Software Foundation; either version 1, or (at your option)
      8  *   any later version.
      9  *
     10  *   This program is distributed in the hope that it will be useful,
     11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  *   GNU General Public License for more details.
     14  *
     15  *   You should have received a copy of the GNU General Public License
     16  *   along with this program; if not, write to the Free Software
     17  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  *
     19  *   $Id$
     20  */
     21 
     22 #ifndef	__common_include__
     23 #define __common_include__
     24 
     25 #include <time.h>
     26 #ifdef _WIN32
     27 #include <malloc.h>
     28 #include <winsock2.h>
     29 #include <ws2tcpip.h>
     30 #include <windows.h>
     31 #include <io.h>
     32 #include <direct.h>
     33 #endif
     34 #include "types.h"
     35 #include "config.h"
     36 #ifndef _WIN32
     37 #include <sys/param.h>
     38 #include <stdbool.h>
     39 #else
     40 typedef int bool;
     41 #define false 0
     42 #define true 1
     43 #endif
     44 
     45 #include "sys.h"
     46 
     47 #include "ircsprintf.h"
     48 #include "list.h"
     49 
     50 #ifdef DEVELOP_CVS
     51 #define ID_Copyright(x) static char id_copyright[] = x
     52 #define ID_Notes(x) static char id_notes[] = x
     53 #else
     54 #define ID_Copyright(x)
     55 #define ID_Notes(x)
     56 #endif
     57 
     58 #define BMAGIC 0x4675636B596F754661736369737473
     59 
     60 #ifdef _WIN32
     61 #define DEADBEEF_ADDR 0xDEADBEEFDEADBEEF
     62 #else
     63 #define DEADBEEF_ADDR 0xDEADBEEF
     64 #endif
     65 
     66 #define BASE_VERSION "UnrealIRCd"
     67 #ifndef _WIN32
     68 #define FDwrite(x,y,z) write(x, y, z)
     69 #else
     70 #define FDwrite(x,y,z) send(x, y, z, 0)
     71 #endif
     72 #ifndef NULL
     73 #define NULL 0
     74 #endif
     75 
     76 #ifdef TRUE
     77 #undef TRUE
     78 #endif
     79 
     80 #ifdef FALSE
     81 #undef FALSE
     82 #endif
     83 
     84 #define FALSE (0)
     85 #define TRUE  (!FALSE)
     86 
     87 #ifndef UNSURE
     88 #define UNSURE (2)
     89 #endif
     90 
     91 #define mycmp(a,b) \
     92  ( (toupper(a[0])!=toupper(b[0])) || smycmp((a)+1,(b)+1) )
     93 extern int smycmp(const char *, const char *);
     94 #ifndef GLIBC2_x
     95 extern int myncmp(const char *, const char *, int);
     96 #endif
     97 
     98 extern char *strtoken(char **, char *, char *);
     99 extern char *strtoken_noskip(char **, char *, char *);
    100 
    101 extern MODVAR int  global_count, max_global_count;
    102 #ifdef _WIN32
    103 extern int gettimeofday(struct timeval *tp, void *tzp);
    104 #endif
    105 
    106 #define PRECISE_CHECK
    107 
    108 #ifndef MAX
    109 #define MAX(a, b)	((a) > (b) ? (a) : (b))
    110 #endif
    111 #ifndef MIN
    112 #define MIN(a, b)	((a) < (b) ? (a) : (b))
    113 #endif
    114 
    115 extern MODVAR u_char tolowertab[], touppertab[];
    116 #undef tolower
    117 #define tolower(c) (tolowertab[(u_char)(c)])
    118 #undef toupper
    119 #define toupper(c) (touppertab[(u_char)(c)])
    120 #undef isalpha
    121 #undef isdigit
    122 #undef isxdigit
    123 #undef isalnum
    124 #undef isprint
    125 #undef isascii
    126 #undef isgraph
    127 #undef ispunct
    128 #undef islower
    129 #undef isupper
    130 #undef isspace
    131 #undef iscntrl
    132 extern MODVAR unsigned char char_atribs[];
    133 
    134 #define PRINT 1
    135 #define CNTRL 2
    136 #define ALPHA 4
    137 #define PUNCT 8
    138 #define DIGIT 16
    139 #define SPACE 32
    140 #define ALLOW 64
    141 #define ALLOWN 128
    142 
    143 #ifndef KLINE_TEMP
    144 #define KLINE_PERM 0
    145 #define KLINE_TEMP 1
    146 #define KLINE_AKILL 2
    147 #define KLINE_EXCEPT 3
    148 #endif
    149 
    150 #define isallowed(c) (char_atribs[(u_char)(c)]&ALLOW)
    151 #define	iscntrl(c) (char_atribs[(u_char)(c)]&CNTRL)
    152 #define isalpha(c) (char_atribs[(u_char)(c)]&ALPHA)
    153 #define isspace(c) (char_atribs[(u_char)(c)]&SPACE)
    154 #define islower(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) > 0x5f))
    155 #define isupper(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) < 0x60))
    156 #define isdigit(c) (char_atribs[(u_char)(c)]&DIGIT)
    157 #define	isxdigit(c) (isdigit(c) || ('a' <= (c) && (c) <= 'f') || \
    158 		     ('A' <= (c) && (c) <= 'F'))
    159 #define isalnum(c) (char_atribs[(u_char)(c)]&(DIGIT|ALPHA))
    160 #define isprint(c) (char_atribs[(u_char)(c)]&PRINT)
    161 #define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f)
    162 #define isgraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32))
    163 #define ispunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT)))
    164 #define iswseperator(c) (!isalnum(c) && !((u_char)c >= 128))
    165 
    166 /*
    167  * Protocol support text.  DO NO CHANGE THIS unless you know what
    168  * you are doing.
    169  */
    170 
    171 /* IRCu/Hybrid/unrealircd way now :) -Stskeeps */
    172 
    173 #define EXPAR1	extchmstr[0]
    174 #define EXPAR2	extchmstr[1]
    175 #define EXPAR3	extchmstr[2]
    176 #define EXPAR4	extchmstr[3]
    177 #define CHPAR1  "beI"
    178 
    179 #ifdef _WIN32
    180 /*
    181  * Used to display a string to the GUI interface.
    182  * Windows' internal strerror() function doesn't work with socket errors.
    183  */
    184 extern int DisplayString(HWND hWnd, char *InBuf, ...);
    185 #else
    186 typedef int SOCKET;
    187 #define INVALID_SOCKET -1
    188 #endif
    189 
    190 #if defined(__FreeBSD__) || defined(__APPLE__)
    191 extern char *malloc_options;
    192 #endif
    193 
    194 extern int lu_noninv, lu_inv, lu_serv, lu_oper,
    195     lu_unknown, lu_channel, lu_lu, lu_lulocal, lu_lserv,
    196     lu_clu, lu_mlu, lu_cglobalu, lu_mglobalu;
    197 
    198 extern MODVAR time_t now;
    199 
    200 #ifndef _WIN32
    201 #if defined(__STDC__)
    202 #define __const         const
    203 #define __signed        signed
    204 #define __volatile      volatile
    205 #ifndef __GNUC__
    206 #define __inline
    207 #endif
    208 
    209 #else
    210 #ifndef __GNUC__
    211 #define __const
    212 #define __inline
    213 #define __signed
    214 #define __volatile
    215 #ifndef NO_ANSI_KEYWORDS
    216 #define const                           /* delete ANSI C keywords */
    217 #define inline
    218 #define signed
    219 #define volatile
    220 #endif
    221 #endif
    222 #endif
    223 #else
    224 #define inline __inline
    225 #endif
    226 
    227 #define READBUF_SIZE 8192
    228 
    229 #endif /* __common_include__ */