#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"
#include "s_stats.h"
#include "send.h"
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <errno.h>
#include <stdlib.h>
#include <string.h>
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)
{
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;
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;
}
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++;