author | Tero Marttila <terom@fixme.fi> |
Mon, 16 Mar 2009 23:34:05 +0200 | |
changeset 70 | a9a4c5e6aa30 |
parent 69 | 6f298b6e0d5f |
child 75 | ff6272398d2e |
permissions | -rw-r--r-- |
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 |
* Parse the prefix into a nickmask and pass on to irc_log_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
|
166 |
*/ |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
167 |
static err_t irc_log_event_prefix (struct irc_log_ctx *ctx, struct irc_log_chan *chan_ctx, const char *prefix, |
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
|
168 |
const char *type, const char *target, const char *message) |
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
|
169 |
{ |
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
|
170 |
char prefix_buf[IRC_PREFIX_MAX]; |
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_nm nm; |
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 |
err_t 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
|
173 |
|
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
|
174 |
// parse nickmask |
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
|
175 |
if ((err = irc_nm_parse(&nm, prefix_buf, prefix))) |
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 |
return 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
|
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 |
// log |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
179 |
return irc_log_event(ctx, chan_ctx, &nm, type, target, message); |
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
|
180 |
} |
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
|
181 |
|
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
|
182 |
/** |
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
|
183 |
* 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
|
184 |
* |
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
|
185 |
* :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
|
186 |
*/ |
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
|
187 |
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
|
188 |
{ |
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
|
189 |
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
|
190 |
|
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
|
191 |
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
|
192 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
193 |
irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, 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
|
194 |
} |
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
|
195 |
|
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
|
196 |
/** |
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
|
197 |
* 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
|
198 |
* |
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
|
199 |
* :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
|
200 |
* |
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
|
201 |
* 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
|
202 |
*/ |
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
|
203 |
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
|
204 |
{ |
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
|
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
|
209 |
// 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
|
210 |
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
|
211 |
// 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
|
212 |
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
|
213 |
*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
|
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 |
// 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
|
216 |
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
|
217 |
|
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 |
// 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
|
219 |
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
|
220 |
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
|
221 |
} |
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 |
// log |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
224 |
irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, 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
|
225 |
} |
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 |
|
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 |
/** |
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 |
* 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
|
229 |
* |
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 |
* :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
|
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 |
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
|
233 |
{ |
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 |
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
|
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 |
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
|
237 |
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
|
238 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
239 |
irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, 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
|
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 |
/** |
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 |
* 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
|
244 |
* |
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 |
* 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
|
246 |
*/ |
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 |
static struct irc_cmd_handler _chan_cmd_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
|
248 |
{ "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
|
249 |
{ "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
|
250 |
{ "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
|
251 |
{ "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
|
252 |
{ "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
|
253 |
{ "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
|
254 |
{ "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
|
255 |
{ 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
|
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 |
|
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 |
* 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
|
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 |
* 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
|
262 |
*/ |
38
0c2e0cb46c3a
implement irc_chan_callbacks, and add on_msg
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
263 |
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
|
264 |
.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
|
265 |
.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
|
266 |
}; |
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
|
267 |
|
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
|
268 |
/** |
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
|
269 |
* 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
|
270 |
*/ |
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
|
271 |
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
|
272 |
{ |
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
|
273 |
// 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
|
274 |
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
|
275 |
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
|
276 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
277 |
// remove from channels list |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
278 |
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
|
279 |
|
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
|
280 |
// 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
|
281 |
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
|
282 |
} |
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
|
283 |
|
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 |
* 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
|
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 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
|
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 |
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
|
290 |
|
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 |
// 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
|
292 |
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
|
293 |
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
|
294 |
|
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
|
295 |
// 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
|
296 |
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
|
297 |
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
|
298 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
299 |
// add to channels list |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
300 |
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
|
301 |
|
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
|
302 |
// 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
|
303 |
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
|
304 |
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
|
305 |
|
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 |
// 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
|
307 |
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
|
308 |
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
|
309 |
|
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 |
// 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
|
311 |
// 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
|
312 |
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
|
313 |
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
|
314 |
|
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
|
315 |
// 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
|
316 |
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
|
317 |
|
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 |
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
|
319 |
|
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 |
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 |
// 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
|
322 |
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
|
323 |
|
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 |
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
|
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 |
|
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 |
/** |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
328 |
* 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
|
329 |
* |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
330 |
* 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
|
331 |
*/ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
332 |
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
|
333 |
{ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
334 |
err_t err; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
335 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
336 |
// 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
|
337 |
chan_ctx->stopping = true; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
338 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
339 |
// log the CLOSE event |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
340 |
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
|
341 |
goto error; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
342 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
343 |
// ok |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
344 |
return SUCCESS; |
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 |
error: |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
347 |
// destroy it uncleanly |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
348 |
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
|
349 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
350 |
return 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 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
353 |
/** |
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
|
354 |
* 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
|
355 |
*/ |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
356 |
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
|
357 |
{ |
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
|
358 |
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
|
359 |
|
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
360 |
// allocate |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
361 |
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
|
362 |
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
|
363 |
|
56
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
364 |
// store |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
365 |
ctx->nexus = nexus; |
56
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
366 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
367 |
// initialize |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
368 |
TAILQ_INIT(&ctx->channels); |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
369 |
|
65
d7508879ad01
add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents:
61
diff
changeset
|
370 |
log_info("module initialized"); |
d7508879ad01
add --module support, and tweak irc_net docs
Tero Marttila <terom@fixme.fi>
parents:
61
diff
changeset
|
371 |
|
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
|
372 |
// ok |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
373 |
*ctx_ptr = ctx; |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
374 |
|
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
|
375 |
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
|
376 |
} |
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
|
377 |
|
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
|
378 |
/** |
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
|
379 |
* 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
|
380 |
* |
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
|
381 |
* 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
|
382 |
* |
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
|
383 |
* 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
|
384 |
*/ |
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
|
385 |
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
|
386 |
{ |
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
|
387 |
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
|
388 |
|
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
|
389 |
// 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
|
390 |
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
|
391 |
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
|
392 |
|
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
|
393 |
// 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
|
394 |
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
|
395 |
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
|
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 |
// 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
|
398 |
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
|
399 |
} |
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 |
/** |
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 |
* 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
|
403 |
* |
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 |
* 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
|
405 |
* |
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 |
* 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
|
407 |
* 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
|
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 |
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
|
410 |
{ |
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 |
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
|
412 |
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
|
413 |
|
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 |
// 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
|
415 |
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
|
416 |
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
|
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 |
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
|
419 |
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
|
420 |
|
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 |
// 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
|
422 |
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
|
423 |
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
|
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 |
// 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
|
426 |
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
|
427 |
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
|
428 |
|
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 |
// 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
|
430 |
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
|
431 |
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
|
432 |
|
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
|
433 |
// 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
|
434 |
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
|
435 |
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
|
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 |
// 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
|
438 |
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
|
439 |
} |
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 |
/** |
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 |
* 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
|
443 |
*/ |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
444 |
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
|
445 |
{ |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
446 |
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
|
447 |
|
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
448 |
// wrong state |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
449 |
if (ctx->unloading) |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
450 |
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
|
451 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
452 |
// 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
|
453 |
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
|
454 |
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
|
455 |
|
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
|
456 |
} 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
|
457 |
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
|
458 |
|
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
|
459 |
} else { |
66
ef8c9d7daf62
all options are now fully implemented
Tero Marttila <terom@fixme.fi>
parents:
65
diff
changeset
|
460 |
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
|
461 |
} |
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
|
462 |
|
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
|
463 |
// 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
|
464 |
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
|
465 |
} |
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
|
466 |
|
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
467 |
/** |
70
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
468 |
* 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
|
469 |
*/ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
470 |
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
|
471 |
{ |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
475 |
// 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
|
476 |
ctx->unloading = true; |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
477 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
478 |
// stop logging each channel |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
479 |
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
|
480 |
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
|
481 |
} |
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
482 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
483 |
// 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
|
484 |
return SUCCESS; |
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 |
|
a9a4c5e6aa30
implement module unloading, although module_destroy is currently never called
Tero Marttila <terom@fixme.fi>
parents:
69
diff
changeset
|
487 |
/** |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
488 |
* 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
|
489 |
*/ |
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
490 |
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
|
491 |
.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
|
492 |
.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
|
493 |
.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
|
494 |
}; |
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
|
495 |