ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/hook.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/hook.c (file contents):
Revision 1646 by michael, Wed Nov 7 21:02:43 2012 UTC vs.
Revision 2358 by michael, Thu Jul 4 20:16:08 2013 UTC

# Line 2 | Line 2
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3   *
4   *  Copyright (C) 2003 Piotr Nizynski, Advanced IRC Services Project Team
5 < *  Copyright (C) 2005 Hybrid Development Team
5 > *  Copyright (C) 2005-2013 Hybrid Development Team
6   *
7   *  This program is free software; you can redistribute it and/or modify
8   *  it under the terms of the GNU General Public License as published by
# Line 37 | Line 37
37   #include "send.h"
38   #include "client.h"
39  
40 < static dlink_list callback_list = { NULL, NULL, 0} ;
40 > static dlink_list callback_list;
41 >
42  
43   /*! \brief Creates a new callback.
44   * \param name name used to identify the callback
# Line 69 | Line 70 | register_callback(const char *name, CBFU
70    }
71  
72    cb = MyMalloc(sizeof(struct Callback));
73 +
74    if (func != NULL)
75      dlinkAdd(func, MyMalloc(sizeof(dlink_node)), &cb->chain);
76  
# Line 89 | Line 91 | register_callback(const char *name, CBFU
91   void *
92   execute_callback(struct Callback *cb, ...)
93   {
94 <  void *res;
94 >  void *res = NULL;
95    va_list args;
96  
97    cb->called++;
# Line 99 | Line 101 | execute_callback(struct Callback *cb, ..
101      return NULL;
102  
103    va_start(args, cb);
104 <  res = ((CBFUNC *) cb->chain.head->data)(args);
104 >  res = ((CBFUNC *)cb->chain.head->data)(args);
105    va_end(args);
106  
107    return res;
# Line 114 | Line 116 | execute_callback(struct Callback *cb, ..
116   void *
117   pass_callback(dlink_node *this_hook, ...)
118   {
119 <  void *res;
119 >  void *res = NULL;
120    va_list args;
121  
122    if (this_hook->next == NULL)
123      return NULL;  /* reached the last one */
124  
125    va_start(args, this_hook);
126 <  res = ((CBFUNC *) this_hook->next->data)(args);
126 >  res = ((CBFUNC *)this_hook->next->data)(args);
127    va_end(args);
128  
129    return res;
# Line 134 | Line 136 | pass_callback(dlink_node *this_hook, ...
136   struct Callback *
137   find_callback(const char *name)
138   {
139 <  dlink_node *ptr;
139 >  dlink_node *ptr = NULL;
140  
141    DLINK_FOREACH(ptr, callback_list.head)
142    {
# Line 174 | Line 176 | install_hook(struct Callback *cb, CBFUNC
176   void
177   uninstall_hook(struct Callback *cb, CBFUNC *hook)
178   {
179 <  /* let it core if not found */
179 >  /* Let it core if not found */
180    dlink_node *ptr = dlinkFind(&cb->chain, hook);
181  
182    dlinkDelete(ptr, &cb->chain);
# Line 188 | Line 190 | uninstall_hook(struct Callback *cb, CBFU
190   void
191   stats_hooks(struct Client *source_p)
192   {
191  dlink_node *ptr;
193    char lastused[32];
194 +  const dlink_node *ptr = NULL;
195  
196    sendto_one(source_p, ":%s %d %s : %-20s %-20s Used     Hooks", me.name,
197               RPL_STATSDEBUG, source_p->name, "Callback", "Last Execution");
# Line 198 | Line 200 | stats_hooks(struct Client *source_p)
200  
201    DLINK_FOREACH(ptr, callback_list.head)
202    {
203 <    struct Callback *cb = ptr->data;
203 >    const struct Callback *cb = ptr->data;
204  
205      if (cb->last != 0)
206        snprintf(lastused, sizeof(lastused), "%d seconds ago",
# Line 208 | Line 210 | stats_hooks(struct Client *source_p)
210  
211      sendto_one(source_p, ":%s %d %s : %-20s %-20s %-8u %d", me.name,
212                 RPL_STATSDEBUG, source_p->name, cb->name, lastused, cb->called,
213 <               dlink_list_length(&cb->chain));
213 >               dlink_list_length(&cb->chain));
214    }
215  
216    sendto_one(source_p, ":%s %d %s : ", me.name, RPL_STATSDEBUG,

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)