/* SYNTAX: WHO [<nicks> | <channels> | **] */ static void cmd_who(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { char *channel, *rest; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &channel, &rest)) return; if (strcmp(channel, "*") == 0 || *channel == '\0') { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); channel = IRC_CHANNEL(item)->name; } if (strcmp(channel, "**") == 0) { /* ** displays all nicks.. */ *channel = '\0'; } irc_send_cmdv(server, *rest == '\0' ? "WHO %s" : "WHO %s %s", channel, rest); cmd_params_free(free_arg); }
static void cmd_names(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { GHashTable *optlist; char *channel; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, "names", &optlist, &channel)) return; if (strcmp(channel, "*") == 0 || *channel == '\0') { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); channel = IRC_CHANNEL(item)->name; } if (strcmp(channel, "**") == 0) { /* ** displays all nicks.. */ irc_send_cmd(server, "NAMES"); } else { irc_send_cmdv(server, "NAMES %s", channel); } cmd_params_free(free_arg); }
static void event_names_list(const char *data, SERVER_REC *server) { CHANNEL_REC *chanrec; char *params, *type, *channel, *names, *ptr; g_return_if_fail(data != NULL); params = event_get_params(data, 4, NULL, &type, &channel, &names); chanrec = channel_find(server, channel); if (chanrec == NULL || chanrec->names_got) { /* unknown channel / names list already read */ g_free(params); return; } /* type = '=' = public, '*' = private, '@' = secret. This is actually pretty useless to check here, but at least we get to know if the channel is +p or +s a few seconds before we receive the MODE reply... */ if (*type == '*') parse_channel_modes(IRC_CHANNEL(chanrec), NULL, "+p"); else if (*type == '@') parse_channel_modes(IRC_CHANNEL(chanrec), NULL, "+s"); while (*names != '\0') { while (*names == ' ') names++; ptr = names; while (*names != '\0' && *names != ' ') names++; if (*names != '\0') *names++ = '\0'; if (*ptr == '@' && g_strcasecmp(server->nick, ptr+1) == 0) chanrec->chanop = TRUE; nicklist_insert(chanrec, ptr+isnickflag(*ptr), *ptr == '@', *ptr == '+', FALSE); } g_free(params); }
/* SYNTAX: INVITE <nick> [<channel>] */ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { char *nick, *channame; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 2, &nick, &channame)) return; if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*channame == '\0' || strcmp(channame, "*") == 0) { if (!IS_IRC_CHANNEL(item)) cmd_param_error(CMDERR_NOT_JOINED); channame = IRC_CHANNEL(item)->name; } irc_send_cmdv(server, "INVITE %s %s", nick, channame); cmd_params_free(free_arg); }
/* SYNTAX: BAN [<channel>] [<nicks>] */ static void cmd_ban(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) { IRC_CHANNEL_REC *chanrec; char *channel, *nicks; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, item, &channel, &nicks)) return; if (*nicks != '\0') { /* setting ban - don't handle here */ cmd_params_free(free_arg); return; } /* display bans */ chanrec = IRC_CHANNEL(item); if (chanrec == NULL && *channel == '\0') cmd_param_error(CMDERR_NOT_JOINED); if (*channel != '\0' && g_strcmp0(channel, "*") != 0) chanrec = irc_channel_find(server, channel); if (chanrec == NULL || !chanrec->synced) { /* not joined to such channel or not yet synced, ask ban lists from server */ bans_ask_channel(channel, server, item); } else { bans_show_channel(chanrec, server); } signal_stop(); cmd_params_free(free_arg); }