X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/428ca87b01ad6c0487b424ce478f775cb7d94519..ea41b24fd4807e3565bf5f8f293e2efc4c20b62d:/modules/m_list.c diff --git a/modules/m_list.c b/modules/m_list.c index e28c6db4..29204c64 100644 --- a/modules/m_list.c +++ b/modules/m_list.c @@ -1,5 +1,5 @@ /* - * charybdis: An advanced ircd. + * Solanum: a slightly advanced ircd * m_list_safelist.c: Version of /list that uses the safelist code. * * Copyright (c) 2006 William Pitcock @@ -29,8 +29,6 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: m_list.c 3372 2007-04-03 10:18:07Z nenolod $ */ #include "stdinc.h" @@ -51,15 +49,19 @@ #include "inline/stringops.h" #include "s_assert.h" #include "logger.h" -#include "irc_radixtree.h" +#include "rb_radixtree.h" + +static const char list_desc[] = "Provides the LIST command to clients to view non-hidden channels"; static rb_dlink_list safelisting_clients = { NULL, NULL, 0 }; +static struct ev_entry *iterate_clients_ev = NULL; + static int _modinit(void); static void _moddeinit(void); -static int m_list(struct MsgBuf *, struct Client *, struct Client *, int, const char **); -static int mo_list(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +static void m_list(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +static void mo_list(struct MsgBuf *, struct Client *, struct Client *, int, const char **); static void list_one_channel(struct Client *source_p, struct Channel *chptr, int visible); @@ -72,7 +74,7 @@ static void safelist_iterate_clients(void *unused); static void safelist_channel_named(struct Client *source_p, const char *name, int operspy); struct Message list_msgtab = { - "LIST", 0, 0, 0, MFLG_SLOW, + "LIST", 0, 0, 0, 0, {mg_unreg, {m_list, 0}, mg_ignore, mg_ignore, mg_ignore, {mo_list, 0}} }; @@ -83,9 +85,7 @@ mapi_hfn_list_av1 list_hfnlist[] = { {NULL, NULL} }; -DECLARE_MODULE_AV1(list, _modinit, _moddeinit, list_clist, NULL, list_hfnlist, "$Revision: 3372 $"); - -static struct ev_entry *iterate_clients_ev = NULL; +DECLARE_MODULE_AV2(list, _modinit, _moddeinit, list_clist, NULL, list_hfnlist, NULL, NULL, list_desc); static int _modinit(void) { @@ -130,7 +130,8 @@ static void safelist_check_cliexit(hook_data_client_exit * hdata) * XXX - With SAFELIST, do we really need to continue pacing? * In theory, the server cannot be lagged by this. --nenolod */ -static int m_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +static void +m_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0L; @@ -138,7 +139,7 @@ static int m_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Clien { sendto_one_notice(source_p, ":/LIST aborted"); safelist_client_release(source_p); - return 0; + return; } if (parc < 2 || !IsChannelName(parv[1])) @@ -148,19 +149,20 @@ static int m_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Clien { sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "LIST"); sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name); - return 0; + return; } else last_used = rb_current_time(); } - return mo_list(msgbuf_p, client_p, source_p, parc, parv); + mo_list(msgbuf_p, client_p, source_p, parc, parv); } /* mo_list() * parv[1] = channel */ -static int mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +static void +mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct ListClient *params; char *p; @@ -172,7 +174,7 @@ static int mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Clie { sendto_one_notice(source_p, ":/LIST aborted"); safelist_client_release(source_p); - return 0; + return; } if (parc > 1) @@ -191,7 +193,7 @@ static int mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Clie if (args && IsChannelName(args)) { safelist_channel_named(source_p, args, operspy); - return 0; + return; } /* Multiple channels, possibly with parameters. */ @@ -286,8 +288,6 @@ static int mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Clie } safelist_client_instantiate(source_p, params); - - return 0; } /* @@ -317,19 +317,16 @@ static void list_one_channel(struct Client *source_p, struct Channel *chptr, * safelist_sendq_exceeded() * * inputs - pointer to client that needs checking - * outputs - 1 if a client has exceeded the reserved - * sendq limit, 0 if not + * outputs - true if a client has exceeded the reserved + * sendq limit, false if not * side effects - none * * When safelisting, we only use half of the SendQ at any * given time. */ -static int safelist_sendq_exceeded(struct Client *client_p) +static bool safelist_sendq_exceeded(struct Client *client_p) { - if (rb_linebuf_len(&client_p->localClient->buf_sendq) > (get_sendq(client_p) / 2)) - return YES; - else - return NO; + return rb_linebuf_len(&client_p->localClient->buf_sendq) > (get_sendq(client_p) / 2); } /* @@ -367,12 +364,12 @@ static void safelist_client_instantiate(struct Client *client_p, struct ListClie * outputs - none * side effects - the client is no longer being * listed - * - * Please do not ever call this on a non-local client. - * If you do, you will get SIGSEGV. */ static void safelist_client_release(struct Client *client_p) { + if(!MyClient(client_p)) + return; + s_assert(MyClient(client_p)); rb_dlinkFindDestroy(client_p, &safelisting_clients); @@ -474,11 +471,11 @@ static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, static void safelist_iterate_client(struct Client *source_p) { struct Channel *chptr; - struct irc_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; - IRC_RADIXTREE_FOREACH_FROM(chptr, &iter, channel_tree, source_p->localClient->safelist_data->chname) + RB_RADIXTREE_FOREACH_FROM(chptr, &iter, channel_tree, source_p->localClient->safelist_data->chname) { - if (safelist_sendq_exceeded(source_p->from) == YES) + if (safelist_sendq_exceeded(source_p->from)) { rb_free(source_p->localClient->safelist_data->chname); source_p->localClient->safelist_data->chname = rb_strdup(chptr->chname);