X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/cc200171d7c40be3b204460f9c14d5d37e771866..d3455e2c7e2f9040e1b7628d9cf52b26a24dcefc:/src/channel.c diff --git a/src/channel.c b/src/channel.c index a1b2905..d1acd20 100644 --- a/src/channel.c +++ b/src/channel.c @@ -40,15 +40,15 @@ #include "whowas.h" #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */ #include "s_newconf.h" -#include "s_log.h" +#include "logger.h" extern rb_dlink_list global_channel_list; extern struct config_channel_entry ConfigChannel; -extern BlockHeap *channel_heap; -extern BlockHeap *ban_heap; -extern BlockHeap *topic_heap; -extern BlockHeap *member_heap; +extern rb_bh *channel_heap; +extern rb_bh *ban_heap; +extern rb_bh *topic_heap; +extern rb_bh *member_heap; static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_SERVICE, @@ -73,10 +73,10 @@ static int h_can_join; void init_channels(void) { - channel_heap = BlockHeapCreate(sizeof(struct Channel), CHANNEL_HEAP_SIZE); - ban_heap = BlockHeapCreate(sizeof(struct Ban), BAN_HEAP_SIZE); - topic_heap = BlockHeapCreate(TOPICLEN + 1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE); - member_heap = BlockHeapCreate(sizeof(struct membership), MEMBER_HEAP_SIZE); + channel_heap = rb_bh_create(sizeof(struct Channel), CHANNEL_HEAP_SIZE, "channel_heap"); + ban_heap = rb_bh_create(sizeof(struct Ban), BAN_HEAP_SIZE, "ban_heap"); + topic_heap = rb_bh_create(TOPICLEN + 1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE, "topic_heap"); + member_heap = rb_bh_create(sizeof(struct membership), MEMBER_HEAP_SIZE, "member_heap"); h_can_join = register_hook("can_join"); } @@ -88,25 +88,25 @@ struct Channel * allocate_channel(const char *chname) { struct Channel *chptr; - chptr = BlockHeapAlloc(channel_heap); - DupString(chptr->chname, chname); + chptr = rb_bh_alloc(channel_heap); + chptr->chname = rb_strdup(chname); return (chptr); } void free_channel(struct Channel *chptr) { - MyFree(chptr->chname); - BlockHeapFree(channel_heap, chptr); + rb_free(chptr->chname); + rb_bh_free(channel_heap, chptr); } struct Ban * allocate_ban(const char *banstr, const char *who) { struct Ban *bptr; - bptr = BlockHeapAlloc(ban_heap); - DupString(bptr->banstr, banstr); - DupString(bptr->who, who); + bptr = rb_bh_alloc(ban_heap); + bptr->banstr = rb_strdup(banstr); + bptr->who = rb_strdup(who); return (bptr); } @@ -114,9 +114,9 @@ allocate_ban(const char *banstr, const char *who) void free_ban(struct Ban *bptr) { - MyFree(bptr->banstr); - MyFree(bptr->who); - BlockHeapFree(ban_heap, bptr); + rb_free(bptr->banstr); + rb_free(bptr->who); + rb_bh_free(ban_heap, bptr); } @@ -205,7 +205,7 @@ add_user_to_channel(struct Channel *chptr, struct Client *client_p, int flags) if(client_p->user == NULL) return; - msptr = BlockHeapAlloc(member_heap); + msptr = rb_bh_alloc(member_heap); msptr->chptr = chptr; msptr->client_p = client_p; @@ -242,12 +242,12 @@ remove_user_from_channel(struct membership *msptr) if(client_p->servptr == &me) rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers); - chptr->users_last = CurrentTime; + chptr->users_last = rb_current_time(); if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0) destroy_channel(chptr); - BlockHeapFree(member_heap, msptr); + rb_bh_free(member_heap, msptr); return; } @@ -279,12 +279,12 @@ remove_user_from_channels(struct Client *client_p) if(client_p->servptr == &me) rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers); - chptr->users_last = CurrentTime; + chptr->users_last = rb_current_time(); if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0) destroy_channel(chptr); - BlockHeapFree(member_heap, msptr); + rb_bh_free(member_heap, msptr); } client_p->user->channel.head = client_p->user->channel.tail = NULL; @@ -784,7 +784,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) /* join throttling stuff --nenolod */ else if(chptr->mode.join_num > 0 && chptr->mode.join_time > 0) { - if ((CurrentTime - chptr->join_delta <= + if ((rb_current_time() - chptr->join_delta <= chptr->mode.join_time) && (chptr->join_count >= chptr->mode.join_num)) i = ERR_THROTTLE; @@ -942,7 +942,7 @@ check_spambot_warning(struct Client *source_p, const char *name) else { if((t_delta = - (CurrentTime - source_p->localClient->last_leave_time)) > + (rb_current_time() - source_p->localClient->last_leave_time)) > JOIN_LEAVE_COUNT_EXPIRE_TIME) { decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME); @@ -953,7 +953,7 @@ check_spambot_warning(struct Client *source_p, const char *name) } else { - if((CurrentTime - + if((rb_current_time() - (source_p->localClient->last_join_time)) < GlobalSetOptions.spam_time) { /* oh, its a possible spambot */ @@ -961,9 +961,9 @@ check_spambot_warning(struct Client *source_p, const char *name) } } if(name != NULL) - source_p->localClient->last_join_time = CurrentTime; + source_p->localClient->last_join_time = rb_current_time(); else - source_p->localClient->last_leave_time = CurrentTime; + source_p->localClient->last_leave_time = rb_current_time(); } } @@ -989,7 +989,7 @@ check_splitmode(void *unused) splitmode = 1; sendto_realops_snomask(SNO_GENERAL, L_ALL, "Network split, activating splitmode"); - eventAddIsh("check_splitmode", check_splitmode, NULL, 2); + check_splitmode_ev = rb_event_addish("check_splitmode", check_splitmode, NULL, 2); } } /* in splitmode, check whether its finished */ @@ -1000,7 +1000,7 @@ check_splitmode(void *unused) sendto_realops_snomask(SNO_GENERAL, L_ALL, "Network rejoined, deactivating splitmode"); - eventDelete(check_splitmode, NULL); + rb_event_delete(check_splitmode_ev); } } } @@ -1020,7 +1020,7 @@ allocate_topic(struct Channel *chptr) if(chptr == NULL) return; - ptr = BlockHeapAlloc(topic_heap); + ptr = rb_bh_alloc(topic_heap); /* Basically we allocate one large block for the topic and * the topic info. We then split it up into two and shove it @@ -1050,7 +1050,7 @@ free_topic(struct Channel *chptr) * MUST change this as well */ ptr = chptr->topic; - BlockHeapFree(topic_heap, ptr); + rb_bh_free(topic_heap, ptr); chptr->topic = NULL; chptr->topic_info = NULL; }