Debian Codegraph @

modules/hostserv/hostserv.h

raw
1 #ifndef INLINE_HOSTSERV_H
2 #define INLINE_HOSTSERV_H
3
4 typedef struct {
5 const char *host;
6 sourceinfo_t *si;
7 int approved;
8 const char *target;
9 } hook_host_request_t;
10
11 /*
12 * do_sethost(user_t *u, char *host)
13 *
14 * Sets a virtual host on a single nickname/user.
15 *
16 * Inputs:
17 * - User to set a vHost on
18 * - a vHost
19 *
20 * Outputs:
21 * - none
22 *
23 * Side Effects:
24 * - The vHost is set on the user.
25 */
26 static inline void do_sethost(user_t *u, const char *host)
27 {
28 service_t *svs;
29
30 if (!strcmp(u->vhost, host ? host : u->host))
31 return;
32
33 svs = service_find("hostserv");
34
35 user_sethost(svs->me, u, host ? host : u->host);
36 }
37
38 /*
39 * do_sethost_all(myuser_t *mu, char *host)
40 *
41 * Sets a virtual host on all nicknames in an account.
42 *
43 * Inputs:
44 * - an account name
45 * - a vHost
46 *
47 * Outputs:
48 * - none
49 *
50 * Side Effects:
51 * - The vHost is set on all users logged into
52 * the account.
53 */
54 static inline void do_sethost_all(myuser_t *mu, const char *host)
55 {
56 mowgli_node_t *n;
57 user_t *u;
58
59 MOWGLI_ITER_FOREACH(n, mu->logins.head)
60 {
61 u = n->data;
62
63 do_sethost(u, host);
64 }
65 }
66
67 static inline void hs_sethost_all(myuser_t *mu, const char *host, const char *assigner)
68 {
69 mowgli_node_t *n;
70 mynick_t *mn;
71 char buf[BUFSIZE];
72 char timestring[16];
73
74 MOWGLI_ITER_FOREACH(n, mu->nicks.head)
75 {
76 mn = n->data;
77 snprintf(buf, BUFSIZE, "%s:%s", "private:usercloak", mn->nick);
78 metadata_delete(mu, buf);
79 }
80 if (host != NULL)
81 metadata_add(mu, "private:usercloak", host);
82 else
83 metadata_delete(mu, "private:usercloak");
84
85 snprintf(timestring, 16, "%lu", (unsigned long)time(NULL));
86 metadata_add(mu, "private:usercloak-timestamp", timestring);
87
88 if (assigner != NULL)
89 metadata_add(mu, "private:usercloak-assigner", assigner);
90 else
91 metadata_delete(mu, "private:usercloak-assigner");
92 }
93 #endif