Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

struct.h

Go to the documentation of this file.
00001 
00011 /*
00012  * Copyright (c) 1998 Greg Poma
00013  * Copyright (c) 2001 James Hess
00014  * Portions Copyright (c) 1996, 1997 Max Byrd, Chip Norkus
00015  * All rights reserved.
00016  * 
00017  * Redistribution and use in source and binary forms, with or without
00018  * modification, are permitted provided that the following conditions
00019  * are met:
00020  * 1. Redistributions of source code must retain the above copyright
00021  *    notice, this list of conditions and the following disclaimer.
00022  * 2. Redistributions in binary form must reproduce the above copyright
00023  *    notice, this list of conditions and the following disclaimer in the
00024  *    documentation and/or other materials provided with the distribution.
00025  * 3. Neither the name of the authors nor the names of its contributors
00026  *    may be used to endorse or promote products derived from this software
00027  *    without specific prior written permission.
00028  * 
00029  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
00030  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00032  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
00033  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00034  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00035  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00036  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00037  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00038  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00039  * SUCH DAMAGE.
00040  */
00041 #ifndef _STRUCT_H
00042 #define _STRUCT_H
00043 
00044 #include "queue.h"
00045 #include "options.h"
00046 #include "services.h"
00047 
00048 #if PASSLEN < 15
00049 #error PASSLEN must be 15 or higher so that nick and channel password fields \
00050        have 16 bytes for MD5 data.
00051 #endif
00052 
00053 #define KEYLEN 23
00054 
00055 typedef unsigned long flag_t;
00056 typedef struct helpline_t help_line;
00057 typedef struct _memobox MemoBox;
00058 typedef struct _naccesslist nAccessList;
00059 typedef struct helpcache_t help_cache;
00060 typedef struct _regnicklist RegNickList;
00061 typedef struct _userlist UserList;
00062 typedef struct _memolist MemoList;
00063 typedef struct cnicklist_struct cNickList;
00064 typedef struct caccesslist_struct cAccessList;
00065 typedef struct cnicklisthashent_struct cNickListHashEnt;
00066 typedef struct caccesslisthashent_struct cAccessListHashEnt;
00067 typedef struct cakicklist_struct cAkickList;
00068 typedef struct cbanlist_struct cBanList;
00069 typedef struct regchanlist_struct RegChanList;
00070 typedef struct chanlist_struct ChanList;
00071 typedef struct database_struct database;
00072 typedef struct memoblocklist_struct MemoBlock;
00073 typedef struct service_struct Service;
00074 typedef struct operlist_struct OperList;
00075 typedef struct _identifydata IdentifyData;
00076 typedef struct _ChanTrigInfo ChanTrigger;
00077 typedef struct mask_structure MaskData;
00078 typedef u_int16_t IdVal;
00079 typedef u_int16_t HashKeyVal;
00080 
00081 #define IDVAL_MAX USHRT_MAX
00082 
00083 struct memoblocklist_struct;
00084 struct RegNickIdMap;
00085 
00089 class RegId
00090 {
00091     public:
00092         friend void saveNickData(void);
00093 
00094         RegId() : a(0), b(0) { }
00095 
00096         RegId(IdVal aIn, IdVal bIn) : a(aIn), b(bIn) {
00097         }
00098 
00099         RegId& operator=(const RegId &x) {
00100             a = x.a;
00101             b = x.b;
00102 
00103             return *this;
00104         }
00105 
00106         bool operator==(const RegId &x) { return (a == x.a && b == x.b); }
00107         bool operator!=(const RegId &x) { return (a != x.a || b != x.b); }
00108         bool operator<(const RegId &x) {
00109             if (a < x.a || (a == x.a && a < x.b))
00110                 return 1;
00111             return 0;
00112         }
00113         bool operator>(const RegId &x) {
00114             if (a > x.a || (a == x.a && a > x.b))
00115                 return 1;
00116             return 0;
00117         }
00118 
00119         void SetNext(RegId &topId);
00120         void SetDirect(RegId &topId, IdVal aVal, IdVal bVal);
00121         RegNickIdMap *getIdMap();
00122         RegNickList *getNickItem();
00123         const char *getNick();
00124         const char *getChan();
00125 
00126         HashKeyVal getHashKey() const { 
00127             HashKeyVal x = (a ^ 27);
00128             return (x + (b * IDVAL_MAX));
00129         }
00130 
00131     private:
00132         IdVal a, b;
00133 };
00134 
00138 struct RegNickIdMap
00139 {
00140     RegId id;
00141     RegNickList *nick;
00142 
00143     LIST_ENTRY(RegNickIdMap)     id_lst; 
00144 };
00145 
00149 struct _ChanTrigInfo
00150 {
00151     LIST_ENTRY(_ChanTrigInfo)    cn_lst;
00152     int                          impose_modes;
00153     char                         *chan_name;
00154     short                        op_trigger, ak_trigger;
00155     short                        flags;
00156 };
00157 
00158 
00163 class RateInfo
00164 {
00165     public:
00166         RateInfo();
00167         void Event(int weight, time_t tNow);
00168         void Warn();
00169         int  Warned(), GetLev();
00170 
00171     private:
00173         time_t lastEventTime;
00174 
00176         unsigned int rateFloodValue;
00177 
00179         unsigned int numOfEvents;
00180 
00182         unsigned char warningsSent;
00183 };
00184 
00186 struct helpline_t {
00188   char line [81];   
00189 
00191   help_line *next;
00192 };
00193 
00195 struct helpcache_t {
00197   char *name;
00198 
00200   help_line *first;
00201 
00203   help_cache *next;
00204 };
00205 
00207 struct _naccesslist {
00209   char            mask[71];
00210 
00212   LIST_ENTRY(_naccesslist)  al_lst;
00213 };
00214 
00215 
00224 // Registered nick list structure
00230 
00231 struct _regnicklist {
00233   char nick[NICKLEN];
00234 
00236   char user[USERLEN];
00237 
00239   u_char badpws;
00240 
00242   char *host;
00243 
00245   unsigned char password[PASSLEN+1];
00246 
00247 #ifdef TRACK_GECOS
00248 
00249   char *gecos;
00250 #endif
00251 
00253   char *url;
00254 
00256   char *markby;
00257 
00259   char email[EMAILLEN];
00260 
00262   time_t timestamp;
00263 
00265   time_t timereg;
00266 
00268   u_int amasks;
00269 
00271   unsigned int flags;
00272 
00274   flag_t opflags;
00275 
00277   unsigned int chans;
00278 
00280   unsigned int idtime;
00281 
00283   time_t is_readtime;
00284 
00286   RegId  regnum;
00287 
00289   u_int32_t chpw_key;
00290 
00292   MemoBox *memos;
00293 
00295   LIST_HEAD(,_naccesslist)  acl;
00296 
00298   LIST_ENTRY(_regnicklist)  rn_lst;
00299 };
00300 
00302 struct _identifydata {
00304   char   *nick;
00305 
00307   time_t timestamp;
00308 
00310   RegId idnum;
00311 };
00312 
00314 struct _userlist {
00316   char nick[NICKLEN];
00317 
00319   char user[USERLEN];
00320 
00322   u_char badpws;
00323 
00325   char *host;
00326 
00327 #ifdef TRACK_GECOS
00328 
00329   char *gecos;
00330 #endif
00331 
00333   unsigned int oflags;
00334 
00336   RateInfo floodlevel;
00337 
00339   unsigned int caccess;
00340 
00342   time_t timestamp;
00343 
00345   ChanList *chan[NICKCHANHASHSIZE];
00346 
00348   RegNickList *reg;
00349 
00351   IdentifyData id;
00352 
00354   RegId idnum;
00355 
00357   u_int32_t auth_cookie;
00358 
00360   LIST_ENTRY(_userlist)     ul_lst; 
00361 };
00362 
00364 struct _memolist {
00366   int          flags;
00367 
00369   time_t       sent;          
00370 
00372   char         from[NICKLEN]; 
00373 
00375   char        *memotxt;
00376 
00378   char         to[CHANLEN];
00379 
00381   RegNickList *realto;
00382 
00384   LIST_ENTRY(_memolist)    ml_lst;
00385 
00387   LIST_ENTRY(_memolist)    ml_sent;
00388 };
00389 
00391 struct _memobox {
00393   int          memocnt;
00394 
00396   int          flags;
00397 
00399   int          max;
00400 
00402   MemoBlock    *firstMblock;
00403 
00405   RegNickList *forward;
00406 
00408   LIST_HEAD(,_memolist)    mb_memos;
00409 
00411   LIST_HEAD(,_memolist)    mb_sent;
00412 };
00413 
00415 struct memoblocklist_struct {
00417   RegId     blockId;
00418 
00420   MemoBlock *next;
00421 };
00422 
00424 struct operlist_struct {
00426   RegNickList *who;
00427 
00429   struct operlist_struct *next;
00430 };
00431 
00433 struct cnicklist_struct {
00434 
00436   UserList       *person;
00437 
00439   int             op;
00440 
00441   cNickList      *next;              
00442   cNickList      *previous;          
00443   cNickList      *hashnext;          
00444   cNickList      *hashprev;          
00445 };
00446 
00448 struct cnicklisthashent_struct {
00449   cNickList      *item;
00450   cNickList      *lastitem;
00451 };
00452 
00454 struct caccesslist_struct {
00455 
00457   RegId      nickId;
00458 
00460 
00461   short           uflags;
00462 
00464   int index;
00465 
00467   cAccessList    *next;
00468 
00470   cAccessList    *previous;
00471   cAccessList    *hashnext;
00472   cAccessList    *hashprev;
00473 };
00474 
00475 struct caccesslisthashent_struct {
00476   cAccessList    *item, *lastitem;
00477 };
00478 
00480 struct cakicklist_struct {
00481 
00483         char            mask[USERLEN+HOSTLEN+3];
00484 
00486         char            reason[51 + NICKLEN];
00487 
00489         int index;
00490 
00492         time_t          added;
00493 
00495         cAkickList     *next;
00496 
00498         cAkickList     *previous;
00499 };
00500 
00502 struct cbanlist_struct {
00504   char            ban[NICKLEN + USERLEN + HOSTLEN];
00505 
00507   cBanList       *next;
00508 
00510   cBanList       *previous;
00511 };
00512 
00514 struct chanlist_struct {
00515 
00517         char name[CHANLEN];
00518 
00520         cBanList       *firstBan;
00521 
00523         cBanList       *lastBan;
00524 
00526         cNickListHashEnt users[CHANUSERHASHSIZE];
00527 
00529         cNickList      *firstUser;
00530 
00532         cNickList      *lastUser;
00533 
00535         long modes;
00536 
00538         RegChanList *reg;
00539 
00540         ChanList *next, *previous, *hashnext, *hashprev;
00541 };
00542 
00544 struct regchanlist_struct {
00545 
00547   char            name[CHANLEN];
00548 
00550   RegId       founderId;
00551 
00553   int             facc;
00554 
00556   char            desc[CHANDESCBUF];
00557 
00559   char            *autogreet;
00560 
00562   char            *topic;
00563 
00565   char            *url;
00566 
00568   char        *markby;
00569 
00571   char            tsetby[NICKLEN];
00572 
00574   unsigned char   password[PASSLEN+1];
00575 
00577   time_t          ttimestamp;
00578 
00580   long            mlock;
00581 
00583   long            flags;
00584 
00586   time_t          timereg;
00587 
00589   time_t          timestamp;
00590 
00592   char            key[KEYLEN];
00593 
00595   long            limit;
00596 
00598   u_int           ops;
00599 
00601   int             akicks;
00602 
00604   int             tlocklevel;
00605 
00607   int             restrictlevel;
00608 
00610   int             memolevel;
00611 
00613   u_int32_t chpw_key;
00614 
00616   IdentifyData    id;
00617 
00619   cAkickList     *firstAkick;
00620 
00622   cAkickList     *lastAkick;
00623 
00625   cAccessListHashEnt op[OPHASHSIZE];
00626 
00628   cAccessList    *firstOp;
00629 
00631   cAccessList    *lastOp;
00632 
00634   RegChanList       *next;
00635 
00637   RegChanList       *previous;
00638 
00640   RegChanList       *hashnext;
00641 
00643   RegChanList       *hashprev;
00644 
00646   u_char badpws;
00647 
00648 };
00649 
00651 struct service_struct {
00652 
00654   char            name[21];
00655 
00657   char            uname[10];
00658 
00660   char            host[67];
00661 
00663   char            rname[51];
00664 
00666   char            mode[10];
00667 
00668 };
00669 
00671 struct database_struct {
00673         FILE *ns;
00674 
00675 #ifdef REQ_EMAIL
00676 
00677         FILE *nsreg;
00678 #endif
00679 
00681         FILE *cs;
00682 
00684         FILE *os;
00685 
00687         FILE *ms;
00688 
00690         FILE *is;
00691 
00693         FILE *trigger;
00694 
00695 };
00696 
00698 struct mask_structure
00699 {
00701     char *nick;
00702 
00704     char *user;
00705 
00707     char *host;
00708 };
00709 
00710 #endif /* _STRUCT_H */
00711 

Generated at Sat Oct 25 20:56:10 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.