Parcourir la source

* Removed all the channels.mod dependancies
Exported all the necesary functions


svn: 772

Bryan Drewery il y a 22 ans
Parent
commit
99cf7ca436

+ 6 - 1
src/botnet.c

@@ -22,6 +22,11 @@
 #include "botmsg.h"
 #include "tandem.h"
 #include "core_binds.h"
+#ifdef HUB
+# ifdef S_AUTOLOCK
+#  include "src/mod/channels.mod/channels.h"
+# endif /* S_AUTOLOCK */
+#endif /* HUB */
 
 extern int			dcc_total, backgrd, connect_timeout, max_dcc,
 				cfg_count;
@@ -1658,7 +1663,7 @@ void check_botnet_pings()
   }
 #ifdef HUB
 #ifdef S_AUTOLOCK
-  local_check_should_lock();
+  check_should_lock();
 #endif /* S_AUTOLOCK */
 #ifdef G_BACKUP
   check_should_backup();

+ 1 - 7
src/chanprog.c

@@ -222,17 +222,11 @@ void checkchans(int which)
       }
     }
   } else if (which == 1) {
-    module_entry *me = NULL;
-
     for (chan = chanset; chan; chan = chan_next) {
       chan_next = chan->next;
       if (chan->status & CHAN_FLAGGED) {
         putlog(LOG_MISC, "*", "No longer supporting channel %s", chan->dname);
-        /* remove_channel(chan); */
-        if ((me = module_find("channels", 0, 0))) {
-          Function *func = me->funcs;
-          (func[CHANNEL_REMOVE]) (chan);
-        }
+        remove_channel(chan);
       }
     }
   }

+ 0 - 11
src/misc.c

@@ -1117,17 +1117,6 @@ char *replace(const char *string, char *oldie, char *newbie)
   return (newstring);
 }
 
-void local_check_should_lock()
-{
-  module_entry *me = NULL;
-
-  if ((me = module_find("channels", 0, 0))) {
-    Function *func = me->funcs;
-    /* check_should_lock() */
-    (func[51]) ();
-  }
-}
-
 /* convert binary hashes to hex */
 char *btoh(const unsigned char *md, int len)
 {

+ 0 - 1
src/misc.h

@@ -35,7 +35,6 @@ char *color(int, int, int);
 void shuffle(char *, char *);
 void showhelp(int, struct flag_record *, char *);
 char *btoh(const unsigned char *, int);
-void local_check_should_lock();
 int listen_all(int, int);
 char *replace(const char *, char *, char *);
 int goodpass(char *, int, char *);

+ 8 - 68
src/mod/channels.mod/channels.c

@@ -21,16 +21,16 @@ static Function *global = NULL;
 static Function *irc_funcs = NULL;
 #endif /* LEAF */
 
-static int 			use_info;
+int 			use_info;
 static char 			glob_chanmode[64];		/* Default chanmode (drummer,990731) */
 static char 			*lastdeletedmask = NULL;
 static struct udef_struct 	*udef = NULL;
 static int 			global_stopnethack_mode;
 static int 			global_revenge_mode;
 static int 			global_idle_kick;		/* Default idle-kick setting. */
-static int 			global_ban_time;
-static int 			global_exempt_time;
-static int 			global_invite_time;
+int 			global_ban_time;
+int 			global_exempt_time;
+int 			global_invite_time;
 
 /* Global channel settings (drummer/dw) */
 static char 			glob_chanset[512] = "";
@@ -67,7 +67,7 @@ struct cfg_entry CFG_LOCKTHRESHOLD, CFG_KILLTHRESHOLD;
 #endif /* S_AUTOLOCK */
 
 /* This will close channels if the HUB:leaf count is skewed from config setting */
-static void check_should_lock()
+void check_should_lock()
 {
 #ifdef S_AUTOLOCK
 #ifdef HUB
@@ -542,7 +542,7 @@ static void get_mode_protect(struct chanset_t *chan, char *s)
 
 /* Returns true if this is one of the channel masks
  */
-static int ismodeline(masklist *m, char *username)
+int ismodeline(masklist *m, char *username)
 {
   for (; m && m->mask[0]; m = m->next)  
     if (!rfc_casecmp(m->mask, username))
@@ -552,7 +552,7 @@ static int ismodeline(masklist *m, char *username)
 
 /* Returns true if user matches one of the masklist -- drummer
  */
-static int ismasked(masklist *m, char *username)
+int ismasked(masklist *m, char *username)
 {
   for (; m && m->mask[0]; m = m->next)
     if (wild_match(m->mask, username))
@@ -583,7 +583,7 @@ inline static int chanset_unlink(struct chanset_t *chan)
  * This includes the removal of all channel-bans, -exempts and -invites, as
  * well as all user flags related to the channel.
  */
-static void remove_channel(struct chanset_t *chan)
+void remove_channel(struct chanset_t *chan)
 {
    int		 i;
    module_entry	*me = NULL;
@@ -819,66 +819,6 @@ static Function channels_table[] =
   (Function) NULL,
   (Function) 0,
   (Function) channels_report,
-  /* 4 - 7 */
-  (Function) u_setsticky_mask,
-  (Function) u_delban,
-  (Function) u_addban,
-  (Function) write_bans,
-  /* 8 - 11 */
-  (Function) get_chanrec,
-  (Function) add_chanrec,
-  (Function) del_chanrec,
-  (Function) set_handle_chaninfo,
-  /* 12 - 15 */
-  (Function) 0,
-  (Function) u_match_mask,
-  (Function) u_equals_mask,
-  (Function) clear_channel,
-  /* 16 - 19 */
-  (Function) set_handle_laston,
-  (Function) NULL, /* [17] used to be ban_time <Wcc[07/19/02]> */
-  (Function) & use_info,
-  (Function) get_handle_chaninfo,
-  /* 20 - 23 */
-  (Function) u_sticky_mask,
-  (Function) ismasked,
-  (Function) add_chanrec_by_handle,
-  (Function) NULL, /* [23] used to be isexempted() <cybah> */
-  /* 24 - 27 */
-  (Function) NULL, /* [24] used to be exempt_time <Wcc[07/19/02]> */
-  (Function) NULL, /* [25] used to be isinvited() <cybah> */
-  (Function) NULL, /* [26] used to be ban_time <Wcc[07/19/02]> */
-  (Function) NULL,
-  /* 28 - 31 */
-  (Function) NULL, /* [28] used to be u_setsticky_exempt() <cybah> */
-  (Function) u_delexempt,
-  (Function) u_addexempt,
-  (Function) NULL,
-  /* 32 - 35 */
-  (Function) NULL,/* [32] used to be u_sticky_exempt() <cybah> */
-  (Function) NULL,
-  (Function) NULL,	/* [34] used to be killchanset().	*/
-  (Function) u_delinvite,
-  /* 36 - 39 */
-  (Function) u_addinvite,
-  (Function) channel_add,
-  (Function) channel_modify,
-  (Function) write_exempts,
-  /* 40 - 43 */
-  (Function) write_invites,
-  (Function) ismodeline,
-  (Function) initudef,
-  (Function) ngetudef,
-  /* 44 - 47 */
-  (Function) expired_mask,
-  (Function) remove_channel,
-  (Function) & global_ban_time,
-  (Function) & global_exempt_time,
-  /* 48 - 51 */
-  (Function) & global_invite_time,
-  (Function) write_chans,
-  (Function) write_config,
-  (Function) check_should_lock,
 };
 
 void channels_describe(struct cfg_entry *cfgent, int idx)

+ 37 - 104
src/mod/channels.mod/channels.h

@@ -41,123 +41,56 @@ struct udef_struct {
 
 #define PLSMNS(x) (x ? '+' : '-')
 
-static void del_chanrec(struct userrec *u, char *);
-static struct chanuserrec *get_chanrec(struct userrec *u, char *chname);
-static struct chanuserrec *add_chanrec(struct userrec *u, char *chname);
-static void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname);
-static void get_handle_chaninfo(char *handle, char *chname, char *s);
-static void set_handle_chaninfo(struct userrec *bu, char *handle,
-				char *chname, char *info);
-static void set_handle_laston(char *chan, struct userrec *u, time_t n);
-static int u_sticky_mask(maskrec *u, char *uhost);
-static int u_setsticky_mask(struct chanset_t *chan, maskrec *m, char *uhost,
-			    int sticky, char *botcmd);
-
-static int u_equals_mask(maskrec *u, char *uhost);
-static int u_match_mask(struct maskrec *rec, char *mask);
-static int u_delexempt (struct chanset_t * c, char * who, int doit);
-static int u_addexempt (struct chanset_t * chan, char * exempt, char * from,
- 			char * note,  time_t expire_time, int flags);
-static int u_delinvite (struct chanset_t * c, char * who, int doit);
-static int u_addinvite (struct chanset_t * chan, char * invite, char * from,
- 			char * note,  time_t expire_time, int flags);
-static int u_delban(struct chanset_t *c, char *who, int doit);
-static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
-		    time_t expire_time, int flags);
 static void tell_bans(int idx, int show_inact, char *match);
-static int write_bans(FILE * f, int idx);
-static int write_config (FILE * f, int idx);
+
 static void check_expired_bans(void);
-static void tell_exempts (int idx, int show_inact, char * match);
-static int write_exempts (FILE * f, int idx);
-static int write_chans (FILE * f, int idx);
 static void check_expired_exempts(void);
-static void tell_invites (int idx, int show_inact, char * match);
-static int write_invites (FILE * f, int idx);
 static void check_expired_invites(void);
-static void clear_channel(struct chanset_t *, int);
+static void tell_exempts (int idx, int show_inact, char * match);
+static void tell_invites (int idx, int show_inact, char * match);
 static void get_mode_protect(struct chanset_t *chan, char *s);
 static void set_mode_protect(struct chanset_t *chan, char *set);
-static int ismasked(masklist *m, char *user);
-static int ismodeline(masklist *m, char *user);
-int channel_modify(char *result, struct chanset_t *chan, int items, char **item);
-static int channel_add(char *result, char *, char *);
 static int getudef(struct udef_chans *, char *);
-static void initudef(int type, char *, int);
 static void setudef(struct udef_struct *, char *, int);
-static void remove_channel(struct chanset_t *);
-static int ngetudef(char *, char *);
-static int expired_mask(struct chanset_t *chan, char *who);
 inline static int chanset_unlink(struct chanset_t *chan);
 
-#else
-
-/* 4 - 7 */
-#define u_setsticky_mask ((int (*)(struct chanset_t *, maskrec *, char *, int, char *))channels_funcs[4])
-#define u_delban ((int (*)(struct chanset_t *, char *, int))channels_funcs[5])
-#define u_addban ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[6])
-#define write_bans ((int (*)(FILE *, int))channels_funcs[7])
-/* 8 - 11 */
-#define get_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[8])
-#define add_chanrec ((struct chanuserrec *(*)(struct userrec *, char *))channels_funcs[9])
-#define del_chanrec ((void (*)(struct userrec *, char *))channels_funcs[10])
-#define set_handle_chaninfo ((void (*)(struct userrec *, char *, char *, char *))channels_funcs[11])
-/* 12 - 15 */
-/* UNUSED 12 */
-#define u_match_mask ((int (*)(maskrec *, char *))channels_funcs[13])
-#define u_equals_mask ((int (*)(maskrec *, char *))channels_funcs[14])
-#define clear_channel ((void (*)(struct chanset_t *, int))channels_funcs[15])
-/* 16 - 19 */
-#define set_handle_laston ((void (*)(char *,struct userrec *,time_t))channels_funcs[16])
-/* *HOLE* channels_funcs[17] used to be ban_time <wcc[07/19/02]> */
-#define use_info (*(int *)(channels_funcs[18]))
-#define get_handle_chaninfo ((void (*)(char *, char *, char *))channels_funcs[19])
-/* 20 - 23 */
-#define u_sticky_mask ((int (*)(maskrec *, char *))channels_funcs[20])
-#define ismasked ((int (*)(masklist *, char *))channels_funcs[21])
-#define add_chanrec_by_handle ((void (*)(struct userrec *, char *, char *))channels_funcs[22])
-/* *HOLE* channels_funcs[23] used to be isexempted() <cybah> */
-/* 24 - 27 */
-/* *HOLE* channels_funcs[24] used to be exempt_time <wcc[07/19/02]> */
-/* *HOLE* channels_funcs[25] used to be isinvited() by arthur2 <cybah> */
-/* *HOLE* channels_funcs[26] used to be invite_time <wcc[07/19/02]> */
-/* *HOLE* channels_funcs[27] used to be u_match_exempt() by arthur2 <cybah> */
-/* 28 - 31 */
-/* *HOLE* channels_funcs[28] used to be u_setsticky_exempt() <cybah> */
-#define u_delexempt ((int (*)(struct chanset_t *, char *, int))channels_funcs[29])
-#define u_addexempt ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[30])
-/* *HOLE* channels_funcs[31] used to be u_equals_exempt() <cybah> */
-/* 32 - 35 */
-/* *HOLE* channels_funcs[32] used to be u_sticky_exempt() <cybah> */
-/* *HOLE* channels_funcs[33] used to be u_match_invite() <cybah> */
-/* *HOLE* channels_funcs[34] used to be killchanset().			*/
-#define u_delinvite ((int (*)(struct chanset_t *, char *, int))channels_funcs[35])
-/* 36 - 39 */
-#define u_addinvite ((int (*)(struct chanset_t *, char *, char *, char *, time_t, int))channels_funcs[36])
-#define channel_add ((int (*)(char *, char *, char *))channels_funcs[37])
-//#define channel_modify ((int (*)(char *, struct chanset_t *, int, char **))channels_funcs[38])
-#define write_exempts ((int (*)(FILE *, int))channels_funcs[39])
-/* 40 - 43 */
-#define write_invites ((int (*)(FILE *, int))channels_funcs[40])
-#define ismodeline ((int(*)(masklist *, char *))channels_funcs[41])
-#define initudef ((void(*)(int, char *,int))channels_funcs[42])
-#define ngetudef ((int(*)(char *, char *))channels_funcs[43])
-/* 44 - 47 */
-#define expired_mask ((int (*)(struct chanset_t *, char *))channels_funcs[44])
-#define remove_channel ((void (*)(struct chanset_t *))channels_funcs[45])
-#define global_ban_time (*(int *)(channels_funcs[46]))
-#define global_exempt_time (*(int *)(channels_funcs[47]))
-/* 48 - 51 */
-#define global_invite_time (*(int *)(channels_funcs[48]))
-#define write_chans ((int (*)(FILE *, int))channels_funcs[49])
-#define write_config ((int (*)(FILE *, int))channels_funcs[50])
-#define check_should_lock ((void (*)(void))channels_funcs[51])
-
+#endif				/* MAKING_CHANNELS */
 
+int ngetudef(char *, char *);
+void initudef(int type, char *, int);
+void remove_channel(struct chanset_t *);
+void add_chanrec_by_handle(struct userrec *, char *, char *);
+void get_handle_chaninfo(char *, char *, char *);
+void set_handle_chaninfo(struct userrec *, char *, char *, char *);
+struct chanuserrec *get_chanrec(struct userrec *u, char *);
+struct chanuserrec *add_chanrec(struct userrec *u, char *);
+void del_chanrec(struct userrec *, char *);
+int write_bans(FILE *, int);
+int write_config (FILE *, int);
+int write_exempts (FILE *, int);
+int write_chans (FILE *, int);
+int write_invites (FILE *, int);
+int expired_mask(struct chanset_t *, char *);
+void set_handle_laston(char *, struct userrec *, time_t);
+int u_delexempt(struct chanset_t *, char *, int);
+int u_addexempt(struct chanset_t *, char *, char *, char *,  time_t, int);
+int u_delinvite(struct chanset_t *, char *, int);
+int u_addinvite(struct chanset_t *, char *, char *, char *,  time_t, int);
+int u_delban(struct chanset_t *, char *, int);
+int u_addban(struct chanset_t *, char *, char *, char *, time_t, int);
+int u_sticky_mask(maskrec *, char *);
+int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, char *);
 int SplitList(char *, const char *, int *, const char ***);
 int channel_modify(char *, struct chanset_t *, int, char **);
-
-#endif				/* MAKING_CHANNELS */
+int channel_add(char *, char *, char *);
+void check_should_lock();
+void clear_channel(struct chanset_t *, int);
+int u_equals_mask(maskrec *, char *);
+int u_match_mask(struct maskrec *, char *);
+int ismasked(masklist *, char *);
+int ismodeline(masklist *, char *);
+
+extern int		use_info, global_ban_time, global_exempt_time, global_invite_time;
 
 /* Macro's here because their functions were replaced by something more
  * generic. <cybah>

+ 2 - 2
src/mod/channels.mod/tclchan.c

@@ -698,7 +698,7 @@ static void clear_masklist(masklist *m)
 
 /* Clear out channel data from memory.
  */
-static void clear_channel(struct chanset_t *chan, int reset)
+void clear_channel(struct chanset_t *chan, int reset)
 {
   memberlist *m = NULL, *m1 = NULL;
 
@@ -722,7 +722,7 @@ static void clear_channel(struct chanset_t *chan, int reset)
 
 /* Create new channel and parse commands.
  */
-static int channel_add(char *result, char *newname, char *options)
+int channel_add(char *result, char *newname, char *options)
 {
   struct chanset_t *chan = NULL;
   int items = 0;

+ 2 - 2
src/mod/channels.mod/udefchan.c

@@ -16,7 +16,7 @@ static int getudef(struct udef_chans *ul, char *name)
   return val;
 }
 
-static int ngetudef(char *name, char *chan)
+int ngetudef(char *name, char *chan)
 {
   struct udef_struct *l = NULL;
   struct udef_chans *ll = NULL;
@@ -51,7 +51,7 @@ static void setudef(struct udef_struct *us, char *name, int value)
     us->values = ul;
 }
 
-static void initudef(int type, char *name, int defined)
+void initudef(int type, char *name, int defined)
 {
   struct udef_struct *ul = NULL, *ul_last = NULL;
 

+ 22 - 27
src/mod/channels.mod/userchan.c

@@ -19,7 +19,7 @@ struct chanuserrec *get_chanrec(struct userrec *u, char *chname)
   return NULL;
 }
 
-static struct chanuserrec *add_chanrec(struct userrec *u, char *chname)
+struct chanuserrec *add_chanrec(struct userrec *u, char *chname)
 {
   struct chanuserrec *ch = NULL;
 
@@ -40,7 +40,7 @@ static struct chanuserrec *add_chanrec(struct userrec *u, char *chname)
   return ch;
 }
 
-static void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname)
+void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname)
 {
   struct userrec *u = NULL;
 
@@ -51,7 +51,7 @@ static void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname)
     add_chanrec(u, chname);
 }
 
-static void get_handle_chaninfo(char *handle, char *chname, char *s)
+void get_handle_chaninfo(char *handle, char *chname, char *s)
 {
   struct userrec *u = NULL;
   struct chanuserrec *ch = NULL;
@@ -74,7 +74,7 @@ static void get_handle_chaninfo(char *handle, char *chname, char *s)
   return;
 }
 
-static void set_handle_chaninfo(struct userrec *bu, char *handle,
+void set_handle_chaninfo(struct userrec *bu, char *handle,
 				char *chname, char *info)
 {
   struct userrec *u = NULL;
@@ -105,7 +105,7 @@ static void set_handle_chaninfo(struct userrec *bu, char *handle,
   }
 }
 
-static void del_chanrec(struct userrec *u, char *chname)
+void del_chanrec(struct userrec *u, char *chname)
 {
   struct chanuserrec *ch = u->chanrec, *lst = NULL;
 
@@ -127,7 +127,7 @@ static void del_chanrec(struct userrec *u, char *chname)
   }
 }
 
-static void set_handle_laston(char *chan, struct userrec *u, time_t n)
+void set_handle_laston(char *chan, struct userrec *u, time_t n)
 {
   struct chanuserrec *ch = NULL;
 
@@ -142,7 +142,7 @@ static void set_handle_laston(char *chan, struct userrec *u, time_t n)
 
 /* Is this mask sticky?
  */
-static int u_sticky_mask(maskrec *u, char *uhost)
+int u_sticky_mask(maskrec *u, char *uhost)
 {
   for (; u; u = u->next)
     if (!rfc_casecmp(u->mask, uhost))
@@ -152,8 +152,7 @@ static int u_sticky_mask(maskrec *u, char *uhost)
 
 /* Set sticky attribute for a mask.
  */
-static int u_setsticky_mask(struct chanset_t *chan, maskrec *u, char *uhost,
-			    int sticky, char *botcmd)
+int u_setsticky_mask(struct chanset_t *chan, maskrec *u, char *uhost, int sticky, char *botcmd)
 {
   int j;
 
@@ -198,7 +197,7 @@ static int u_setsticky_mask(struct chanset_t *chan, maskrec *u, char *uhost,
  *   1       temporary ban
  *   2       perm ban
  */
-static int u_equals_mask(maskrec *u, char *mask)
+int u_equals_mask(maskrec *u, char *mask)
 {
   for (; u; u = u->next)
     if (!rfc_casecmp(u->mask, mask)) {
@@ -210,7 +209,7 @@ static int u_equals_mask(maskrec *u, char *mask)
   return 0;
 }
 
-static int u_match_mask(maskrec *rec, char *mask)
+int u_match_mask(maskrec *rec, char *mask)
 {
   for (; rec; rec = rec->next)
     if (wild_match(rec->mask, mask))
@@ -218,7 +217,7 @@ static int u_match_mask(maskrec *rec, char *mask)
   return 0;
 }
 
-static int u_delban(struct chanset_t *c, char *who, int doit)
+int u_delban(struct chanset_t *c, char *who, int doit)
 {
   int j, i = 0;
   maskrec *t = NULL;
@@ -273,7 +272,7 @@ static int u_delban(struct chanset_t *c, char *who, int doit)
   return i;
 }
 
-static int u_delexempt (struct chanset_t * c, char * who, int doit)
+int u_delexempt (struct chanset_t * c, char * who, int doit)
 {
   int j, i = 0;
   maskrec *t = NULL;
@@ -323,7 +322,7 @@ static int u_delexempt (struct chanset_t * c, char * who, int doit)
   return i;
 }
 
-static int u_delinvite(struct chanset_t *c, char *who, int doit)
+int u_delinvite(struct chanset_t *c, char *who, int doit)
 {
   int j, i = 0;
   maskrec *t = NULL;
@@ -375,8 +374,7 @@ static int u_delinvite(struct chanset_t *c, char *who, int doit)
 
 /* Note: If first char of note is '*' it's a sticky ban.
  */
-static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
-		    time_t expire_time, int flags)
+int u_addban(struct chanset_t *chan, char *ban, char *from, char *note, time_t expire_time, int flags)
 {
   char host[1024] = "", s[1024] = "";
   maskrec *p = NULL, *l = NULL, **u = chan ? &chan->bans : &global_bans;
@@ -460,8 +458,7 @@ static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
 
 /* Note: If first char of note is '*' it's a sticky invite.
  */
-static int u_addinvite(struct chanset_t *chan, char *invite, char *from,
-		       char *note, time_t expire_time, int flags)
+int u_addinvite(struct chanset_t *chan, char *invite, char *from, char *note, time_t expire_time, int flags)
 {
   char host[1024] = "", s[1024] = "";
   maskrec *p = NULL, *l, **u = chan ? &chan->invites : &global_invites;
@@ -538,8 +535,7 @@ static int u_addinvite(struct chanset_t *chan, char *invite, char *from,
 
 /* Note: If first char of note is '*' it's a sticky exempt.
  */
-static int u_addexempt(struct chanset_t *chan, char *exempt, char *from,
-		       char *note, time_t expire_time, int flags)
+int u_addexempt(struct chanset_t *chan, char *exempt, char *from, char *note, time_t expire_time, int flags)
 {
   char host[1024] = "", s[1024] = "";
   maskrec *p = NULL, *l, **u = chan ? &chan->exempts : &global_exempts;
@@ -1051,7 +1047,7 @@ static void tell_invites(int idx, int show_inact, char *match)
     dprintf(idx, "%s.\n", INVITES_USEINVITESALL);
 }
 
-static int write_config(FILE *f, int idx)
+int write_config(FILE *f, int idx)
 {
   int i = 0;
 #ifdef S_DCCPASS
@@ -1077,7 +1073,7 @@ static int write_config(FILE *f, int idx)
 }
 /* Write the ban lists and the ignore list to a file.
  */
-static int write_bans(FILE *f, int idx)
+int write_bans(FILE *f, int idx)
 {
   struct chanset_t *chan = NULL;
   maskrec *b = NULL;
@@ -1147,7 +1143,7 @@ static int write_bans(FILE *f, int idx)
 }
 /* Write the exemptlists to a file.
  */
-static int write_exempts(FILE *f, int idx)
+int write_exempts(FILE *f, int idx)
 {
   struct chanset_t *chan = NULL;
   maskrec *e = NULL;
@@ -1200,7 +1196,7 @@ static int write_exempts(FILE *f, int idx)
 
 /* Write the invitelists to a file.
  */
-static int write_invites(FILE *f, int idx)
+int write_invites(FILE *f, int idx)
 {
   struct chanset_t *chan = NULL;
   maskrec *ir = NULL;
@@ -1253,7 +1249,7 @@ static int write_invites(FILE *f, int idx)
 
 /* Write the channels to the userfile
  */
-static int write_chans(FILE *f, int idx)
+int write_chans(FILE *f, int idx)
 {
   char w[1024] = "";
   struct chanset_t *chan = NULL;
@@ -1341,7 +1337,6 @@ flood-nick %d:%d closed-ban %d ban-time %d exempt-time %d invite-time %d \
   return 1;
 }
 
-
 static void channels_writeuserfile(void)
 {
 #ifdef HUB
@@ -1375,7 +1370,7 @@ static void channels_writeuserfile(void)
  * Returns 1 if a mask on `chan' by `who' may be expired and 0 if
  * not.
  */
-static int expired_mask(struct chanset_t *chan, char *who)
+int expired_mask(struct chanset_t *chan, char *who)
 {
   memberlist *m = NULL, *m2 = NULL;
   char buf[UHOSTLEN] = "", *snick = NULL, *sfrom = NULL;

+ 1 - 1
src/mod/irc.mod/cmdsirc.c

@@ -732,7 +732,7 @@ void mdop_request(char *botnick, char *code, char *par)
     }
     strcat(work, "\n");
   }
-  tputs(servi, work, strlen(work));
+  tputs(serv, work, strlen(work));
 }
 
 static void cmd_deop(struct userrec *u, int idx, char *par)

+ 1 - 8
src/mod/irc.mod/irc.c

@@ -52,10 +52,9 @@ static bind_table_t *BT_msgc = NULL;
 #endif /* S_AUTHCMDS */
 
 
-static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL;
+static Function *global = NULL;
 
 
-static int ctcp_mode;
 static int net_type = 0;
 static int strict_host;
 static int wait_split = 300;		/* Time to wait for user to return from
@@ -1573,12 +1572,6 @@ char *irc_start(Function * global_funcs)
 
   module_register(MODULE_NAME, irc_table, 1, 3);
 
-  server_funcs = module_depend(MODULE_NAME, "server", 1, 0);
-
-  if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires channels module 1.0 or later.";
-  }
   add_cfg(&CFG_OPBOTS);
   add_cfg(&CFG_INBOTS);
   add_cfg(&CFG_LAGTHRESHOLD);

+ 7 - 7
src/mod/irc.mod/mode.c

@@ -1273,7 +1273,7 @@ static int gotmode(char *from, char *msg)
             if (m && !chan_sentkick(m)) {
               m->flags |= SENTKICK;
               sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MASSDEOP));
-              tputs(servi, tmp, strlen(tmp));
+              tputs(serv, tmp, strlen(tmp));
               if (ufrom) {
                 sprintf(tmp, STR("Mass deop on %s by %s"), chan->dname, nfrom);
                 deflag_user(ufrom, DEFLAG_MDOP, tmp, chan);
@@ -1291,7 +1291,7 @@ static int gotmode(char *from, char *msg)
               if (m && !chan_sentkick(m)) {
                 m->flags |= SENTKICK;
                 sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
-                tputs(servi, tmp, strlen(tmp));
+                tputs(serv, tmp, strlen(tmp));
                 if (ufrom) {
                   sprintf(tmp, STR("Mass op on %s by %s"), chan->dname, nfrom);
                   deflag_user(ufrom, DEFLAG_MOP, tmp, chan);
@@ -1366,7 +1366,7 @@ static int gotmode(char *from, char *msg)
             m = ismember(chan, nfrom);
             if (!m || !chan_sentkick(m)) {
               sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_BADOP));
-              tputs(servi, tmp, strlen(tmp));
+              tputs(serv, tmp, strlen(tmp));
               if (m)
                 m->flags |= SENTKICK;
             }
@@ -1389,7 +1389,7 @@ static int gotmode(char *from, char *msg)
                 if (!(m->flags & CHANOP)) {
                   if (!chan_sentkick(m)) {
                     sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_BADOPPED));
-                    tputs(servi, tmp, strlen(tmp));
+                    tputs(serv, tmp, strlen(tmp));
                     m->flags |= SENTKICK;
                   }
                 }
@@ -1421,7 +1421,7 @@ static int gotmode(char *from, char *msg)
           m = ismember(chan, nfrom);
           if (!m || !chan_sentkick(m)) {
             sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
-            tputs(servi, tmp, strlen(tmp));
+            tputs(serv, tmp, strlen(tmp));
             if (m)
               m->flags |= SENTKICK;
           }
@@ -1444,13 +1444,13 @@ static int gotmode(char *from, char *msg)
               if (!(m->flags & CHANOP) && (rfc_casecmp(botname, trg))) {
                 if (!chan_sentkick(m)) {
                   sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
-                  tputs(servi, tmp, strlen(tmp));
+                  tputs(serv, tmp, strlen(tmp));
                   m->flags |= SENTKICK;
                 }
               }
             } else {
               sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
-              tputs(servi, tmp, strlen(tmp));
+              tputs(serv, tmp, strlen(tmp));
             }
           }
         }

+ 11 - 56
src/mod/server.mod/server.c

@@ -12,13 +12,14 @@
 #include "src/auth.h"
 #include "src/dns.h"
 #include "src/egg_timer.h"
+#include "src/mod/channels.mod/channels.h"
 #include "server.h"
 
 static Function *global = NULL;
 extern struct cfg_entry CFG_OPTIMESLACK;
 extern int		cfg_noshare;
-static int checked_hostmask;	/* Used in request_op()/check_hostmask() cleared on connect */
-static int ctcp_mode;
+int checked_hostmask;	/* Used in request_op()/check_hostmask() cleared on connect */
+int ctcp_mode;
 int serv;		/* sock # of server currently */
 int servidx;		/* idx of server */
 static int strict_host;		/* strict masking of hosts ? */
@@ -27,10 +28,10 @@ int newserverport;		/* new server port? */
 char newserverpass[121] = "";	/* new server password? */
 static time_t trying_server;	/* trying to connect to a server right now? */
 static int curserv;		/* current position in server list: */
-static int flud_thr;		/* msg flood threshold */
-static int flud_time;		/* msg flood time */
-static int flud_ctcp_thr;	/* ctcp flood threshold */
-static int flud_ctcp_time;	/* ctcp flood time */
+int flud_thr;		/* msg flood threshold */
+int flud_time;		/* msg flood time */
+int flud_ctcp_thr;	/* ctcp flood threshold */
+int flud_ctcp_time;	/* ctcp flood time */
 char botuserhost[121] = "";	/* bot's user@host (refreshed whenever the
 				   bot joins a channel) */
 				/* may not be correct user@host BUT it's
@@ -41,7 +42,7 @@ static int nick_juped = 0;	/* True if origbotname is juped(RPL437) (dw) */
 static int check_stoned;	/* Check for a stoned server? */
 static int serverror_quit;	/* Disconnect from server if ERROR
 				   messages received? */
-static int quiet_reject;	/* Quietly reject dcc chat or sends from
+int quiet_reject;	/* Quietly reject dcc chat or sends from
 				   users without access? */
 static int waiting_for_awake;	/* set when i unidle myself, cleared when
 				   i get the response */
@@ -57,8 +58,8 @@ static struct server_list *serverlist = NULL;	/* old-style queue, still used by
 int cycle_time;			/* cycle time till next server connect */
 int default_port;		/* default IRC port */
 static char oldnick[NICKLEN] = "";	/* previous nickname *before* rehash */
-static int trigger_on_ignore;	/* trigger bindings if user is ignored ? */
-static int answer_ctcp;		/* answer how many stacked ctcp's ? */
+int trigger_on_ignore;	/* trigger bindings if user is ignored ? */
+int answer_ctcp;		/* answer how many stacked ctcp's ? */
 static int lowercase_ctcp;	/* answer lowercase CTCP's (non-standard) */
 static int check_mode_r;	/* check for IRCNET +r modes */
 static int net_type;
@@ -73,8 +74,7 @@ static char stackable2cmds[511] = "";
 static time_t last_time;
 static int use_penalties;
 static int use_fastdeq;
-static int nick_len;		/* Maximal nick length allowed on the
-				   network. */
+int nick_len;			/* Maximal nick length allowed on the network. */
 static int kick_method;
 static int optimize_kicks;
 
@@ -1481,51 +1481,6 @@ static Function server_table[] =
   (Function) NULL,
   (Function) 0,
   (Function) server_report,
-  /* 4 - 7 */
-  (Function) NULL,		/* char * (points to botname later on)	*/
-  (Function) 0,
-  (Function) & quiet_reject,	/* int					*/
-  (Function) 0,
-  /* 8 - 11 */
-  (Function) & flud_thr,	/* int					*/
-  (Function) & flud_time,	/* int					*/
-  (Function) & flud_ctcp_thr,	/* int					*/
-  (Function) & flud_ctcp_time,	/* int					*/
-  /* 12 - 15 */
-  (Function) match_my_nick,
-  (Function) 0,
-  (Function) 0,
-  (Function) & answer_ctcp,	/* int					*/
-  /* 16 - 19 */
-  (Function) & trigger_on_ignore, /* int				*/
-  (Function) check_bind_ctcpr,
-  (Function) detect_avalanche,
-  (Function) 0,
-  /* 20 - 23 */
-  (Function) 0,
-  (Function) 0,
-  (Function) 0,
-  (Function) 0,
-  /* 24 - 27 */
-  (Function) 0,
-  (Function) 0,	
-  (Function) 0,	
-  (Function) 0,
-  /* 28 - 31 */
-  (Function) 0,
-  (Function) 0,
-  (Function) 0,
-  (Function) 0,
-  /* 32 - 35 */
-  (Function) 0,
-  (Function) 0,	
-  (Function) 0,
-  (Function) 0,
-  /* 36 - 38 */
-  (Function) 0,	
-  (Function) & nick_len,	/* int					*/
-  (Function) 0,
-  (Function) & checked_hostmask,
 };
 
 char *server_start(Function *global_funcs)

+ 11 - 62
src/mod/server.mod/server.h

@@ -7,6 +7,8 @@
 #ifndef _EGG_MOD_SERVER_SERVER_H
 #define _EGG_MOD_SERVER_SERVER_H
 
+#include "src/tclhash.h"
+
 #define DO_LOST 1
 #define NO_LOST 0
 
@@ -21,67 +23,6 @@
 } while (0)
 
 
-#ifndef MAKING_SERVER
-/* 4 - 7 */
-/* UNUSED 5 */
-#define quiet_reject (*(int *)(server_funcs[6]))
-/* UNUSED 7 */
-#define servi (*(int *)(server_funcs[7]))
-/* 8 - 11 */
-#define flud_thr (*(int*)(server_funcs[8]))
-#define flud_time (*(int*)(server_funcs[9]))
-#define flud_ctcp_thr (*(int*)(server_funcs[10]))
-#define flud_ctcp_time (*(int*)(server_funcs[11]))
-/* 12 - 15 */
-#define match_my_nick ((int(*)(char *))server_funcs[12])
-/* UNUSED 14 */
-#define answer_ctcp (*(int *)(server_funcs[15]))
-/* 16 - 19 */
-#define trigger_on_ignore (*(int *)(server_funcs[16]))
-#define check_bind_ctcpr ((int(*)(char*,char*,struct userrec*,char*,char*,char*,bind_table_t *))server_funcs[17])
-#define detect_avalanche ((int(*)(char *))server_funcs[18])
-/* 19 UNUSED */
-/* 20 - 22 */
-/* UNUSED 20 */
-/* UNUSED 21 */
-/* UNUSED 22 */
-/* 23 - 26 */
-/* UNUSED 23 */
-/* UNUSED 24 */
-/* UNUSED 25 */
-/* 26 -- UNUSED */
-/* 27 - 30 */
-/* UNUSED -- 28 */
-/* UNUSED -- 29 */
-/* UNUSED -- 30 */
-/* 31 - 34 */
-/* UNUSED -- 33 */
-/* UNUSED -- 34 */
-/* 35 - 38 */
-/* UNUSED 35 */
-/* 36 UNUSED */
-#define nick_len (*(int *)(server_funcs[37]))
-/* 38 UNUSED */
-#define checked_hostmask (*(int *)(server_funcs[39]))
-
-#else		/* MAKING_SERVER */
-
-/* Macros for commonly used commands.
- */
-
-#define free_null(ptr)	do {				\
-	free(ptr);					\
-	ptr = NULL;					\
-} while (0)
-
-#define write_to_server(x,y) do {                       \
-        tputs(serv, (x), (y));                          \
-        tputs(serv, "\r\n", 2);                         \
-} while (0)
-
-
-#endif		/* MAKING_SERVER */
-
 struct server_list {
   struct server_list	*next;
 
@@ -104,9 +45,17 @@ enum {
 #endif		/* _EGG_MOD_SERVER_SERVER_H */
 
 void nuke_server(char *);
-extern int 		serv, servidx, cycle_time, default_port, newserverport;
+int match_my_nick(char *);
+
+extern int 		serv, servidx, cycle_time, default_port, newserverport,
+			nick_len, checked_hostmask, ctcp_mode, quiet_reject,
+			flud_thr, flud_time, flud_ctcp_thr, flud_ctcp_time,
+			answer_ctcp, trigger_on_ignore;
 extern time_t		server_online;
 extern char		cursrvname[], botrealname[], botuserhost[], ctcp_reply[],
 			newserver[], newserverpass[];
 
+int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);
+int detect_avalanche(char *);
+
 #endif /*leaf*/

+ 8 - 13
src/mod/server.mod/servmsg.c

@@ -147,7 +147,7 @@ static int check_bind_raw(char *from, char *code, char *msg)
 }
 
 
-static int check_bind_ctcpr(char *nick, char *uhost, struct userrec *u,
+int check_bind_ctcpr(char *nick, char *uhost, struct userrec *u,
                            char *dest, char *keyword, char *args,
                            bind_table_t *table)
 {
@@ -157,7 +157,7 @@ static int check_bind_ctcpr(char *nick, char *uhost, struct userrec *u,
 }
 
 
-static int match_my_nick(char *nick)
+int match_my_nick(char *nick)
 {
   if (!rfc_casecmp(nick, botname))
     return 1;
@@ -236,11 +236,8 @@ static int got442(char *from, char *msg)
   chan = findchan(chname);
   if (chan)
     if (shouldjoin(chan)) {
-      module_entry *me = module_find("channels", 0, 0);
-
       putlog(LOG_MISC, chname, IRC_SERVNOTONCHAN, chname);
-      if (me && me->funcs)
-	(me->funcs[CHANNEL_CLEAR])(chan, 1);
+      clear_channel(chan, 1);
       chan->status &= ~CHAN_ACTIVE;
       dprintf(DP_MODE, "JOIN %s %s\n", chan->name,
 	      chan->channel.key[0] ? chan->channel.key : chan->key_prot);
@@ -346,7 +343,7 @@ static int detect_flood(char *floodnick, char *floodhost, char *from, int which)
 /* Check for more than 8 control characters in a line.
  * This could indicate: beep flood CTCP avalanche.
  */
-static int detect_avalanche(char *msg)
+int detect_avalanche(char *msg)
 {
   int count = 0;
   unsigned char *p = NULL;
@@ -950,15 +947,13 @@ static void connect_server(void);
 
 static void kill_server(int idx, void *x)
 {
-  module_entry *me = NULL;
+  struct chanset_t *chan = NULL;
 
   disconnect_server(idx, NO_LOST);	/* eof_server will lostdcc() it. */
-  if ((me = module_find("channels", 0, 0)) && me->funcs) {
-    struct chanset_t *chan;
 
-    for (chan = chanset; chan; chan = chan->next)
-      (me->funcs[CHANNEL_CLEAR]) (chan, 1);
-  }
+  for (chan = chanset; chan; chan = chan->next)
+     clear_channel(chan, 1);
+
   /* A new server connection will be automatically initiated in
      about 2 seconds. */
 }

+ 2 - 5
src/mod/share.mod/share.c

@@ -30,7 +30,7 @@ static const int min_exemptinvite	= 1000000;
 /* Minimum version that supports userfile features. */
 static const int min_uffeature		= 1000000;
 
-static Function *global = NULL, *transfer_funcs = NULL, *channels_funcs = NULL;
+static Function *global = NULL, *transfer_funcs = NULL;
 #ifdef LEAF
 static Function *irc_funcs = NULL;
 #endif /* LEAF */
@@ -2138,10 +2138,7 @@ char *share_start(Function *global_funcs)
     module_undepend(MODULE_NAME);
     return "This module requires transfer module 2.0 or later.";
   }
-  if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires channels module 1.0 or later.";
-  }
+
 #ifdef LEAF
   if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 0, 0))) {
     module_undepend(MODULE_NAME);

+ 13 - 18
src/users.c

@@ -30,6 +30,7 @@
 #include "chan.h"
 #include "modules.h"
 #include "tandem.h"
+#include "src/mod/channels.mod/channels.h"
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #ifdef HUB
@@ -812,30 +813,24 @@ int readuserfile(char *file, struct userrec **ret)
 	  }
         } else if (!strcmp(code, "+")) {
          if (s[0] && lasthand[0] == '*' && lasthand[1] == CHANS_NAME[1]) {
-           module_entry *me = NULL;
+           char *options = NULL, *chan = NULL, *my_ptr = NULL;
+           char resultbuf[2048] = "";
 
-           if ((me = module_find("channels", 0, 0))) {
-             Function *func = me->funcs;
-             char *options = NULL, *chan = NULL, *my_ptr = NULL;
-             char resultbuf[2048] = "";
+           options = my_ptr = strdup(s);
 
-             options = my_ptr = strdup(s);
-
-             newsplit(&options);
-             newsplit(&options);
-             chan = newsplit(&options);
+           newsplit(&options);
+           newsplit(&options);
+           chan = newsplit(&options);
 /* FIXME: THIS HACK FOR { } REMOVAL SHOULD JUST NOT WRITE THEM? */
-             newsplit(&options);
-             options[strlen(options) - 1] = 0;
+           newsplit(&options);
+           options[strlen(options) - 1] = 0;
 /* Above is a hack to remove { } */
-             if ((func[37]) (resultbuf, chan, options) != OK) {	/* channel_add() */
-printf("BUF: %s\n", resultbuf);
-               putlog(LOG_MISC, "*", "Channel parsing error in userfile on line %d", line);
-               free(my_ptr);
-               return 0;
-             }
+           if (channel_add(resultbuf, chan, options) != OK) {
+             putlog(LOG_MISC, "*", "Channel parsing error in userfile on line %d", line);
              free(my_ptr);
+             return 0;
            }
+           free(my_ptr);
          }
 	} else if (!strncmp(code, "::", 2)) {
 	  /* channel-specific bans */