Debian Codegraph @

modules/hostserv/main.c

raw
1 /*
2 * Copyright (c) 2005 Atheme Development Group
3 * Rights to this code are documented in doc/LICENSE.
4 *
5 * This file contains the main() routine.
6 *
7 */
8
9 #include "atheme.h"
10 #include "hostserv.h"
11
12 DECLARE_MODULE_V1
13 (
14 "hostserv/main", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void on_user_identify(user_t *u);
20 service_t *hostsvs;
21
22 void _modinit(module_t *m)
23 {
24 hook_add_event("user_identify");
25 hook_add_user_identify(on_user_identify);
26
27 hostsvs = service_add("hostserv", NULL);
28 }
29
30 void _moddeinit(module_unload_intent_t intent)
31 {
32 if (hostsvs != NULL)
33 service_delete(hostsvs);
34
35 hook_del_user_identify(on_user_identify);
36 }
37
38 static void on_user_identify(user_t *u)
39 {
40 myuser_t *mu = u->myuser;
41 metadata_t *md;
42 char buf[NICKLEN + 20];
43
44 snprintf(buf, sizeof buf, "private:usercloak:%s", u->nick);
45 md = metadata_find(mu, buf);
46 if (md == NULL)
47 md = metadata_find(mu, "private:usercloak");
48 if (md == NULL)
49 return;
50
51 do_sethost(u, md->value);
52 }
53
54 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
55 * vim:ts=8
56 * vim:sw=8
57 * vim:noexpandtab
58 */