summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-batch.h
blob: 4ecc1b9958a0c8cce2c4696243c9e5cc5390c058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
 *
 * This file is part of WeeChat, the extensible chat client.
 *
 * WeeChat is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * WeeChat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WeeChat.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef WEECHAT_PLUGIN_IRC_BATCH_H
#define WEECHAT_PLUGIN_IRC_BATCH_H

#include <time.h>

struct t_hashtable;
struct t_irc_server;

struct t_irc_batch
{
    char *reference;                    /* batch reference                  */
    char *parent_ref;                   /* ref of parent batch (optional)   */
    char *type;                         /* type                             */
    char *parameters;                   /* parameters                       */
    struct t_hashtable *tags;           /* batch message tags               */
    time_t start_time;                  /* start time (to auto-purge if     */
                                        /* batch end is not received)       */
    char **messages;                    /* messages separated by '\n'       */
    int end_received;                   /* batch end reference received     */
    int messages_processed;             /* 1 if msgs have been processed    */
    struct t_irc_batch *prev_batch;     /* link to previous batch           */
    struct t_irc_batch *next_batch;     /* link to next batch               */
};

extern void irc_batch_generate_random_ref (char *string, int size);
extern struct t_irc_batch *irc_batch_search (struct t_irc_server *server,
                                             const char *reference);
extern struct t_irc_batch *irc_batch_start_batch (struct t_irc_server *server,
                                                  const char *reference,
                                                  const char *parent_ref,
                                                  const char *type,
                                                  const char *parameters,
                                                  struct t_hashtable *tags);
extern int irc_batch_add_message (struct t_irc_server *server,
                                  const char *reference,
                                  const char *irc_message);
extern void irc_batch_end_batch (struct t_irc_server *server,
                                 const char *reference);
extern void irc_batch_free (struct t_irc_server *server,
                            struct t_irc_batch *batch);
extern void irc_batch_free_all (struct t_irc_server *server);
extern char *irc_batch_modifier_cb (const void *pointer, void *data,
                                    const char *modifier,
                                    const char *modifier_data,
                                    const char *string);

extern struct t_hdata *irc_batch_hdata_batch_cb (const void *pointer,
                                                 void *data,
                                                 const char *hdata_name);
extern void irc_batch_print_log (struct t_irc_server *server);

#endif /* WEECHAT_PLUGIN_IRC_BATCH_H */