diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2014-07-02 18:33:39 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2014-07-02 18:33:39 +0000 |
commit | 6f93e362a461bdb889ed409b3b7dfad8a3c5fab9 (patch) | |
tree | d463a92d37b27cbb40e215f9b57ba39a451c1b27 /src | |
parent | d2c717bcaba9f2306df1fde214f21c71eace06ac (diff) |
- Removed hooking system
- Update help/stats
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@4157 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/Makefile.in | 30 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/hook.c | 214 | ||||
-rw-r--r-- | src/ircd.c | 1 | ||||
-rw-r--r-- | src/packet.c | 1 | ||||
-rw-r--r-- | src/s_auth.c | 1 | ||||
-rw-r--r-- | src/s_bsd.c | 1 | ||||
-rw-r--r-- | src/s_bsd_poll.c | 1 | ||||
-rw-r--r-- | src/s_bsd_select.c | 1 | ||||
-rw-r--r-- | src/s_user.c | 1 |
11 files changed, 14 insertions, 239 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 0c1c73a..d3f2d2b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,6 @@ ircd_SOURCES = channel.c \ fdlist.c \ getopt.c \ hash.c \ - hook.c \ hostmask.c \ irc_res.c \ irc_reslib.c \ diff --git a/src/Makefile.in b/src/Makefile.in index f378ec2..d758c1c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -108,20 +108,20 @@ am_ircd_OBJECTS = channel.$(OBJEXT) channel_mode.$(OBJEXT) \ client.$(OBJEXT) conf.$(OBJEXT) conf_class.$(OBJEXT) \ conf_db.$(OBJEXT) conf_parser.$(OBJEXT) conf_lexer.$(OBJEXT) \ dbuf.$(OBJEXT) event.$(OBJEXT) fdlist.$(OBJEXT) \ - getopt.$(OBJEXT) hash.$(OBJEXT) hook.$(OBJEXT) \ - hostmask.$(OBJEXT) irc_res.$(OBJEXT) irc_reslib.$(OBJEXT) \ - irc_string.$(OBJEXT) ircd.$(OBJEXT) ircd_signal.$(OBJEXT) \ - list.$(OBJEXT) listener.$(OBJEXT) log.$(OBJEXT) \ - match.$(OBJEXT) memory.$(OBJEXT) mempool.$(OBJEXT) \ - modules.$(OBJEXT) motd.$(OBJEXT) rng_mt.$(OBJEXT) \ - numeric.$(OBJEXT) packet.$(OBJEXT) parse.$(OBJEXT) \ - s_bsd_epoll.$(OBJEXT) s_bsd_poll.$(OBJEXT) \ - s_bsd_devpoll.$(OBJEXT) s_bsd_kqueue.$(OBJEXT) \ - s_bsd_select.$(OBJEXT) restart.$(OBJEXT) resv.$(OBJEXT) \ - rsa.$(OBJEXT) s_auth.$(OBJEXT) s_bsd.$(OBJEXT) \ - s_gline.$(OBJEXT) s_misc.$(OBJEXT) s_serv.$(OBJEXT) \ - s_user.$(OBJEXT) send.$(OBJEXT) version.$(OBJEXT) \ - watch.$(OBJEXT) whowas.$(OBJEXT) + getopt.$(OBJEXT) hash.$(OBJEXT) hostmask.$(OBJEXT) \ + irc_res.$(OBJEXT) irc_reslib.$(OBJEXT) irc_string.$(OBJEXT) \ + ircd.$(OBJEXT) ircd_signal.$(OBJEXT) list.$(OBJEXT) \ + listener.$(OBJEXT) log.$(OBJEXT) match.$(OBJEXT) \ + memory.$(OBJEXT) mempool.$(OBJEXT) modules.$(OBJEXT) \ + motd.$(OBJEXT) rng_mt.$(OBJEXT) numeric.$(OBJEXT) \ + packet.$(OBJEXT) parse.$(OBJEXT) s_bsd_epoll.$(OBJEXT) \ + s_bsd_poll.$(OBJEXT) s_bsd_devpoll.$(OBJEXT) \ + s_bsd_kqueue.$(OBJEXT) s_bsd_select.$(OBJEXT) \ + restart.$(OBJEXT) resv.$(OBJEXT) rsa.$(OBJEXT) \ + s_auth.$(OBJEXT) s_bsd.$(OBJEXT) s_gline.$(OBJEXT) \ + s_misc.$(OBJEXT) s_serv.$(OBJEXT) s_user.$(OBJEXT) \ + send.$(OBJEXT) version.$(OBJEXT) watch.$(OBJEXT) \ + whowas.$(OBJEXT) ircd_OBJECTS = $(am_ircd_OBJECTS) am__DEPENDENCIES_1 = AM_V_lt = $(am__v_lt_@AM_V@) @@ -371,7 +371,6 @@ ircd_SOURCES = channel.c \ fdlist.c \ getopt.c \ hash.c \ - hook.c \ hostmask.c \ irc_res.c \ irc_reslib.c \ @@ -519,7 +518,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hook.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hostmask.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irc_res.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irc_reslib.Po@am__quote@ @@ -33,7 +33,6 @@ #include "channel.h" #include "client.h" #include "event.h" -#include "hook.h" #include "irc_string.h" #include "s_bsd.h" #include "ircd.h" diff --git a/src/hook.c b/src/hook.c deleted file mode 100644 index 86b2e86..0000000 --- a/src/hook.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) - * - * Copyright (c) 2003 Piotr Nizynski, Advanced IRC Services Project Team - * Copyright (c) 2005-2014 ircd-hybrid development team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/*! \file hook.c - * \brief Provides a generic event hooking interface. - * \version $Id$ - */ - -#include "stdinc.h" -#include "list.h" -#include "hook.h" -#include "ircd.h" -#include "memory.h" -#include "numeric.h" -#include "irc_string.h" -#include "send.h" -#include "client.h" - - -static dlink_list callback_list; - - -/*! \brief Creates a new callback. - * \param name Name used to identify the callback - * (can be NULL for anonymous callbacks) - * \param func Initial function attached to the chain - * (can be NULL to create an empty chain) - * \return Pointer to Callback structure or NULL if already exists - * \note Once registered, a callback should never be freed! - * That's because there may be modules which depend on it - * (even if no functions are attached). That's also why - * we dynamically allocate the struct here -- we don't want - * to allow anyone to place it in module data, which can be - * unloaded at any time. - */ -struct Callback * -register_callback(const char *name, CBFUNC *func) -{ - struct Callback *cb = NULL; - - if (name != NULL) - { - if ((cb = find_callback(name)) != NULL) - { - if (func != NULL) - dlinkAddTail(func, MyMalloc(sizeof(dlink_node)), &cb->chain); - - return cb; - } - } - - cb = MyMalloc(sizeof(struct Callback)); - - if (func != NULL) - dlinkAdd(func, MyMalloc(sizeof(dlink_node)), &cb->chain); - - if (name != NULL) - { - cb->name = xstrdup(name); - dlinkAdd(cb, &cb->node, &callback_list); - } - - return cb; -} - -/*! \brief Passes control down the callback hook chain. - * \param cb Pointer to Callback structure - * \param ... Argument to pass - * \return function Return value - */ -void * -execute_callback(struct Callback *cb, ...) -{ - void *res = NULL; - va_list args; - - cb->called++; - cb->last = CurrentTime; - - if (!is_callback_present(cb)) - return NULL; - - va_start(args, cb); - res = ((CBFUNC *)cb->chain.head->data)(args); - va_end(args); - - return res; -} - -/*! \brief Called by a hook function to pass code flow further - * in the hook chain. - * \param this_hook Pointer to dlink_node of the current hook function - * \param ... (original or modified) arguments to be passed - * \return callback Return value - */ -void * -pass_callback(dlink_node *this_hook, ...) -{ - void *res = NULL; - va_list args; - - if (this_hook->next == NULL) - return NULL; /* Reached the last one */ - - va_start(args, this_hook); - res = ((CBFUNC *)this_hook->next->data)(args); - va_end(args); - - return res; -} - -/*! \brief Finds a named callback. - * \param name Name of the callback - * \return Pointer to Callback structure or NULL if not found - */ -struct Callback * -find_callback(const char *name) -{ - dlink_node *ptr = NULL; - - DLINK_FOREACH(ptr, callback_list.head) - { - struct Callback *cb = ptr->data; - - if (!irccmp(cb->name, name)) - return cb; - } - - return NULL; -} - -/*! \brief Installs a hook for the given callback. - * - * The new hook is installed at the beginning of the chain, - * so it has full control over functions installed earlier. - * - * \param cb Pointer to Callback structure - * \param hook Address of hook function - * \return Pointer to dlink_node of the hook (used when passing - * control to the next hook in the chain); - * valid till uninstall_hook() is called - */ -dlink_node * -install_hook(struct Callback *cb, CBFUNC *hook) -{ - dlink_node *node = MyMalloc(sizeof(dlink_node)); - - dlinkAdd(hook, node, &cb->chain); - return node; -} - -/*! \brief Removes a specific hook for the given callback. - * \param cb Pointer to Callback structure - * \param hook Address of hook function - */ -void -uninstall_hook(struct Callback *cb, CBFUNC *hook) -{ - /* Let it core if not found */ - dlink_node *ptr = dlinkFind(&cb->chain, hook); - - dlinkDelete(ptr, &cb->chain); - MyFree(ptr); -} - -/*! \brief Displays registered callbacks and lengths of their hook chains. - * (This is the handler of /stats h) - * \param source_p Pointer to struct Client - */ -void -stats_hooks(struct Client *source_p) -{ - char lastused[IRCD_BUFSIZE]; - const dlink_node *ptr = NULL; - - sendto_one(source_p, ":%s %d %s : %-20s %-20s Used Hooks", me.name, - RPL_STATSDEBUG, source_p->name, "Callback", "Last Execution"); - sendto_one(source_p, ":%s %d %s : ------------------------------------" - "--------------------", me.name, RPL_STATSDEBUG, source_p->name); - - DLINK_FOREACH(ptr, callback_list.head) - { - const struct Callback *cb = ptr->data; - - if (cb->last != 0) - snprintf(lastused, sizeof(lastused), "%d seconds ago", - (int) (CurrentTime - cb->last)); - else - strcpy(lastused, "NEVER"); - - sendto_one(source_p, ":%s %d %s : %-20s %-20s %-8u %d", me.name, - RPL_STATSDEBUG, source_p->name, cb->name, lastused, cb->called, - dlink_list_length(&cb->chain)); - } -} @@ -56,7 +56,6 @@ #include "modules.h" #include "memory.h" #include "mempool.h" -#include "hook.h" #include "ircd_getopt.h" #include "supported.h" #include "watch.h" diff --git a/src/packet.c b/src/packet.c index c31a616..d24534b 100644 --- a/src/packet.c +++ b/src/packet.c @@ -36,7 +36,6 @@ #include "packet.h" #include "irc_string.h" #include "memory.h" -#include "hook.h" #include "send.h" #include "s_misc.h" diff --git a/src/s_auth.c b/src/s_auth.c index bf0727a..6d8af40 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -43,7 +43,6 @@ #include "conf.h" #include "client.h" #include "event.h" -#include "hook.h" #include "irc_string.h" #include "ircd.h" #include "packet.h" diff --git a/src/s_bsd.c b/src/s_bsd.c index aee198c..99c516e 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -48,7 +48,6 @@ #include "send.h" #include "memory.h" #include "s_user.h" -#include "hook.h" static const char *comm_err_str[] = { "Comm OK", "Error during bind()", "Error during DNS lookup", "connect timeout", "Error during connect()", diff --git a/src/s_bsd_poll.c b/src/s_bsd_poll.c index cd0bf0c..b5bed68 100644 --- a/src/s_bsd_poll.c +++ b/src/s_bsd_poll.c @@ -30,7 +30,6 @@ #include "fdlist.h" #include "list.h" #include "memory.h" -#include "hook.h" #include "ircd.h" #include "s_bsd.h" #include "log.h" diff --git a/src/s_bsd_select.c b/src/s_bsd_select.c index c797d8d..c95b81b 100644 --- a/src/s_bsd_select.c +++ b/src/s_bsd_select.c @@ -28,7 +28,6 @@ #if USE_IOPOLL_MECHANISM == __IOPOLL_MECHANISM_SELECT #include "list.h" #include "fdlist.h" -#include "hook.h" #include "ircd.h" #include "s_bsd.h" #include "log.h" diff --git a/src/s_user.c b/src/s_user.c index 772c16a..106e0b7 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -49,7 +49,6 @@ #include "packet.h" #include "rng_mt.h" #include "userhost.h" -#include "hook.h" #include "s_misc.h" #include "parse.h" #include "watch.h" |