]> jfr.im git - solanum.git/blame - modules/cap_batch.c
Implement the netsplit batch type.
[solanum.git] / modules / cap_batch.c
CommitLineData
23738912
EM
1/*
2 * charybdis: an advanced ircd.
3 * cap_batch.c: implement the batch IRCv3.2 capability
4 *
5 * Copyright (c) 2016 Elizabeth Myers <elizabeth@interlinked.me>
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 "batch.h"
36#include "inline/stringops.h"
37
38static const char cap_batch_desc[] =
39 "Provides the batch client capability";
40
41static void cap_batch_process(hook_data *);
42
43mapi_hfn_list_av1 cap_batch_hfnlist[] = {
44 { "outbound_msgbuf", (hookfn) cap_batch_process },
45 { NULL, NULL }
46};
47
48static void
49cap_batch_process(hook_data *data)
50{
51 struct MsgBuf *msgbuf = data->arg1;
52 struct Client *client_p = data->client;
53 struct Batch *batch_p;
54
55 if(rb_strcasecmp(msgbuf->cmd, "quit") == 0)
56 {
57 if(!IsClient(client_p) || MyConnect(client_p))
58 /* Remote users only please */
59 return;
60
61 /* Now find our batch... */
62 if((batch_p = find_batch(BATCH_NETSPLIT, client_p->from)) == NULL)
63 return;
64
65 /* Boom */
66 msgbuf_append_tag(msgbuf, "batch", batch_p->id, CLICAP_BATCH);
67 }
68}
69
70DECLARE_MODULE_AV2(cap_batch, NULL, NULL, NULL, NULL, cap_batch_hfnlist, NULL, NULL, cap_batch_desc);