From 6f93e362a461bdb889ed409b3b7dfad8a3c5fab9 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 2 Jul 2014 18:33:39 +0000 Subject: - 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 --- configure | 2 +- help/stats | 7 +- include/conf.h | 1 - include/hook.h | 53 ------------- modules/m_stats.c | 3 +- src/Makefile.am | 1 - src/Makefile.in | 30 ++++---- src/conf.c | 1 - src/hook.c | 214 ----------------------------------------------------- src/ircd.c | 1 - src/packet.c | 1 - src/s_auth.c | 1 - src/s_bsd.c | 1 - src/s_bsd_poll.c | 1 - src/s_bsd_select.c | 1 - src/s_user.c | 1 - 16 files changed, 19 insertions(+), 300 deletions(-) delete mode 100644 include/hook.h delete mode 100644 src/hook.c diff --git a/configure b/configure index daafa41..e699358 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Id: configure.ac 3465 2014-05-01 20:56:52Z michael . +# From configure.ac Id: configure.ac 3920 2014-06-09 11:56:33Z michael . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for ircd-hybrid 8.1.18. # diff --git a/help/stats b/help/stats index 4931347..ddf2b53 100644 --- a/help/stats +++ b/help/stats @@ -10,16 +10,15 @@ LETTER (* = Oper only.) X A - Shows the DNS servers in use * c - Shows configured connect {} blocks * d - Shows temporary D lines -* D - Shows D lines +* D - Shows permanent D lines * e - Shows exemptions to D lines X E - Shows active timers/events X f - Shows file descriptors * g - Shows pending G lines * G - Shows G lines -X h - Shows ircd callback statistics * H - Shows configured hub/leaf entries ^ i - Shows configured auth {} blocks -^ K - Shows K lines (or matched klines) +^ K - Shows permanent K lines (or matched permanent klines) ^ k - Shows temporary K lines (or matched temporary klines) * L - Shows IP and generic info about [nick] * l - Shows hostname and generic info about [nick] @@ -32,7 +31,7 @@ X h - Shows ircd callback statistics * s - Shows configured service {} blocks * T - Shows configured motd {} blocks * t - Shows generic server stats -* U - Shows shared {} blocks +* U - Shows configured shared {} and cluster {} blocks ^ u - Shows server uptime * v - Shows connected servers and their idle times * x - Shows gecos bans diff --git a/include/conf.h b/include/conf.h index ec6e807..b8c8ee9 100644 --- a/include/conf.h +++ b/include/conf.h @@ -29,7 +29,6 @@ #include "config.h" #include "ircd_defs.h" #include "client.h" -#include "hook.h" #include "conf_class.h" diff --git a/include/hook.h b/include/hook.h deleted file mode 100644 index 945db6b..0000000 --- a/include/hook.h +++ /dev/null @@ -1,53 +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.h - * \brief Provides a generic event hooking interface. - * \version $Id$ - */ - -#ifndef __HOOK_H_INCLUDED -#define __HOOK_H_INCLUDED - -#define is_callback_present(c) (!!dlink_list_length(&c->chain)) - -typedef void *CBFUNC(va_list); - -struct Callback -{ - char *name; - dlink_list chain; - dlink_node node; - unsigned int called; - time_t last; -}; - -struct Client; - -extern struct Callback *register_callback(const char *, CBFUNC *); -extern void *execute_callback(struct Callback *, ...); -extern struct Callback *find_callback(const char *); -extern dlink_node *install_hook(struct Callback *, CBFUNC *); -extern void uninstall_hook(struct Callback *, CBFUNC *); -extern void *pass_callback(dlink_node *, ...); -extern void stats_hooks(struct Client *); -#endif diff --git a/modules/m_stats.c b/modules/m_stats.c index 23dea16..4705d33 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -43,7 +43,6 @@ #include "s_user.h" #include "event.h" #include "dbuf.h" -#include "hook.h" #include "parse.h" #include "modules.h" #include "resv.h" @@ -1547,7 +1546,7 @@ static const struct StatsStruct { 'F', fd_dump, 1, 1 }, { 'g', stats_pending_glines, 1, 0 }, { 'G', stats_glines, 1, 0 }, - { 'h', stats_hooks, 1, 1 }, + { 'h', stats_hubleaf, 1, 1 }, { 'H', stats_hubleaf, 1, 0 }, { 'i', stats_auth, 0, 0 }, { 'I', stats_auth, 0, 0 }, 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@ diff --git a/src/conf.c b/src/conf.c index bfda03d..6b4b40f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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)); - } -} diff --git a/src/ircd.c b/src/ircd.c index 5ad971f..91770f1 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -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" -- cgit