]> jfr.im git - solanum.git/blame - modules/cap_server_time.c
client: handle UID rollover. ircd-ratbox r28917
[solanum.git] / modules / cap_server_time.c
CommitLineData
4bdf963c
AC
1/*
2 * charybdis: an advanced ircd.
3 * cap_server_time.c: implement the server-time IRCv3.2 capability
4 *
5 * Copyright (c) 2016 William Pitcock <nenolod@dereferenced.org>
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice is present in all copies.
10 *
11 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
13 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
14 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
15 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
16 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
17 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
19 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
20 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21 * POSSIBILITY OF SUCH DAMAGE.
22 */
23
24#include "stdinc.h"
25#include "modules.h"
26#include "hook.h"
27#include "client.h"
28#include "ircd.h"
29#include "send.h"
30#include "s_conf.h"
31#include "s_user.h"
32#include "s_serv.h"
33#include "numeric.h"
34#include "chmode.h"
35#include "inline/stringops.h"
36
37static void cap_server_time_process(hook_data *);
38
39mapi_hfn_list_av1 cap_server_time_hfnlist[] = {
40 { "outbound_msgbuf", (hookfn) cap_server_time_process },
41 { NULL, NULL }
42};
43
44unsigned int CLICAP_SERVER_TIME = 0;
45
46static void
47cap_server_time_process(hook_data *data)
48{
49 static char buf[IRCD_BUFSIZE];
50 time_t ts = rb_current_time();
51 struct MsgBuf *msgbuf = data->arg1;
52
df06f4c9 53 strftime(buf, sizeof buf, "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&ts));
4bdf963c
AC
54
55 msgbuf_append_tag(msgbuf, "time", buf, CLICAP_SERVER_TIME);
56}
57
58static int
59_modinit(void)
60{
61 CLICAP_SERVER_TIME = capability_put(cli_capindex, "server-time", NULL);
62 return 0;
63}
64
65static void
66_moddeinit(void)
67{
68 capability_orphan(cli_capindex, "server-time");
69}
70
71DECLARE_MODULE_AV1(cap_server_time, _modinit, _moddeinit, NULL, NULL, cap_server_time_hfnlist, "$Revision$");