author | Tero Marttila <terom@fixme.fi> |
Thu, 12 Mar 2009 18:11:44 +0200 | |
changeset 37 | 4fe4a3c4496e |
parent 26 | aec062af155d |
child 38 | 0c2e0cb46c3a |
permissions | -rw-r--r-- |
26 | 1 |
#ifndef IRC_CHAN_H |
2 |
#define IRC_CHAN_H |
|
3 |
||
4 |
/** |
|
5 |
* @file |
|
6 |
* |
|
7 |
* Support for IRC channels, including tracking their state and actions on them. |
|
8 |
*/ |
|
9 |
struct irc_chan_info; |
|
10 |
struct irc_chan; |
|
11 |
||
12 |
#include "irc_net.h" |
|
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
13 |
#include "irc_cmd.h" |
26 | 14 |
#include "error.h" |
15 |
#include <sys/queue.h> |
|
16 |
||
17 |
/** |
|
18 |
* IRC channel info, as required to create an irc_chan |
|
19 |
*/ |
|
20 |
struct irc_chan_info { |
|
21 |
/** Channel name, with the [#&!] prefix */ |
|
22 |
const char *channel; |
|
23 |
||
24 |
}; |
|
25 |
||
26 |
/** |
|
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
27 |
* Semantic IRC channel callbacks |
26 | 28 |
*/ |
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
29 |
struct irc_chan_callbacks { |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
30 |
/** Joined the channel */ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
31 |
void (*on_self_join) (struct irc_chan *chan, void *arg); |
26 | 32 |
}; |
33 |
||
34 |
/** |
|
35 |
* IRC channel state |
|
36 |
*/ |
|
37 |
struct irc_chan { |
|
38 |
/** The irc_net.channels list */ |
|
39 |
TAILQ_ENTRY(irc_chan) node; |
|
40 |
||
41 |
/* The network we're on */ |
|
42 |
struct irc_net *net; |
|
43 |
||
44 |
/** Our identifying info */ |
|
45 |
struct irc_chan_info info; |
|
46 |
||
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
47 |
/** State flags */ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
48 |
struct { |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
49 |
/** JOIN request sent, waiting for reply */ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
50 |
bool joining; |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
51 |
|
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
52 |
/** Currently joined to channel */ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
53 |
bool joined; |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
54 |
|
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
55 |
} state; |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
56 |
|
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
57 |
/** General command handlers */ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
58 |
irc_cmd_handlers_t handlers; |
26 | 59 |
}; |
60 |
||
61 |
/** |
|
62 |
* Return the channel's name |
|
63 |
*/ |
|
64 |
const char* irc_chan_name (struct irc_chan *chan); |
|
65 |
||
66 |
/** |
|
67 |
* Build/initialize a new irc_chan struct. This does not have any external side-effects. |
|
68 |
* |
|
69 |
* The channel will be in the IRC_CHAN_INIT state after this. |
|
70 |
* |
|
71 |
* @param chan_ptr the new irc_chan is returned via this pointer |
|
72 |
* @param net the irc_net this channel is on |
|
73 |
* @param info the channel's identifying information |
|
74 |
* @param err error codes are returned via this |
|
75 |
*/ |
|
76 |
err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err); |
|
77 |
||
78 |
/** |
|
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
79 |
* Destroy irc_chan state, without doing anything to the network |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
80 |
*/ |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
81 |
void irc_chan_destroy (struct irc_chan *chan); |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
82 |
|
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
83 |
/** |
26 | 84 |
* Send the initial JOIN message. |
85 |
* |
|
86 |
* The channel must be in the IRC_CHAN_INIT state, and will transition to the IRC_CHAN_JOINING state. |
|
87 |
* |
|
88 |
* @param chan the channel to JOIN |
|
89 |
*/ |
|
90 |
err_t irc_chan_join (struct irc_chan *chan); |
|
91 |
||
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
92 |
|
26 | 93 |
#endif |