mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
Move marking of services entirely to m_services.c; mark all services when m_services loads and unmark them when it unloads.
This commit is contained in:
parent
7d60375446
commit
c46a4ecd97
2 changed files with 65 additions and 21 deletions
|
@ -48,6 +48,12 @@
|
|||
#include "whowas.h"
|
||||
#include "monitor.h"
|
||||
|
||||
static int _modinit(void);
|
||||
static void _moddeinit(void);
|
||||
|
||||
static void mark_services(void);
|
||||
static void unmark_services(void);
|
||||
|
||||
static int me_su(struct Client *, struct Client *, int, const char **);
|
||||
static int me_login(struct Client *, struct Client *, int, const char **);
|
||||
static int me_rsfnc(struct Client *, struct Client *, int, const char **);
|
||||
|
@ -56,6 +62,8 @@ static int me_nickdelay(struct Client *, struct Client *, int, const char **);
|
|||
static void h_svc_server_introduced(hook_data_client *);
|
||||
static void h_svc_whois(hook_data_client *);
|
||||
static void h_svc_stats(hook_data_int *);
|
||||
static void h_svc_conf_read_start(void *);
|
||||
static void h_svc_conf_read_end(void *);
|
||||
|
||||
struct Message su_msgtab = {
|
||||
"SU", 0, 0, 0, MFLG_SLOW,
|
||||
|
@ -82,10 +90,24 @@ mapi_hfn_list_av1 services_hfnlist[] = {
|
|||
{ "doing_whois", (hookfn) h_svc_whois },
|
||||
{ "doing_whois_global", (hookfn) h_svc_whois },
|
||||
{ "server_introduced", (hookfn) h_svc_server_introduced },
|
||||
{ "conf_read_start", (hookfn) h_svc_conf_read_start },
|
||||
{ "conf_read_end", (hookfn) h_svc_conf_read_end },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
DECLARE_MODULE_AV1(services, NULL, NULL, services_clist, NULL, services_hfnlist, "$Revision: 1907 $");
|
||||
DECLARE_MODULE_AV1(services, _modinit, _moddeinit, services_clist, NULL, services_hfnlist, "$Revision: 1907 $");
|
||||
|
||||
static int
|
||||
_modinit(void)
|
||||
{
|
||||
mark_services();
|
||||
}
|
||||
|
||||
static void
|
||||
_moddeinit(void)
|
||||
{
|
||||
unmark_services();
|
||||
}
|
||||
|
||||
static int
|
||||
me_su(struct Client *client_p, struct Client *source_p,
|
||||
|
@ -346,3 +368,44 @@ h_svc_stats(hook_data_int *data)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
h_svc_conf_read_start(void *dummy)
|
||||
{
|
||||
unmark_services();
|
||||
}
|
||||
|
||||
static void
|
||||
unmark_services(void)
|
||||
{
|
||||
struct Client *target_p;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, global_serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
target_p->flags &= ~FLAGS_SERVICE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
h_svc_conf_read_end(void *dummy)
|
||||
{
|
||||
mark_services();
|
||||
}
|
||||
|
||||
static void
|
||||
mark_services(void)
|
||||
{
|
||||
struct Client *target_p;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, service_list.head)
|
||||
{
|
||||
target_p = find_server(NULL, (const char *)ptr->data);
|
||||
|
||||
if (target_p)
|
||||
target_p->flags |= FLAGS_SERVICE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1688,22 +1688,6 @@ conf_set_serverhide_links_delay(void *data)
|
|||
ConfigServerHide.links_delay = val;
|
||||
}
|
||||
|
||||
static int
|
||||
conf_begin_service(struct TopConf *tc)
|
||||
{
|
||||
struct Client *target_p;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, global_serv_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
|
||||
target_p->flags &= ~FLAGS_SERVICE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
conf_set_service_name(void *data)
|
||||
{
|
||||
|
@ -1732,9 +1716,6 @@ conf_set_service_name(void *data)
|
|||
|
||||
tmp = rb_strdup(data);
|
||||
rb_dlinkAddAlloc(tmp, &service_list);
|
||||
|
||||
if((target_p = find_server(NULL, tmp)))
|
||||
target_p->flags |= FLAGS_SERVICE;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2363,7 +2344,7 @@ newconf_init()
|
|||
add_top_conf("channel", NULL, NULL, conf_channel_table);
|
||||
add_top_conf("serverhide", NULL, NULL, conf_serverhide_table);
|
||||
|
||||
add_top_conf("service", conf_begin_service, NULL, NULL);
|
||||
add_top_conf("service", NULL, NULL, NULL);
|
||||
add_conf_item("service", "name", CF_QSTRING, conf_set_service_name);
|
||||
|
||||
add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL);
|
||||
|
|
Loading…
Reference in a new issue