"Fossies" - the Fresh Open Source Software Archive

Member "bahamut-2.1.5/include/struct.h" (28 May 2020, 56294 Bytes) of package /linux/privat/bahamut-2.1.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "struct.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.1.4_vs_2.1.5.

    1 /************************************************************************
    2  *   IRC - Internet Relay Chat, include/struct.h
    3  *   Copyright (C) 1990 Jarkko Oikarinen and
    4  *                      University of Oulu, Computing Center
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 1, or (at your option)
    9  *   any later version.
   10  *
   11  *   This program is distributed in the hope that it will be useful,
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *   GNU General Public License for more details.
   15  *
   16  *   You should have received a copy of the GNU General Public License
   17  *   along with this program; if not, write to the Free Software
   18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   19  *
   20  *
   21  */
   22 
   23 #ifndef __struct_include__
   24 #define __struct_include__
   25 
   26 #include "config.h"
   27 #if !defined(CONFIG_H_LEVEL_184)
   28 #error Incorrect config.h for this revision of ircd.
   29 #endif
   30 
   31 #include "sys.h"
   32 
   33 #include <stdio.h>
   34 #include <sys/types.h>
   35 #include <sys/socket.h>
   36 #include <netinet/in.h>
   37 #include <netdb.h>
   38 #if defined( HAVE_STDDEF_H )
   39 #include <stddef.h>
   40 #endif
   41 #ifdef ORATIMING
   42 #include <sys/time.h>
   43 #endif
   44 
   45 #ifdef USE_SYSLOG
   46 #include <syslog.h>
   47 #if defined( HAVE_SYS_SYSLOG_H )
   48 #include <sys/syslog.h>
   49 #endif
   50 #endif
   51 
   52 #ifdef USE_SSL
   53 #include <openssl/rsa.h>       /* OpenSSL stuff */
   54 #include <openssl/crypto.h>
   55 #include <openssl/x509.h>
   56 #include <openssl/pem.h>
   57 #include <openssl/ssl.h>
   58 #include <openssl/err.h>
   59 #endif
   60 
   61 #define REPORT_DO_DNS_     ":%s NOTICE AUTH :*** Looking up your hostname..."
   62 #define REPORT_FIN_DNS_    ":%s NOTICE AUTH :*** Found your hostname"
   63 #define REPORT_FIN_DNSC_   ":%s NOTICE AUTH :*** Found your hostname, cached"
   64 #define REPORT_FAIL_DNS_   ":%s NOTICE AUTH :*** Couldn't look up your "\
   65                            "hostname"
   66 #define REPORT_DO_ID_      ":%s NOTICE AUTH :*** Checking Ident"
   67 #define REPORT_FIN_ID_     ":%s NOTICE AUTH :*** Got Ident response"
   68 #define REPORT_FAIL_ID_    ":%s NOTICE AUTH :*** No Ident response"
   69 #define REPORT_REJECT_ID_  ":%s NOTICE AUTH :*** Ignoring encrypted/unusable "\
   70                            "Ident response"
   71 
   72 extern char REPORT_DO_DNS[256], REPORT_FIN_DNS[256], REPORT_FIN_DNSC[256], 
   73     REPORT_FAIL_DNS[256], REPORT_DO_ID[256], REPORT_FIN_ID[256], 
   74     REPORT_FAIL_ID[256], REPORT_REJECT_ID[256];
   75 
   76 #include "hash.h"
   77 
   78 #include "sbuf.h"
   79 
   80 typedef struct Client aClient;
   81 typedef struct Channel aChannel;
   82 typedef struct User anUser;
   83 typedef struct Server aServer;
   84 typedef struct SLink Link;
   85 typedef struct SLinkD DLink;
   86 typedef struct ChanLink chanMember;
   87 typedef struct SMode Mode;
   88 typedef struct Watch aWatch;
   89 typedef struct Ban aBan;
   90 #ifdef INVITE_LISTS
   91 typedef struct LInvite anInvite;
   92 #endif
   93 #ifdef EXEMPT_LISTS
   94 typedef struct Exempt aBanExempt;
   95 #endif
   96 typedef struct ListOptions LOpts;
   97 typedef struct Listener aListener;
   98 typedef struct Conf_Connect aConnect;
   99 typedef struct Conf_Allow aAllow;
  100 typedef struct Conf_Oper aOper;
  101 typedef struct Conf_Me Conf_Me;
  102 typedef struct Conf_Port aPort;
  103 typedef struct Conf_Class aClass;
  104 typedef struct Conf_Modules Conf_Modules;
  105 typedef long ts_val;
  106 
  107 typedef struct MotdItem aMotd;
  108 typedef struct SAliasInfo AliasInfo;
  109 typedef struct SServicesTag ServicesTag;
  110 
  111 
  112 
  113 #define HOSTLEN     63  /* Length of hostname.  Updated to */
  114 
  115 /* comply with RFC1123 */
  116 
  117 #define HOSTIPLEN   45  /* Length of an IPv4 or IPv6 address */
  118 
  119 #define NICKLEN     30  
  120 
  121 /* Necessary to put 9 here instead of 10  if  
  122  * s_msg.c/m_nick has been corrected.  This 
  123  * preserves compatibility with old * servers --msa 
  124  */
  125 
  126 #define MAX_DATE_STRING 32  /* maximum string length for a date string */
  127 
  128 #define USERLEN         10
  129 #define REALLEN         50
  130 #define TOPICLEN        307
  131 #define KILLLEN             400
  132 #define CHANNELLEN          32
  133 #define PASSWDLEN       63
  134 #define KEYLEN          23
  135 #define BUFSIZE         512 /* WARNING: *DONT* CHANGE THIS!!!! */
  136 #define MAXRECIPIENTS       20
  137 #define MAXBANS         200
  138 #define MAXINVITELIST       100
  139 #define MAXEXEMPTLIST       100
  140 
  141 #define MOTDLINELEN     90
  142 
  143 #define        MAXSILES        10
  144 #define        MAXSILELENGTH   128
  145 
  146 #define MAXDCCALLOW 5
  147 #define DCC_LINK_ME 0x01    /* This is my dcc allow */
  148 #define DCC_LINK_REMOTE 0x02    /* I need to remove these dcc allows from
  149                  * these clients when I die
  150                  */
  151 
  152 #define USERHOST_REPLYLEN   (NICKLEN+HOSTLEN+USERLEN+5)
  153 
  154 /*
  155  * 'offsetof' is defined in ANSI-C. The following definition * is not
  156  * absolutely portable (I have been told), but so far * it has worked
  157  * on all machines I have needed it. The type * should be size_t but...
  158  * --msa
  159  */
  160 
  161 #ifndef offsetof
  162 #define offsetof(t,m) (int)((&((t *)0L)->m))
  163 #endif
  164 
  165 #define elementsof(x) (sizeof(x)/sizeof(x[0]))
  166 
  167 /* flags for bootup options (command line flags) */
  168 
  169 #define BOOT_CONSOLE     1
  170 #define BOOT_QUICK   2
  171 #define BOOT_DEBUG   4
  172 #define BOOT_TTY     8
  173 #define BOOT_OPER    16
  174 #define BOOT_STDERR  64
  175 #define STAT_LOG     -6 /* logfile for -x */
  176 #define STAT_CONNECTING  -4
  177 #define STAT_HANDSHAKE   -3
  178 #define STAT_ME      -2
  179 #define STAT_UNKNOWN     -1
  180 /* the line of truth lies here (truth == registeredness) */
  181 #define STAT_SERVER  0
  182 #define STAT_CLIENT  1
  183 
  184 /* status macros. */
  185 
  186 #define IsRegisteredUser(x) ((x)->status == STAT_CLIENT)
  187 #define IsRegistered(x)     ((x)->status >= STAT_SERVER)
  188 #define IsConnecting(x)     ((x)->status == STAT_CONNECTING)
  189 #define IsHandshake(x)      ((x)->status == STAT_HANDSHAKE)
  190 #define IsMe(x)         ((x)->status == STAT_ME)
  191 #define IsUnknown(x)        ((x)->status == STAT_UNKNOWN)
  192 #define IsServer(x)     ((x)->status == STAT_SERVER)
  193 #define IsClient(x)     ((x)->status == STAT_CLIENT)
  194 #define IsLog(x)        ((x)->status == STAT_LOG)
  195 
  196 #define SetConnecting(x)    ((x)->status = STAT_CONNECTING)
  197 #define SetHandshake(x)     ((x)->status = STAT_HANDSHAKE)
  198 #define SetMe(x)        ((x)->status = STAT_ME)
  199 #define SetUnknown(x)       ((x)->status = STAT_UNKNOWN)
  200 #define SetServer(x)        ((x)->status = STAT_SERVER)
  201 #define SetClient(x)        ((x)->status = STAT_CLIENT)
  202 #define SetLog(x)       ((x)->status = STAT_LOG)
  203 
  204 #define FLAGS_PINGSENT     0x000001   /* Unreplied ping sent */
  205 #define FLAGS_DEADSOCKET   0x000002   /* Local socket is dead--Exiting soon */
  206 #define FLAGS_KILLED       0x000004   /* Prevents "QUIT" from being sent for
  207                        * this */
  208 #define FLAGS_BLOCKED      0x000008   /* socket is in a blocked condition */
  209 #define FLAGS_CLOSING      0x000010   /* set when closing to suppress errors */
  210 #define FLAGS_LISTEN       0x000020   /* used to mark clients which we listen()
  211                        * on */
  212 #define FLAGS_HAVERECVQ    0x000040   /* Client has full commands in their recvq */
  213 #define FLAGS_DOINGDNS     0x000080   /* client is waiting for a DNS 
  214                        * response */
  215 #define FLAGS_AUTH     0x000100   /* client is waiting on rfc931 
  216                        * response */
  217 #define FLAGS_WRAUTH       0x000200   /* set if we havent writen to ident 
  218                        * server */
  219 #define FLAGS_LOCAL    0x000400   /* set for local clients */
  220 #define FLAGS_GOTID    0x000800   /* successful ident lookup achieved */
  221 #define FLAGS_DOID     0x001000   /* I-lines say must use ident return */
  222 #define FLAGS_NONL     0x002000   /* No \n in buffer */
  223 #define FLAGS_NORMALEX     0x004000   /* Client exited normally */
  224 #define FLAGS_SENDQEX      0x008000   /* Sendq exceeded */
  225 #define FLAGS_ULINE        0x020000   /* client is U-lined */
  226 #define FLAGS_USERBURST    0x040000   /* server in nick/channel netburst */
  227 #define FLAGS_TOPICBURST   0x080000   /* server in topic netburst */
  228 #define FLAGS_BURST    (FLAGS_USERBURST | FLAGS_TOPICBURST)
  229 #define FLAGS_SOBSENT      0x100000   /* we've sent an SOB, just have to 
  230                        * send an EOB */
  231 #define FLAGS_EOBRECV      0x200000   /* we're waiting on an EOB */
  232 #define FLAGS_BAD_DNS      0x400000   /* spoofer-guy */
  233 #define FLAGS_SERV_NEGO    0x800000  /* This is a server that has passed
  234                        * connection tests, but is a stat < 0
  235                        * for handshake purposes */
  236 #define FLAGS_RC4IN        0x1000000  /* This link is rc4 encrypted. */
  237 #define FLAGS_RC4OUT       0x2000000  /* This link is rc4 encrypted. */
  238 #define FLAGS_ZIPPED_IN    0x4000000  /* This link is gzipped. */
  239 #define FLAGS_ZIPPED_OUT   0x8000000 /* This link is gzipped. */
  240 #define FLAGS_SSL          0x10000000 /* client is using SSL */
  241 #define FLAGS_SPOOFED      0x20000000 /* User's host was spoofed (via SVSHOST) */
  242 
  243 /* Capabilities of the ircd or clients */
  244 
  245 #define CAPAB_DKEY    0x0001 /* server supports dh-key exchange */
  246 #define CAPAB_ZIP     0x0002 /* server supports gz'd links */
  247 #define CAPAB_DOZIP   0x0004 /* output to this link shall be gzipped */
  248 #define CAPAB_DODKEY  0x0008 /* do I do dkey with this link? */
  249 #define CAPAB_BURST   0x0010 /* server supports BURST command */
  250 #define CAPAB_UNCONN  0x0020 /* server supports UNCONNECT */
  251 #ifdef NOQUIT
  252 #define CAPAB_NOQUIT  0x0040 /* noquit support */
  253 #endif
  254 #define CAPAB_NICKIPSTR 0x0080 /* Nick IP as a string support */
  255 
  256 
  257 #define SetDKEY(x)  ((x)->capabilities |= CAPAB_DKEY)
  258 #define CanDoDKEY(x)    ((x)->capabilities & CAPAB_DKEY)
  259 /* N: line, flag E */
  260 #define SetWantDKEY(x) ((x)->capabilities |= CAPAB_DODKEY)
  261 #define WantDKEY(x) ((x)->capabilities & CAPAB_DODKEY) 
  262 
  263 #define SetZipCapable(x) ((x)->capabilities |= CAPAB_ZIP)
  264 #define IsZipCapable(x) ((x)->capabilities & CAPAB_ZIP)
  265 /* this is set in N: line, flag Z */
  266 #define DoZipThis(x)    ((x)->capabilities & CAPAB_DOZIP) 
  267 
  268 #define SetBurst(x)     ((x)->capabilities |= CAPAB_BURST)
  269 #define IsBurst(x)      ((x)->capabilities & CAPAB_BURST)
  270 
  271 #define SetUnconnect(x) ((x)->capabilities |= CAPAB_UNCONN)
  272 #define IsUnconnect(x)  ((x)->capabilities & CAPAB_UNCONN)
  273 
  274 #ifdef NOQUIT
  275 #define SetNoquit(x)    ((x)->capabilities |= CAPAB_NOQUIT)
  276 #define IsNoquit(x)     ((x)->capabilities & CAPAB_NOQUIT)
  277 #endif
  278 
  279 #define SetNickIPStr(x) ((x)->capabilities |= CAPAB_NICKIPSTR)
  280 #define IsNickIPStr(x)  ((x)->capabilities & CAPAB_NICKIPSTR)
  281 
  282 /* flag macros. */
  283 #define IsULine(x) ((x)->flags & FLAGS_ULINE)
  284 
  285 
  286 /* User Modes */
  287 #define UMODE_o     0x00001 /* umode +o - Oper */
  288 #define UMODE_O     0x00002 /* umode +O - Local Oper */
  289 #define UMODE_i     0x00004 /* umode +i - Invisible */
  290 #define UMODE_w     0x00008 /* umode +w - Get wallops */
  291 #define UMODE_s     0x00010 /* umode +s - Server notices */
  292 #define UMODE_c     0x00020 /* umode +c - Client connections/exits */
  293 #define UMODE_r     0x00040 /* umode +r - registered nick */
  294 #define UMODE_k     0x00080 /* umode +k - Server kill messages */
  295 #define UMODE_f     0x00100 /* umode +f - Server flood messages */
  296 #define UMODE_y     0x00200 /* umode +y - Stats/links */
  297 #define UMODE_d     0x00400 /* umode +d - Debug info */
  298 #define UMODE_P     0x00800     /* umode +P - User wants extra privacy (no spamfilter) */
  299 #define UMODE_g     0x01000 /* umode +g - Globops */
  300 #define UMODE_b     0x02000 /* umode +b - Chatops */
  301 #define UMODE_a     0x04000 /* umode +a - Services Admin */
  302 #define UMODE_A     0x08000     /* umode +A - Server Admin */
  303 #define UMODE_n     0x10000 /* umode +n - Routing Notices */
  304 #define UMODE_h     0x20000     /* umode +h - Helper */
  305 #define UMODE_m     0x40000     /* umode +m - spambot notices */
  306 #define UMODE_R     0x80000     /* unmode +R - No non registered msgs */
  307 #define UMODE_e     0x100000    /* umode +e - oper notices for the above +D */
  308 #define UMODE_x     0x200000    /* umode +x - Squelch with notice */
  309 #define UMODE_X     0x400000    /* umode +X - Squelch without notice */
  310 #define UMODE_D     0x800000    /* umode +D - Hidden dccallow umode */
  311 #define UMODE_F     0x1000000   /* umode +F - no cptr->since message rate throttle */
  312 #define UMODE_j     0x2000000   /* umode +j - client rejection notices */
  313 #define UMODE_K     0x4000000   /* umode +K - U: lined server kill messages */
  314 #define UMODE_I     0x8000000   /* umode +I - invisible oper (masked) */
  315 #define UMODE_S     0x10000000  /* umode +S - User is using SSL */
  316 #define UMODE_C     0x20000000  /* umode +C - User is only accepting private messages from users who share a common channel with them */
  317 #define UMODE_H     0x40000000  /* umode +H - User is host-masked */
  318 /* WARNING: Do not add any values greater than 0x40000000 unless you change Client->umode to unsigned long
  319             (and change everything else to support it) -Kobi & xPsycho. */
  320 
  321 /* for sendto_ops_lev */
  322 
  323 #define CCONN_LEV   1
  324 #define REJ_LEV     2
  325 #define SKILL_LEV   3
  326 #define SPY_LEV     4
  327 #define DEBUG_LEV   5
  328 #define FLOOD_LEV   6
  329 #define SPAM_LEV    7
  330 #define DCCSEND_LEV 8
  331 #define USKILL_LEV  9
  332 #define ADMIN_LEV   10
  333 
  334 /* SEND_UMODES:
  335  *  we send these to remote servers.
  336  * ALL_UMODES
  337  *  we send these to our clients.
  338  *  if you don't put something in ALL_UMODES, 
  339  *  that mode will be 'silent.'
  340  */
  341 
  342 #define SEND_UMODES (UMODE_a|UMODE_i|UMODE_o|UMODE_r|UMODE_A|UMODE_I|UMODE_R|UMODE_S|UMODE_C|UMODE_H|UMODE_P)
  343 #define ALL_UMODES (SEND_UMODES|UMODE_b|UMODE_c|UMODE_d|UMODE_e|UMODE_f|\
  344                     UMODE_g|UMODE_h|UMODE_j|UMODE_k|UMODE_m|UMODE_n|UMODE_s|\
  345                     UMODE_w|UMODE_y|UMODE_F|UMODE_K|UMODE_O)
  346 
  347 /* modes users can set themselves */
  348 #define USER_UMODES (UMODE_i|UMODE_k|UMODE_w|UMODE_s|UMODE_R|UMODE_C|UMODE_H|UMODE_P)
  349 
  350 /* modes only opers can have */
  351 #define OPER_UMODES (UMODE_a|UMODE_b|UMODE_c|UMODE_d|UMODE_e|UMODE_f|UMODE_g|\
  352                      UMODE_h|UMODE_j|UMODE_m|UMODE_n|UMODE_y|UMODE_A|UMODE_F|\
  353                      UMODE_K)
  354 
  355 #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID)
  356 
  357 #define IsOper(x)       ((x)->umode & UMODE_o)
  358 #define IsLocOp(x)      ((x)->umode & UMODE_O)
  359 #define IsInvisible(x)      ((x)->umode & UMODE_i)
  360 #define IsAnOper(x)     ((x)->umode & (UMODE_o|UMODE_O))
  361 #define CanBeOper(x)        ((x)->umode & (UMODE_o|UMODE_O|UMODE_I))
  362 #define IsARegNick(x)           ((x)->umode & (UMODE_r))
  363 #define IsRegNick(x)            ((x)->umode & UMODE_r)
  364 #define IsSAdmin(x)             ((x)->umode & UMODE_a)
  365 #define IsAdmin(x)              ((x)->umode & UMODE_A)
  366 #define IsUmodef(x)             ((x)->umode & UMODE_f)
  367 #define IsUmodec(x)             ((x)->umode & UMODE_c)
  368 #define IsUmodeC(x)     ((x)->umode & UMODE_C)
  369 #define IsUmodey(x)             ((x)->umode & UMODE_y)
  370 #define IsUmoded(x)             ((x)->umode & UMODE_d)
  371 #define IsUmodeb(x)             ((x)->umode & UMODE_b)
  372 #define IsUmoden(x)             ((x)->umode & UMODE_n)
  373 #define IsUmodem(x)             ((x)->umode & UMODE_m)
  374 #define IsUmodeh(x)             ((x)->umode & UMODE_h)
  375 #define IsUmodee(x)             ((x)->umode & UMODE_e)
  376 #define IsUmodej(x)     ((x)->umode & UMODE_j)
  377 #define IsUmodeK(x)     ((x)->umode & UMODE_K)
  378 #define IsUmodek(x)     ((x)->umode & UMODE_k)
  379 #define IsUmodeS(x)     ((x)->umode & UMODE_S)
  380 #define IsUmodes(x)     ((x)->umode & UMODE_s)
  381 #define IsUmodeI(x)     ((x)->umode & UMODE_I)
  382 #define IsUmodeH(x)     ((x)->umode & UMODE_H)
  383 #define IsUmodeP(x)     ((x)->umode & UMODE_P)
  384 #define IsNoNonReg(x)           ((x)->umode & UMODE_R)
  385 #define IsWSquelch(x)           ((x)->umode & UMODE_x)
  386 #define IsSSquelch(x)           ((x)->umode & UMODE_X)
  387 #define IsSquelch(x)            (IsSSquelch(x) || IsWSquelch(x))
  388 #define IsPerson(x)     ((x)->user && IsClient(x))
  389 #define IsPrivileged(x)     (IsAnOper(x) || IsServer(x))
  390 #define SendWallops(x)      ((x)->umode & UMODE_w)
  391 #define SendServNotice(x)   ((x)->umode & UMODE_s)
  392 #define SendCConnNotice(x)  ((x)->umode & UMODE_c)
  393 #define SendRejNotice(x)    ((x)->umode & UMODE_j)
  394 #define SendSkillNotice(x)  ((x)->umode & UMODE_k)
  395 #define SendSUkillNotice(x) ((x)->umode & UMODE_K)
  396 #define SendSpyNotice(x)    ((x)->umode & UMODE_y)
  397 #define SendDCCNotice(x)    ((x)->umode & UMODE_e)
  398 #define SendFloodNotice(x)      ((x)->umode & UMODE_f)
  399 #define SendSpamNotice(x)       ((x)->umode & UMODE_m)
  400 #define SendDebugNotice(x)  ((x)->umode & UMODE_d)
  401 #define SendGlobops(x)          ((x)->umode & UMODE_g)
  402 #define SendChatops(x)          ((x)->umode & UMODE_b)
  403 #define SendRnotice(x)          ((x)->umode & UMODE_n)
  404 #define NoMsgThrottle(x)    ((x)->umode & UMODE_F)
  405 #define IsListening(x)      ((x)->flags & FLAGS_LISTEN)
  406 #define IsLocal(x)      ((x)->flags & FLAGS_LOCAL)
  407 #define IsDead(x)       ((x)->flags & FLAGS_DEADSOCKET)
  408 #define SetOper(x)      ((x)->umode |= UMODE_o)
  409 #define SetRegNick(x)           ((x)->umode |= UMODE_r)
  410 #define SetNoNonReg(x)          ((x)->umode |= UMODE_R)
  411 #define SetSAdmin(x)            ((x)->umode |= UMODE_a)
  412 #define SetLocOp(x)         ((x)->umode |= UMODE_O)
  413 #define SetInvisible(x)     ((x)->umode |= UMODE_i)
  414 #define SetWallops(x)       ((x)->umode |= UMODE_w)
  415 #define SetWSquelch(x)          ((x)->umode |= UMODE_x)
  416 #define SetSSquelch(x)          ((x)->umode |= UMODE_X)
  417 #define SetNoMsgThrottle(x) ((x)->umode |= UMODE_F)
  418 #define SetDNS(x)       ((x)->flags |= FLAGS_DOINGDNS)
  419 #define DoingDNS(x)     ((x)->flags & FLAGS_DOINGDNS)
  420 #define DoingAuth(x)        ((x)->flags & FLAGS_AUTH)
  421 #define NoNewLine(x)        ((x)->flags & FLAGS_NONL)
  422 #define SeenDCCNotice(x)        ((x)->umode & UMODE_D)
  423 #define SetDCCNotice(x)         ((x)->umode |= UMODE_D)
  424 
  425 #define SetNegoServer(x)    ((x)->flags |= FLAGS_SERV_NEGO)
  426 #define IsNegoServer(x)     ((x)->flags & FLAGS_SERV_NEGO)
  427 #define ClearNegoServer(x)  ((x)->flags &= ~FLAGS_SERV_NEGO)
  428 #define IsRC4OUT(x)     ((x)->flags & FLAGS_RC4OUT)
  429 #define SetRC4OUT(x)        ((x)->flags |= FLAGS_RC4OUT)
  430 #define IsRC4IN(x)      ((x)->flags & FLAGS_RC4IN)
  431 #define SetRC4IN(x)     ((x)->flags |= FLAGS_RC4IN)
  432 #define RC4EncLink(x)       (((x)->flags & (FLAGS_RC4IN|FLAGS_RC4OUT)) ==\
  433                                  (FLAGS_RC4IN|FLAGS_RC4OUT))
  434 
  435 #define ZipIn(x)        ((x)->flags & FLAGS_ZIPPED_IN)
  436 #define SetZipIn(x)     ((x)->flags |= FLAGS_ZIPPED_IN)
  437 #define ZipOut(x)       ((x)->flags & FLAGS_ZIPPED_OUT)
  438 #define SetZipOut(x)        ((x)->flags |= FLAGS_ZIPPED_OUT)
  439 
  440 #define IsSSL(x)        ((x)->flags & FLAGS_SSL)
  441 #define SetSSL(x)       ((x)->flags |= FLAGS_SSL)
  442 
  443 #define ClearSAdmin(x)          ((x)->umode &= ~UMODE_a)
  444 #define ClearAdmin(x)           ((x)->umode &= ~UMODE_A)
  445 #define ClearUmodef(x)          ((x)->umode &= ~UMODE_f)
  446 #define ClearUmodem(x)          ((x)->umode &= ~UMODE_m)
  447 #define ClearUmodec(x)          ((x)->umode &= ~UMODE_c)
  448 #define ClearUmodey(x)          ((x)->umode &= ~UMODE_y)
  449 #define ClearUmoded(x)          ((x)->umode &= ~UMODE_d)
  450 #define ClearUmodeb(x)          ((x)->umode &= ~UMODE_b)
  451 #define ClearUmoden(x)          ((x)->umode &= ~UMODE_n)
  452 #define ClearUmodeh(x)          ((x)->umode &= ~UMODE_h)
  453 #define ClearUmodee(x)          ((x)->umode &= ~UMODE_e)
  454 #define ClearUmodej(x)      ((x)->umode &= ~UMODE_j)
  455 #define ClearUmodeK(x)      ((x)->umode &= ~UMODE_K)
  456 #define ClearUmodek(x)      ((x)->umode &= ~UMODE_k)
  457 #define ClearUmodes(x)      ((x)->umode &= ~UMODE_s)
  458 #define ClearUmodeI(x)      ((x)->umode &= ~UMODE_I)
  459 #define ClearNoNonReg(x)        ((x)->umode &= ~UMODE_R)
  460 #define ClearWSquelch(x)        ((x)->umode &= ~UMODE_x)
  461 #define ClearSSquelch(x)        ((x)->umode &= ~UMODE_X)
  462 #define ClearOper(x)        ((x)->umode &= ~UMODE_o)
  463 #define ClearLocOp(x)       ((x)->umode &= ~UMODE_O)
  464 #define ClearInvisible(x)   ((x)->umode &= ~UMODE_i)
  465 #define ClearWallops(x)     ((x)->umode &= ~UMODE_w)
  466 #define ClearNoMsgThrottle(x)   ((x)->umode &= ~UMODE_F)
  467 #define ClearDNS(x)     ((x)->flags &= ~FLAGS_DOINGDNS)
  468 #define ClearAuth(x)        ((x)->flags &= ~FLAGS_AUTH)
  469 
  470 /* Oper flags */
  471 
  472 /* defined operator access levels */ 
  473 #define OFLAG_REHASH    0x00000001  /* Oper can /rehash server */
  474 #define OFLAG_DIE   0x00000002  /* Oper can /die the server */
  475 #define OFLAG_RESTART   0x00000004  /* Oper can /restart the server */
  476 #define OFLAG_HELPOP    0x00000010  /* Oper can send /HelpOps */
  477 #define OFLAG_GLOBOP    0x00000020  /* Oper can send /GlobOps */
  478 #define OFLAG_WALLOP    0x00000040  /* Oper can send /WallOps */
  479 #define OFLAG_LOCOP 0x00000080  /* Oper can send /LocOps */
  480 #define OFLAG_LROUTE    0x00000100  /* Oper can do local routing */
  481 #define OFLAG_GROUTE    0x00000200  /* Oper can do global routing */
  482 #define OFLAG_LKILL 0x00000400  /* Oper can do local kills */
  483 #define OFLAG_GKILL 0x00000800  /* Oper can do global kills */
  484 #define OFLAG_KLINE 0x00001000  /* Oper can /kline users */
  485 #define OFLAG_UNKLINE   0x00002000  /* Oper can /unkline users */
  486 #define OFLAG_LNOTICE   0x00004000  /* Oper can send local serv notices */
  487 #define OFLAG_GNOTICE   0x00008000  /* Oper can send global notices */
  488 #define OFLAG_ADMIN 0x00010000  /* Admin */
  489 #define OFLAG_UMODEc    0x00020000  /* Oper can set umode +c : client connect */
  490 #define OFLAG_UMODEf    0x00040000  /* Oper can set umode +f : flood notices */
  491 #define OFLAG_SADMIN    0x00080000  /* Oper can be a services admin */
  492 #define OFLAG_ZLINE 0x00100000  /* Oper can use /zline and /unzline */
  493 #define OFLAG_UMODEy    0x00200000  /* Oper can set umode +y : spy */
  494 #define OFLAG_UMODEd    0x00400000  /* Oper can set umode +d : debug */
  495 #define OFLAG_UMODEb    0x00800000  /* Oper can set umode +b : chatops */
  496 #define OFLAG_UMODEF    0x01000000  /* Oper can set umode +F : no flood throttling */
  497 #define OFLAG_LOCAL (OFLAG_REHASH|OFLAG_HELPOP|OFLAG_GLOBOP|OFLAG_WALLOP|\
  498                          OFLAG_LOCOP|OFLAG_LROUTE|OFLAG_LKILL|OFLAG_KLINE|\
  499                          OFLAG_UNKLINE|OFLAG_LNOTICE|OFLAG_UMODEc|OFLAG_UMODEf|OFLAG_UMODEd|\
  500                          OFLAG_UMODEb|OFLAG_UMODEy)
  501 #define OFLAG_GLOBAL    (OFLAG_LOCAL|OFLAG_GROUTE|OFLAG_GKILL|OFLAG_GNOTICE)
  502 #define OFLAG_ISGLOBAL  (OFLAG_GROUTE|OFLAG_GKILL|OFLAG_GNOTICE|OFLAG_SADMIN|OFLAG_UMODEF)
  503 #define OPCanZline(x)           ((x)->oflag & OFLAG_SADMIN)
  504 #define OPCanRehash(x)          ((x)->oflag & OFLAG_REHASH)
  505 #define OPCanDie(x)         ((x)->oflag & OFLAG_DIE)
  506 #define OPCanRestart(x)         ((x)->oflag & OFLAG_RESTART)
  507 #define OPCanHelpOp(x)          ((x)->oflag & OFLAG_HELPOP)
  508 #define OPCanGlobOps(x)         ((x)->oflag & OFLAG_GLOBOP)
  509 #define OPCanWallOps(x)         ((x)->oflag & OFLAG_WALLOP)
  510 #define OPCanLocOps(x)          ((x)->oflag & OFLAG_LOCOP)
  511 #define OPCanLRoute(x)          ((x)->oflag & OFLAG_LROUTE)
  512 #define OPCanGRoute(x)          ((x)->oflag & OFLAG_GROUTE)
  513 #define OPCanLKill(x)           ((x)->oflag & OFLAG_LKILL)
  514 #define OPCanGKill(x)           ((x)->oflag & OFLAG_GKILL)
  515 #define OPCanKline(x)           ((x)->oflag & OFLAG_KLINE)
  516 #define OPCanUnKline(x)         ((x)->oflag & OFLAG_UNKLINE)
  517 #define OPCanLNotice(x)         ((x)->oflag & OFLAG_LNOTICE)
  518 #define OPCanGNotice(x)         ((x)->oflag & OFLAG_GNOTICE)
  519 #define OPIsAdmin(x)            ((x)->oflag & OFLAG_ADMIN)
  520 #define OPIsSAdmin(x)           ((x)->oflag & OFLAG_SADMIN)
  521 #define OPCanUModec(x)          ((x)->oflag & OFLAG_UMODEc)
  522 #define OPCanUModef(x)          ((x)->oflag & OFLAG_UMODEf)
  523 #define OPCanUModey(x)          ((x)->oflag & OFLAG_UMODEy)     
  524 #define OPCanUModed(x)          ((x)->oflag & OFLAG_UMODEd)     
  525 #define OPCanUModeb(x)          ((x)->oflag & OFLAG_UMODEb)
  526 #define OPCanUModeF(x)      ((x)->oflag & OFLAG_UMODEF)
  527 #define OPClearRehash(x)    ((x)->oflag &= ~OFLAG_REHASH)
  528 #define OPClearDie(x)       ((x)->oflag &= ~OFLAG_DIE)  
  529 #define OPClearRestart(x)   ((x)->oflag &= ~OFLAG_RESTART)
  530 #define OPClearHelpOp(x)    ((x)->oflag &= ~OFLAG_HELPOP)
  531 #define OPClearGlobOps(x)   ((x)->oflag &= ~OFLAG_GLOBOP)
  532 #define OPClearWallOps(x)   ((x)->oflag &= ~OFLAG_WALLOP)
  533 #define OPClearLocOps(x)    ((x)->oflag &= ~OFLAG_LOCOP)
  534 #define OPClearLRoute(x)    ((x)->oflag &= ~OFLAG_LROUTE)
  535 #define OPClearGRoute(x)    ((x)->oflag &= ~OFLAG_GROUTE)
  536 #define OPClearLKill(x)     ((x)->oflag &= ~OFLAG_LKILL)
  537 #define OPClearGKill(x)     ((x)->oflag &= ~OFLAG_GKILL)
  538 #define OPClearKline(x)     ((x)->oflag &= ~OFLAG_KLINE)
  539 #define OPClearUnKline(x)   ((x)->oflag &= ~OFLAG_UNKLINE)
  540 #define OPClearLNotice(x)   ((x)->oflag &= ~OFLAG_LNOTICE)
  541 #define OPClearGNotice(x)   ((x)->oflag &= ~OFLAG_GNOTICE)
  542 #define OPClearAdmin(x)     ((x)->oflag &= ~OFLAG_ADMIN)
  543 #define OPClearSAdmin(x)    ((x)->oflag &= ~OFLAG_SADMIN)
  544 #define OPClearUModec(x)    ((x)->oflag &= ~OFLAG_UMODEc)
  545 #define OPClearUModef(x)    ((x)->oflag &= ~OFLAG_UMODEf)
  546 #define OPClearUModey(x)        ((x)->oflag &= ~OFLAG_UMODEy) 
  547 #define OPClearUModed(x)        ((x)->oflag &= ~OFLAG_UMODEd) 
  548 #define OPClearUModeb(x)        ((x)->oflag &= ~OFLAG_UMODEb)
  549 #define OPClearZLine(x)     ((x)->oflag &= ~OFLAG_ZLINE)
  550 #define OPClearUModeF(x)    ((x)->oflag &= ~OFLAG_UMODEF)
  551 
  552 /* defined debugging levels */
  553 #define DEBUG_FATAL  0
  554 #define DEBUG_ERROR  1 /* report_error() and other errors that are found */
  555 #define DEBUG_NOTICE 3
  556 #define DEBUG_DNS    4 /* used by all DNS related routines - a *lot* */
  557 #define DEBUG_INFO   5 /* general usful info */
  558 #define DEBUG_NUM    6 /* numerics */
  559 #define DEBUG_SEND   7 /* everything that is sent out */
  560 #define DEBUG_DEBUG  8 /* anything to do with debugging, ie unimportant :) */
  561 #define DEBUG_MALLOC 9 /* malloc/free calls */
  562 #define DEBUG_LIST  10 /* debug list use */
  563 /* defines for curses in client */
  564 #define DUMMY_TERM  0
  565 #define CURSES_TERM 1
  566 #define TERMCAP_TERM    2
  567 
  568 struct Counter 
  569 {
  570     int         server;      /* servers */
  571     int         myserver;    /* my servers */
  572     int         myulined;    /* my ulined servers */
  573     int         oper;        /* Opers */
  574     int         chan;        /* Channels */
  575     int         local;       /* Local Clients */
  576     int         total;       /* total clients */
  577     int         invisi;      /* invisible clients */
  578     int         unknown;     /* unknown connections */
  579     int         max_loc;     /* MAX local clients */
  580     int         max_tot;     /* MAX global clients */
  581     ts_val      start;       /* when we started collecting info */
  582     u_long      today;       /* Client Connections today */
  583     ts_val      day;         /* when today started */
  584     u_long  weekly;      /* connections this week */
  585     ts_val  week;        /* when this week started */
  586     u_long  monthly;     /* connections this month */
  587     ts_val  month;       /* when this month started */
  588     u_long  yearly;      /* this is gonna be big */
  589     ts_val  year;        /* when this year started (HEH!) */
  590 };
  591 
  592 struct MotdItem 
  593 {
  594     char        line[MOTDLINELEN];
  595     struct MotdItem *next;
  596 };
  597 
  598 /* lets speed this up... also removed away information. *tough* Dianora */
  599 typedef struct Whowas 
  600 {
  601     int         hashv;
  602     char        name[NICKLEN + 1];
  603     char        username[USERLEN + 1];
  604     char        hostname[HOSTLEN + 1];
  605 #ifdef USER_HOSTMASKING
  606     char        mhostname[HOSTLEN + 1];
  607     char        hostip[HOSTIPLEN + 1];
  608 #endif
  609     char       *servername;
  610     char        realname[REALLEN + 1];
  611     time_t      logoff;
  612     long umode;
  613     struct Client *online;  /* Pointer to new nickname for chasing or NULL */
  614     
  615     struct Whowas *next;    /* for hash table... */
  616     
  617     struct Whowas *prev;    /* for hash table... */
  618     struct Whowas *cnext;   /* for client struct linked list */
  619     struct Whowas *cprev;   /* for client struct linked list */
  620 } aWhowas;
  621 
  622 /* configuration structures */
  623 
  624 #define CONF_ILLEGAL            0x80000000
  625 #define CONF_MATCH              0x40000000
  626 
  627 #define CONF_CLIENT             0x0002
  628 #define CONF_CONNECT_SERVER     0x0004
  629 #define CONF_NOCONNECT_SERVER   0x0008
  630 #define CONF_LOCOP              0x0010
  631 #define CONF_OPERATOR           0x0020
  632 #define CONF_ME                 0x0040
  633 #define CONF_KILL               0x0080
  634 #define CONF_ADMIN              0x0100
  635 #define CONF_CLASS              0x0200
  636 #define CONF_SERVICE            0x0400
  637 #define CONF_LISTEN_PORT        0x1000
  638 #define CONF_HUB                0x2000
  639 #define CONF_ELINE              0x4000
  640 #define CONF_FLINE              0x8000
  641 #define CONF_QUARANTINE         0x40000
  642 #define CONF_ULINE              0x80000
  643 #define CONF_DRPASS             0x100000    /* die/restart pass, from df465 */
  644 #define CONF_GCOS               0x200000
  645 #define CONF_SQLINE             0x400000
  646 #define CONF_MONINFO            0x800000    /* proxy monitor info */
  647 #define CONF_OPS                (CONF_OPERATOR | CONF_LOCOP)
  648 #define CONF_SERVER_MASK        (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER)
  649 #define CONF_CLIENT_MASK        (CONF_CLIENT | CONF_SERVICE | CONF_OPS | \
  650                                  CONF_SERVER_MASK)
  651 #define IsIllegal(x)            ((x)->status & CONF_ILLEGAL)
  652 
  653 /* did the password field specify OPER? */
  654 #define CONF_FLAGS_I_OPERPORT      0x0002
  655 /* does NAME in I:HOST::NAME have an @? */
  656 #define CONF_FLAGS_I_NAME_HAS_AT   0x0004
  657 /* does HOST in I:HOST::NAME have an @? */
  658 #define CONF_FLAGS_I_HOST_HAS_AT   0x0008
  659 /* do we match allow:hostmask? */
  660 #define CONF_FLAGS_I_MATCH_NAME    0x0010
  661 /* do we match allow:ipmask? */
  662 #define CONF_FLAGS_I_MATCH_HOST    0x0020
  663 /* remove throttle on match? */
  664 #define CONF_FLAGS_NOTHROTTLE      0x0040
  665 /* force umode +F? */
  666 #define CONF_FLAGS_FORCEFLOOD      0x0080
  667 /* skip clone checks? */
  668 #define CONF_FLAGS_SKIPCLONES      0x0100
  669 
  670 /* Port block flags */
  671 #define CONF_FLAGS_P_SSL      0x01
  672 #define CONF_FLAGS_P_NODNS    0x02
  673 #define CONF_FLAGS_P_NOIDENT  0x04
  674 
  675 /* global configuration flags */
  676 
  677 #define FLAGS_HUB       0x0001
  678 #define FLAGS_SERVHUB   0x0002
  679 #define FLAGS_SMOTD     0x0004
  680 #define FLAGS_CRYPTPASS 0x0008
  681 #define FLAGS_WGMONURL  0x0010
  682 #define FLAGS_WGMONHOST 0x0020
  683 #define FLAGS_WGMON     (FLAGS_WGMONURL|FLAGS_WGMONHOST)
  684 #define FLAGS_SHOWLINKS 0x0040
  685 #define FLAGS_SPLITOPOK 0x0080
  686 #define FLAGS_REMREHOK  0x0100
  687 
  688 
  689 /* flags for connects */
  690 
  691 #define CONN_ZIP    0x001   /* zippable    */
  692 #define CONN_DKEY   0x010   /* cryptable   */
  693 #define CONN_HUB    0x100   /* hubbable!   */
  694 
  695 /* U:line flags in Server struct */
  696 
  697 #define ULF_SFDIRECT    0x00000001  /* send shortform commands */
  698 #define ULF_NOBTOPIC    0x00000002  /* don't send TOPICs on burst */
  699 #define ULF_NOAWAY      0x00000004  /* don't send AWAYs at all */
  700 #define ULF_NOBAWAY     0x00000008  /* don't send AWAYs on burst */
  701 #define ULF_NOCHANMSG   0x00000010  /* don't send channel messages/notices */
  702 #define ULF_NONOTICE    0x00000020  /* don't send private notices */
  703 #define ULF_NOGLOBOPS   0x00000040  /* don't send globops */
  704 
  705 
  706 struct Conf_Connect
  707 {
  708     /* this is currently BOTH C:lines and N:lines */
  709     char *host;
  710     char *apasswd;  /* nline password - to accept connection */
  711     char *cpasswd;  /* cline password - to connect out with  */
  712     char *name;
  713     char *source;   /* when connecting, use this IP address  */
  714     int ipnum_family;
  715     union
  716     {
  717         struct in_addr ip4;
  718         struct in6_addr ip6;
  719     } ipnum;    /* ip address host field */
  720     int   port;
  721     int   flags;
  722     int   legal;
  723     int   uflags;   /* U:lined flags */
  724     aClient *acpt;  /* whos using this! */
  725     time_t   hold;  /* used for autoconnections */
  726     char *class_name;   /* the accual name of our class */
  727     aClass   *class;    /* pointer to the class */
  728     aConnect *next;
  729 };
  730 
  731 struct Conf_Allow
  732 {
  733     /* this is an I:line */
  734     char *ipmask;
  735     char *passwd;
  736     char *hostmask;
  737     int   port;
  738     int   flags;
  739     int   clients;
  740     int   legal;
  741     char *class_name;
  742     aClass *class;
  743     aAllow *next;
  744 };
  745 
  746 struct Conf_Me
  747 {
  748     /* combined A, X and M lines */
  749     char *servername;
  750     char *info;
  751     char *diepass;
  752     char *restartpass;
  753     char *admin[3];     /* our three admin lines */
  754 };
  755 
  756 #define MAXHOSTS 32
  757 
  758 struct Conf_Oper
  759 {
  760     /* this is an O:line */
  761     char *hosts[MAXHOSTS+1];
  762     char *passwd;
  763     char *nick;
  764     int   flags;
  765     int   legal;
  766     int   opers;    /* number of opers currently using this */
  767     char *class_name;
  768     aClass *class;
  769     aOper *next;
  770 };
  771 
  772 struct Conf_Modules
  773 {
  774     char *module_path;
  775     char *autoload[128];
  776     char *optload[128];
  777 };
  778 
  779 struct Conf_Port
  780 {
  781     char *allow;
  782     char *address;
  783     int   port;
  784     int   flags; /* For ssl flag (and noidentd/nodns flags in the future...) */
  785     aListener *lstn;
  786     int   legal;
  787     aPort *next;
  788 };
  789 
  790 struct Conf_Class
  791 {
  792     char        *name;
  793     int          connfreq;
  794     int          pingfreq;
  795     int          maxlinks;
  796     long         maxsendq;
  797     int          ip24clones;
  798     int          links;
  799     int          refs;
  800     int          maxrecvq;
  801     aClass      *next;
  802 };
  803 
  804 struct Listener {
  805         struct Listener *next;              /* next listener */
  806         int             fd;                 /* fd of this listener */
  807         u_short         port; 
  808         char            allow_string[HOSTLEN + 1];   /* allow from */
  809         char            vhost_string[HOSTLEN + 1];   /* bind to */
  810     int allow_cidr_bits;
  811     struct
  812     {
  813         char ip[16];
  814     } allow_ip; /* allow from */
  815         time_t          lasttime;           /* last time I accepted */
  816         long            sendK;              /* counters, see below */
  817         u_short         sendB;           
  818         long            sendM;          
  819         long            receiveK;      
  820         u_short         receiveB;     
  821         long            receiveM;    
  822         u_long          ccount;   /* total number of clients to connect here */
  823         int             clients;  /* number of clients currently on this */
  824         aPort           *aport;   /* link to the P: line I came from */
  825         int             flags;    /* Flags for ssl (and nodns/noidentd in the future) */
  826 #ifdef USE_SSL
  827         SSL             *ssl;
  828         X509            *client_cert;
  829 #endif
  830 };
  831 
  832 struct SServicesTag
  833 {
  834   char *tag;
  835   int raw;
  836   long umode;
  837   ServicesTag *next;
  838 };
  839 
  840 /* Client structures */
  841 struct User
  842 {
  843     Link       *channel;       /* chain of channel pointer blocks */
  844     Link       *invited;       /* chain of invite pointer blocks */
  845     char       *away;          /* pointer to away message */
  846     time_t      last;
  847     int         joined;        /* number of channels joined */
  848     char        username[USERLEN + 1];
  849     char        host[HOSTLEN + 1];
  850 #ifdef USER_HOSTMASKING
  851     char        mhost[HOSTLEN + 1];
  852 #endif
  853     char       *server;        /* pointer to scached server name */
  854     unsigned int servicetype;  /* set by SVSMODE +T */
  855     unsigned long servicestamp; /* set by SVSMODE +d */
  856     ServicesTag *servicestag;  /* set by SVSTAG */
  857     AliasInfo  *alias;         /* shortform alias data for U:lined clients */
  858     /*
  859      * In a perfect world the 'server' name should not be needed, a
  860      * pointer to the client describing the server is enough. 
  861      * Unfortunately, in reality, server may not yet be in links while
  862      * USER is introduced... --msa
  863      */
  864     Link       *silence;      /* chain of silenced users */
  865     LOpts      *lopt;     /* Saved /list options */
  866     Link       *dccallow;     /* chain of dcc send allowed users */
  867 #if (RIDICULOUS_PARANOIA_LEVEL>=1)
  868     char       *real_oper_host;
  869     char       *real_oper_username;
  870     char       *real_oper_ip;
  871 #endif
  872     aOper      *oper;
  873     aAllow     *allow;
  874 };
  875 
  876 struct Server
  877 {
  878     char       *up;       /* Pointer to scache name */
  879     char        bynick[NICKLEN + 1];
  880     char        byuser[USERLEN + 1];
  881     char        byhost[HOSTLEN + 1];
  882     aConnect   *aconn;              /* N-line pointer for this server */
  883     int         dkey_flags;         /* dkey flags */
  884 #ifdef HAVE_ENCRYPTION_ON
  885     void       *sessioninfo_in;   /* pointer to opaque sessioninfo structure */
  886     void       *sessioninfo_out;  /* pointer to opaque sessioninfo structure */
  887     void       *rc4_in;           /* etc */
  888     void       *rc4_out;          /* etc */
  889 #endif
  890     void       *zip_out;
  891     void       *zip_in;
  892     int         uflags;           /* U:lined flags */
  893 };
  894 
  895 struct Client 
  896 {
  897     struct Client *next, *prev, *hnext;
  898     anUser     *user;       /* ...defined, if this is a User */
  899     aServer    *serv;       /* ...defined, if this is a server */
  900     aWhowas    *whowas;     /* Pointers to whowas structs */
  901     time_t      lasttime;   /* ...should be only LOCAL clients? --msa */
  902     time_t      firsttime;  /* time client was created */
  903     time_t      since;      /* last time we parsed something */
  904     ts_val      tsinfo;     /* TS on the nick, SVINFO on servers */
  905     long        flags;      /* client flags */
  906     long        umode;      /* We can illeviate overflow this way
  907                                Note: if you change this, you need to also
  908                                change struct SearchOptions,
  909                                struct Whowas and struct SServicesTag -Kobi.
  910                              */
  911     aClient    *from;       /* == self, if Local Client, *NEVER* NULL! */
  912     aClient    *uplink;     /* this client's uplink to the network */
  913     int         fd;         /* >= 0, for local clients */
  914     int         hopcount;   /* number of servers to this 0 = local */
  915     short       status;     /* Client type */
  916     char        nicksent;
  917     char        name[HOSTLEN + 1];  /* Unique name of the client, nick or
  918                      * host */
  919     char        info[REALLEN + 1];  /* Free form additional client 
  920                      * information */
  921 #ifdef FLUD
  922     Link       *fludees;
  923 #endif
  924     
  925     unsigned int ip_family;
  926     union
  927     {
  928     struct in_addr ip4;
  929     struct in6_addr ip6;
  930     } ip; /* keep real ip# too */
  931     char        hostip[HOSTIPLEN + 1]; /* Keep real ip as string 
  932                     * too - Dianora */
  933     
  934     Link *watch; /* user's watch list */
  935     int watches; /* how many watches this user has set */
  936 
  937 #ifdef THROTTLE_ENABLE
  938     struct {                /* clone tracking */
  939         aClient     *prev;
  940         aClient     *next;
  941     } clone;
  942 #endif
  943     
  944 /*
  945 ####### #     # ### #     #  #####   #####
  946    #    #     #  #  ##    # #     # #     #
  947    #    #     #  #  # #   # #       #
  948    #    #######  #  #  #  # #  ####  #####
  949    #    #     #  #  #   # # #     #       #
  950    #    #     #  #  #    ## #     # #     #
  951    #    #     # ### #     #  #####   #####
  952 
  953 ######  ####### #       ####### #     #
  954 #     # #       #       #     # #  #  #
  955 #     # #       #       #     # #  #  #
  956 ######  #####   #       #     # #  #  #
  957 #     # #       #       #     # #  #  #
  958 #     # #       #       #     # #  #  #
  959 ######  ####### ####### #######  ## ##
  960 
  961  #####  ####### #     # #     # #######
  962 #     # #     # #     # ##    #    #
  963 #       #     # #     # # #   #    #
  964 #       #     # #     # #  #  #    #
  965 #       #     # #     # #   # #    #
  966 #     # #     # #     # #    ##    #
  967  #####  #######  #####  #     #    #
  968 
  969    #    ######  #######    #       #######  #####     #    #
  970   # #   #     # #          #       #     # #     #   # #   #
  971  #   #  #     # #          #       #     # #        #   #  #
  972 #     # ######  #####      #       #     # #       #     # #
  973 ####### #   #   #          #       #     # #       ####### #
  974 #     # #    #  #          #       #     # #     # #     # #
  975 #     # #     # #######    ####### #######  #####  #     # #######
  976 
  977 ####### #     # #       #     # ### ### ###
  978 #     # ##    # #        #   #  ### ### ###
  979 #     # # #   # #         # #   ### ### ###
  980 #     # #  #  # #          #     #   #   #
  981 #     # #   # # #          #
  982 #     # #    ## #          #    ### ### ###
  983 ####### #     # #######    #    ### ### ###
  984 
  985 */
  986     /*
  987      * The following fields are allocated only for local clients 
  988      * (directly connected to this server with a socket.  The first
  989      * of them MUST be the "count"--it is the field to which the
  990      * allocation is tied to! Never refer to  these fields, if (from != self).
  991      */
  992     
  993     int         count;      /* Amount of data in buffer */
  994 #ifdef FLUD
  995     time_t      fludblock;
  996     struct fludbot *fluders;
  997 #endif
  998 #ifdef ANTI_SPAMBOT
  999     time_t      last_join_time;  /* when this client last joined a channel */
 1000     time_t      last_leave_time; /* when this client last left a channel */
 1001     int         join_leave_count;   /* count of JOIN/LEAVE in less 
 1002                      * than MIN_JOIN_LEAVE_TIME seconds */
 1003     int         oper_warn_count_down;   /* warn opers of this possible spambot 
 1004                      * every time this gets to 0 */
 1005 #endif
 1006     char        buffer[BUFSIZE];        /* Incoming message buffer */
 1007     short       lastsq;          /* # of 2k blocks when sendqueued called 
 1008                   * last */
 1009     SBuf        sendQ;       /* Outgoing message queue--if socket full */
 1010     SBuf        recvQ;       /* Hold for data incoming yet to be parsed */
 1011     long        sendM;       /* Statistics: protocol messages send */
 1012     long        sendK;       /* Statistics: total k-bytes send */
 1013     long        receiveM;    /* Statistics: protocol messages received */
 1014     long        receiveK;    /* Statistics: total k-bytes received */
 1015     u_short     sendB;       /* counters to count upto 1-k lots of bytes */
 1016     u_short     receiveB;    /* sent and received. */
 1017     long        lastrecvM;       /* to check for activity --Mika */
 1018     int         priority;
 1019     aListener  *lstn;            /* listener which we accepted from */
 1020     int         authfd;          /* fd for rfc931 authentication */
 1021     char        username[USERLEN + 1]; /* username here now for auth stuff */
 1022     unsigned short port;     /* and the remote port# too :-) */
 1023     struct hostent *hostp;
 1024 #ifdef ANTI_NICK_FLOOD
 1025     time_t      last_nick_change;
 1026     int         number_of_nick_changes;
 1027 #endif
 1028 #ifdef NO_AWAY_FLUD
 1029     time_t      alas;   /* last time of away set */
 1030     int     acount;         /* count of away settings */
 1031 #endif
 1032     
 1033     char        sockhost[HOSTLEN + 1];  /* This is the host name from
 1034                      * the socket and after which the 
 1035                      * connection was accepted. */
 1036     char        passwd[PASSWDLEN + 1];
 1037     /* try moving this down here to prevent weird problems... ? */
 1038     int         oflag;          /* Operator Flags */
 1039     int sockerr;                /* what was the last error returned for
 1040                  * this socket? */
 1041     int capabilities;           /* what this server/client supports */
 1042     aClass  *class;             /* our current effective class */
 1043 
 1044 #ifdef MSG_TARGET_LIMIT
 1045     struct {
 1046        struct Client *cli;
 1047        time_t sent;
 1048     } targets[MSG_TARGET_MAX];              /* structure for target rate limiting */
 1049     time_t last_target_complain;
 1050     unsigned int num_target_errors;
 1051 #endif
 1052 
 1053 #ifdef USE_SSL
 1054     SSL  *ssl;
 1055     X509 *client_cert;
 1056 #endif
 1057 
 1058     char *webirc_username;
 1059     char *webirc_ip;
 1060 };
 1061 
 1062 #define CLIENT_LOCAL_SIZE sizeof(aClient)
 1063 #define CLIENT_REMOTE_SIZE offsetof(aClient,count)
 1064 /* statistics structures */
 1065 struct stats
 1066 {
 1067     unsigned int is_cl;     /* number of client connections */
 1068     unsigned int is_sv;     /* number of server connections */
 1069     unsigned int is_ni;     /* connection but no idea who it was */
 1070     unsigned short is_cbs;  /* bytes sent to clients */
 1071     unsigned short is_cbr;  /* bytes received to clients */
 1072     unsigned short is_sbs;  /* bytes sent to servers */
 1073     unsigned short is_sbr;  /* bytes received to servers */
 1074     unsigned long is_cks;   /* k-bytes sent to clients */
 1075     unsigned long is_ckr;   /* k-bytes received to clients */
 1076     unsigned long is_sks;   /* k-bytes sent to servers */
 1077     unsigned long is_skr;   /* k-bytes received to servers */
 1078     time_t      is_cti;     /* time spent connected by clients */
 1079     time_t      is_sti;     /* time spent connected by servers */
 1080     unsigned int is_ac;     /* connections accepted */
 1081     unsigned int is_ref;    /* accepts refused */
 1082     unsigned int is_throt;  /* accepts throttled */
 1083     unsigned int is_drone;  /* refused drones */
 1084     unsigned int is_unco;   /* unknown commands */
 1085     unsigned int is_wrdi;   /* command going in wrong direction */
 1086     unsigned int is_unpf;   /* unknown prefix */
 1087     unsigned int is_empt;   /* empty message */
 1088     unsigned int is_num;    /* numeric message */
 1089     unsigned int is_kill;   /* number of kills generated on collisions */
 1090     unsigned int is_fake;   /* MODE 'fakes' */
 1091     unsigned int is_asuc;   /* successful auth requests */
 1092     unsigned int is_abad;   /* bad auth requests */
 1093     unsigned int is_udp;    /* packets recv'd on udp port */
 1094     unsigned int is_loc;    /* local connections made */
 1095     unsigned int is_ref_1;  /* refused at kline stage 1 */
 1096     unsigned int is_ref_2;  /* refused at kline stage 2 */
 1097 #ifdef FLUD
 1098     unsigned int is_flud;   /* users/channels flood protected */
 1099 #endif                      /* FLUD */
 1100 };
 1101 
 1102 /* mode structure for channels */
 1103 
 1104 struct SMode 
 1105 {
 1106     unsigned int mode;
 1107     int         limit;
 1108     char        key[KEYLEN + 1];
 1109     char        jr_num;     /* join rate limit: joins */
 1110     char        jr_time;    /* join rate limit: time */
 1111     short       jrl_size;   /* join rate limit: calculated token bucket size */
 1112 };
 1113 
 1114 
 1115 /* Alias data for super clients and shortform commands */
 1116 struct SAliasInfo
 1117 {
 1118     char    *shortform; /* command shortform (NS) */
 1119     char    *nick;      /* entity nickname (NickServ) */
 1120     char    *server;    /* entity's server (services) */
 1121     aClient *client;    /* associated online client */
 1122 };
 1123 
 1124 
 1125 #define MF_UNREG    0x0001  /* may be used by unregistered connections */
 1126 #define MF_RIDLE    0x0002  /* reset idle time */
 1127 #define MF_ALIAS    0x0004  /* aliastab index valid */
 1128 
 1129 /* Message table structure */
 1130 struct Message
 1131 {
 1132     char            *cmd;           /* command name */
 1133     int              (*func)();     /* callback function */
 1134     short            parameters;    /* number of parameters */
 1135     short            flags;         /* command flags */
 1136     int              aliasidx;      /* aliastab index */
 1137     unsigned int     count;         /* number of times used */
 1138     unsigned long    bytes;         /* number of bytes used */
 1139 };
 1140 
 1141 typedef struct msg_tree 
 1142 {
 1143     char       *final;
 1144     struct Message *msg;
 1145     struct msg_tree *pointers[26];
 1146 } MESSAGE_TREE;
 1147 
 1148 /*
 1149  * Move BAN_INFO information out of the SLink struct its _only_ used
 1150  * for bans, no use wasting the memory for it in any other type of
 1151  * link. Keep in mind, doing this that it makes it slower as more
 1152  * Malloc's/Free's have to be done, on the plus side bans are a smaller
 1153  * percentage of SLink usage. Over all, the th+hybrid coding team came
 1154  * to the conclusion it was worth the effort.
 1155  * 
 1156  * - Dianora
 1157  */
 1158 
 1159 struct Ban 
 1160 {
 1161     char       *banstr;
 1162     char       *who;
 1163     time_t      when;
 1164     u_char      type;
 1165     aBan       *next;
 1166 };
 1167 
 1168 #ifdef INVITE_LISTS
 1169 /* channel invite list structure */
 1170 
 1171 struct LInvite
 1172 {
 1173     char*        invstr;
 1174     char*        who;
 1175     time_t       when;
 1176     anInvite*    next;
 1177 };
 1178 #endif
 1179 
 1180 #ifdef EXEMPT_LISTS
 1181 /* channel ban exempt list structure */
 1182 
 1183 struct Exempt
 1184 {
 1185     char*        banstr;
 1186     char*        who;
 1187     time_t       when;
 1188     u_char       type;
 1189     aBanExempt*  next;
 1190 };
 1191 #endif
 1192 
 1193 /* channel member link structure, used for chanmember chains */
 1194 struct ChanLink 
 1195 {
 1196     struct ChanLink *next;
 1197     aClient *cptr;
 1198     int flags;
 1199     time_t when;
 1200     int last_message_number;    /* Number of messages sent to channel within max_messages_time */
 1201     time_t last_message_time;   /* When last message was sent to channel. -Holbrook */
 1202     unsigned int banserial;     /* used for bquiet cache */
 1203 };
 1204 
 1205 /* general link structure used for chains */
 1206 
 1207 struct SLink 
 1208 {
 1209     struct SLink *next;
 1210     union
 1211     {
 1212     aClient    *cptr;
 1213     aChannel   *chptr;
 1214     aConnect   *aconn;  /* here for resolver purposes */
 1215     aBan       *banptr;
 1216     aWatch *wptr;
 1217     char       *cp;
 1218     } value;
 1219     int         flags;
 1220 };
 1221 
 1222 struct SLinkD
 1223 {
 1224     struct SLinkD *next;
 1225     struct SLinkD *prev;
 1226     union
 1227     {
 1228     aClient    *cptr;
 1229     aChannel   *chptr;
 1230     aBan       *banptr;
 1231     aWatch *wptr;
 1232     char       *cp;
 1233     } value;
 1234     int         flags;
 1235 };
 1236 
 1237 /* channel structure */
 1238 
 1239 struct Channel 
 1240 {
 1241     struct Channel *nextch, *prevch, *hnextch;
 1242     int         hashv;      /* raw hash value */
 1243     Mode        mode;
 1244     char        chname[CHANNELLEN+1];
 1245     char        topic[TOPICLEN + 1];
 1246     char        topic_nick[NICKLEN + 1 + USERLEN + 1 + HOSTLEN + 1];
 1247     time_t      topic_time;
 1248     int         users;
 1249     chanMember* members;
 1250     Link*       invites; /* users invited to the channel */
 1251     aBan*       banlist;
 1252 #ifdef INVITE_LISTS
 1253     anInvite*   invite_list; /* +I list */
 1254 #endif
 1255 #ifdef EXEMPT_LISTS
 1256     aBanExempt* banexempt_list;
 1257 #endif
 1258     ts_val      channelts;
 1259 #ifdef FLUD
 1260     time_t      fludblock;
 1261     struct fludbot *fluders;
 1262 #endif
 1263     short       jrl_bucket;     /* join rate limit: token bucket */
 1264     short       jrw_bucket;     /* join rate warning: token bucket */
 1265     time_t      jrl_last;       /* join rate limit: last use timestamp */
 1266     time_t      jrw_last;       /* join rate warning: last use timestamp */
 1267     int         jrw_debt_ctr;   /* join rate warning: in-debt counter */
 1268     int         jrw_debt_ts;    /* join rate warning: debt begin timestamp */
 1269     unsigned int banserial;     /* used for bquiet cache */
 1270     int join_connect_time;      /* Number of seconds the user must be online to be able to join */
 1271     int talk_connect_time;      /* Number of seconds the user must be online to be able to talk on the channel */
 1272     int talk_join_time;         /* Number of seconds the user must be on the channel to be able to tlak on the channel */
 1273     int max_bans;               /* Maximum number of bans ops can add (default: MAXBANS) */
 1274     int max_invites;            /* Maximum number of invites ops can add (default: MAXINVITELIST) */
 1275     int max_messages;           /* Maximum number of messages can be sent within max_messages_time */
 1276     int max_messages_time;      /* Number of seconds for how many messages can be sent, e.g., 5:10, 5 messages in 10 seconds */
 1277     char *greetmsg;             /* Special greeting message */
 1278     int xflags;                 /* The eXtended channel flags */
 1279 };
 1280 
 1281 #define TS_CURRENT  5   /* current TS protocol version */
 1282 #define TS_MIN      3   /* minimum supported TS protocol version */
 1283 #define TS_DOESTS   0x20000000
 1284 #define DoesTS(x)   ((x)->tsinfo == TS_DOESTS)
 1285 /* Channel Related macros follow */
 1286 
 1287 /* Channel related flags */
 1288 
 1289 #define CHFL_CHANOP     0x0001  /* Channel operator */
 1290 #define CHFL_VOICE      0x0002  /* the power to speak */
 1291 #define CHFL_DEOPPED    0x0004  /* deopped by us, modes need to be bounced */
 1292 #define CHFL_BANNED     0x0008  /* is banned */
 1293 #define CHFL_HALFOP     0x0010  /* channel half-op */
 1294 
 1295 /* ban mask types */
 1296 
 1297 #define MTYP_FULL      0x01    /* mask is nick!user@host */
 1298 #define MTYP_USERHOST  0x02    /* mask is user@host */
 1299 #define MTYP_HOST      0x04    /* mask is host only */
 1300 
 1301 /* Channel Visibility macros */
 1302 
 1303 #define MODE_CHANOP CHFL_CHANOP
 1304 #define MODE_VOICE  CHFL_VOICE
 1305 #define MODE_DEOPPED    CHFL_DEOPPED
 1306 #define MODE_PRIVATE    0x00008
 1307 #define MODE_SECRET     0x00010
 1308 #define MODE_MODERATED  0x00020
 1309 #define MODE_TOPICLIMIT 0x00040
 1310 #define MODE_INVITEONLY 0x00080
 1311 #define MODE_NOPRIVMSGS 0x00100
 1312 #define MODE_KEY    0x00200
 1313 #define MODE_BAN    0x00400
 1314 #define MODE_LIMIT  0x00800
 1315 #define MODE_REGISTERED 0x01000
 1316 #define MODE_REGONLY    0x02000
 1317 #define MODE_NOCTRL 0x04000
 1318 #define MODE_OPERONLY   0x08000
 1319 #define MODE_MODREG     0x10000
 1320 #define MODE_LISTED 0x20000
 1321 #define MODE_JOINRATE   0x40000
 1322 #define MODE_SSLONLY    0x80000
 1323 #define MODE_AUDITORIUM 0x100000
 1324 #define MODE_PRIVACY    0x200000 /* cmode +P - Channel wants extra privacy (no spamfilter) */
 1325 
 1326 /* mode flags which take another parameter (With PARAmeterS) */
 1327 
 1328 #define MODE_WPARAS (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT)
 1329 
 1330 /*
 1331  * Undefined here, these are used in conjunction with the above modes
 1332  * in the source. #define       MODE_DEL       0x40000000 #define
 1333  * MODE_ADD       0x80000000
 1334  */
 1335 
 1336 #define HoldChannel(x)      (!(x))
 1337 
 1338 /*name invisible */
 1339 
 1340 #define SecretChannel(x)    ((x) && ((x)->mode.mode & MODE_SECRET))
 1341 
 1342 /* channel not shown but names are */
 1343 
 1344 #define HiddenChannel(x)    ((x) && ((x)->mode.mode & MODE_PRIVATE))
 1345 
 1346 /* channel visible */
 1347 
 1348 #define ShowChannel(v,c)    (!SecretChannel(c) || IsMember((v),(c)))
 1349 #define PubChannel(x)       ((!x) || ((x)->mode.mode &\
 1350                                  (MODE_PRIVATE | MODE_SECRET)) == 0)
 1351 
 1352 #define IsMember(blah,chan) ((blah && blah->user && \
 1353         find_channel_link((blah->user)->channel, chan)) ? 1 : 0)
 1354 
 1355 #define IsChannelName(name) ((name) && (*(name) == '#'))
 1356 
 1357 /* Extended Channel Flags */
 1358 #define XFLAG_SET               0x0001 /* This is to indicate the channel has enabled xflag(s) */
 1359 #define XFLAG_NO_NOTICE         0x0002
 1360 #define XFLAG_NO_CTCP           0x0004
 1361 #define XFLAG_NO_PART_MSG       0x0008
 1362 #define XFLAG_NO_QUIT_MSG       0x0010
 1363 #define XFLAG_EXEMPT_IDENTD     0x0020
 1364 #define XFLAG_EXEMPT_REGISTERED 0x0040
 1365 #define XFLAG_EXEMPT_INVITES    0x0080
 1366 #define XFLAG_EXEMPT_OPPED      0x0100
 1367 #define XFLAG_EXEMPT_VOICED     0x0200
 1368 #define XFLAG_HIDE_MODE_LISTS   0x0400
 1369 #define XFLAG_USER_VERBOSE      0x0800
 1370 #define XFLAG_OPER_VERBOSE      0x1000
 1371 #define XFLAG_SJR               0x2000 /* Services join request */
 1372 #define XFLAG_NO_NICK_CHANGE    0x4000
 1373 #define XFLAG_NO_UTF8           0x8000
 1374 #define XFLAG_EXEMPT_WEBIRC     0x10000
 1375 
 1376 struct FlagList
 1377 {
 1378     char *option;
 1379     int flag;
 1380 };
 1381 
 1382 /* Misc macros */
 1383 
 1384 #define BadPtr(x) (!(x) || (*(x) == '\0'))
 1385 
 1386 #define isvalid(c) (((c) >= 'A' && (c) < '~') || IsDigit(c) || (c) == '-')
 1387 
 1388 #define MyConnect(x)            ((x)->fd >= 0)
 1389 #define MyClient(x)         (MyConnect(x) && IsClient(x))
 1390 #define MyOper(x)           (MyConnect(x) && IsOper(x))
 1391 
 1392 /* String manipulation macros */
 1393 
 1394 /* strncopynt --> strncpyzt to avoid confusion, sematics changed N must
 1395  * be now the number of bytes in the array --msa */
 1396 
 1397 #define strncpyzt(x, y, N) do{(void)strncpy(x,y,N);x[N-1]='\0';}while(0)
 1398 #define StrEq(x,y)  (!strcmp((x),(y)))
 1399 
 1400 /* used in SetMode() in channel.c and m_umode() in s_msg.c */
 1401 
 1402 #define MODE_NULL      0
 1403 #define MODE_ADD       0x40000000
 1404 #define MODE_DEL       0x20000000
 1405 
 1406 /* return values for hunt_server() */
 1407 
 1408 #define HUNTED_NOSUCH   (-1)    /* if the hunted server is not found */
 1409 #define HUNTED_ISME 0   /* if this server should execute the command */
 1410 #define HUNTED_PASS 1   /* if message passed onwards successfully */
 1411 
 1412 /* used when sending to #mask or $mask */
 1413 
 1414 #define MATCH_SERVER  1
 1415 #define MATCH_HOST    2
 1416 
 1417 /* used for async dns values */
 1418 
 1419 #define ASYNC_NONE  (-1)
 1420 #define ASYNC_CLIENT    0
 1421 #define ASYNC_CONNECT   1
 1422 #define ASYNC_CONF  2
 1423 #define ASYNC_SERVER    3
 1424 
 1425 /* misc variable externs */
 1426 
 1427 extern char version[128], *infotext[];
 1428 extern char *generation, *creation;
 1429 
 1430 /* misc defines */
 1431 
 1432 #define ZIP_NEXT_BUFFER -4
 1433 #define RC4_NEXT_BUFFER -3
 1434 #define FLUSH_BUFFER    -2
 1435 #define COMMA       ","
 1436 
 1437 #ifdef ORATIMING
 1438 /*
 1439  * Timing stuff (for performance measurements): compile with
 1440  * -DORATIMING and put a TMRESET where you want the counter of time
 1441  * spent set to 0, a TMPRINT where you want the accumulated results,
 1442  * and TMYES/TMNO pairs around the parts you want timed -orabidoo
 1443  */
 1444 
 1445 extern struct timeval tsdnow, tsdthen;
 1446 extern unsigned long tsdms;
 1447 
 1448 #define TMRESET tsdms=0;
 1449 #define TMYES gettimeofday(&tsdthen, NULL);
 1450 #define TMNO gettimeofday(&tsdnow, NULL);\
 1451              if (tsdnow.tv_sec!=tsdthen.tv_sec) \
 1452                  tsdms+=1000000*(tsdnow.tv_sec-tsdthen.tv_sec);\
 1453                  tsdms+=tsdnow.tv_usec; tsdms-=tsdthen.tv_usec;
 1454 #define TMPRINT sendto_ops("Time spent: %ld ms", tsdms);
 1455 #else
 1456 #define TMRESET
 1457 #define TMYES
 1458 #define TMNO
 1459 #define TMPRINT
 1460 #endif
 1461 
 1462 /* allow 5 minutes after server rejoins the network before allowing
 1463  * chanops new channel */
 1464 
 1465 #ifdef FLUD
 1466 struct fludbot 
 1467 {
 1468     struct Client *fluder;
 1469     int         count;
 1470     time_t      first_msg, last_msg;
 1471     struct fludbot *next;
 1472 };
 1473 
 1474 #endif /* FLUD */
 1475 
 1476 struct Watch 
 1477 {
 1478     aWatch  *hnext;
 1479     time_t   lasttime;
 1480     Link  *watch;
 1481     char  nick[1];
 1482 };
 1483 
 1484 struct ListOptions 
 1485 {
 1486     LOpts *next;
 1487     Link  *yeslist, *nolist;
 1488     int   starthash;
 1489     short int   showall, only_listed;
 1490     unsigned short usermin;
 1491     int   usermax;
 1492     time_t   currenttime;
 1493     time_t   chantimemin;
 1494     time_t   chantimemax;
 1495     time_t   topictimemin;
 1496     time_t   topictimemax;
 1497 };
 1498 
 1499 typedef struct SearchOptions 
 1500 {
 1501     long umodes;
 1502     char *nick;
 1503     char *user;
 1504     char *host;
 1505     char *gcos;
 1506     char *ip;
 1507     int class;
 1508     int class_value;
 1509     unsigned int cidr_bits;
 1510     unsigned int cidr_family;
 1511     struct
 1512     {
 1513     char ip[16];
 1514     } cidr_ip;
 1515     int ts;
 1516     int ts_value;
 1517     aChannel *channel;
 1518     aClient *server;
 1519     unsigned int channelflags;
 1520     unsigned int client_type;
 1521     unsigned umode_plus:1;
 1522     unsigned nick_plus:1;
 1523     unsigned user_plus:1;
 1524     unsigned host_plus:1;
 1525     unsigned gcos_plus:1;
 1526     unsigned ip_plus:1;
 1527     unsigned cidr_plus:1;
 1528     unsigned chan_plus:1;
 1529     unsigned serv_plus:1;
 1530     unsigned away_plus:1;
 1531     unsigned check_away:1;
 1532     unsigned check_umode:1;
 1533     unsigned show_chan:1;
 1534     unsigned search_chan:1;
 1535     unsigned ip_show:1;
 1536     unsigned realhost_show:1;
 1537     unsigned maskhost_show:1;
 1538     unsigned client_type_plus:1;
 1539 } SOpts;
 1540 
 1541 /*
 1542  * Send /LIST as long as their output isn't blocking
 1543  * and we haven't used 2/3rds of their sendQ
 1544  */
 1545 #define IsSendable(x)      (!((x)->flags & FLAGS_BLOCKED) && \
 1546                             SBufLength(&(x)->sendQ) < (int) \
 1547                             ((float) (x)->class->maxsendq / 1.5))
 1548 #define DoList(x)          (((x)->user) && ((x)->user->lopt))
 1549 
 1550 /* internal defines for cptr->sockerr */
 1551 #define IRCERR_BUFALLOC    -11
 1552 #define IRCERR_ZIP     -12
 1553 #define IRCERR_SSL     -13
 1554 
 1555 #endif /* __struct_include__ */
 1556