30 |
|
#include "channel_mode.h" |
31 |
|
#include "client.h" |
32 |
|
#include "hash.h" |
33 |
+ |
#include "conf.h" |
34 |
|
#include "hostmask.h" |
35 |
|
#include "irc_string.h" |
36 |
|
#include "sprintf_irc.h" |
39 |
|
#include "s_serv.h" /* captab */ |
40 |
|
#include "s_user.h" |
41 |
|
#include "send.h" |
41 |
– |
#include "conf.h" /* ConfigFileEntry, ConfigChannel */ |
42 |
|
#include "event.h" |
43 |
|
#include "memory.h" |
44 |
< |
#include "balloc.h" |
44 |
> |
#include "mempool.h" |
45 |
> |
#include "s_misc.h" |
46 |
|
|
47 |
|
struct config_channel_entry ConfigChannel; |
48 |
|
dlink_list global_channel_list = { NULL, NULL, 0 }; |
49 |
< |
BlockHeap *ban_heap; /*! \todo ban_heap shouldn't be a global var */ |
49 |
> |
mp_pool_t *ban_pool; /*! \todo ban_pool shouldn't be a global var */ |
50 |
|
|
51 |
< |
static BlockHeap *member_heap = NULL; |
52 |
< |
static BlockHeap *channel_heap = NULL; |
51 |
> |
static mp_pool_t *member_pool = NULL; |
52 |
> |
static mp_pool_t *channel_pool = NULL; |
53 |
|
|
54 |
|
static char buf[IRCD_BUFSIZE]; |
55 |
|
static char modebuf[MODEBUFLEN]; |
65 |
|
add_capability("IE", CAP_IE, 1); |
66 |
|
add_capability("CHW", CAP_CHW, 1); |
67 |
|
|
68 |
< |
channel_heap = BlockHeapCreate("channel", sizeof(struct Channel), CHANNEL_HEAP_SIZE); |
69 |
< |
ban_heap = BlockHeapCreate("ban", sizeof(struct Ban), BAN_HEAP_SIZE); |
70 |
< |
member_heap = BlockHeapCreate("member", sizeof(struct Membership), CHANNEL_HEAP_SIZE*2); |
68 |
> |
channel_pool = mp_pool_new(sizeof(struct Channel), MP_CHUNK_SIZE_CHANNEL); |
69 |
> |
ban_pool = mp_pool_new(sizeof(struct Ban), MP_CHUNK_SIZE_BAN); |
70 |
> |
member_pool = mp_pool_new(sizeof(struct Membership), MP_CHUNK_SIZE_MEMBER); |
71 |
|
} |
72 |
|
|
73 |
|
/*! \brief adds a user to a channel by adding another link to the |
114 |
|
chptr->last_join_time = CurrentTime; |
115 |
|
} |
116 |
|
|
117 |
< |
ms = BlockHeapAlloc(member_heap); |
117 |
> |
ms = mp_pool_get(member_pool); |
118 |
> |
memset(ms, 0, sizeof(*ms)); |
119 |
> |
|
120 |
|
ms->client_p = who; |
121 |
|
ms->chptr = chptr; |
122 |
|
ms->flags = flags; |
138 |
|
dlinkDelete(&member->channode, &chptr->members); |
139 |
|
dlinkDelete(&member->usernode, &client_p->channel); |
140 |
|
|
141 |
< |
BlockHeapFree(member_heap, member); |
141 |
> |
mp_pool_release(member); |
142 |
|
|
143 |
|
if (chptr->members.head == NULL) |
144 |
|
destroy_channel(chptr); |
294 |
|
send_members(client_p, chptr, modebuf, parabuf); |
295 |
|
|
296 |
|
send_mode_list(client_p, chptr, &chptr->banlist, 'b'); |
297 |
< |
|
298 |
< |
if (IsCapable(client_p, CAP_EX)) |
296 |
< |
send_mode_list(client_p, chptr, &chptr->exceptlist, 'e'); |
297 |
< |
if (IsCapable(client_p, CAP_IE)) |
298 |
< |
send_mode_list(client_p, chptr, &chptr->invexlist, 'I'); |
297 |
> |
send_mode_list(client_p, chptr, &chptr->exceptlist, 'e'); |
298 |
> |
send_mode_list(client_p, chptr, &chptr->invexlist, 'I'); |
299 |
|
} |
300 |
|
|
301 |
|
/*! \brief check channel name for invalid characters |
339 |
|
MyFree(bptr->host); |
340 |
|
MyFree(bptr->who); |
341 |
|
|
342 |
< |
BlockHeapFree(ban_heap, bptr); |
342 |
> |
mp_pool_release(bptr); |
343 |
|
} |
344 |
|
|
345 |
|
/* free_channel_list() |
371 |
|
|
372 |
|
assert(!EmptyString(chname)); |
373 |
|
|
374 |
< |
chptr = BlockHeapAlloc(channel_heap); |
374 |
> |
chptr = mp_pool_get(channel_pool); |
375 |
> |
|
376 |
> |
memset(chptr, 0, sizeof(*chptr)); |
377 |
|
|
378 |
|
/* doesn't hurt to set it here */ |
379 |
|
chptr->channelts = CurrentTime; |
406 |
|
dlinkDelete(&chptr->node, &global_channel_list); |
407 |
|
hash_del_channel(chptr); |
408 |
|
|
409 |
< |
BlockHeapFree(channel_heap, chptr); |
409 |
> |
mp_pool_release(chptr); |
410 |
|
} |
411 |
|
|
412 |
|
/*! |
597 |
|
{ |
598 |
|
const struct Ban *bp = ptr->data; |
599 |
|
|
600 |
< |
if (match(bp->name, who->name) && match(bp->username, who->username)) |
600 |
> |
if (!match(bp->name, who->name) && !match(bp->username, who->username)) |
601 |
|
{ |
602 |
|
switch (bp->type) |
603 |
|
{ |
604 |
|
case HM_HOST: |
605 |
< |
if (match(bp->host, who->host) || match(bp->host, who->sockhost)) |
605 |
> |
if (!match(bp->host, who->host) || !match(bp->host, who->sockhost)) |
606 |
|
return 1; |
607 |
|
break; |
608 |
|
case HM_IPV4: |
858 |
|
*/ |
859 |
|
void |
860 |
|
set_channel_topic(struct Channel *chptr, const char *topic, |
861 |
< |
const char *topic_info, time_t topicts) |
861 |
> |
const char *topic_info, time_t topicts, int local) |
862 |
|
{ |
863 |
< |
strlcpy(chptr->topic, topic, sizeof(chptr->topic)); |
863 |
> |
if (local) |
864 |
> |
strlcpy(chptr->topic, topic, IRCD_MIN(sizeof(chptr->topic), ServerInfo.max_topic_length + 1)); |
865 |
> |
else |
866 |
> |
strlcpy(chptr->topic, topic, sizeof(chptr->topic)); |
867 |
> |
|
868 |
|
strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info)); |
869 |
|
chptr->topic_time = topicts; |
870 |
|
} |