src/irc_log.c
author Tero Marttila <terom@fixme.fi>
Fri, 27 Mar 2009 00:08:32 +0200
changeset 80 1b989bc67760
parent 75 ff6272398d2e
child 83 c8e2dac08207
permissions -rw-r--r--
add NICK/QUIT logging to irc_log
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
     1
#include "module.h"
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
     2
#include "irc_chan.h"
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
     3
#include "error.h"
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
#include "log.h"
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
     6
#include <stdlib.h>
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
     7
#include <string.h>
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
     8
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
     9
#include <event2/event.h>
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
#include <evsql.h>
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
/**
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    13
 * The irc_log module state.
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
 */
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
    15
struct irc_log_ctx {
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    16
    /** The nexus this module is loaded for */
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    17
    struct nexus *nexus;
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    18
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
    /** The database connection */
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
    struct evsql *db;
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    21
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    22
    /**
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    23
     * Our logged channels
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    24
     */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    25
    TAILQ_HEAD(irc_log_ctx_channels, irc_log_chan) channels;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    26
    
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    27
    /** Are we currently unloading ourself (via irc_log_unload) ? */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    28
    bool unloading;
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
    29
};
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    31
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    32
 * State required to use irc_cmd_handler with irc_chan.handlers.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    33
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    34
struct irc_log_chan {
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    35
    /** The irc_log context */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    36
    struct irc_log_ctx *ctx;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    37
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    38
    /** The target channel */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    39
    struct irc_chan *chan;
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    40
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    41
    /** Are we stopping (irc_log_chan_stop called)? */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    42
    bool stopping;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    43
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    44
    /** We are part of the irc_log_ctx.channels list */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    45
    TAILQ_ENTRY(irc_log_chan) ctx_channels;
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    46
};
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    47
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    48
/*
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    49
 * Forward-declare
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    50
 */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    51
static void irc_log_chan_destroy (struct irc_log_chan *chan_ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    52
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    53
/**
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    54
 * The irc_log_ctx has completed stopping all the channels, and should now destroy itself
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    55
 */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    56
static void irc_log_stopped (struct irc_log_ctx *ctx)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    57
{
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    58
    // schedule an evsql_destroy
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    59
    if (evsql_destroy_next(ctx->db))
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    60
        log_fatal("evsql_destroy_next failed");
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    61
    
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    62
    // free ourself
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    63
    free(ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    64
}
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    65
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    66
/**
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    67
 * The irc_log_chan has completed shutdown
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    68
 */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    69
static void irc_log_chan_stopped (struct irc_log_chan *chan_ctx)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    70
{
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    71
    struct irc_log_ctx *ctx = chan_ctx->ctx;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    72
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    73
    // destroy the channel
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    74
    irc_log_chan_destroy(chan_ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    75
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    76
    // was it the final channel for unloading?
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    77
    if (ctx->unloading && TAILQ_EMPTY(&ctx->channels))
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    78
        irc_log_stopped(ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    79
}
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    80
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    81
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    82
 * Our evsql result handler for irc_log_event INSERTs.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
    83
 */
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    84
static void irc_log_on_sql_result (struct evsql_result *res, void *arg)
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    85
{
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    86
    struct irc_log_chan *chan_ctx = arg;
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    87
    err_t err;
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    88
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    89
    // check errors
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    90
    if ((err = evsql_result_check(res)))
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    91
        log_error("irc_log_event: %s", evsql_result_error(res));
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    92
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    93
    // ok, don't need the result anymore
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    94
    evsql_result_free(res);
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    95
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    96
    // if stopping, then handle that
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    97
    if (chan_ctx->stopping)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
    98
        irc_log_chan_stopped(chan_ctx);
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
    99
}
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   100
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   101
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   102
 * Log the event into our database.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   103
 *
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   104
 * Any of chan_ctx, source, target, message can be NULL to insert NULLs
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   105
 */
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   106
static err_t irc_log_event (struct irc_log_ctx *ctx, struct irc_log_chan *chan_ctx, const struct irc_nm *source,
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   107
        const char *type, const char *target, const char *message)
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   108
{
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   109
    struct evsql_query *query;
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   110
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   111
    // unpack the nick/user/hostname args, as source can be NULL
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   112
    const char *network = chan_ctx ? chan_ctx->chan->net->info.network : NULL;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   113
    const char *channel = chan_ctx ? irc_chan_name(chan_ctx->chan) : NULL;
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   114
    const char *nickname = source ? source->nickname : NULL;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   115
    const char *username = source ? source->username : NULL;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   116
    const char *hostname = source ? source->hostname : NULL;
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   117
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   118
    // our SQL query
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   119
    static struct evsql_query_info sql = {
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   120
        "INSERT INTO logs ("
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   121
        "  network, channel, nickname, username, hostname, type, target, message"
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   122
        " ) VALUES ("
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   123
        "  $1::varchar, $2::varchar, $3::varchar, $4::varchar, $5::varchar, $6::varchar, $7::varchar, $8::varchar"
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   124
        " )", { 
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   125
            EVSQL_TYPE(STRING),     // network
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   126
            EVSQL_TYPE(STRING),     // channel
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   127
            EVSQL_TYPE(STRING),     // nickname
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   128
            EVSQL_TYPE(STRING),     // username
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   129
            EVSQL_TYPE(STRING),     // hostname
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   130
            EVSQL_TYPE(STRING),     // type
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   131
            EVSQL_TYPE(STRING),     // target
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   132
            EVSQL_TYPE(STRING),     // message
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   133
            EVSQL_TYPE_END
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   134
        }
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   135
    };
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   136
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   137
    // drop lines if not connected
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   138
    if (ctx->db == NULL) {
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   139
        log_warn("no database connected");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   140
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   141
        return ERR_MODULE_CONF;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   142
    }
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   143
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   144
    // run the INSERT
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   145
    if ((query = evsql_query_exec(ctx->db, NULL, &sql, &irc_log_on_sql_result, chan_ctx,
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   146
        network, channel, nickname, username, hostname, type, target, message
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   147
    )) == NULL) {
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   148
        // XXX: get evsql_query error info somehow...
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   149
        log_error("evsql_query_exec failed for %s:%s - %s!%s@%s - %s -> %s - %s", 
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   150
            network, channel, nickname, username, hostname, type, target, message
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   151
        );
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   152
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   153
        return ERR_EVSQL_QUERY_EXEC;
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   154
    }
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   155
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   156
    // ok
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   157
    log_debug("%s:%s - %s!%s@%s - %s -> %s - %s", 
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   158
        network, channel, nickname, username, hostname, type, target, message
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   159
    );
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   160
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   161
    return SUCCESS;
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   162
}
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   163
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   164
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   165
 * Log a simple channel event of the form:
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   166
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   167
 * :nm <type> <channel> [<msg>]
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   168
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   169
static void irc_log_on_chan_generic (const struct irc_line *line, void *arg)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   170
{
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   171
    struct irc_log_chan *chan_ctx = arg;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   172
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   173
    const char *msg = line->args[1];
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   174
75
ff6272398d2e change irc_line.prefix into a
Tero Marttila <terom@fixme.fi>
parents: 70
diff changeset
   175
    irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, NULL, msg);
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   176
}
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   177
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   178
/**
80
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   179
 * Log a NICK event on a channel
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   180
 *
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   181
 * :nm NICK <nickname>
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   182
 *
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   183
 * This logs the new nickname as the target
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   184
 */
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   185
static void irc_log_on_chan_NICK (const struct irc_line *line, void *arg)
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   186
{
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   187
    struct irc_log_chan *chan_ctx = arg;
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   188
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   189
    const char *nickname = line->args[0];
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   190
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   191
    // log it
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   192
    irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, nickname, NULL);
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   193
}
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   194
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   195
/**
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   196
 * Log a QUIT event on a channel
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   197
 *
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   198
 * :nm QUIT [<message>]
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   199
 */
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   200
static void irc_log_on_chan_QUIT (const struct irc_line *line, void *arg)
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   201
{
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   202
    struct irc_log_chan *chan_ctx = arg;
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   203
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   204
    const char *message = line->args[0];
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   205
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   206
    // log it
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   207
    irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, NULL, message);
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   208
}
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   209
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   210
/**
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   211
 * Log a MODE event on a channel
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   212
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   213
 * :nm MODE <channel> [<modearg> [...]]
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   214
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   215
 * This conacts all the modeargs together, and logs that as the message
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   216
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   217
static void irc_log_on_chan_MODE (const struct irc_line *line, void *arg)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   218
{
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   219
    struct irc_log_chan *chan_ctx = arg;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   220
    char message[512], *ptr = message;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   221
    const char *cmdarg;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   222
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   223
    // iterate over each arg
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   224
    FOREACH_IRC_LINE_ARGS(line, cmdarg) {
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   225
        // separate with spaces
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   226
        if (cmdarg > line->args[0])
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   227
            *ptr++ = ' ';
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   228
        
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   229
        // append
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   230
        ptr += snprintf(ptr, (message + 512 - ptr), "%s", cmdarg);
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   231
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   232
        // buffer full?
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   233
        if (ptr > message + 512)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   234
            break;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   235
    }
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   236
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   237
    // log
75
ff6272398d2e change irc_line.prefix into a
Tero Marttila <terom@fixme.fi>
parents: 70
diff changeset
   238
    irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, NULL, message);
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   239
}
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   240
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   241
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   242
 * Log a KICK event on a channel
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   243
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   244
 * :nm KICK <channel> <target> [<comment>]
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   245
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   246
static void irc_log_on_chan_KICK (const struct irc_line *line, void *arg)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   247
{
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   248
    struct irc_log_chan *chan_ctx = arg;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   249
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   250
    const char *target = line->args[1];    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   251
    const char *msg = line->args[2];
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   252
75
ff6272398d2e change irc_line.prefix into a
Tero Marttila <terom@fixme.fi>
parents: 70
diff changeset
   253
    irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, target, msg);
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   254
}
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   255
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   256
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   257
 * Our low-level channel-specific message handlers for logged channels.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   258
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   259
 * Note that these get a `struct irc_log_chan*` as an argument.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   260
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   261
static struct irc_cmd_handler _chan_cmd_handlers[] = {
80
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   262
    {   "NICK",     &irc_log_on_chan_NICK           },
1b989bc67760 add NICK/QUIT logging to irc_log
Tero Marttila <terom@fixme.fi>
parents: 75
diff changeset
   263
    {   "QUIT",     &irc_log_on_chan_QUIT           },
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   264
    {   "JOIN",     &irc_log_on_chan_generic        },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   265
    {   "PART",     &irc_log_on_chan_generic        },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   266
    {   "MODE",     &irc_log_on_chan_MODE           },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   267
    {   "TOPIC",    &irc_log_on_chan_generic        },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   268
    {   "KICK",     &irc_log_on_chan_KICK           },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   269
    {   "PRIVMSG",  &irc_log_on_chan_generic        },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   270
    {   "NOTICE",   &irc_log_on_chan_generic        },
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   271
    {   NULL,       NULL                            }
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   272
};
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   273
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   274
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   275
 * Our high-level channel-specific callbacks for logged channels.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   276
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   277
 * Note that these get a `struct irc_log_chan*` as an argument.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   278
 */
38
0c2e0cb46c3a implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   279
static struct irc_chan_callbacks _chan_callbacks = {
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   280
    .on_self_join       = NULL,
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   281
    .on_msg             = NULL,
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   282
};
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   283
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   284
/**
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   285
 * Release resources associated with the given irc_log_chan without doing any clean shutdown stuff
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   286
 */
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   287
static void irc_log_chan_destroy (struct irc_log_chan *chan_ctx)
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   288
{
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   289
    // remove any handlers/callbacks
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   290
    irc_cmd_remove(&chan_ctx->chan->handlers, _chan_cmd_handlers, chan_ctx);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   291
    irc_chan_remove_callbacks(chan_ctx->chan, &_chan_callbacks, chan_ctx);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   292
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   293
    // remove from channels list
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   294
    TAILQ_REMOVE(&chan_ctx->ctx->channels, chan_ctx, ctx_channels);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   295
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   296
    // free ourselves
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   297
    free(chan_ctx);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   298
}
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   299
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   300
/**
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   301
 * Begin logging the given channel
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   302
 */
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   303
static err_t irc_log_chan (struct irc_log_ctx *ctx, struct irc_chan *chan, struct error_info *err)
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   304
{
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   305
    struct irc_log_chan *chan_ctx;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   306
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   307
    // alloc
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   308
    if ((chan_ctx = calloc(1, sizeof(*chan_ctx))) == NULL)
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   309
        return SET_ERROR(err, ERR_CALLOC);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   310
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   311
    // store
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   312
    chan_ctx->ctx = ctx;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   313
    chan_ctx->chan = chan;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   314
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   315
    // add to channels list
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   316
    TAILQ_INSERT_TAIL(&ctx->channels, chan_ctx, ctx_channels);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   317
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   318
    // add low-level handlers
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   319
    if ((ERROR_CODE(err) = irc_cmd_add(&chan_ctx->chan->handlers, _chan_cmd_handlers, chan_ctx)))
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   320
        goto error;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   321
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   322
    // add channel callbacks
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   323
    if ((ERROR_CODE(err) = irc_chan_add_callbacks(chan_ctx->chan, &_chan_callbacks, chan_ctx)))
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   324
        goto error;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   325
    
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   326
    // log an OPEN message
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   327
    // XXX: move this to when we first JOIN the channel
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   328
    if ((ERROR_CODE(err) = irc_log_event(ctx, chan_ctx, NULL, "OPEN", NULL, NULL)))
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   329
        goto error;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   330
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   331
    // ok
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   332
    log_info("logging channel %s:%s", chan_ctx->chan->net->info.network, irc_chan_name(chan_ctx->chan));
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   333
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   334
    return SUCCESS;
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   335
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   336
error:
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   337
    // cleanup
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   338
    irc_log_chan_destroy(chan_ctx);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   339
    
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   340
    return ERROR_CODE(err);
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   341
}
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   342
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   343
/**
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   344
 * Stop logging the given channel, shutting it down nicely and then releasing its resources.
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   345
 *
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   346
 * If shutting it down nicely fails, this just destroys it.
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   347
 */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   348
static err_t irc_log_chan_stop (struct irc_log_chan *chan_ctx)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   349
{
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   350
    err_t err;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   351
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   352
    // mark it as stopping, so the result callback knows to destroy it
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   353
    chan_ctx->stopping = true;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   354
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   355
    // log the CLOSE event
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   356
    if ((err = irc_log_event(chan_ctx->ctx, chan_ctx, NULL, "CLOSE", NULL, NULL)))
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   357
        goto error;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   358
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   359
    // ok
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   360
    return SUCCESS;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   361
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   362
error:
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   363
    // destroy it uncleanly
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   364
    irc_log_chan_destroy(chan_ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   365
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   366
    return err;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   367
}
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   368
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   369
/**
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   370
 * Allocate and initialize an irc_log_ctx. This doesn't do very much, the real magic happens in irc_log_conf.
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   371
 */
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   372
static err_t irc_log_init (struct nexus *nexus, void **ctx_ptr, struct error_info *err)
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   373
{
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   374
    struct irc_log_ctx *ctx;
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   375
    
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   376
    // allocate
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   377
    if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   378
        return SET_ERROR(err, ERR_CALLOC);
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   379
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   380
    // store
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   381
    ctx->nexus = nexus;
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   382
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   383
    // initialize
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   384
    TAILQ_INIT(&ctx->channels);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   385
65
d7508879ad01 add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents: 61
diff changeset
   386
    log_info("module initialized");
d7508879ad01 add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents: 61
diff changeset
   387
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   388
    // ok
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   389
    *ctx_ptr = ctx;
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   390
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   391
    return SUCCESS;
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   392
}
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   393
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   394
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   395
 * Process the irc_log.db_info config option.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   396
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   397
 * Creates a new evsql handle.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   398
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   399
 * Fails if ctx->db is already set.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   400
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   401
static err_t irc_log_conf_db_info (struct irc_log_ctx *ctx, char *value, struct error_info *err)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   402
{
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   403
    log_info("connect to database: %s", value);
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   404
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   405
    // already connected?
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   406
    if (ctx->db)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   407
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "irc_log.db_info already set");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   408
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   409
    // create a new evsql handle
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   410
    if ((ctx->db = evsql_new_pq(ctx->nexus->ev_base, value, NULL, NULL)) == NULL)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   411
       return SET_ERROR(err, ERR_EVSQL_NEW_PQ);
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   412
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   413
    // ok
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   414
    return SUCCESS;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   415
}
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   416
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   417
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   418
 * Process the irc_log.channel config option.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   419
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   420
 * Creates a new irc_log_chan context, looks up the channel, adds our command handlers, and logs an OPEN event.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   421
 *
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   422
 * Fails if the value is invalid, we don't have a database connected, the channel doesn't exist, adding our command
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   423
 * handlers/callbacks fails, or sending the initial INSERT-OPEN query fails.
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   424
 */
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   425
static err_t irc_log_conf_channel (struct irc_log_ctx *ctx, char *value, struct error_info *err)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   426
{
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   427
    const char *network, *channel;
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   428
    struct irc_chan *chan;
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   429
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   430
    // parse required args
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   431
    if ((network = strsep(&value, ":")) == NULL)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   432
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "invalid <network> for irc_log.channel");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   433
        
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   434
    if ((channel = strsep(&value, ":")) == NULL)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   435
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "invalid <channel> for irc_log.channel");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   436
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   437
    // extraneous stuff?
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   438
    if (value)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   439
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "trailing data for irc_log.channel");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   440
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   441
    // have a db configured?
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   442
    if (!ctx->db)
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   443
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "irc_log.channel used without any irc_log.db_info");
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   444
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   445
    // get the channel?
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   446
    if ((chan = irc_client_get_chan(ctx->nexus->client, network, channel)) == NULL)
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   447
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown channel name");
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   448
69
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   449
    // begin logging it
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   450
    if (irc_log_chan(ctx, chan, err))
6f298b6e0d5f create irc_log_chan function to log a new irc_log_chan, and irc_log_chan_destroy to remove the added callbacks/command handlers
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
   451
        return ERROR_CODE(err);
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   452
    
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   453
    // ok
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   454
    return SUCCESS;
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   455
}
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   456
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   457
/**
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   458
 * Set a config option
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   459
 */
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   460
static err_t irc_log_conf (void *_ctx, const char *name, char *value, struct error_info *err)
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   461
{
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   462
    struct irc_log_ctx *ctx = _ctx;
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   463
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   464
    // wrong state
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   465
    if (ctx->unloading)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   466
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "module is being unloaded");
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   467
    
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   468
    // apply the config setting
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   469
    if (strcmp(name, "db_info") == 0) {
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   470
        return irc_log_conf_db_info(ctx, value, err);
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   471
67
aa94bf2b5f9b implement the SQL logs table and the INSERT-logging code for mod_irc_log
Tero Marttila <terom@fixme.fi>
parents: 66
diff changeset
   472
    } else if (strcmp(name, "channel") == 0) {
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   473
        return irc_log_conf_channel(ctx, value, err);
55
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   474
6f7f6ae729d0 'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents: 45
diff changeset
   475
    } else {
66
ef8c9d7daf62 all options are now fully implemented
Tero Marttila <terom@fixme.fi>
parents: 65
diff changeset
   476
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown configuration option");
23
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   477
    }
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   478
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   479
    // ok
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   480
    return SUCCESS;
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   481
}
542c73d07d3c add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   482
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   483
/**
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   484
 * Deinitialize, logging CLOSE events for all channels, and removing any hooks we've added
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   485
 */
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   486
static err_t irc_log_unload (void *_ctx)
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   487
{
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   488
    struct irc_log_ctx *ctx = _ctx;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   489
    struct irc_log_chan *chan_ctx;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   490
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   491
    // update our state to mark ourselves as unloading
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   492
    ctx->unloading = true;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   493
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   494
    // stop logging each channel
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   495
    TAILQ_FOREACH(chan_ctx, &ctx->channels, ctx_channels) {
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   496
        irc_log_chan_stop(chan_ctx);
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   497
    }
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   498
    
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   499
    // wait for all the channels to be stopped, which will call irc_log_stopped
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   500
    return SUCCESS;
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   501
}
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   502
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   503
/**
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   504
 * The module function table
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   505
 */
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   506
struct module_funcs irc_log_funcs = {
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   507
    .init       = &irc_log_init,
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   508
    .conf       = &irc_log_conf,
70
a9a4c5e6aa30 implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents: 69
diff changeset
   509
    .unload     = &irc_log_unload,
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   510
};
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 67
diff changeset
   511