2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
|
* Copyright (c) 2000 Kevin L. Mitchell <klmitch@mit.edu> |
5 |
< |
* Copyright (c) 2013-2017 ircd-hybrid development team |
5 |
> |
* Copyright (c) 2013-2018 ircd-hybrid development team |
6 |
|
* |
7 |
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
* it under the terms of the GNU General Public License as published by |
57 |
|
static struct Motd * |
58 |
|
motd_create(const char *mask, const char *path) |
59 |
|
{ |
60 |
< |
struct Motd *motd = xcalloc(sizeof(struct Motd)); |
60 |
> |
struct Motd *motd = xcalloc(sizeof(*motd)); |
61 |
|
|
62 |
|
if (EmptyString(mask)) |
63 |
|
motd->type = MOTD_UNIVERSAL; |
140 |
|
} |
141 |
|
|
142 |
|
/* Ok, allocate a structure; we'll realloc later to trim memory */ |
143 |
< |
struct MotdCache *cache = xcalloc(sizeof(struct MotdCache) + (MOTD_LINESIZE * MOTD_MAXLINES)); |
143 |
> |
struct MotdCache *cache = xcalloc(sizeof(*cache) + (MOTD_LINESIZE * MOTD_MAXLINES)); |
144 |
|
cache->ref = 1; |
145 |
|
cache->path = xstrdup(motd->path); |
146 |
|
cache->maxcount = motd->maxcount; |
159 |
|
fclose(file); /* Close the file */ |
160 |
|
|
161 |
|
/* Trim memory usage a little */ |
162 |
< |
motd->cache = xcalloc(sizeof(struct MotdCache) + (MOTD_LINESIZE * cache->count)); |
163 |
< |
memcpy(motd->cache, cache, sizeof(struct MotdCache) + (MOTD_LINESIZE * cache->count)); |
162 |
> |
motd->cache = xcalloc(sizeof(*motd->cache) + (MOTD_LINESIZE * cache->count)); |
163 |
> |
memcpy(motd->cache, cache, sizeof(*motd->cache) + (MOTD_LINESIZE * cache->count)); |
164 |
|
xfree(cache); |
165 |
|
|
166 |
|
/* Now link it in */ |
247 |
|
return motd; |
248 |
|
break; |
249 |
|
case MOTD_IPMASKV4: |
250 |
< |
if (client_p->connection->aftype == AF_INET) |
251 |
< |
if (match_ipv4(&client_p->connection->ip, &motd->address, motd->addrbits)) |
252 |
< |
return motd; |
250 |
> |
if (client_p->connection->aftype == AF_INET) |
251 |
> |
if (match_ipv4(&client_p->connection->ip, &motd->address, motd->addrbits)) |
252 |
> |
return motd; |
253 |
|
break; |
254 |
|
case MOTD_IPMASKV6: |
255 |
< |
if (client_p->connection->aftype == AF_INET6) |
256 |
< |
if (match_ipv6(&client_p->connection->ip, &motd->address, motd->addrbits)) |
257 |
< |
return motd; |
255 |
> |
if (client_p->connection->aftype == AF_INET6) |
256 |
> |
if (match_ipv6(&client_p->connection->ip, &motd->address, motd->addrbits)) |
257 |
> |
return motd; |
258 |
|
break; |
259 |
|
default: break; |
260 |
|
} |