home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / other / irc / include / struct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-14  |  17.3 KB  |  557 lines

  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. #ifndef    __struct_include__
  22. #define __struct_include__
  23.  
  24. #include "config.h"
  25.  
  26. #include <stdio.h>
  27. #include <sys/types.h>
  28. #include <netinet/in.h>
  29. #include <netdb.h>
  30. #ifdef STDDEFH
  31. # include <stddef.h>
  32. #endif
  33.  
  34. #ifdef USE_SYSLOG
  35. # include <syslog.h>
  36. # ifdef SYSSYSLOGH
  37. #  include <sys/syslog.h>
  38. # endif
  39. #endif
  40. #ifdef    pyr
  41. #include <sys/time.h>
  42. #endif
  43.  
  44. typedef    struct    ConfItem aConfItem;
  45. typedef    struct     Client    aClient;
  46. typedef    struct    Channel    aChannel;
  47. typedef    struct    User    anUser;
  48. typedef    struct    Server    aServer;
  49. typedef    struct    SLink    Link;
  50. typedef    struct    SMode    Mode;
  51.  
  52. #ifndef VMSP
  53. #include "class.h"
  54. #include "dbuf.h"    /* THIS REALLY SHOULDN'T BE HERE!!! --msa */
  55. #endif
  56.  
  57. #define    HOSTLEN        63    /* Length of hostname.  Updated to         */
  58.                 /* comply with RFC1123                     */
  59.  
  60. #define    NICKLEN        9    /* Necessary to put 9 here instead of 10
  61.                 ** if s_msg.c/m_nick has been corrected.
  62.                 ** This preserves compatibility with old
  63.                 ** servers --msa
  64.                 */
  65. #define    USERLEN        10
  66. #define    REALLEN         50
  67. #define    TOPICLEN    80
  68. #define    CHANNELLEN    200
  69. #define    PASSWDLEN     20
  70. #define    KEYLEN        23
  71. #define    BUFSIZE        512        /* WARNING: *DONT* CHANGE THIS!!!! */
  72. #define    MAXRECIPIENTS     20
  73. #define    MAXBANS        20
  74. #define    MAXBANLENGTH    1024
  75.  
  76. #define    USERHOST_REPLYLEN    (NICKLEN+HOSTLEN+USERLEN+5)
  77.  
  78. #ifdef USE_SERVICES
  79. #include "service.h"
  80. #endif
  81.  
  82. /*
  83. ** 'offsetof' is defined in ANSI-C. The following definition
  84. ** is not absolutely portable (I have been told), but so far
  85. ** it has worked on all machines I have needed it. The type
  86. ** should be size_t but...  --msa
  87. */
  88. #ifndef offsetof
  89. #define    offsetof(t,m) (int)((&((t *)0L)->m))
  90. #endif
  91.  
  92. #define    elementsof(x) (sizeof(x)/sizeof(x[0]))
  93.  
  94. /*
  95. ** flags for bootup options (command line flags)
  96. */
  97. #define    BOOT_CONSOLE    1
  98. #define    BOOT_QUICK    2
  99. #define    BOOT_DEBUG    4
  100. #define    BOOT_INETD    8
  101. #define    BOOT_TTY    16
  102. #define    BOOT_OPER    32
  103. #define    BOOT_AUTODIE    64
  104.  
  105. #define    STAT_LOG    -6    /* logfile for -x */
  106. #define    STAT_MASTER    -5    /* Local ircd master before identification */
  107. #define    STAT_CONNECTING    -4
  108. #define    STAT_HANDSHAKE    -3
  109. #define    STAT_ME        -2
  110. #define    STAT_UNKNOWN    -1
  111. #define    STAT_SERVER    0
  112. #define    STAT_CLIENT    1
  113. #define    STAT_SERVICE    2    /* Services not implemented yet */
  114.  
  115. /*
  116.  * status macros.
  117.  */
  118. #define    IsRegisteredUser(x)    ((x)->status == STAT_CLIENT)
  119. #define    IsRegistered(x)        ((x)->status >= STAT_SERVER)
  120. #define    IsConnecting(x)        ((x)->status == STAT_CONNECTING)
  121. #define    IsHandshake(x)        ((x)->status == STAT_HANDSHAKE)
  122. #define    IsMe(x)            ((x)->status == STAT_ME)
  123. #define    IsUnknown(x)        ((x)->status == STAT_UNKNOWN || \
  124.                  (x)->status == STAT_MASTER)
  125. #define    IsServer(x)        ((x)->status == STAT_SERVER)
  126. #define    IsClient(x)        ((x)->status == STAT_CLIENT)
  127. #define    IsLog(x)        ((x)->status == STAT_LOG)
  128. #define    IsService(x)        ((x)->status == STAT_SERVICE)
  129.  
  130. #define    SetMaster(x)        ((x)->status = STAT_MASTER)
  131. #define    SetConnecting(x)    ((x)->status = STAT_CONNECTING)
  132. #define    SetHandshake(x)        ((x)->status = STAT_HANDSHAKE)
  133. #define    SetMe(x)        ((x)->status = STAT_ME)
  134. #define    SetUnknown(x)        ((x)->status = STAT_UNKNOWN)
  135. #define    SetServer(x)        ((x)->status = STAT_SERVER)
  136. #define    SetClient(x)        ((x)->status = STAT_CLIENT)
  137. #define    SetLog(x)        ((x)->status = STAT_LOG)
  138. #define    SetService(x)        ((x)->status = STAT_SERVICE)
  139.  
  140. #define    FLAGS_PINGSENT   0x0001    /* Unreplied ping sent */
  141. #define    FLAGS_DEADSOCKET 0x0002    /* Local socket is dead--Exiting soon */
  142. #define    FLAGS_KILLED     0x0004    /* Prevents "QUIT" from being sent for this */
  143. #define    FLAGS_OPER       0x0008    /* Operator */
  144. #define    FLAGS_LOCOP      0x0010 /* Local operator -- SRB */
  145. #define    FLAGS_INVISIBLE  0x0020 /* makes user invisible */
  146. #define    FLAGS_WALLOP     0x0040 /* send wallops to them */
  147. #define    FLAGS_SERVNOTICE 0x0080 /* server notices such as kill */
  148. #define    FLAGS_BLOCKED    0x0100    /* socket is in a blocked condition */
  149. #define    FLAGS_UNIX     0x0200    /* socket is in the unix domain, not inet */
  150. #define    FLAGS_CLOSING    0x0400    /* set when closing to suppress errors */
  151. #define    FLAGS_LISTEN     0x0800 /* used to mark clients which we listen() on */
  152. #define    FLAGS_CHKACCESS  0x1000 /* ok to check clients access if set */
  153. #define    FLAGS_DOINGDNS     0x2000 /* client is waiting for a DNS response */
  154. #define    FLAGS_AUTH     0x4000 /* client is waiting on rfc931 response */
  155. #define    FLAGS_WRAUTH     0x8000    /* set if we havent writen to ident server */
  156. #define    FLAGS_LOCAL    0x10000 /* set for local clients */
  157. #define    FLAGS_GOTID    0x20000    /* successful ident lookup achieved */
  158. #define    FLAGS_DOID    0x40000    /* I-lines say must use ident return */
  159. #define    FLAGS_NONL    0x80000 /* No \n in buffer */
  160.  
  161. #define    SEND_UMODES    (FLAGS_INVISIBLE|FLAGS_OPER|FLAGS_WALLOP)
  162. #define    ALL_UMODES    (SEND_UMODES|FLAGS_SERVNOTICE)
  163. #define    FLAGS_ID    (FLAGS_DOID|FLAGS_GOTID)
  164.  
  165. /*
  166.  * flags macros.
  167.  */
  168. #define    IsOper(x)        ((x)->flags & FLAGS_OPER)
  169. #define    IsLocOp(x)        ((x)->flags & FLAGS_LOCOP)
  170. #define    IsInvisible(x)        ((x)->flags & FLAGS_INVISIBLE)
  171. #define    IsAnOper(x)        ((x)->flags & (FLAGS_OPER|FLAGS_LOCOP))
  172. #define    IsPerson(x)        ((x)->user && IsClient(x))
  173. #define    IsPrivileged(x)        (IsAnOper(x) || IsServer(x))
  174. #define    SendWallops(x)        ((x)->flags & FLAGS_WALLOP)
  175. #define    SendServNotice(x)    ((x)->flags & FLAGS_SERVNOTICE)
  176. #define    IsUnixSocket(x)        ((x)->flags & FLAGS_UNIX)
  177. #define    IsListening(x)        ((x)->flags & FLAGS_LISTEN)
  178. #define    DoAccess(x)        ((x)->flags & FLAGS_CHKACCESS)
  179. #define    IsLocal(x)        ((x)->flags & FLAGS_LOCAL)
  180. #define    IsDead(x)        ((x)->flags & FLAGS_DEADSOCKET)
  181.  
  182. #define    SetOper(x)        ((x)->flags |= FLAGS_OPER)
  183. #define    SetLocOp(x)            ((x)->flags |= FLAGS_LOCOP)
  184. #define    SetInvisible(x)        ((x)->flags |= FLAGS_INVISIBLE)
  185. #define    SetWallops(x)          ((x)->flags |= FLAGS_WALLOP)
  186. #define    SetUnixSock(x)        ((x)->flags |= FLAGS_UNIX)
  187. #define    SetDNS(x)        ((x)->flags |= FLAGS_DOINGDNS)
  188. #define    DoingDNS(x)        ((x)->flags & FLAGS_DOINGDNS)
  189. #define    SetAccess(x)        ((x)->flags |= FLAGS_CHKACCESS)
  190. #define    DoingAuth(x)        ((x)->flags & FLAGS_AUTH)
  191. #define    NoNewLine(x)        ((x)->flags & FLAGS_NONL)
  192.  
  193. #define    ClearOper(x)        ((x)->flags &= ~FLAGS_OPER)
  194. #define    ClearInvisible(x)    ((x)->flags &= ~FLAGS_INVISIBLE)
  195. #define    ClearWallops(x)        ((x)->flags &= ~FLAGS_WALLOP)
  196. #define    ClearDNS(x)        ((x)->flags &= ~FLAGS_DOINGDNS)
  197. #define    ClearAuth(x)        ((x)->flags &= ~FLAGS_AUTH)
  198. #define    ClearAccess(x)        ((x)->flags &= ~FLAGS_CHKACCESS)
  199.  
  200. /*
  201.  * defined debugging levels
  202.  */
  203. #define    DEBUG_FATAL  0
  204. #define    DEBUG_ERROR  1    /* report_error() and other errors that are found */
  205. #define    DEBUG_NOTICE 3
  206. #define    DEBUG_DNS    4    /* used by all DNS related routines - a *lot* */
  207. #define    DEBUG_INFO   5    /* general usful info */
  208. #define    DEBUG_NUM    6    /* numerics */
  209. #define    DEBUG_SEND   7    /* everything that is sent out */
  210. #define    DEBUG_DEBUG  8    /* anything to do with debugging, ie unimportant :) */
  211. #define    DEBUG_MALLOC 9    /* malloc/free calls */
  212. #define    DEBUG_LIST  10    /* debug list use */
  213.  
  214. /*
  215.  * defines for curses in client
  216.  */
  217. #define    DUMMY_TERM    0
  218. #define    CURSES_TERM    1
  219. #define    TERMCAP_TERM    2
  220.  
  221. struct    ConfItem    {
  222.     unsigned int    status;    /* If CONF_ILLEGAL, delete when no clients */
  223.     int    clients;    /* Number of *LOCAL* clients using this */
  224.     struct    in_addr ipnum;    /* ip number of host field */
  225.     char    *host;
  226.     char    *passwd;
  227.     char    *name;
  228.     int    port;
  229.     time_t    hold;    /* Hold action until this time (calendar time) */
  230. #ifndef VMSP
  231.     aClass    *class;  /* Class of connection */
  232. #endif
  233.     struct    ConfItem *next;
  234. };
  235.  
  236. #define    CONF_ILLEGAL        0x80000000
  237. #define    CONF_MATCH        0x40000000
  238. #define    CONF_QUARANTINED_SERVER    0x0001
  239. #define    CONF_CLIENT        0x0002
  240. #define    CONF_CONNECT_SERVER    0x0004
  241. #define    CONF_NOCONNECT_SERVER    0x0008
  242. #define    CONF_LOCOP        0x0010
  243. #define    CONF_OPERATOR        0x0020
  244. #define    CONF_ME            0x0040
  245. #define    CONF_KILL        0x0080
  246. #define    CONF_ADMIN        0x0100
  247. #ifdef     R_LINES
  248. #define    CONF_RESTRICT        0x0200
  249. #endif
  250. #define    CONF_CLASS        0x0400
  251. #define    CONF_SERVICE        0x0800
  252. #define    CONF_LEAF        0x1000
  253. #define    CONF_LISTEN_PORT    0x2000
  254. #define    CONF_HUB        0x4000
  255.  
  256. #define    CONF_OPS        (CONF_OPERATOR | CONF_LOCOP)
  257. #define    CONF_SERVER_MASK    (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER)
  258. #define    CONF_CLIENT_MASK    (CONF_CLIENT | CONF_SERVICE | CONF_OPS | \
  259.                  CONF_SERVER_MASK)
  260.  
  261. #define    IsIllegal(x)    ((x)->status & CONF_ILLEGAL)
  262.  
  263. /*
  264.  * Client structures
  265.  */
  266. struct    User    {
  267.     struct    User    *nextu;
  268.     Link    *channel;    /* chain of channel pointer blocks */
  269.     Link    *invited;    /* chain of invite pointer blocks */
  270.     char    *away;        /* pointer to away message */
  271.     time_t    last;
  272.     int    refcnt;        /* Number of times this block is referenced */
  273.     int    joined;        /* number of channels joined */
  274.     char    username[USERLEN+1];
  275.     char    host[HOSTLEN+1];
  276.         char    server[HOSTLEN+1];
  277.                 /*
  278.                 ** In a perfect world the 'server' name
  279.                 ** should not be needed, a pointer to the
  280.                 ** client describing the server is enough.
  281.                 ** Unfortunately, in reality, server may
  282.                 ** not yet be in links while USER is
  283.                 ** introduced... --msa
  284.                 */
  285. #ifdef    LIST_DEBUG
  286.     aClient    *bcptr;
  287. #endif
  288. };
  289.  
  290. struct    Server    {
  291.     struct    Server    *nexts;
  292.     anUser    *user;        /* who activated this connection */
  293.     char    up[HOSTLEN+1];    /* uplink for this server */
  294.     char    by[NICKLEN+1];
  295.     aConfItem *nline;    /* N-line pointer for this server */
  296. #ifdef    LIST_DEBUG
  297.     aClient    *bcptr;
  298. #endif
  299. };
  300.  
  301. struct Client    {
  302.     struct    Client *next,*prev, *hnext;
  303.     anUser    *user;        /* ...defined, if this is a User */
  304.     aServer    *serv;        /* ...defined, if this is a server */
  305. #ifdef USE_SERVICES
  306.     aService *service;
  307. #endif
  308.     int    hashv;        /* raw hash value */
  309.     time_t    lasttime;    /* ...should be only LOCAL clients? --msa */
  310.     time_t    firsttime;    /* time client was created */
  311.     time_t    since;        /* last time we parsed something */
  312.     long    flags;        /* client flags */
  313.     aClient    *from;        /* == self, if Local Client, *NEVER* NULL! */
  314.     int    fd;        /* >= 0, for local clients */
  315.     int    hopcount;    /* number of servers to this 0 = local */
  316.     short    status;        /* Client type */
  317.     char    name[HOSTLEN+1]; /* Unique name of the client, nick or host */
  318.     char    username[USERLEN+1]; /* username here now for auth stuff */
  319.     char    info[REALLEN+1]; /* Free form additional client information */
  320.     /*
  321.     ** The following fields are allocated only for local clients
  322.     ** (directly connected to *this* server with a socket.
  323.     ** The first of them *MUST* be the "count"--it is the field
  324.     ** to which the allocation is tied to! *Never* refer to
  325.     ** these fields, if (from != self).
  326.     */
  327.     int    count;        /* Amount of data in buffer */
  328.     char    buffer[BUFSIZE]; /* Incoming message buffer */
  329.     short    lastsq;        /* # of 2k blocks when sendqueued called last*/
  330.     dbuf    sendQ;        /* Outgoing message queue--if socket full */
  331.     dbuf    recvQ;        /* Hold for data incoming yet to be parsed */
  332.     long    sendM;        /* Statistics: protocol messages send */
  333.     long    sendK;        /* Statistics: total k-bytes send */
  334.     long    receiveM;    /* Statistics: protocol messages received */
  335.     long    receiveK;    /* Statistics: total k-bytes received */
  336.     u_short    sendB;        /* counters to count upto 1-k lots of bytes */
  337.     u_short    receiveB;    /* sent and received. */
  338.     aClient    *acpt;        /* listening client which we accepted from */
  339.     Link    *confs;        /* Configuration record associated */
  340.     int    authfd;        /* fd for rfc931 authentication */
  341.     struct    in_addr    ip;    /* keep real ip# too */
  342.     unsigned short    port;    /* and the remote port# too :-) */
  343.     struct    hostent    *hostp;
  344. #ifdef    pyr
  345.     struct    timeval    lw;
  346. #endif
  347.     char    sockhost[HOSTLEN+1]; /* This is the host name from the socket
  348.                   ** and after which the connection was
  349.                   ** accepted.
  350.                   */
  351.     char    passwd[PASSWDLEN+1];
  352. };
  353.  
  354. #define    CLIENT_LOCAL_SIZE sizeof(aClient)
  355. #define    CLIENT_REMOTE_SIZE offsetof(aClient,count)
  356.  
  357. /*
  358.  * statistics structures
  359.  */
  360. struct    stats {
  361.     unsigned int    is_cl;    /* number of client connections */
  362.     unsigned int    is_sv;    /* number of server connections */
  363.     unsigned int    is_ni;    /* connection but no idea who it was */
  364.     unsigned short    is_cbs;    /* bytes sent to clients */
  365.     unsigned short    is_cbr;    /* bytes received to clients */
  366.     unsigned short    is_sbs;    /* bytes sent to servers */
  367.     unsigned short    is_sbr;    /* bytes received to servers */
  368.     unsigned long    is_cks;    /* k-bytes sent to clients */
  369.     unsigned long    is_ckr;    /* k-bytes received to clients */
  370.     unsigned long    is_sks;    /* k-bytes sent to servers */
  371.     unsigned long    is_skr;    /* k-bytes received to servers */
  372.     time_t         is_cti;    /* time spent connected by clients */
  373.     time_t        is_sti;    /* time spent connected by servers */
  374.     unsigned int    is_ac;    /* connections accepted */
  375.     unsigned int    is_ref;    /* accepts refused */
  376.     unsigned int    is_unco; /* unknown commands */
  377.     unsigned int    is_wrdi; /* command going in wrong direction */
  378.     unsigned int    is_unpf; /* unknown prefix */
  379.     unsigned int    is_empt; /* empty message */
  380.     unsigned int    is_num;    /* numeric message */
  381.     unsigned int    is_kill; /* number of kills generated on collisions */
  382.     unsigned int    is_fake; /* MODE 'fakes' */
  383.     unsigned int    is_asuc; /* successful auth requests */
  384.     unsigned int    is_abad; /* bad auth requests */
  385.     unsigned int    is_udp;    /* packets recv'd on udp port */
  386.     unsigned int    is_loc;    /* local connections made */
  387. };
  388.  
  389. /* mode structure for channels */
  390.  
  391. struct    SMode    {
  392.     unsigned int    mode;
  393.     int    limit;
  394.     char    key[KEYLEN+1];
  395. };
  396.  
  397. /* Message table structure */
  398.  
  399. struct    Message    {
  400.     char    *cmd;
  401.     int    (* func)();
  402.     unsigned int    count;
  403.     int    parameters;
  404.     char    flags;
  405.         /* bit 0 set means that this command is allowed to be used
  406.          * only on the average of once per 2 seconds -SRB */
  407.     unsigned long    bytes;
  408. };
  409.  
  410. /* general link structure used for chains */
  411.  
  412. struct    SLink    {
  413.     struct    SLink    *next;
  414.     union {
  415.         aClient    *cptr;
  416.         aChannel *chptr;
  417.         aConfItem *aconf;
  418.         char    *cp;
  419.     } value;
  420.     int    flags;
  421. };
  422.  
  423. /* channel structure */
  424.  
  425. struct Channel    {
  426.     struct    Channel *nextch, *prevch, *hnextch;
  427.     int    hashv;        /* raw hash value */
  428.     Mode    mode;
  429.     char    topic[TOPICLEN+1];
  430.     int    users;
  431.     Link    *members;
  432.     Link    *invites;
  433.     Link    *banlist;
  434.     char    chname[1];
  435. };
  436.  
  437. /*
  438. ** Channel Related macros follow
  439. */
  440.  
  441. /* Channel related flags */
  442.  
  443. #define    CHFL_CHANOP     0x0001 /* Channel operator */
  444. #define    CHFL_VOICE      0x0002 /* the power to speak */
  445. #define    CHFL_BAN    0x0004 /* ban channel flag */
  446.  
  447. /* Channel Visibility macros */
  448.  
  449. #define    MODE_CHANOP    CHFL_CHANOP
  450. #define    MODE_VOICE    CHFL_VOICE
  451. #define    MODE_PRIVATE    0x0004
  452. #define    MODE_SECRET    0x0008
  453. #define    MODE_MODERATED  0x0010
  454. #define    MODE_TOPICLIMIT 0x0020
  455. #define    MODE_INVITEONLY 0x0040
  456. #define    MODE_NOPRIVMSGS 0x0080
  457. #define    MODE_KEY    0x0100
  458. #define    MODE_BAN    0x0200
  459. #define    MODE_LIMIT    0x0400
  460. #define MODE_FLAGS    0x07ff
  461. /*
  462.  * mode flags which take another parameter (With PARAmeterS)
  463.  */
  464. #define    MODE_WPARAS    (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT)
  465. /*
  466.  * Undefined here, these are used in conjunction with the above modes in
  467.  * the source.
  468. #define    MODE_DEL       0x40000000
  469. #define    MODE_ADD       0x80000000
  470.  */
  471.  
  472. #define    HoldChannel(x)        (!(x))
  473. /* name invisible */
  474. #define    SecretChannel(x)    ((x) && ((x)->mode.mode & MODE_SECRET))
  475. /* channel not shown but names are */
  476. #define    HiddenChannel(x)    ((x) && ((x)->mode.mode & MODE_PRIVATE))
  477. /* channel visible */
  478. #define    ShowChannel(v,c)    (PubChannel(c) || IsMember((v),(c)))
  479. #define    PubChannel(x)        ((!x) || ((x)->mode.mode &\
  480.                  (MODE_PRIVATE | MODE_SECRET)) == 0)
  481.  
  482. #define    IsMember(user,chan) (find_user_link((chan)->members,user) ? 1 : 0)
  483. #define    IsChannelName(name) ((name) && (*(name) == '#' || *(name) == '&'))
  484.  
  485. /* Misc macros */
  486.  
  487. #define    BadPtr(x) (!(x) || (*(x) == '\0'))
  488.  
  489. #define    isvalid(c) (((c) >= 'A' && (c) <= '~') || isdigit(c) || (c) == '-')
  490.  
  491. #define    MyConnect(x)            ((x)->fd >= 0)
  492. #define    MyClient(x)            (MyConnect(x) && IsClient(x))
  493. #define    MyOper(x)            (MyConnect(x) && IsOper(x))
  494.  
  495. /* String manipulation macros */
  496.  
  497. /* strncopynt --> strncpyzt to avoid confusion, sematics changed
  498.    N must be now the number of bytes in the array --msa */
  499. #define    strncpyzt(x, y, N) do{(void)strncpy(x,y,N);x[N-1]='\0';}while(0)
  500. #define    StrEq(x,y)    (!strcmp((x),(y)))
  501.  
  502. /* used in SetMode() in channel.c and m_umode() in s_msg.c */
  503.  
  504. #define    MODE_NULL      0
  505. #define    MODE_ADD       0x40000000
  506. #define    MODE_DEL       0x20000000
  507.  
  508. /* return values for hunt_server() */
  509.  
  510. #define    HUNTED_NOSUCH    (-1)    /* if the hunted server is not found */
  511. #define    HUNTED_ISME    0    /* if this server should execute the command */
  512. #define    HUNTED_PASS    1    /* if message passed onwards successfully */
  513.  
  514. /* used when sending to #mask or $mask */
  515.  
  516. #define    MATCH_SERVER  1
  517. #define    MATCH_HOST    2
  518.  
  519. /* used for async dns values */
  520.  
  521. #define    ASYNC_NONE    (-1)
  522. #define    ASYNC_CLIENT    0
  523. #define    ASYNC_CONNECT    1
  524. #define    ASYNC_CONF    2
  525. #define    ASYNC_SERVER    3
  526.  
  527. /* misc variable externs */
  528.  
  529. extern    char    *version, *infotext[];
  530. extern    char    *generation, *creation;
  531.  
  532. /* misc defines */
  533.  
  534. #define    FLUSH_BUFFER    -2
  535. #define    UTMP        "/etc/utmp"
  536. #define    COMMA        ","
  537.  
  538. /* IRC client structures */
  539.  
  540. #ifdef    CLIENT_COMPILE
  541. typedef    struct    Ignore {
  542.     char    user[NICKLEN+1];
  543.     char    from[USERLEN+HOSTLEN+2];
  544.     int    flags;
  545.     struct    Ignore    *next;
  546. } anIgnore;
  547.  
  548. #define    IGNORE_PRIVATE    1
  549. #define    IGNORE_PUBLIC    2
  550. #define    IGNORE_TOTAL    3
  551.  
  552. #define    HEADERLEN    200
  553.  
  554. #endif
  555.  
  556. #endif /* __struct_include__ */
  557.