summaryrefslogtreecommitdiff
path: root/src/perl/xs/Irssi-server.xs
blob: 326b8d998e8ed10c17fba6e30cc7b3a66704d802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
MODULE = Irssi  PACKAGE = Irssi

void
servers()
PREINIT:
	GSList *tmp;
	HV *stash;
PPCODE:
	stash = gv_stashpv("Irssi::Server", 0);
	for (tmp = servers; tmp != NULL; tmp = tmp->next) {
		XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash)));
	}

void
reconnects()
PREINIT:
	GSList *tmp;
	HV *stash;
PPCODE:
	stash = gv_stashpv("Irssi::Reconnect", 0);
	for (tmp = reconnects; tmp != NULL; tmp = tmp->next) {
		XPUSHs(sv_2mortal(sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(tmp->data))), stash)));
	}

Irssi::Connect
irc_server_create_conn(dest, port=6667, password=NULL, nick=NULL)
	char *dest
	int port
	char *password
	char *nick

Irssi::Server
server_find_tag(tag)
	char *tag
CODE:
	RETVAL = (IRC_SERVER_REC *) server_find_tag(tag);
OUTPUT:
	RETVAL

Irssi::Server
server_find_ircnet(ircnet)
	char *ircnet
CODE:
	RETVAL = (IRC_SERVER_REC *) server_find_ircnet(ircnet);
OUTPUT:
	RETVAL

#*******************************
MODULE = Irssi	PACKAGE = Irssi::Server  PREFIX = server_
#*******************************

void
values(server)
	Irssi::Server server
PREINIT:
        HV *hv, *stash;
	char *type;
PPCODE:
	type = "IRC";

	hv = newHV();
	hv_store(hv, "type", 4, new_pv(type), 0);
	server_fill_hash(hv, server);

	hv_store(hv, "real_address", 12, new_pv(server->real_address), 0);
	hv_store(hv, "version", 7, new_pv(server->version), 0);
	hv_store(hv, "usermode", 8, new_pv(server->usermode), 0);
	hv_store(hv, "userhost", 8, new_pv(server->userhost), 0);
	hv_store(hv, "last_invite", 11, new_pv(server->last_invite), 0);
	hv_store(hv, "away_reason", 11, new_pv(server->away_reason), 0);
	hv_store(hv, "usermode_away", 13, newSViv(server->usermode_away), 0);
	hv_store(hv, "server_operator", 15, newSViv(server->server_operator), 0);
	XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));

int
server_connect(server)
	Irssi::Server server
CODE:
	RETVAL = server_connect((SERVER_REC *) server);
OUTPUT:
	RETVAL

void
server_disconnect(server)
	Irssi::Server server
CODE:
	server_disconnect((SERVER_REC *) server);

char *
irc_server_get_channels(server)
	Irssi::Server server

void
send_raw(server, cmd)
	Irssi::Server server
	char *cmd
CODE:
	irc_send_cmd(server, cmd);

void
irc_send_cmd_split(server, cmd, arg, max_nicks)
	Irssi::Server server
	char *cmd
	int arg
	int max_nicks

void
ctcp_send_reply(server, data)
	Irssi::Server server
	char *data

void
server_redirect_init(server, command, last, ...)
	Irssi::Server server
	char *command
	int last
PREINIT:
	GSList *list;
	int n;
CODE:
	list = NULL;
	for (n = 3; n < items; n++) {
		list = g_slist_append(list, SvPV(ST(n), PL_na));
	}
	server_redirect_initv(server, command, last, list);

int
server_redirect_single_event(server, arg, last, group, event, signal, argpos)
	Irssi::Server server
	char *arg
	int last
	int group
	char *event
	char *signal
	int argpos

void
server_redirect_event(server, arg, last, ...)
	Irssi::Server server
	char *arg
	int last
PREINIT:
	int n, group;
CODE:
	group = 0;
	for (n = 3; n+3 <= items; n += 3, last--) {
		group = server_redirect_single_event(server, arg, last > 0, group,
			(char *) SvPV(ST(n), PL_na), (char *) SvPV(ST(n+1), PL_na), (int) SvIV(ST(n+2)));
	}

#*******************************
MODULE = Irssi	PACKAGE = Irssi::Connect  PREFIX = irc_server_
#*******************************

void
values(conn)
	Irssi::Connect conn
PREINIT:
        HV *hv;
PPCODE:
	hv = newHV();
	connect_fill_hash(hv, conn);
	XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));

Irssi::Server
irc_server_connect(conn)
	Irssi::Connect conn

#*******************************
MODULE = Irssi	PACKAGE = Irssi::Reconnect
#*******************************

void
values(reconnect)
	Irssi::Reconnect reconnect
PREINIT:
        HV *hv;
PPCODE:
	hv = newHV();
	add_connect_hash(hv, reconnect->conn);
	hv_store(hv, "tag", 3, newSViv(reconnect->tag), 0);
	hv_store(hv, "next_connect", 12, newSViv(reconnect->next_connect), 0);
	XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));