libpurple/protocols/irc/parse.c

branch
soc.2013.gobjectification.plugins
changeset 36663
c61b6dbc1f03
parent 36637
9b0109ae118d
child 36782
64936dae41a3
equal deleted inserted replaced
36662:f61c3e4338c4 36663:c61b6dbc1f03
31 #include "irc.h" 31 #include "irc.h"
32 32
33 #include <stdio.h> 33 #include <stdio.h>
34 #include <stdlib.h> 34 #include <stdlib.h>
35 #include <ctype.h> 35 #include <ctype.h>
36
37 static GSList *cmds = NULL;
36 38
37 static char *irc_send_convert(struct irc_conn *irc, const char *string); 39 static char *irc_send_convert(struct irc_conn *irc, const char *string);
38 static char *irc_recv_convert(struct irc_conn *irc, const char *string); 40 static char *irc_recv_convert(struct irc_conn *irc, const char *string);
39 41
40 static void irc_parse_error_cb(struct irc_conn *irc, char *input); 42 static void irc_parse_error_cb(struct irc_conn *irc, char *input);
193 return PURPLE_CMD_RET_OK; 195 return PURPLE_CMD_RET_OK;
194 } 196 }
195 197
196 static void irc_register_command(struct _irc_user_cmd *c) 198 static void irc_register_command(struct _irc_user_cmd *c)
197 { 199 {
200 PurpleCmdId id;
198 PurpleCmdFlag f; 201 PurpleCmdFlag f;
199 char args[10]; 202 char args[10];
200 char *format; 203 char *format;
201 size_t i; 204 size_t i;
202 205
219 break; 222 break;
220 } 223 }
221 224
222 args[i] = '\0'; 225 args[i] = '\0';
223 226
224 purple_cmd_register(c->name, args, PURPLE_CMD_P_PROTOCOL, f, "irc", 227 id = purple_cmd_register(c->name, args, PURPLE_CMD_P_PROTOCOL, f, "irc",
225 irc_parse_purple_cmd, _(c->help), NULL); 228 irc_parse_purple_cmd, _(c->help), NULL);
229 cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id));
226 } 230 }
227 231
228 void irc_register_commands(void) 232 void irc_register_commands(void)
229 { 233 {
230 struct _irc_user_cmd *c; 234 struct _irc_user_cmd *c;
231 235
232 for (c = _irc_cmds; c && c->name; c++) 236 for (c = _irc_cmds; c && c->name; c++)
233 irc_register_command(c); 237 irc_register_command(c);
238 }
239
240 void irc_unregister_commands(void)
241 {
242 while (cmds) {
243 PurpleCmdId id = GPOINTER_TO_UINT(cmds->data);
244 purple_cmd_unregister(id);
245 cmds = g_slist_delete_link(cmds, cmds);
246 }
234 } 247 }
235 248
236 static char *irc_send_convert(struct irc_conn *irc, const char *string) 249 static char *irc_send_convert(struct irc_conn *irc, const char *string)
237 { 250 {
238 char *utf8; 251 char *utf8;

mercurial