Mercurial > pidgin
annotate src/protocols/irc/cmds.c @ 12062:4ccd528ffe6e
[gaim-migrate @ 14357]
SF #1355632 from Ka-Hing Cheung
"patch to reorder translators"
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Sun, 13 Nov 2005 00:20:53 +0000 |
| parents | 39734dd473e0 |
| children | 879f90dbd21f |
| rev | line source |
|---|---|
| 6333 | 1 /** |
| 2 * @file cmds.c | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
| 7 * | |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 | |
| 23 #include "internal.h" | |
| 24 | |
| 25 #include "conversation.h" | |
| 8504 | 26 #include "debug.h" |
| 6333 | 27 #include "notify.h" |
| 8624 | 28 #include "util.h" |
| 8504 | 29 |
| 6333 | 30 #include "irc.h" |
| 31 | |
| 32 | |
| 33 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); | |
| 34 | |
| 35 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 36 { | |
| 11338 | 37 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account); |
| 6333 | 38 char *buf; |
| 39 | |
| 40 if (!convo) | |
| 6350 | 41 return 1; |
| 6333 | 42 |
| 43 buf = g_strdup_printf(_("Unknown command: %s"), cmd); | |
| 11338 | 44 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_IM) |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
45 gaim_conv_im_write(GAIM_CONV_IM(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 46 else |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
47 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 48 g_free(buf); |
| 49 | |
| 50 return 1; | |
| 51 } | |
| 52 | |
| 53 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 54 { | |
| 55 char *buf, *message, *cur; | |
| 56 | |
| 57 if (args[0] && strcmp(cmd, "back")) { | |
| 58 message = strdup(args[0]); | |
| 59 for (cur = message; *cur; cur++) { | |
| 60 if (*cur == '\n') | |
| 61 *cur = ' '; | |
| 62 } | |
| 63 buf = irc_format(irc, "v:", "AWAY", message); | |
| 64 g_free(message); | |
| 65 } else { | |
| 66 buf = irc_format(irc, "v", "AWAY"); | |
| 67 } | |
| 68 irc_send(irc, buf); | |
| 69 g_free(buf); | |
| 70 | |
| 71 return 0; | |
| 72 } | |
| 73 | |
| 74 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 75 { | |
| 76 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 10933 | 77 char *action, *escaped, *dst, **newargs; |
| 6333 | 78 const char *src; |
| 79 GaimConversation *convo; | |
| 80 | |
| 81 if (!args || !args[0] || !gc) | |
| 82 return 0; | |
| 83 | |
| 6376 | 84 action = g_malloc(strlen(args[0]) + 10); |
| 6333 | 85 |
| 86 sprintf(action, "\001ACTION "); | |
| 87 | |
| 88 src = args[0]; | |
| 89 dst = action + 8; | |
| 90 while (*src) { | |
| 91 if (*src == '\n') { | |
| 92 if (*(src + 1) == '\0') { | |
| 93 break; | |
| 94 } else { | |
| 95 *dst++ = ' '; | |
| 96 src++; | |
| 97 continue; | |
| 98 } | |
| 99 } | |
| 100 *dst++ = *src++; | |
| 101 } | |
| 102 *dst++ = '\001'; | |
| 103 *dst = '\0'; | |
| 104 | |
| 105 newargs = g_new0(char *, 2); | |
| 106 newargs[0] = g_strdup(target); | |
| 107 newargs[1] = action; | |
| 108 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); | |
| 109 g_free(newargs[0]); | |
| 110 g_free(newargs[1]); | |
| 111 g_free(newargs); | |
| 112 | |
| 11338 | 113 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, target, irc->account); |
| 9130 | 114 if (convo) { |
| 10933 | 115 escaped = g_markup_escape_text(args[0], -1); |
| 116 action = g_strdup_printf("/me %s", escaped); | |
| 117 g_free(escaped); | |
| 6333 | 118 if (action[strlen(action) - 1] == '\n') |
| 119 action[strlen(action) - 1] = '\0'; | |
| 11338 | 120 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) |
| 9130 | 121 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), |
| 122 gaim_connection_get_display_name(gc), | |
| 123 0, action, time(NULL)); | |
| 124 else | |
| 125 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | |
| 126 action, 0, time(NULL)); | |
| 6333 | 127 g_free(action); |
| 128 } | |
| 129 | |
| 130 return 1; | |
| 131 } | |
| 132 | |
| 133 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 134 { | |
| 135 char *buf; | |
| 136 | |
| 137 if (!args || !args[0] || !(args[1] || target)) | |
| 138 return 0; | |
| 139 | |
| 140 buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target); | |
| 141 irc_send(irc, buf); | |
| 142 g_free(buf); | |
| 143 | |
| 144 return 0; | |
| 145 } | |
| 146 | |
| 147 int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 148 { | |
| 149 char *buf; | |
| 150 | |
| 151 if (!args || !args[0]) | |
| 152 return 0; | |
| 153 | |
| 154 if (args[1]) | |
| 155 buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]); | |
| 156 else | |
| 157 buf = irc_format(irc, "vc", "JOIN", args[0]); | |
| 158 irc_send(irc, buf); | |
| 159 g_free(buf); | |
| 160 | |
| 161 return 0; | |
| 162 } | |
| 163 | |
| 164 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 165 { | |
| 166 char *buf; | |
| 167 GaimConversation *convo; | |
| 168 | |
| 169 if (!args || !args[0]) | |
| 170 return 0; | |
| 171 | |
| 11338 | 172 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account); |
| 10246 | 173 if (!convo) |
| 6350 | 174 return 0; |
| 6333 | 175 |
| 176 if (args[1]) | |
| 177 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | |
| 178 else | |
| 179 buf = irc_format(irc, "vcn", "KICK", target, args[0]); | |
| 180 irc_send(irc, buf); | |
| 181 g_free(buf); | |
| 182 | |
| 183 return 0; | |
| 184 } | |
| 185 | |
| 8114 | 186 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 187 { | |
| 8352 | 188 gaim_roomlist_show_with_account(irc->account); |
| 8114 | 189 |
| 190 return 0; | |
| 191 } | |
| 192 | |
| 6333 | 193 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 194 { | |
| 195 GaimConnection *gc; | |
| 196 char *buf; | |
| 197 | |
| 198 if (!args) | |
| 199 return 0; | |
| 200 | |
| 201 if (!strcmp(cmd, "mode")) { | |
| 10208 | 202 if (!args[0] && irc_ischannel(target)) |
| 6333 | 203 buf = irc_format(irc, "vc", "MODE", target); |
| 204 else if (args[0] && (*args[0] == '+' || *args[0] == '-')) | |
| 205 buf = irc_format(irc, "vcv", "MODE", target, args[0]); | |
| 206 else if (args[0]) | |
| 207 buf = irc_format(irc, "vv", "MODE", args[0]); | |
| 208 else | |
| 6350 | 209 return 0; |
| 6333 | 210 } else if (!strcmp(cmd, "umode")) { |
| 211 if (!args[0]) | |
| 6350 | 212 return 0; |
| 6333 | 213 gc = gaim_account_get_connection(irc->account); |
| 214 buf = irc_format(irc, "vnv", "MODE", gaim_connection_get_display_name(gc), args[0]); | |
| 6365 | 215 } else { |
| 216 return 0; | |
| 6333 | 217 } |
| 6365 | 218 |
| 6333 | 219 irc_send(irc, buf); |
| 220 g_free(buf); | |
| 221 | |
| 222 return 0; | |
| 223 } | |
| 224 | |
| 225 int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 226 { | |
| 227 char *buf; | |
| 228 | |
| 10208 | 229 if (!args || (!args[0] && !irc_ischannel(target))) |
| 6333 | 230 return 0; |
| 231 | |
| 232 buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target); | |
| 233 irc_send(irc, buf); | |
| 234 g_free(buf); | |
| 235 | |
| 236 irc->nameconv = g_strdup(target); | |
| 237 | |
| 238 return 0; | |
| 239 } | |
| 240 | |
| 241 int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 242 { | |
| 243 char *buf; | |
| 244 | |
| 245 if (!args || !args[0]) | |
| 246 return 0; | |
| 247 | |
| 248 buf = irc_format(irc, "v:", "NICK", args[0]); | |
| 249 irc_send(irc, buf); | |
| 250 g_free(buf); | |
| 251 | |
| 252 return 0; | |
| 253 } | |
| 254 | |
| 255 int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 256 { | |
| 257 char **nicks, **ops, *sign, *mode; | |
| 258 int i = 0, used = 0; | |
| 259 | |
| 260 if (!args || !args[0] || !*args[0]) | |
| 261 return 0; | |
| 262 | |
| 263 if (!strcmp(cmd, "op")) { | |
| 264 sign = "+"; | |
| 265 mode = "o"; | |
| 266 } else if (!strcmp(cmd, "deop")) { | |
| 267 sign = "-"; | |
| 268 mode = "o"; | |
| 269 } else if (!strcmp(cmd, "voice")) { | |
| 270 sign = "+"; | |
| 271 mode = "v"; | |
| 272 } else if (!strcmp(cmd, "devoice")) { | |
| 273 sign = "-"; | |
| 274 mode = "v"; | |
| 275 } else { | |
| 276 gaim_debug(GAIM_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); | |
| 277 return 0; | |
| 278 } | |
| 279 | |
| 280 nicks = g_strsplit(args[0], " ", -1); | |
| 281 | |
| 282 for (i = 0; nicks[i]; i++) | |
| 283 /* nothing */; | |
| 284 ops = g_new0(char *, i * 2 + 1); | |
| 285 | |
| 286 for (i = 0; nicks[i]; i++) { | |
| 287 if (!*nicks[i]) | |
| 288 continue; | |
| 289 ops[used++] = mode; | |
| 290 ops[used++] = nicks[i]; | |
| 291 } | |
| 292 | |
| 293 irc_do_mode(irc, target, sign, ops); | |
| 294 g_free(ops); | |
| 295 | |
| 6350 | 296 return 0; |
| 6333 | 297 } |
| 298 | |
| 299 int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 300 { | |
| 301 char *buf; | |
| 302 | |
| 303 if (!args) | |
| 304 return 0; | |
| 305 | |
| 306 if (args[1]) | |
| 307 buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]); | |
| 308 else | |
| 309 buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target); | |
| 310 irc_send(irc, buf); | |
| 311 g_free(buf); | |
| 312 | |
| 313 return 0; | |
| 314 } | |
| 315 | |
| 316 int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 317 { | |
| 318 char *stamp; | |
| 319 char *buf; | |
| 320 | |
| 321 if (args && args[0]) { | |
| 10208 | 322 if (irc_ischannel(args[0])) |
| 6333 | 323 return 0; |
| 324 stamp = g_strdup_printf("\001PING %lu\001", time(NULL)); | |
| 325 buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp); | |
| 326 g_free(stamp); | |
| 327 } else { | |
| 6350 | 328 stamp = g_strdup_printf("%s %lu", target, time(NULL)); |
| 6333 | 329 buf = irc_format(irc, "v:", "PING", stamp); |
| 330 g_free(stamp); | |
| 331 } | |
| 332 irc_send(irc, buf); | |
| 333 g_free(buf); | |
| 334 | |
| 335 return 0; | |
| 336 } | |
| 337 | |
| 338 int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 339 { | |
| 340 const char *cur, *end; | |
| 341 char *msg, *buf; | |
| 342 | |
| 343 if (!args || !args[0] || !args[1]) | |
| 344 return 0; | |
| 345 | |
| 346 cur = args[1]; | |
| 347 end = args[1]; | |
| 348 while (*end && *cur) { | |
| 349 end = strchr(cur, '\n'); | |
| 350 if (!end) | |
| 351 end = cur + strlen(cur); | |
| 352 msg = g_strndup(cur, end - cur); | |
| 353 buf = irc_format(irc, "vt:", "PRIVMSG", args[0], msg); | |
| 354 irc_send(irc, buf); | |
| 355 g_free(msg); | |
| 356 g_free(buf); | |
| 357 cur = end + 1; | |
| 358 } | |
| 359 | |
| 360 return 0; | |
| 361 } | |
| 362 | |
| 363 int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 364 { | |
| 365 char *buf; | |
| 366 | |
| 9440 | 367 if (!irc->quitting) { |
| 11763 | 368 /* |
| 369 * Use gaim_account_get_string(irc->account, "quitmsg", IRC_DEFAULT_QUIT) | |
| 370 * and uncomment the appropriate account preference in irc.c if we | |
| 371 * decide we want custom quit messages. | |
| 372 */ | |
| 373 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : IRC_DEFAULT_QUIT); | |
| 9440 | 374 irc_send(irc, buf); |
| 375 g_free(buf); | |
| 376 | |
| 377 irc->quitting = TRUE; | |
| 378 } | |
| 6333 | 379 |
| 380 return 0; | |
| 381 } | |
| 382 | |
| 383 int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 384 { | |
| 385 char *buf; | |
| 386 | |
| 387 if (!args || !args[0]) | |
| 388 return 0; | |
| 389 | |
| 390 buf = irc_format(irc, "v", args[0]); | |
| 391 irc_send(irc, buf); | |
| 392 g_free(buf); | |
| 393 | |
| 394 return 0; | |
| 395 } | |
| 396 | |
| 397 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 398 { | |
| 399 GaimConversation *convo; | |
| 400 GaimConnection *gc; | |
| 401 | |
| 402 if (!args || !args[0]) | |
| 403 return 0; | |
| 404 | |
| 11338 | 405 convo = gaim_conversation_new(GAIM_CONV_TYPE_IM, irc->account, args[0]); |
| 6333 | 406 |
| 407 if (args[1]) { | |
| 408 gc = gaim_account_get_connection(irc->account); | |
| 409 irc_cmd_privmsg(irc, cmd, target, args); | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
410 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), |
| 6982 | 411 args[1], GAIM_MESSAGE_SEND, time(NULL)); |
| 6333 | 412 } |
| 413 | |
| 414 return 0; | |
| 415 } | |
| 416 | |
| 417 int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 418 { | |
| 419 char *buf; | |
| 420 | |
| 421 if (!args || !args[0]) | |
| 422 return 0; | |
| 423 | |
| 10208 | 424 if (!irc_ischannel(target)) /* not a channel, punt */ |
| 6333 | 425 return 0; |
| 426 | |
| 427 if (args[1]) | |
| 428 buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]); | |
| 429 else | |
| 430 buf = irc_format(irc, "vcn", "REMOVE", target, args[0]); | |
| 431 irc_send(irc, buf); | |
| 432 g_free(buf); | |
| 433 | |
| 434 return 0; | |
| 435 } | |
| 436 | |
| 12013 | 437 int irc_cmd_service(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 438 { | |
| 439 char *capital_cmd, *buf; | |
| 440 | |
| 441 if (!args || !args[0]) | |
| 442 return 0; | |
| 443 | |
| 444 /* cmd will be one of nickserv, chanserv, memoserv or operserv */ | |
| 445 capital_cmd = g_ascii_strup(cmd, -1); | |
| 446 buf = irc_format(irc, "v:", capital_cmd, args[0]); | |
| 447 irc_send(irc, buf); | |
| 448 g_free(capital_cmd); | |
| 449 g_free(buf); | |
| 450 | |
| 451 return 0; | |
| 452 } | |
| 453 | |
| 10564 | 454 int irc_cmd_time(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 455 { | |
| 456 char *buf; | |
| 457 | |
| 458 buf = irc_format(irc, "v", "TIME"); | |
| 459 irc_send(irc, buf); | |
| 460 g_free(buf); | |
| 461 | |
| 462 return 0; | |
| 463 } | |
| 464 | |
| 6333 | 465 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 466 { | |
| 467 char *buf; | |
| 468 const char *topic; | |
| 469 GaimConversation *convo; | |
| 470 | |
| 471 if (!args) | |
| 472 return 0; | |
| 473 | |
| 11338 | 474 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, target, irc->account); |
| 10246 | 475 if (!convo) |
| 6350 | 476 return 0; |
| 6333 | 477 |
| 478 if (!args[0]) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
479 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(convo)); |
| 6333 | 480 |
| 8504 | 481 if (topic) { |
| 9762 | 482 char *tmp, *tmp2; |
|
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10609
diff
changeset
|
483 tmp = g_markup_escape_text(topic, -1); |
| 9762 | 484 tmp2 = gaim_markup_linkify(tmp); |
| 485 buf = g_strdup_printf(_("current topic is: %s"), tmp2); | |
| 8504 | 486 g_free(tmp); |
| 9762 | 487 g_free(tmp2); |
| 8504 | 488 } else |
| 6333 | 489 buf = g_strdup(_("No topic is set")); |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
490 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), target, buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 491 g_free(buf); |
| 492 | |
| 493 return 0; | |
| 494 } | |
| 495 | |
| 496 buf = irc_format(irc, "vt:", "TOPIC", target, args[0]); | |
| 497 irc_send(irc, buf); | |
| 498 g_free(buf); | |
| 499 | |
| 500 return 0; | |
| 501 } | |
| 502 | |
| 503 int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 504 { | |
| 505 char *buf; | |
| 506 | |
| 507 if (!args || !args[0]) | |
| 6350 | 508 return 0; |
| 6333 | 509 |
| 510 if (!strcmp(cmd, "wallops")) | |
| 511 buf = irc_format(irc, "v:", "WALLOPS", args[0]); | |
| 512 else if (!strcmp(cmd, "operwall")) | |
| 513 buf = irc_format(irc, "v:", "OPERWALL", args[0]); | |
| 6365 | 514 else |
| 515 return 0; | |
| 6333 | 516 |
| 517 irc_send(irc, buf); | |
| 518 g_free(buf); | |
| 519 | |
| 520 return 0; | |
| 521 } | |
| 522 | |
| 523 int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 524 { | |
| 525 char *buf; | |
| 526 | |
| 527 if (!args || !args[0]) | |
| 528 return 0; | |
| 529 | |
| 10609 | 530 if (args[1]) { |
| 531 buf = irc_format(irc, "vvn", "WHOIS", args[0], args[1]); | |
| 532 irc->whois.nick = g_strdup(args[1]); | |
| 533 } else { | |
| 534 buf = irc_format(irc, "vn", "WHOIS", args[0]); | |
| 535 irc->whois.nick = g_strdup(args[0]); | |
| 536 } | |
| 537 | |
| 6333 | 538 irc_send(irc, buf); |
| 539 g_free(buf); | |
| 540 | |
| 541 return 0; | |
| 542 } | |
| 543 | |
| 544 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops) | |
| 545 { | |
| 546 char *buf, mode[5]; | |
| 547 int i = 0; | |
| 548 | |
| 549 if (!sign) | |
| 550 return; | |
| 551 | |
| 552 while (ops[i]) { | |
| 553 if (ops[i + 2] && ops[i + 4]) { | |
| 554 g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign, | |
| 555 ops[i], ops[i + 2], ops[i + 4]); | |
| 556 buf = irc_format(irc, "vcvnnn", "MODE", target, mode, | |
| 557 ops[i + 1], ops[i + 3], ops[i + 5]); | |
| 558 i += 6; | |
| 559 } else if (ops[i + 2]) { | |
| 560 g_snprintf(mode, sizeof(mode), "%s%s%s", | |
| 561 sign, ops[i], ops[i + 2]); | |
| 562 buf = irc_format(irc, "vcvnn", "MODE", target, mode, | |
| 563 ops[i + 1], ops[i + 3]); | |
| 564 i += 4; | |
| 565 } else { | |
| 566 g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]); | |
| 567 buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]); | |
| 568 i += 2; | |
| 569 } | |
| 570 irc_send(irc, buf); | |
| 571 g_free(buf); | |
| 572 } | |
| 6350 | 573 |
| 574 return; | |
| 6333 | 575 } |
