projects
/
ircu2.10.12-pk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added basic ssl support to ircu
[ircu2.10.12-pk.git]
/
ircd
/
motd.c
diff --git
a/ircd/motd.c
b/ircd/motd.c
index 3b77ac326ef0880e1d1da4965b7bad7340a3284b..bdad75eeb5bb5c20d7d3679b0dcc36461b2c4341 100644
(file)
--- 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.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 "ircd_reply.h"
#include "ircd_string.h"
#include "match.h"
@@
-46,7
+47,7
@@
#include "s_stats.h"
#include "send.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>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@
-70,14
+71,9
@@
static struct Motd *
motd_create(const char *hostmask, const char *path, int maxcount)
{
struct Motd* tmp;
motd_create(const char *hostmask, const char *path, int maxcount)
{
struct Motd* tmp;
- int type = MOTD_UNIVERSAL;
assert(0 != path);
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)
{
/* 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));
MotdList.freelist = tmp->next;
} else
tmp = (struct Motd *)MyMalloc(sizeof(struct Motd));
-
tmp->next = 0;
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);
if (hostmask != NULL)
DupString(tmp->hostmask, hostmask);
+ else
+ tmp->hostmask = NULL;
DupString(tmp->path, path);
tmp->maxcount = maxcount;
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);
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)
{
/* 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;
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;
}
return ptr;
}
@@
-438,10
+447,10
@@
motd_memory_count(struct Client *cptr)
struct Motd *ptr;
struct MotdCache *cache;
unsigned int mt = 0, /* motd count */
struct Motd *ptr;
struct MotdCache *cache;
unsigned int mt = 0, /* motd count */
- mtm = 0, /* memory consumed by motd */
mtc = 0, /* motd cache count */
mtc = 0, /* motd cache count */
- mtcm = 0, /* memory consumed by motd cache */
mtf = 0; /* motd free list count */
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++;
if (MotdList.local)
{
mt++;