X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fmotd.c;h=bdad75eeb5bb5c20d7d3679b0dcc36461b2c4341;hb=refs%2Fheads%2Fupstream;hp=3b77ac326ef0880e1d1da4965b7bad7340a3284b;hpb=87a7b6e0340041ea7a4fca02dd0280aa86d8cfd4;p=ircu2.10.12-pk.git diff --git a/ircd/motd.c b/ircd/motd.c index 3b77ac3..bdad75e 100644 --- a/ircd/motd.c +++ b/ircd/motd.c @@ -34,6 +34,7 @@ #include "ircd.h" #include "ircd_alloc.h" #include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "match.h" @@ -46,7 +47,7 @@ #include "s_stats.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include #include @@ -70,14 +71,9 @@ static struct Motd * motd_create(const char *hostmask, const char *path, int maxcount) { struct Motd* tmp; - int type = MOTD_UNIVERSAL; assert(0 != path); - if (hostmask != NULL && find_class(hostmask)) - type = MOTD_CLASS; - else - type = MOTD_HOSTMASK; /* allocate memory and initialize the structure */ if (MotdList.freelist) { @@ -85,12 +81,21 @@ motd_create(const char *hostmask, const char *path, int maxcount) MotdList.freelist = tmp->next; } else tmp = (struct Motd *)MyMalloc(sizeof(struct Motd)); - tmp->next = 0; - tmp->type = type; + + if (hostmask == NULL) + tmp->type = MOTD_UNIVERSAL; + else if (find_class(hostmask)) + tmp->type = MOTD_CLASS; + else if (ipmask_parse(hostmask, &tmp->address, &tmp->addrbits)) + tmp->type = MOTD_IPMASK; + else + tmp->type = MOTD_HOSTMASK; if (hostmask != NULL) DupString(tmp->hostmask, hostmask); + else + tmp->hostmask = NULL; DupString(tmp->path, path); tmp->maxcount = maxcount; @@ -250,15 +255,19 @@ motd_lookup(struct Client *cptr) return MotdList.remote; c_class = get_client_class(cptr); + assert(c_class != NULL); /* check the motd blocks first */ for (ptr = MotdList.other; ptr; ptr = ptr->next) { - if (ptr->type == MOTD_CLASS && - !match(ptr->hostmask, c_class)) + if (ptr->type == MOTD_CLASS + && !match(ptr->hostmask, c_class)) + return ptr; + else if (ptr->type == MOTD_HOSTMASK + && !match(ptr->hostmask, cli_sockhost(cptr))) return ptr; - else if (ptr->type == MOTD_HOSTMASK && c_class != NULL && - !match(ptr->hostmask, cli_sockhost(cptr))) + else if (ptr->type == MOTD_IPMASK + && ipmask_check(&cli_ip(cptr), &ptr->address, ptr->addrbits)) return ptr; } @@ -438,10 +447,10 @@ motd_memory_count(struct Client *cptr) struct Motd *ptr; struct MotdCache *cache; unsigned int mt = 0, /* motd count */ - mtm = 0, /* memory consumed by motd */ mtc = 0, /* motd cache count */ - mtcm = 0, /* memory consumed by motd cache */ mtf = 0; /* motd free list count */ + size_t mtm = 0, /* memory consumed by motd */ + mtcm = 0; /* memory consumed by motd cache */ if (MotdList.local) { mt++;