X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/c81afd158057056dae1436c4a24a64e1d4448e34..9dd128b4da6e54ca9f97cfcd48e345a57790ffbe:/extensions/extb_combi.c diff --git a/extensions/extb_combi.c b/extensions/extb_combi.c index 86a9d530..c9f35642 100644 --- a/extensions/extb_combi.c +++ b/extensions/extb_combi.c @@ -42,17 +42,18 @@ #include "client.h" #include "ircd.h" -// #define DEBUG(s) sendto_realops_snomask(SNO_DEBUG, L_NETWIDE, (s)) -#define DEBUG(s) +static const char extb_desc[] = "Combination ($&, $|) extban types"; + +// #define MOD_DEBUG(s) sendto_realops_snomask(SNO_DEBUG, L_NETWIDE, (s)) +#define MOD_DEBUG(s) #define RETURN_INVALID { recursion_depth--; return EXTBAN_INVALID; } static int _modinit(void); static void _moddeinit(void); static int eb_or(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); static int eb_and(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); -static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, int is_and); +static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, bool is_and); static int recursion_depth = 0; -static const char extb_desc[] = "Combination ($&, $|) extban types"; DECLARE_MODULE_AV2(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc); @@ -75,30 +76,30 @@ _moddeinit(void) static int eb_or(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type) { - return eb_combi(data, client_p, chptr, mode_type, FALSE); + return eb_combi(data, client_p, chptr, mode_type, false); } static int eb_and(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type) { - return eb_combi(data, client_p, chptr, mode_type, TRUE); + return eb_combi(data, client_p, chptr, mode_type, true); } static int eb_combi(const char *data, struct Client *client_p, - struct Channel *chptr, long mode_type, int is_and) + struct Channel *chptr, long mode_type, bool is_and) { const char *p, *banend; - int have_result = FALSE; + bool have_result = false; int allowed_nodes = 11; size_t datalen; if (recursion_depth >= 5) { - DEBUG("combo invalid: recursion depth too high"); + MOD_DEBUG("combo invalid: recursion depth too high"); return EXTBAN_INVALID; } if (EmptyString(data)) { - DEBUG("combo invalid: empty data"); + MOD_DEBUG("combo invalid: empty data"); return EXTBAN_INVALID; } @@ -107,7 +108,7 @@ static int eb_combi(const char *data, struct Client *client_p, /* I'd be sad if this ever happened, but if it does we * could overflow the buffer used below, so... */ - DEBUG("combo invalid: > BANLEN"); + MOD_DEBUG("combo invalid: > BANLEN"); return EXTBAN_INVALID; } banend = data + datalen; @@ -116,7 +117,7 @@ static int eb_combi(const char *data, struct Client *client_p, p = data + 1; banend--; if (*banend != ')') { - DEBUG("combo invalid: starting but no closing paren"); + MOD_DEBUG("combo invalid: starting but no closing paren"); return EXTBAN_INVALID; } } else { @@ -125,7 +126,7 @@ static int eb_combi(const char *data, struct Client *client_p, /* Empty combibans are invalid. */ if (banend == p) { - DEBUG("combo invalid: no data (after removing parens)"); + MOD_DEBUG("combo invalid: no data (after removing parens)"); return EXTBAN_INVALID; } @@ -142,28 +143,28 @@ static int eb_combi(const char *data, struct Client *client_p, recursion_depth++; while (--allowed_nodes) { - int invert = FALSE; + bool invert = false; char *child_data, child_data_buf[BANLEN]; ExtbanFunc f; if (*p == '~') { - invert = TRUE; + invert = true; p++; if (p == banend) { - DEBUG("combo invalid: no data after ~"); + MOD_DEBUG("combo invalid: no data after ~"); RETURN_INVALID; } } f = extban_table[(unsigned char) *p++]; if (!f) { - DEBUG("combo invalid: non-existant child extban"); + MOD_DEBUG("combo invalid: non-existant child extban"); RETURN_INVALID; } if (*p == ':') { unsigned int parencount = 0; - int escaped = FALSE, done = FALSE; + bool escaped = false, done = false; char *o; p++; @@ -172,10 +173,10 @@ static int eb_combi(const char *data, struct Client *client_p, * we already have_result. */ o = child_data = child_data_buf; - while (TRUE) { + while (true) { if (p == banend) { if (parencount) { - DEBUG("combo invalid: EOD while in parens"); + MOD_DEBUG("combo invalid: EOD while in parens"); RETURN_INVALID; } break; @@ -185,11 +186,11 @@ static int eb_combi(const char *data, struct Client *client_p, if (*p != '(' && *p != ')' && *p != '\\' && *p != ',') *o++ = '\\'; *o++ = *p++; - escaped = FALSE; + escaped = false; } else { switch (*p) { case '\\': - escaped = TRUE; + escaped = true; break; case '(': parencount++; @@ -197,7 +198,7 @@ static int eb_combi(const char *data, struct Client *client_p, break; case ')': if (!parencount) { - DEBUG("combo invalid: negative parencount"); + MOD_DEBUG("combo invalid: negative parencount"); RETURN_INVALID; } parencount--; @@ -207,7 +208,7 @@ static int eb_combi(const char *data, struct Client *client_p, if (parencount) *o++ = *p; else - done = TRUE; + done = true; break; default: *o++ = *p; @@ -227,7 +228,7 @@ static int eb_combi(const char *data, struct Client *client_p, int child_result = f(child_data, client_p, chptr, mode_type); if (child_result == EXTBAN_INVALID) { - DEBUG("combo invalid: child invalid"); + MOD_DEBUG("combo invalid: child invalid"); RETURN_INVALID; } @@ -238,26 +239,26 @@ static int eb_combi(const char *data, struct Client *client_p, child_result = child_result == EXTBAN_MATCH; if (is_and ? !child_result : child_result) - have_result = TRUE; + have_result = true; } if (p == banend) break; if (*p++ != ',') { - DEBUG("combo invalid: no ',' after ban"); + MOD_DEBUG("combo invalid: no ',' after ban"); RETURN_INVALID; } if (p == banend) { - DEBUG("combo invalid: banend after ','"); + MOD_DEBUG("combo invalid: banend after ','"); RETURN_INVALID; } } /* at this point, *p should == banend */ if (p != banend) { - DEBUG("combo invalid: more child extbans than allowed"); + MOD_DEBUG("combo invalid: more child extbans than allowed"); RETURN_INVALID; }