Merged 0.7.99 irssi.
[runtime.git] / apps / irssi / src / perl / common / Channel.xs
1 #include "module.h"
2
3 MODULE = Irssi::Channel  PACKAGE = Irssi
4 PROTOTYPES: ENABLE
5
6 void
7 channels()
8 PREINIT:
9         GSList *tmp;
10 PPCODE:
11         for (tmp = channels; tmp != NULL; tmp = tmp->next) {
12                 XPUSHs(sv_2mortal(iobject_bless((CHANNEL_REC *) tmp->data)));
13         }
14
15 Irssi::Channel
16 channel_find(channel)
17         char *channel
18 CODE:
19         RETVAL = channel_find(NULL, channel);
20 OUTPUT:
21         RETVAL
22
23 #*******************************
24 MODULE = Irssi::Channel  PACKAGE = Irssi::Server
25 #*******************************
26
27 void
28 channels(server)
29         Irssi::Server server
30 PREINIT:
31         GSList *tmp;
32 PPCODE:
33         for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
34                 XPUSHs(sv_2mortal(iobject_bless((CHANNEL_REC *) tmp->data)));
35         }
36
37 void
38 channels_join(server, channels, automatic)
39         Irssi::Server server
40         char *channels
41         int automatic
42 CODE:
43         server->channels_join(server, channels, automatic);
44
45 Irssi::Channel
46 channel_create(server, name, automatic)
47         Irssi::Server server
48         char *name
49         int automatic
50 CODE:
51         CHAT_PROTOCOL(server)->channel_create(server, name, automatic);
52
53 Irssi::Channel
54 channel_find(server, name)
55         Irssi::Server server
56         char *name
57
58 void
59 nicks_get_same(server, nick)
60         Irssi::Server server
61         char *nick
62 PREINIT:
63         GSList *list, *tmp;
64 PPCODE:
65         list = nicklist_get_same(server, nick);
66
67         for (tmp = list; tmp != NULL; tmp = tmp->next->next) {
68                 XPUSHs(sv_2mortal(iobject_bless((CHANNEL_REC *) tmp->data)));
69                 XPUSHs(sv_2mortal(iobject_bless((NICK_REC *) tmp->next->data)));
70         }
71         g_slist_free(list);
72
73 #*******************************
74 MODULE = Irssi::Channel  PACKAGE = Irssi::Channel  PREFIX = channel_
75 #*******************************
76
77 void
78 channel_destroy(channel)
79         Irssi::Channel channel
80
81 void
82 nick_insert(channel, nick)
83         Irssi::Channel channel
84         Irssi::Nick nick
85 CODE:
86         nicklist_insert(channel, nick);
87
88 void
89 nick_remove(channel, nick)
90         Irssi::Channel channel
91         Irssi::Nick nick
92 CODE:
93         nicklist_remove(channel, nick);
94
95 Irssi::Nick
96 nick_find(channel, nick)
97         Irssi::Channel channel
98         char *nick
99 CODE:
100         RETVAL = nicklist_find(channel, nick);
101 OUTPUT:
102         RETVAL
103
104 Irssi::Nick
105 nick_find_mask(channel, mask)
106         Irssi::Channel channel
107         char *mask
108 CODE:
109         RETVAL = nicklist_find_mask(channel, mask);
110 OUTPUT:
111         RETVAL
112
113 void
114 nicks(channel)
115         Irssi::Channel channel
116 PREINIT:
117         GSList *list, *tmp;
118 PPCODE:
119         list = nicklist_getnicks(channel);
120
121         for (tmp = list; tmp != NULL; tmp = tmp->next) {
122                 XPUSHs(sv_2mortal(iobject_bless((NICK_REC *) tmp->data)));
123         }
124         g_slist_free(list);