void ignore_signal_ctcp_inbound(gpointer *params) { session *sess = params[0]; gchar *nick = params[2]; gchar *to = params[3]; struct User *user = userlist_find(sess, nick); gchar *hostmask; if (user != NULL) { hostmask = g_strjoin("!", user->nick, user->hostname, NULL); if (!is_channel(sess->server, to)) { if (ignore_check(hostmask, IGNORE_PRIVATE | IGNORE_CTCP)) signal_stop_current(); } else { if (ignore_check(hostmask, IGNORE_PUBLIC | IGNORE_CTCP)) signal_stop_current(); } g_free(hostmask); } }
void inbound_chanmsg (server *serv, session *sess, char *chan, char *from, char *text, char fromme, int id) { struct User *user; int hilight = FALSE; char nickchar[2] = "\000"; char idtext[64]; if (!sess) { if (chan) { sess = find_channel (serv, chan); if (!sess && !is_channel (serv, chan)) sess = find_dialog (serv, chan); } else { sess = find_dialog (serv, from); } if (!sess) return; } if (sess != current_tab) { sess->msg_said = TRUE; sess->new_data = FALSE; lastact_update (sess); } user = userlist_find (sess, from); if (user) { if (user->account) id = TRUE; nickchar[0] = user->prefix[0]; user->lasttalk = time (0); } if (fromme) { if (prefs.hex_away_auto_unmark && serv->is_away) sess->server->p_set_back (sess->server); EMIT_SIGNAL (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, 0); return; } inbound_make_idtext (serv, idtext, sizeof (idtext), id); if (is_hilight (from, text, sess, serv)) hilight = TRUE; if (sess->type == SESS_DIALOG) EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0); else if (hilight) EMIT_SIGNAL (XP_TE_HCHANMSG, sess, from, text, nickchar, idtext, 0); else EMIT_SIGNAL (XP_TE_CHANMSG, sess, from, text, nickchar, idtext, 0); }
/* nick, ident, ip, action, channel, message */ void parse_server (char *data, struct servermsg *msg, const unsigned int modes_left) { int offset = 0; if (data == NULL) return; /* if the message we get, contains '@'... * (used to distinguish between server and user command) */ if (memchr ((void *) data, (int) '@', (size_t) (strchr (data, ' ') - data)) != NULL) { get_token (data, '!', msg->nick, &offset, NICK_MAX_LENGTH); get_token (data, '@', msg->ident, &offset, 9); } else *msg->nick = *msg->ident = '\0'; get_token (data, ' ', msg->host, &offset, 128); get_token (data, ' ', msg->action, &offset, 20); msg->target[0] = '\0'; /* FIXME/NOTE: msg->action_n could be pre-cached in check for mode maybe, * then this two functions could be merged: * advantages: simplicity here, fewer comparisons, somewhat faster * disadvantages: hack on top of hack */ if (isdigit (*msg->action)) process_numeric_cmd (msg, data + offset); else process_named_cmd (msg, data + offset); msg->last_matched = NULL; /* FIXME: add other potential messages */ /* Note: these functions have _also_ to be called when modes_left == 1, * otherwise multi-modes will be wrong when modes_left == 1 (the last mode) * maybe FIXME: add comunication with net.c::count_multi() and if * modes_left == 1 return before */ /* Note2: modes will work like a heap, last comed, first served */ if (msg->action_n == MODE) { if (is_channel (*msg->channel)) /* Is an user mode message */ get_multi__mode_chan (msg->message, modes_left); } return; }
/* ctcp */ void signal_printer_ctcp_inbound(gpointer *params) { session *sess = params[0]; gchar *msg = params[1]; gchar *nick = params[2]; gchar *to = params[3]; if(!is_channel(sess->server, to)) { session_print_format(sess->server->front_session, "ctcp generic", msg, nick); } else { session *chansess = find_channel(sess->server, to); if (!chansess) chansess = sess; session_print_format(chansess, "ctcp generic to channel", msg, nick, to); } }
static void channel_topic(u_char *from, u_char **ArgList) { u_char *topic, *channel; save_message_from(); if (ArgList[1] && is_channel(ArgList[0])) { topic = ArgList[1]; channel = ArgList[0]; message_from(channel, LOG_CRAP); put_it("%s Topic for %s: %s", numeric_banner(), channel, topic); } else { message_from(NULL, LOG_CURRENT); PasteArgs(ArgList, 0); put_it("%s Topic: %s", numeric_banner(), ArgList[0]); } restore_message_from(); }
/* * numbered_command: does (hopefully) the right thing with the numbered * responses from the server. I wasn't real careful to be sure I got them * all, but the default case should handle any I missed (sorry) * * The format of a numeric looks like so: * * :server-name XXX our-nick Arg1 Arg2 Arg3 ... :ArgN * * The last argument traditionally has a colon before it, but this is not * compulsary. The BreakArgs function has already broken this up into * words for us, so that what we get, looks like this: * * server-name -> from parameter * XXX -> comm parameter * our-nick -> ArgList[0] * Arg1 -> ArgList[1] * Arg2 -> ArgList[2] * ... ... * * BUT! There's a wrinkle in the ointment. The first thing we do is slurp * up ArgList[0] (our-nick) and put it in 'user'. Then we increment the * ArgList array, so what we actually end up with is: * * server-name -> from parameter * XXX -> comm parameter * our-nick -> user * Arg1 -> ArgList[0] * Arg2 -> ArgList[1] * ... ... * ArgN -> ArgList[N-1] * NULL -> ArgList[N] */ void numbered_command (const char *from, const char *comm, char const **ArgList) { const char *target; char *copy; int i; int lastlog_level; int old_current_numeric = current_numeric; int numeric; /* All numerics must have a target (our nickname) */ if (!comm || !*comm) { rfc1459_odd(from, comm, ArgList); return; } numeric = atol(comm); if (numeric < 0 || numeric > 999) { rfc1459_odd(from, comm, ArgList); return; } if (!(target = ArgList[0])) { rfc1459_odd(from, comm, ArgList); return; } ArgList++; lastlog_level = set_lastlog_msg_level(LOG_CRAP); if (ArgList[0] && is_channel(ArgList[0])) message_from(ArgList[0], LOG_CRAP); else message_from(NULL, LOG_CRAP); current_numeric = -numeric; /* must be negative of numeric! */ /* * This first switch statement is only used for those numerics * which either need to perform some action before the numeric * is offered to the user, or by those actions which need to offer * the numeric to the user in some special manner. * * Those numerics which require only special display if the user * does not hook them, are handled below. * * Those numerics which require special action after the numeric * is offered to the user, are also handled below. * * Each of these numerics must either "break" (go to step 2) * or must "goto END" (goto step 3). */ switch (numeric) { /* * I added the "set_server_nickname" here because the client * when auto-fudging your nick will sometimes be confused as * what your nickname really is when you connect. Since the * server always tells us who the message was set to (ie, us) * we just kind of take it at its word. */ case 001: /* #define RPL_WELCOME 001 */ { Timeval i; i.tv_sec = 0; i.tv_usec = 50000; select(0, NULL, NULL, NULL, &i); accept_server_nickname(from_server, target); server_is_registered(from_server, 1); userhostbase(from_server, NULL, got_my_userhost, 1); break; } /* * Now instead of the terribly horrible hack using numeric 002 * to get the server name/server version info, we use the 004 * numeric which is what is the most logical choice for it. * * If any of the arguments are missing, we don't abort, because * the client needs 004 to sync. Instead, we just pass in the * NULL values and hope for the best... */ case 004: /* #define RPL_MYINFO 004 */ { const char *server = NULL, *version = NULL, *umodes = NULL; /* The 004 numeric is too import to "odd server stuff" over. */ /* So if the reply is useless, we'll just wing it */ if (!(server = ArgList[0])) server = version = umodes = NULL; else if (!(version = ArgList[1])) server = version = umodes = NULL; else if (!(umodes = ArgList[2])) server = version = umodes = NULL; else { /* Work around ratbox-1.2-3. */ if (!my_stricmp(umodes, "(brown")) if (ArgList[3] && !my_stricmp(ArgList[3], "paper")) if (ArgList[4] && !my_stricmp(ArgList[4], "bag")) if (ArgList[5] && !my_stricmp(ArgList[5], "release)")) { if (!(umodes = ArgList[6])) { rfc1459_odd(from, comm, ArgList); goto END; } } } got_initial_version_28(server, version, umodes); break; } case 005: { int arg; char *set, *value; for (arg = 0; ArgList[arg] && !strchr(ArgList[arg], ' '); arg++) { set = LOCAL_COPY(ArgList[arg]); value = strchr(set, '='); if (value && *value) *value++ = 0; if (*set == '+') /* parameter append */ { const char *ov = get_server_005(from_server, ++set); value = malloc_strdup2(ov, value); set_server_005(from_server, set, value); new_free(&value); } else if (*set == '-') /* parameter removal */ set_server_005(from_server, ++set, NULL); else if (value && *value) set_server_005(from_server, set, value); else set_server_005(from_server, set, space); } break; } case 10: /* EFNext "Use another server" 010 */ { const char *new_server, *new_port_s, *message; int new_port, old_server; PasteArgs(ArgList, 2); if (!(new_server = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(new_port_s = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } new_port = atol(ArgList[1]); /* Must do these things before calling "display_msg" */ old_server = from_server; add_to_server_list(new_server, new_port, NULL, NULL, get_server_group(from_server), NULL, 0); server_reconnects_to(old_server, from_server); from_server = old_server; break; } case 14: /* Erf/TS4 "cookie" numeric 014 */ { const char * cookie; PasteArgs(ArgList, 0); if (!(cookie = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } use_server_cookie(from_server); set_server_cookie(from_server, cookie); goto END; } case 42: /* ircnet's "unique id" numeric 042 */ { const char * unique_id; const char * message; PasteArgs(ArgList, 1); if (!(unique_id = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } else if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } set_server_unique_id(from_server, unique_id); if (do_hook(current_numeric, "%s %s %s", from, unique_id, message)) goto DISPLAY; goto END; } case 301: /* #define RPL_AWAY 301 */ { const char *nick, *message; PasteArgs(ArgList, 1); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } /* Ach. /on 301 doesn't offer 'from' as $0. Bummer. */ if (do_hook(current_numeric, "%s %s", nick, message)) goto DISPLAY; goto END; } case 340: /* #define RPL_USERIP 307 */ if (!get_server_005(from_server, "USERIP")) break; /* FALLTHROUGH */ case 302: /* #define RPL_USERHOST 302 */ userhost_returned(from_server, from, comm, ArgList); goto END; case 303: /* #define RPL_ISON 303 */ ison_returned(from_server, from, comm, ArgList); goto END; case 315: /* #define RPL_ENDOFWHO 315 */ who_end(from_server, from, comm, ArgList); goto END; case 321: /* #define RPL_LISTSTART 321 */ { const char *channel, *user_cnt, *line; channel = ArgList[0] = "Channel"; user_cnt = ArgList[1] = "Users"; line = ArgList[2] = "Topic"; ArgList[3] = NULL; /* Then see if they want to hook /ON LIST */ if (!do_hook(LIST_LIST, "%s %s %s", channel, user_cnt, line)) goto END; /* * Otherwise, this line is ok. */ break; } case 322: /* #define RPL_LIST 322 */ { const char *channel, *user_cnt, *line; int cnt; int funny_flags, funny_min, funny_max; const char *funny_match; PasteArgs(ArgList, 2); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(user_cnt = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(line = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } funny_flags = get_server_funny_flags(from_server); funny_min = get_server_funny_min(from_server); funny_max = get_server_funny_max(from_server); funny_match = get_server_funny_match(from_server); /* * Do not display if the channel has no topic and the user asked * for only channels with topics. */ if (funny_flags & FUNNY_TOPIC && !(line && *line)) goto END; /* * Do not display if the channel does not have the necessary * number of users the user asked for */ cnt = my_atol(user_cnt); if (funny_min && (cnt < funny_min)) goto END; if (funny_max && (cnt > funny_max)) goto END; /* * Do not display if the channel is not private or public as the * user requested. */ if ((funny_flags & FUNNY_PRIVATE) && (*channel != '*')) goto END; if ((funny_flags & FUNNY_PUBLIC) && (*channel == '*')) goto END; /* * Do not display if the channel does not match the user's * supplied wildcard pattern */ if (funny_match && wild_match(funny_match, channel) == 0) goto END; /* Then see if they want to hook /ON LIST */ if (!do_hook(LIST_LIST, "%s %s %s", channel, user_cnt, line)) goto END; /* * Otherwise, this line is ok. */ break; } case 324: /* #define RPL_CHANNELMODEIS 324 */ { const char *mode, *channel; PasteArgs(ArgList, 1); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(mode = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } /* If we're waiting for MODE reply. */ if (channel_is_syncing(channel, from_server)) { int numonchannel, maxnum; copy = LOCAL_COPY(channel); update_channel_mode(channel, mode); update_all_status(); maxnum = get_server_max_cached_chan_size(from_server); if (maxnum >= 0) { numonchannel = number_on_channel(copy, from_server); if (numonchannel <= maxnum) whobase(from_server, copy, add_user_who, add_user_end); else channel_not_waiting(copy, from_server); } else whobase(from_server, copy, add_user_who, add_user_end); #if 0 goto END; #endif } break; } case 352: /* #define RPL_WHOREPLY 352 */ whoreply(from_server, NULL, comm, ArgList); goto END; case 353: /* #define RPL_NAMREPLY 353 */ { const char *type, *channel, *line; PasteArgs(ArgList, 2); if (!(type = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(channel = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(line = ArgList[2])) { line = empty_string; } if (channel_is_syncing(channel, from_server)) { char *line_copy = LOCAL_COPY(line); char *nick; while ((nick = next_arg(line_copy, &line_copy)) != NULL) { /* XXX - Hack to work around space at end of 353 */ forcibly_remove_trailing_spaces(nick, NULL); /* * 1999 Oct 29 -- This is a hack to compensate for * a bug in older ircd implementations that can result * in a truncated nickname at the end of a names reply. * The last nickname in a names list is then always * treated with suspicion until the WHO reply is * completed and we know that its not truncated. --esl */ if (!line || !*line) add_to_channel(channel, nick, from_server, 1, 0, 0, 0); else add_to_channel(channel, nick, from_server, 0, 0, 0, 0); } message_from(channel, LOG_CRAP); break; } else { int cnt; const char *ptr; int funny_flags, funny_min, funny_max; const char *funny_match; funny_flags = get_server_funny_flags(from_server); funny_min = get_server_funny_min(from_server); funny_max = get_server_funny_max(from_server); funny_match = get_server_funny_match(from_server); ptr = line; for (cnt = -1; ptr; cnt++) { if ((ptr = strchr(ptr, ' ')) != NULL) ptr++; } if (funny_min && (cnt < funny_min)) goto END; else if (funny_max && (cnt > funny_max)) goto END; if ((funny_flags & FUNNY_PRIVATE) && (*type == '=')) goto END; if ((funny_flags & FUNNY_PUBLIC) && ((*type == '*') || (*type == '@'))) goto END; if (funny_match && wild_match(funny_match, channel) == 0) goto END; } /* Everything is OK. */ break; } case 354: /* #define RPL_XWHOREPLY 354 */ xwhoreply(from_server, NULL, comm, ArgList); goto END; /* XXX Yea yea, these are out of order. so shoot me. */ case 346: /* #define RPL_INVITELIST (+I for erf) */ case 348: /* #define RPL_EXCEPTLIST (+e for erf) */ case 367: /* #define RPL_BANLIST */ number_of_bans++; break; case 347: /* #define END_OF_INVITELIST */ case 349: /* #define END_OF_EXCEPTLIST */ case 368: /* #define END_OF_BANLIST */ { const char *channel; if (!get_int_var(SHOW_END_OF_MSGS_VAR)) goto END; if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } #ifdef IRCII_LIKE_BAN_SUMMARY if (do_hook(current_numeric, "%s %s %d", from, channel, number_of_bans)) #else if (do_hook(current_numeric, "%s %d %s", from, number_of_bans, channel)) #endif { put_it("%s Total number of %s on %s - %d", banner(), numeric == 347 ? "invites" : (numeric == 349 ? "exceptions" : (numeric == 368 ? "bans" : "wounds")), channel, number_of_bans); } goto END; } /* XXX Shouldn't this set "You're operator" flag for hybrid? */ case 381: /* #define RPL_YOUREOPER 381 */ if (!is_server_registered(from_server)) { rfc1459_odd(from, comm, ArgList); goto END; } break; /* ":%s 401 %s %s :No such nick/channel" */ case 401: /* #define ERR_NOSUCHNICK 401 */ { const char *nick; if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!is_channel(nick)) { notify_mark(from_server, nick, 0, 0); if (get_int_var(AUTO_WHOWAS_VAR)) { int foo = get_int_var(NUM_OF_WHOWAS_VAR); if (foo > -1) send_to_server("WHOWAS %s %d", nick, foo); else send_to_server("WHOWAS %s", nick); } } break; } /* Bizarre dalnet extended who replies. */ /* ":%s 402 %s %s :No such server" */ case 402: { const char *server; if (!(server = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } fake_who_end(from_server, from, comm, server); break; } /* Yet more bizarre dalnet extended who replies. */ /* ":%s 522 %s :/WHO Syntax incorrect, use /who ? for help" */ /* ":%s 523 %s :Error, /who limit of %d exceed." */ case 522: case 523: { /* * This dalnet error message doesn't even give us the * courtesy of telling us which who request was in error, * so we have to guess. Whee. */ fake_who_end(from_server, from, comm, NULL); break; } case 403: /* #define ERR_NOSUCHCHANNEL 403 */ { const char * s; const char * channel; const char * message; PasteArgs(ArgList, 1); /* Some servers BBC and send back an empty reply. */ if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } /* Do not accept 403's from remote servers. */ s = get_server_itsname(from_server); if (my_strnicmp(s, from, strlen(s))) { rfc1459_odd(from, comm, ArgList); goto END; } /* * Some servers BBC and send this instead of a * 315 numeric when a who request has been completed. */ if (fake_who_end(from_server, from, comm, channel)) ; /* * If you try to JOIN or PART the "*" named channel, as may * happen if epic gets confused, the server may tell us that * channel does not exist. But it would be death to try to * destroy that channel as epic will surely do the wrong thing! * Otherwise, we somehow tried to reference a channel that * this server claims does not exist; we blow the channel away * for good measure. */ else if (strcmp(channel, "*")) remove_channel(channel, from_server); break; } case 421: /* #define ERR_UNKNOWNCOMMAND 421 */ { const char *token; if (!(token = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (check_server_redirect(from_server, token)) goto END; if (check_server_wait(from_server, token)) goto END; break; } case 432: /* #define ERR_ERRONEUSNICKNAME 432 */ { const char *nick; if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!my_stricmp(target, nick)) yell("WARNING: Strange invalid nick message received." " You are probably lagged."); else if (get_int_var(AUTO_NEW_NICK_VAR)) fudge_nickname(from_server); else reset_nickname(from_server); break; } case 437: /* av2.9's "Nick collision" numeric 437 */ /* Also, undernet/dalnet "You are banned" */ /* Also, av2.10's "Can't do that" numeric */ /* Also, cs's "too many nick changes" num */ { /* * Ugh. What a total trainwreck this is. Sometimes, I * really hate all the ircd's out there in the world that * have to be supported. * * Well, there are at least four different, occasionally * scrutable ways we can get this numeric. * * 1a) On ircnet -- As an unregistered user, the NICK that * we are trying to register was used in the past 90 * seconds or so. The server expects us to send * another NICK request. * ARGV[0] IS NICK, REGISTERED IS NO * 1b) On ircnet -- As a registered user, the NICK that * we are trying to register was used in the past 90 * seconds or so. The server expects us not to do * anything (like a 432 numeric). * ARGV[0] IS NICK, REGISTERED IS YES * 2) On ircnet -- As a registered user, we are trying to * join a channel that was netsplit in the past 24 hours * or so. The server expects us not to do anything. * ARGV[0] IS CHANNEL, REGISTERED IS YES * 3) On undernet/dalnet -- As a registered user, who is * on a channel where we are banned, a NICK request * was rejected (because we are banned). The server * expects us not to do anything. * ARGV[0] IS CHANNEL, REGISTERED IS YES * 4) On a comstud efnet servers -- As a registered user, * we have changed our nicknames too many times in * too short a time. The server expects us not to do * anything. * ARGV[0] IS ERROR, ARGV[1] IS NULL. * I understand this numeric will be moving to 439. */ /* * Weed out the comstud one first, since it's the most bizarre. */ if (ArgList[0] && ArgList[1] == NULL) { accept_server_nickname(from_server, target); break; } /* * Now if it's a channel, it might be ircnet telling us we * can't join the channel, or undernet telling us that we * can't change our nickname because we're banned. The * easiest way to tell is to see if we are on the channel. */ if (is_channel(ArgList[0])) { /* XXX Is this really neccesary? */ if (!im_on_channel(ArgList[0], from_server)) remove_channel(ArgList[0], from_server); break; } /* * Otherwise, a nick command failed. Oh boy. * If we are registered, abort the nick change and * hope for the best. */ if (is_server_registered(from_server)) { accept_server_nickname(from_server, target); break; } /* * Otherwise, it's an ircnet "nick not available" error. * Let the nickname reset numerics handle this mess. */ /* FALLTHROUGH */ } case 433: /* #define ERR_NICKNAMEINUSE 433 */ case 438: /* EFnet/TS4 "nick collision" numeric 438 */ case 453: /* EFnet/TS4 "nickname lost" numeric 453 */ { const char *nick; if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!my_stricmp(target, nick)) /* * This should stop the "rolling nicks" in their tracks. */ yell("WARNING: Strange invalid nick message received." " You are probably lagged."); else if (get_int_var(AUTO_NEW_NICK_VAR)) fudge_nickname(from_server); else reset_nickname(from_server); if (!from) from = "-1"; break; } case 439: /* Comstud's "Can't change nickname" */ { accept_server_nickname(from_server, target); break; } case 442: /* #define ERR_NOTONCHANNEL 442 */ { const char * s; const char * channel; const char * message; PasteArgs(ArgList, 1); /* Some servers BBC and send back an empty reply. */ if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } /* Do not accept this numeric from remote servers */ s = get_server_itsname(from_server); if (my_strnicmp(s, from, strlen(s))) { rfc1459_odd(from, comm, ArgList); goto END; } /* Do not ever delete the "*" channel */ if (strcmp(ArgList[0], "*")) remove_channel(ArgList[0], from_server); break; } case 451: /* #define ERR_NOTREGISTERED 451 */ /* * Sometimes the server doesn't catch the USER line, so * here we send a simplified version again -lynx */ register_server(from_server, NULL); break; case 462: /* #define ERR_ALREADYREGISTRED 462 */ change_server_nickname(from_server, NULL); break; case 465: /* #define ERR_YOUREBANNEDCREEP 465 */ { /* * There used to be a say() here, but if we arent * connected to a server, then doing say() is not * a good idea. So now it just doesnt do anything. */ server_reconnects_to(from_server, NOSERV); break; } case 477: /* #define ERR_NEEDREGGEDNICK 477 */ /* IRCnet has a different 477 numeric. */ if (ArgList[0] && *ArgList[0] == '+') break; /* FALLTHROUGH */ case 471: /* #define ERR_CHANNELISFULL 471 */ case 473: /* #define ERR_INVITEONLYCHAN 473 */ case 474: /* #define ERR_BANNEDFROMCHAN 474 */ case 475: /* #define ERR_BADCHANNELKEY 475 */ case 476: /* #define ERR_BADCHANMASK 476 */ { const char *channel; if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } cant_join_channel(ArgList[0], from_server); break; } } /* DEFAULT OFFER */ /* * This is the "default hook" case, where we offer to the user all of * the numerics that were not offered above. We simply catenate * all of the arguments into a string and offer to the user. * If the user bites, then we skip the "default display" section. */ copy = alloca(IRCD_BUFFER_SIZE + 1); *copy = 0; for (i = 0; ArgList[i]; i++) { if (i) strlcat(copy, " ", IRCD_BUFFER_SIZE); strlcat(copy, ArgList[i], IRCD_BUFFER_SIZE); } if (!do_hook(current_numeric, "%s %s", from, copy)) goto END; DISPLAY: /* DEFAULT DISPLAY */ /* * This is the "default display" case, where if the user does not * hook the numeric, we output the message in some special way. * If a numeric does not require special outputting, then we will * just display it with ``display_msg'' */ switch (numeric) { case 221: /* #define RPL_UMODEIS 221 */ { const char *umode; PasteArgs(ArgList, 0); if (!(umode = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s Your user mode is \"%s\"", banner(), umode); break; } case 271: /* #define SILENCE_LIST 271 */ { const char *perp, *victim; PasteArgs(ArgList, 1); if (!(perp = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(victim = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s is ignoring %s", banner(), perp, victim); break; } case 301: /* #define RPL_AWAY 301 */ { const char *nick, *message; PasteArgs(ArgList, 1); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s is away: %s", banner(), nick, message); break; } case 311: /* #define RPL_WHOISUSER 311 */ { const char *nick, *user, *host, *channel, *name; PasteArgs(ArgList, 4); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(user = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(host = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(channel = ArgList[3])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(name = ArgList[4])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s is %s@%s (%s)", banner(), nick, user, host, name); break; } case 312: /* #define RPL_WHOISSERVER 312 */ { const char *nick, *server, *pithy; PasteArgs(ArgList, 2); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(server = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(pithy = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s on irc via server %s (%s)", banner(), server, pithy); break; } case 313: /* #define RPL_WHOISOPERATOR 313 */ { const char *nick, *message; PasteArgs(ArgList, 1); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s %s", banner(), ArgList[0], ArgList[1]); break; } case 314: /* #define RPL_WHOWASUSER 314 */ { const char *nick, *user, *host, *unused, *name; PasteArgs(ArgList, 4); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(user = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(host = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(unused = ArgList[3])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(name = ArgList[4])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s was %s@%s (%s)",banner(), nick, user, host, name); break; } case 317: /* #define RPL_WHOISIDLE 317 */ { const char *nick, *idle_str, *startup_str; int idle; const char * unit; char startup_ctime[128]; if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(idle_str = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(startup_str = ArgList[2])) { /* No problem */; } *startup_ctime = 0; if (startup_str) /* Undernet/TS4 */ { time_t startup; if ((startup = atol(startup_str)) != 0) snprintf(startup_ctime, 128, ", signed on at %s", my_ctime(startup)); } if ((idle = atoi(idle_str)) > 59) { idle /= 60; unit = "minute"; } else unit = "second"; put_it ("%s %s has been idle %d %ss%s", banner(), nick, idle, unit, startup_ctime); break; } case 318: /* #define RPL_ENDOFWHOIS 318 */ { PasteArgs(ArgList, 0); if (get_int_var(SHOW_END_OF_MSGS_VAR)) display_msg(from, comm, ArgList); break; } case 319: /* #define RPL_WHOISCHANNELS 319 */ { const char *nick, *channels; PasteArgs(ArgList, 1); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(channels = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s on channels: %s", banner(), channels); break; } case 321: /* #define RPL_LISTSTART 321 */ /* Our screwy 321 handling demands this. BAH! */ put_it("%s Channel Users Topic", banner()); break; case 322: /* #define RPL_LIST 322 */ { static char format[25]; static int last_width = -1; const char *channel, *user_cnt, *line; PasteArgs(ArgList, 2); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(user_cnt = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(line = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } /* Figure out how to display this to the user. */ if (last_width != get_int_var(CHANNEL_NAME_WIDTH_VAR)) { if ((last_width = get_int_var(CHANNEL_NAME_WIDTH_VAR))) snprintf(format, 25, "%%-%u.%us %%-5s %%s", (unsigned) last_width, (unsigned) last_width); else strlcpy(format, "%s\t%-5s %s", sizeof format); } if (*channel == '*') say(format, "Prv", user_cnt, line); else say(format, check_channel_type(channel), user_cnt, line); break; } case 324: /* #define RPL_CHANNELMODEIS 324 */ { const char *mode, *channel; PasteArgs(ArgList, 1); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(mode = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s Mode for channel %s is \"%s\"", banner(), channel, mode); break; } case 329: /* #define CREATION_TIME 329 */ { const char *channel, *time1_str, *time2_str, *time3_str; time_t time1, time2, time3; PasteArgs(ArgList, 2); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(time1_str = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(time2_str = ArgList[2])) { /* No problem */; } if (!(time3_str = ArgList[3])) { /* No problem */; } /* Erf/TS4 support */ if (time2_str && time3_str) { time1 = (time_t)my_atol(time1_str); time2 = (time_t)my_atol(time2_str); time3 = (time_t)my_atol(time3_str); put_it("%s Channel %s was created at %ld, " "+c was last set at %ld, " "and has been opless since %ld", banner(), channel, time1, time2, time3); } else { time1 = (time_t)my_atol(time1_str); put_it("%s Channel %s was created at %s", banner(), channel, my_ctime(time1)); } break; } case 330: /* #define RPL_WHOISLOGGEDIN 330 */ { const char *nick, *login, *reason; PasteArgs(ArgList, 2); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(login = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(reason = ArgList[2])) { reason = "is logged in as"; } put_it("%s %s %s %s", banner(), nick, reason, login); break; } case 332: /* #define RPL_TOPIC 332 */ { const char *channel, *topic; PasteArgs(ArgList, 1); if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(topic = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s Topic for %s: %s", banner(), channel, topic); break; } case 333: /* #define RPL_TOPICWHOTIME 333 */ { const char *channel, *nick, *when_str; time_t howlong; if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(nick = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(when_str = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } howlong = time(NULL) - my_atol(when_str); put_it("%s The topic was set by %s %ld sec ago",banner(), nick, howlong); break; } case 341: /* #define RPL_INVITING 341 */ { const char *nick, *channel; if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(channel = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } message_from(channel, LOG_CRAP); put_it("%s Inviting %s to channel %s", banner(), nick, channel); break; } case 351: /* #define RPL_VERSION 351 */ { const char *version, *itsname, *stuff; PasteArgs(ArgList, 2); if (!(version = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(itsname = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(stuff = ArgList[2])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s Server %s: %s %s",banner(), itsname, version, stuff); break; } case 353: /* #define RPL_NAMREPLY 353 */ { static int last_width; char format[41]; const char *type, *channel, *line; PasteArgs(ArgList, 2); if (!(type = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(channel = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(line = ArgList[2])) { line = empty_string; } /* This is only for when the user joined the channel */ if (channel_is_syncing(channel, from_server)) { /* If the user bites on /ON NAMES, then skip the rest */ message_from(channel, LOG_CRAP); if (do_hook(NAMES_LIST, "%s %s", channel, line)) if (get_int_var(SHOW_CHANNEL_NAMES_VAR)) say("Users on %s: %s", check_channel_type(channel), line); break; } /* If the user grabs /ON NAMES then just stop right here */ if (!do_hook(NAMES_LIST, "%s %s", channel, line)) break; /* This all is for when the user has not just joined channel */ if (last_width != get_int_var(CHANNEL_NAME_WIDTH_VAR)) { if ((last_width = get_int_var(CHANNEL_NAME_WIDTH_VAR))) snprintf(format, 40, "%%s: %%-%u.%us %%s", (unsigned char) last_width, (unsigned char) last_width); else strlcpy(format, "%s: %s\t%s", sizeof format); } else strlcpy(format, "%s: %s\t%s", sizeof format); message_from(channel, LOG_CRAP); if (*type == '=') { if (last_width && ((int)strlen(channel) > last_width)) { char *channel_copy = LOCAL_COPY(channel); channel_copy[last_width-1] = '>'; channel_copy[last_width] = 0; channel = channel_copy; } put_it(format, "Pub", check_channel_type(channel), line); } else if (*type == '*') put_it(format, "Prv", check_channel_type(channel), line); else if (*type == '@') put_it(format, "Sec", check_channel_type(channel), line); break; } case 364: /* #define RPL_LINKS 364 */ { const char *itsname, *uplink, *stuff; PasteArgs(ArgList, 2); if (!(itsname = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(uplink = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(stuff = ArgList[2])) { stuff = empty_string; } if (stuff) put_it("%s %-20s %-20s %s", banner(), itsname, uplink, stuff); else put_it("%s %-20s %s", banner(), itsname, uplink); break; } case 366: /* #define RPL_ENDOFNAMES 366 */ { const char *channel; if (!get_int_var(SHOW_END_OF_MSGS_VAR)) break; if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!channel_is_syncing(channel, from_server)) display_msg(from, comm, ArgList); break; } case 346: /* +I on erf */ case 348: /* +e on erf */ case 367: /* +b */ { const char *channel, *ban, *perp, *when_str; time_t howlong; if (!(channel = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(ban = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(perp = ArgList[2])) { /* No problem. */ } if (!(when_str = ArgList[3])) { /* No problem. */ } if (perp && when_str) { howlong = time(NULL) - my_atol(when_str); put_it("%s %s %-25s set by %-10s %ld sec ago", banner(), channel, ban, perp, howlong); } else put_it("%s %s %s", banner(), channel, ban); break; } case 401: /* #define ERR_NOSUCHNICK 401 */ { const char *nick, *stuff; PasteArgs(ArgList, 1); if (!(nick = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } if (!(stuff = ArgList[1])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s: %s", banner(), nick, stuff); break; } case 219: /* #define RPL_ENDOFSTATS 219 */ case 232: /* #define RPL_ENDOFSERVICES 232 */ case 365: /* #define RPL_ENDOFLINKS 365 */ case 369: /* #define RPL_ENDOFWHOWAS 369 */ case 374: /* #define RPL_ENDOFINFO 374 */ case 394: /* #define RPL_ENDOFUSERS 394 */ { PasteArgs(ArgList, 0); if (get_int_var(SHOW_END_OF_MSGS_VAR)) display_msg(from, comm, ArgList); break; } case 471: /* #define ERR_CHANNELISFULL 471 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s (Channel is full)", banner(), message); break; } case 473: /* #define ERR_INVITEONLYCHAN 473 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s (You must be invited)", banner(), message); break; } case 474: /* #define ERR_BANNEDFROMCHAN 474 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s (You are banned)", banner(), message); break; } case 475: /* #define ERR_BADCHANNELKEY 475 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s (You must give the correct key)", banner(), message); break; } case 476: /* #define ERR_BADCHANMASK 476 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } put_it("%s %s (Bad channel mask)", banner(), message); break; } case 477: /* #define ERR_NEEDREGGEDNICK 477 */ { const char *message; PasteArgs(ArgList, 0); if (!(message = ArgList[0])) { rfc1459_odd(from, comm, ArgList); goto END; } /* IRCnet has a different 477 numeric. */ if (message && *message == '+') { display_msg(from, comm, ArgList); break; } PasteArgs(ArgList, 0); put_it("%s %s (You must use a registered nickname)", banner(), message); break; } default: display_msg(from, comm, ArgList); } END: /* * This is where we clean up after our numeric. Numeric-specific * cleanups can occur here, and then below we reset the display * settings. */ switch (numeric) { case 347: /* #define END_OF_INVITELIST */ case 349: /* #define END_OF_EXCEPTLIST */ case 368: number_of_bans = 0; break; case 464: /* #define ERR_PASSWDMISMATCH 464 */ { char server_num[8]; if (oper_command) oper_command = 0; else if (!is_server_registered(from_server)) { server_reconnects_to(from_server, NOSERV); say("Password required for connection to server %s", get_server_name(from_server)); if (!dumb_mode) { strlcpy(server_num, ltoa(from_server), sizeof server_num); add_wait_prompt("Server Password:", password_sendline, server_num, WAIT_PROMPT_LINE, 0); } } } } current_numeric = old_current_numeric; set_lastlog_msg_level(lastlog_level); message_from(NULL, LOG_CRAP); }
void inbound_notice (server * serv, char *to, char *nick, char *msg, char *ip, int id) { char *po, *ptr = to; session *sess = 0; int server_notice = FALSE; if (is_channel (serv, ptr)) sess = find_channel (serv, ptr); if (!sess && ptr[0] == '@') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '%') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '+') { ptr++; sess = find_channel (serv, ptr); } if (strcmp (nick, ip) == 0) server_notice = TRUE; if (!sess) { ptr = 0; /* paranoia check */ if (msg[0] == '[' && (!serv->have_idmsg || id)) { /* guess where a services bot meant to put this */ if (!find_dialog (serv, nick)) { char *dest = strdup (msg + 1); char *end = strchr (dest, ']'); if (end) { *end = 0; sess = find_channel (serv, dest); } free (dest); } } if (!sess) { if (server_notice) sess = serv->server_session; else sess = serv->front_session; } } if (msg[0] == 1) { msg++; if (!strncmp (msg, "PING", 4)) { inbound_ping_reply (sess, msg + 5, nick); return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (server_notice) EMIT_SIGNAL (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0); else if (ptr) EMIT_SIGNAL (XP_TE_CHANNOTICE, sess, nick, to, msg, NULL, 0); else EMIT_SIGNAL (XP_TE_NOTICE, sess, nick, msg, NULL, NULL, 0); }
void inbound_chanmsg (server *serv, char *chan, char *from, char *text, char fromme) { struct User *user; session *sess; int hilight = FALSE; char nickchar[2] = "\000"; if (chan) { sess = find_channel (serv, chan); if (!sess && !is_channel (serv, chan)) sess = find_dialog (serv, chan); } else { sess = find_dialog (serv, from); } if (!sess) return; if (sess != current_tab) { sess->msg_said = TRUE; sess->new_data = FALSE; } user = find_name (sess, from); if (user) { nickchar[0] = user->prefix[0]; user->lasttalk = time (0); } if (fromme) { if (prefs.auto_unmark_away && serv->is_away) sess->server->p_set_back (sess->server); EMIT_SIGNAL (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, 0); return; } if (sess->type != SESS_DIALOG) if (prefs.beepchans || sess->beep) fe_beep (); if (is_hilight (text, sess, serv)) { hilight = TRUE; if (prefs.beephilight) fe_beep (); } if (sess->type == SESS_DIALOG) EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, NULL, NULL, 0); else if (hilight) EMIT_SIGNAL (XP_TE_HCHANMSG, sess, from, text, nickchar, NULL, 0); else if (prefs.colorednicks) { char tbuf[NICKLEN + 4]; snprintf (tbuf, sizeof (tbuf), "\003%d%s", color_of (from), from); EMIT_SIGNAL (XP_TE_CHANMSG, sess, tbuf, text, nickchar, NULL, 0); } else EMIT_SIGNAL (XP_TE_CHANMSG, sess, from, text, nickchar, NULL, 0); }
void inbound_action (session *sess, char *chan, char *from, char *ip, char *text, int fromme, int id) { session *def = sess; server *serv = sess->server; struct User *user; char nickchar[2] = "\000"; char idtext[64]; int privaction = FALSE; if (!fromme) { if (is_channel (serv, chan)) { sess = find_channel (serv, chan); } else { /* it's a private action! */ privaction = TRUE; /* find a dialog tab for it */ sess = find_dialog (serv, from); /* if non found, open a new one */ if (!sess && prefs.hex_gui_autoopen_dialog) { /* but only if it wouldn't flood */ if (flood_check (from, ip, serv, current_sess, 1)) sess = inbound_open_dialog (serv, from); else sess = serv->server_session; } if (!sess) { sess = find_session_from_nick (from, serv); /* still not good? */ if (!sess) sess = serv->front_session; } } } if (!sess) sess = def; if (sess != current_tab) { if (fromme) { sess->msg_said = FALSE; sess->new_data = TRUE; } else { sess->msg_said = TRUE; sess->new_data = FALSE; } } user = userlist_find (sess, from); if (user) { nickchar[0] = user->prefix[0]; user->lasttalk = time (0); } inbound_make_idtext (serv, idtext, sizeof (idtext), id); if (!fromme && !privaction) { if (is_hilight (from, text, sess, serv)) { EMIT_SIGNAL (XP_TE_HCHANACTION, sess, from, text, nickchar, idtext, 0); return; } } if (fromme) EMIT_SIGNAL (XP_TE_UACTION, sess, from, text, nickchar, idtext, 0); else if (!privaction) EMIT_SIGNAL (XP_TE_CHANACTION, sess, from, text, nickchar, idtext, 0); else if (sess->type == SESS_DIALOG) EMIT_SIGNAL (XP_TE_DPRIVACTION, sess, from, text, idtext, NULL, 0); else EMIT_SIGNAL (XP_TE_PRIVACTION, sess, from, text, idtext, NULL, 0); }
static void process_numeric (session * sess, int n, char *word[], char *word_eol[], char *text) { server *serv = sess->server; /* show whois is the server tab */ session *whois_sess = serv->server_session; /* unless this setting is on */ if (prefs.irc_whois_front) whois_sess = serv->front_session; switch (n) { case 1: inbound_login_start (sess, word[3], word[1]); /* if network is PTnet then you must get your IP address from "001" server message */ if ((strncmp(word[7], "PTnet", 5) == 0) && (strncmp(word[8], "IRC", 3) == 0) && (strncmp(word[9], "Network", 7) == 0) && (strrchr(word[10], '@') != NULL)) { serv->use_who = FALSE; if (prefs.ip_from_server) inbound_foundip (sess, strrchr(word[10], '@')+1); } /* use /NICKSERV */ if (strcasecmp (word[7], "DALnet") == 0 || strcasecmp (word[7], "BRASnet") == 0) serv->nickservtype = 1; /* use /NS */ else if (strcasecmp (word[7], "FreeNode") == 0) serv->nickservtype = 2; goto def; case 4: /* check the ircd type */ serv->use_listargs = FALSE; serv->modes_per_line = 3; /* default to IRC RFC */ if (strncmp (word[5], "bahamut", 7) == 0) /* DALNet */ { serv->use_listargs = TRUE; /* use the /list args */ } else if (strncmp (word[5], "u2.10.", 6) == 0) /* Undernet */ { serv->use_listargs = TRUE; /* use the /list args */ serv->modes_per_line = 6; /* allow 6 modes per line */ } else if (strncmp (word[5], "glx2", 4) == 0) { serv->use_listargs = TRUE; /* use the /list args */ } goto def; case 5: inbound_005 (serv, word); goto def; case 263: /*Server load is temporarily too heavy */ if (fe_is_chanwindow (sess->server)) { fe_chan_list_end (sess->server); fe_message (word_eol[5] + 1, FE_MSG_ERROR); } goto def; case 290: /* CAPAB reply */ if (strstr (word_eol[1], "IDENTIFY-MSG")) { serv->have_idmsg = TRUE; break; } goto def; case 301: inbound_away (serv, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5]); break; case 302: if (serv->skip_next_userhost) { char *eq = strchr (word[4], '='); if (eq) { *eq = 0; if (!serv->p_cmp (word[4] + 1, serv->nick)) { char *at = strrchr (eq + 1, '@'); if (at) inbound_foundip (sess, at + 1); } } serv->skip_next_userhost = FALSE; break; } else goto def; case 303: word[4]++; notify_markonline (serv, word); break; case 305: inbound_uback (serv); goto def; case 306: inbound_uaway (serv); goto def; case 312: if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS3, whois_sess, word[4], word_eol[5], NULL, NULL, 0); else inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, 0xff); break; case 311: /* WHOIS 1st line */ serv->inside_whois = 1; inbound_user_info_start (sess, word[4]); if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS1, whois_sess, word[4], word[5], word[6], word_eol[8] + 1, 0); else inbound_user_info (sess, NULL, word[5], word[6], NULL, word[4], word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], 0xff); break; case 314: /* WHOWAS */ inbound_user_info_start (sess, word[4]); EMIT_SIGNAL (XP_TE_WHOIS1, whois_sess, word[4], word[5], word[6], word_eol[8] + 1, 0); break; case 317: if (!serv->skip_next_whois) { time_t timestamp = (time_t) atol (word[6]); long idle = atol (word[5]); char *tim; char outbuf[64]; snprintf (outbuf, sizeof (outbuf), "%02ld:%02ld:%02ld", idle / 3600, (idle / 60) % 60, idle % 60); if (timestamp == 0) EMIT_SIGNAL (XP_TE_WHOIS4, whois_sess, word[4], outbuf, NULL, NULL, 0); else { tim = ctime (×tamp); tim[19] = 0; /* get rid of the \n */ EMIT_SIGNAL (XP_TE_WHOIS4T, whois_sess, word[4], outbuf, tim, NULL, 0); } } break; case 318: /* END OF WHOIS */ if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS6, whois_sess, word[4], NULL, NULL, NULL, 0); serv->skip_next_whois = 0; serv->inside_whois = 0; break; case 313: case 319: if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS2, whois_sess, word[4], word_eol[5] + 1, NULL, NULL, 0); break; case 307: /* dalnet version */ case 320: /* :is an identified user */ if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS_ID, whois_sess, word[4], word_eol[5] + 1, NULL, NULL, 0); break; case 321: if (!fe_is_chanwindow (sess->server)) EMIT_SIGNAL (XP_TE_CHANLISTHEAD, serv->server_session, NULL, NULL, NULL, NULL, 0); break; case 322: if (fe_is_chanwindow (sess->server)) { fe_add_chan_list (sess->server, word[4], word[5], word_eol[6] + 1); } else { PrintTextf (serv->server_session, "%-16s %-7d %s\017\n", word[4], atoi (word[5]), word_eol[6] + 1); } break; case 323: if (!fe_is_chanwindow (sess->server)) EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); else fe_chan_list_end (sess->server); break; case 324: sess = find_channel (serv, word[4]); if (!sess) sess = serv->server_session; if (sess->ignore_mode) sess->ignore_mode = FALSE; else EMIT_SIGNAL (XP_TE_CHANMODES, sess, word[4], word_eol[5], NULL, NULL, 0); fe_update_mode_buttons (sess, 't', '-'); fe_update_mode_buttons (sess, 'n', '-'); fe_update_mode_buttons (sess, 's', '-'); fe_update_mode_buttons (sess, 'i', '-'); fe_update_mode_buttons (sess, 'p', '-'); fe_update_mode_buttons (sess, 'm', '-'); fe_update_mode_buttons (sess, 'l', '-'); fe_update_mode_buttons (sess, 'k', '-'); handle_mode (serv, word, word_eol, "", TRUE); break; case 329: sess = find_channel (serv, word[4]); if (sess) { if (sess->ignore_date) sess->ignore_date = FALSE; else channel_date (sess, word[4], word[5]); } break; case 330: if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS_AUTH, whois_sess, word[4], word_eol[6] + 1, word[5], NULL, 0); break; case 332: inbound_topic (serv, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5]); break; case 333: inbound_topictime (serv, word[4], word[5], atol (word[6])); break; #if 0 case 338: /* Undernet Real user@host, Real IP */ EMIT_SIGNAL (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6], (word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7], 0); break; #endif case 341: /* INVITE ACK */ EMIT_SIGNAL (XP_TE_UINVITE, sess, word[4], word[5], serv->servername, NULL, 0); break; case 352: /* WHO */ { unsigned int away = 0; session *who_sess = find_channel (serv, word[4]); if (*word[9] == 'G') away = 1; inbound_user_info (sess, word[4], word[5], word[6], word[7], word[8], word_eol[11], away); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); } break; case 354: /* undernet WHOX: used as a reply for irc_away_status */ { unsigned int away = 0; session *who_sess; /* irc_away_status sends out a "152" */ if (!strcmp (word[4], "152")) { who_sess = find_channel (serv, word[5]); if (*word[7] == 'G') away = 1; /* :SanJose.CA.us.undernet.org 354 z1 152 #zed1 z1 H@ */ inbound_user_info (sess, word[5], 0, 0, 0, word[6], 0, away); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); } else goto def; } break; case 315: /* END OF WHO */ { session *who_sess; who_sess = find_channel (serv, word[4]); if (who_sess) { if (!who_sess->doing_who) EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); who_sess->doing_who = FALSE; } else { if (!serv->doing_dns) EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); serv->doing_dns = FALSE; } } break; case 348: /* +e-list entry */ if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], TRUE)) goto def; break; case 349: /* end of exemption list */ sess = find_channel (serv, word[4]); if (!sess) { sess = serv->front_session; goto def; } if (!fe_is_banwindow (sess)) goto def; fe_ban_list_end (sess, TRUE); break; case 353: /* NAMES */ inbound_nameslist (serv, word[5], (word_eol[6][0] == ':') ? word_eol[6] + 1 : word_eol[6]); break; case 366: if (!inbound_nameslist_end (serv, word[4])) goto def; break; case 367: /* banlist entry */ inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], FALSE); break; case 368: sess = find_channel (serv, word[4]); if (!sess) { sess = serv->front_session; goto def; } if (!fe_is_banwindow (sess)) goto def; fe_ban_list_end (sess, FALSE); break; case 369: /* WHOWAS end */ case 406: /* WHOWAS error */ EMIT_SIGNAL (XP_TE_SERVTEXT, whois_sess, text, word[1], word[2], NULL, 0); serv->inside_whois = 0; break; case 372: /* motd text */ case 375: /* motd start */ if (!prefs.skipmotd || serv->motd_skipped) EMIT_SIGNAL (XP_TE_MOTD, serv->server_session, text, NULL, NULL, NULL, 0); break; case 376: /* end of motd */ case 422: /* motd file is missing */ inbound_login_end (sess, text); break; case 433: /* nickname in use */ case 432: /* erroneous nickname */ if (serv->end_of_motd) goto def; inbound_next_nick (sess, word[4]); break; case 437: if (serv->end_of_motd || is_channel (serv, word[4])) goto def; inbound_next_nick (sess, word[4]); break; case 471: EMIT_SIGNAL (XP_TE_USERLIMIT, sess, word[4], NULL, NULL, NULL, 0); break; case 473: EMIT_SIGNAL (XP_TE_INVITE, sess, word[4], NULL, NULL, NULL, 0); break; case 474: EMIT_SIGNAL (XP_TE_BANNED, sess, word[4], NULL, NULL, NULL, 0); break; case 475: EMIT_SIGNAL (XP_TE_KEYWORD, sess, word[4], NULL, NULL, NULL, 0); break; case 601: notify_set_offline (serv, word[4], FALSE); break; case 605: notify_set_offline (serv, word[4], TRUE); break; case 600: case 604: notify_set_online (serv, word[4]); break; default: if (serv->inside_whois && word[4][0]) { /* some unknown WHOIS reply, ircd coders make them up weekly */ if (!serv->skip_next_whois) EMIT_SIGNAL (XP_TE_WHOIS_SPECIAL, whois_sess, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], word[2], NULL, 0); return; } def: if (is_channel (serv, word[4])) { session *realsess = find_channel (serv, word[4]); if (!realsess) realsess = serv->server_session; EMIT_SIGNAL (XP_TE_SERVTEXT, realsess, text, word[1], word[2], NULL, 0); } else { EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); } } }
void parse_notice(char *from, char **Args) { int type; char *to, *high = empty_string, *target, *line; NickList *nick = NULL; ChannelList *tmpc = NULL; char *newline = NULL; PasteArgs(Args, 1); to = Args[0]; line = Args[1]; if (!to || !line) return; if (!*to) { put_it("*** obsolete notice recieved. [%s]", line+1); return; } if (!from || !*from || !strcmp(get_server_itsname(from_server), from)) { parse_server_notice(from, line); return; } if (is_channel(to)) { target = to; type = PUBLIC_NOTICE_LIST; if ((tmpc = lookup_channel(to, from_server, CHAN_NOUNLINK))) nick = find_nicklist_in_channellist(from, tmpc, 0); } else { target = from; type = NOTICE_LIST; } update_stats(NOTICELIST, to, nick, tmpc, 0); set_display_target(target, LOG_NOTICE); doing_notice = 1; if ((check_ignore_notice(from, to, IGNORE_NOTICES, line, &high) == IGNORED)) goto notice_cleanup; if (!check_flooding(from, NOTICE_FLOOD, line, NULL)) goto notice_cleanup; if (!strchr(from, '.')) { notify_mark(from, FromUserHost, 1, 0); line = do_notice_ctcp(from, to, line); if (!*line) goto notice_cleanup; } if (sed && !do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, to, line)) { #if 0 put_it("%s", convert_output_format(fget_string_var(FORMAT_ENCRYPTED_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, line)); #endif sed = 0; goto notice_cleanup; } { char *free_me = NULL; char *s; free_me = newline = stripansi(line); if (wild_match("[*Wall*", line)) { char *channel = NULL, *p, *q; q = p = next_arg(newline, &newline); if ((p = strchr(p, '/'))) { p++; if (*p && *p == '\002') p++; channel = m_strdup(p); if ((p = strchr(channel, ']'))) *p++ = 0; q = channel; if (*q && q[strlen(q)-1] == '\002') q[strlen(q)-1] = 0; } if (channel && *channel) set_display_target(channel, LOG_WALL); else set_display_target(target, LOG_WALL); if (do_hook(type, "%s %s", from, line)) { s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), q, from, FromUserHost, newline); if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); put_it("%s", s); } add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line); logmsg(LOG_WALL, from, 0, "%s", line); /* addtabkey(from, "wall", 0);*/ new_free(&channel); } else { if (type == PUBLIC_NOTICE_LIST) { s = convert_output_format(fget_string_var(check_auto_reply(line)?FORMAT_PUBLIC_NOTICE_AR_FSET:FORMAT_PUBLIC_NOTICE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, newline); if (do_hook(type, "%s %s %s", from, to, line)) put_it("%s", s); } else { s = convert_output_format(fget_string_var(FORMAT_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, newline); if (do_hook(type, "%s %s", from, line)) put_it("%s", s); } if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); logmsg(LOG_NOTICE, from, 0, "%s", line); add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line); } new_free(&free_me); } notice_cleanup: if (beep_on_level & LOG_NOTICE) beep_em(1); reset_display_target(); doing_notice = 0; }
static void inbound_privmsg_helper(char *nickchar, char *prefixchar, char *idtext, int *is_highlight, msg_destination *action_type, session **initial_session, server *serv, char **chan, char *from, char *ip, char *text, int *from_me, int *id, const message_tags_data *tags_data) { struct User *user; session *sess = *initial_session; if (*from_me && sess == NULL) { *action_type = MSGDEST_DIRECT; sess = serv->front_session; } else if (*chan && is_channel (serv, *chan)) { *action_type = MSGDEST_CHANNEL; sess = find_channel (serv, *chan); } else if (*chan && strchr(serv->nick_prefixes, **chan) && is_channel (serv, *chan + 1)) { *action_type = MSGDEST_PREFIX; prefixchar[0] = **chan; ++*chan; sess = find_channel (serv, *chan); } else { char *target = *from_me ? *chan : from; session *userquery = find_dialog (serv, target); if (!userquery) { if (prefs.hex_gui_autoopen_dialog && flood_check (target, ip, serv, current_sess, 1)) { *action_type = MSGDEST_PRIVATE; sess = inbound_open_dialog (serv, target, tags_data); } else { *action_type = MSGDEST_DIRECT; sess = serv->front_session; } } else { *action_type = MSGDEST_PRIVATE; sess = userquery; } } *is_highlight = is_hilight (from, text, sess, serv); if (sess != current_tab) { if (*from_me) { sess->msg_said = FALSE; sess->new_data = TRUE; } else { sess->msg_said = TRUE; sess->new_data = FALSE; } lastact_update (sess); } user = userlist_find (sess, from); if (user) { nickchar[0] = user->prefix[0]; user->lasttalk = time (0); if (user->account) *id = TRUE; if (user->me) *from_me = TRUE; } inbound_make_idtext (serv, idtext, sizeof (idtext), *id); *initial_session = sess; }
static void process_numeric (session * sess, int n, char *word[], char *word_eol[], char *text, const message_tags_data *tags_data) { server *serv = sess->server; /* show whois is the server tab */ session *whois_sess = serv->server_session; /* unless this setting is on */ if (prefs.hex_irc_whois_front) whois_sess = serv->front_session; switch (n) { case 1: inbound_login_start (sess, word[3], word[1], tags_data); /* if network is PTnet then you must get your IP address from "001" server message */ if ((strncmp(word[7], "PTnet", 5) == 0) && (strncmp(word[8], "IRC", 3) == 0) && (strncmp(word[9], "Network", 7) == 0) && (strrchr(word[10], '@') != NULL)) { serv->use_who = FALSE; if (prefs.hex_dcc_ip_from_server) inbound_foundip (sess, strrchr(word[10], '@')+1, tags_data); } goto def; case 4: /* check the ircd type */ serv->use_listargs = FALSE; serv->modes_per_line = 3; /* default to IRC RFC */ if (strncmp (word[5], "bahamut", 7) == 0) /* DALNet */ { serv->use_listargs = TRUE; /* use the /list args */ } else if (strncmp (word[5], "u2.10.", 6) == 0) /* Undernet */ { serv->use_listargs = TRUE; /* use the /list args */ serv->modes_per_line = 6; /* allow 6 modes per line */ } else if (strncmp (word[5], "glx2", 4) == 0) { serv->use_listargs = TRUE; /* use the /list args */ } goto def; case 5: inbound_005 (serv, word, tags_data); goto def; case 263: /*Server load is temporarily too heavy */ if (fe_is_chanwindow (sess->server)) { fe_chan_list_end (sess->server); fe_message (word_eol[4], FE_MSG_ERROR); } goto def; case 301: inbound_away (serv, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], tags_data); break; case 302: if (serv->skip_next_userhost) { char *eq = strchr (word[4], '='); if (eq) { *eq = 0; if (!serv->p_cmp (word[4] + 1, serv->nick)) { char *at = strrchr (eq + 1, '@'); if (at) inbound_foundip (sess, at + 1, tags_data); } } serv->skip_next_userhost = FALSE; break; } else goto def; case 303: word[4]++; notify_markonline (serv, word, tags_data); break; case 305: inbound_uback (serv, tags_data); goto def; case 306: inbound_uaway (serv, tags_data); goto def; case 312: if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS3, whois_sess, word[4], word_eol[5], NULL, NULL, 0, tags_data->timestamp); else inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, NULL, 0xff, tags_data); break; case 311: /* WHOIS 1st line */ serv->inside_whois = 1; inbound_user_info_start (sess, word[4], tags_data); if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS1, whois_sess, word[4], word[5], word[6], word_eol[8] + 1, 0, tags_data->timestamp); else inbound_user_info (sess, NULL, word[5], word[6], NULL, word[4], word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], NULL, 0xff, tags_data); break; case 314: /* WHOWAS */ inbound_user_info_start (sess, word[4], tags_data); EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS1, whois_sess, word[4], word[5], word[6], word_eol[8] + 1, 0, tags_data->timestamp); break; case 317: if (!serv->skip_next_whois) { time_t timestamp = (time_t) atol (word[6]); long idle = atol (word[5]); char *tim; char outbuf[64]; snprintf (outbuf, sizeof (outbuf), "%02ld:%02ld:%02ld", idle / 3600, (idle / 60) % 60, idle % 60); if (timestamp == 0) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS4, whois_sess, word[4], outbuf, NULL, NULL, 0, tags_data->timestamp); else { tim = ctime (×tamp); tim[19] = 0; /* get rid of the \n */ EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS4T, whois_sess, word[4], outbuf, tim, NULL, 0, tags_data->timestamp); } } break; case 318: /* END OF WHOIS */ if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS6, whois_sess, word[4], NULL, NULL, NULL, 0, tags_data->timestamp); serv->skip_next_whois = 0; serv->inside_whois = 0; break; case 313: case 319: if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS2, whois_sess, word[4], word_eol[5] + 1, NULL, NULL, 0, tags_data->timestamp); break; case 307: /* dalnet version */ case 320: /* :is an identified user */ if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_ID, whois_sess, word[4], word_eol[5] + 1, NULL, NULL, 0, tags_data->timestamp); break; case 321: if (!fe_is_chanwindow (sess->server)) EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANLISTHEAD, serv->server_session, NULL, NULL, NULL, NULL, 0, tags_data->timestamp); break; case 322: if (fe_is_chanwindow (sess->server)) { fe_add_chan_list (sess->server, word[4], word[5], word_eol[6] + 1); } else { PrintTextTimeStampf (serv->server_session, tags_data->timestamp, "%-16s %-7d %s\017\n", word[4], atoi (word[5]), word_eol[6] + 1); } break; case 323: if (!fe_is_chanwindow (sess->server)) EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0, tags_data->timestamp); else fe_chan_list_end (sess->server); break; case 324: sess = find_channel (serv, word[4]); if (!sess) sess = serv->server_session; if (sess->ignore_mode) sess->ignore_mode = FALSE; else EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANMODES, sess, word[4], word_eol[5], NULL, NULL, 0, tags_data->timestamp); fe_update_mode_buttons (sess, 'c', '-'); fe_update_mode_buttons (sess, 'r', '-'); fe_update_mode_buttons (sess, 't', '-'); fe_update_mode_buttons (sess, 'n', '-'); fe_update_mode_buttons (sess, 'i', '-'); fe_update_mode_buttons (sess, 'm', '-'); fe_update_mode_buttons (sess, 'l', '-'); fe_update_mode_buttons (sess, 'k', '-'); handle_mode (serv, word, word_eol, "", TRUE, tags_data); break; case 328: /* channel url */ sess = find_channel (serv, word[4]); if (sess) { EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANURL, sess, word[4], word[5] + 1, NULL, NULL, 0, tags_data->timestamp); } break; case 329: sess = find_channel (serv, word[4]); if (sess) { if (sess->ignore_date) sess->ignore_date = FALSE; else channel_date (sess, word[4], word[5], tags_data); } break; case 330: if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_AUTH, whois_sess, word[4], word_eol[6] + 1, word[5], NULL, 0, tags_data->timestamp); inbound_user_info (sess, NULL, NULL, NULL, NULL, word[4], NULL, word[5], 0xff, tags_data); break; case 332: inbound_topic (serv, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], tags_data); break; case 333: inbound_topictime (serv, word[4], word[5], atol (word[6]), tags_data); break; #if 0 case 338: /* Undernet Real user@host, Real IP */ EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6], (word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7], 0, tags_data->timestamp); break; #endif case 341: /* INVITE ACK */ EMIT_SIGNAL_TIMESTAMP (XP_TE_UINVITE, sess, word[4], word[5], serv->servername, NULL, 0, tags_data->timestamp); break; case 352: /* WHO */ { unsigned int away = 0; session *who_sess = find_channel (serv, word[4]); if (*word[9] == 'G') away = 1; inbound_user_info (sess, word[4], word[5], word[6], word[7], word[8], word_eol[11], NULL, away, tags_data); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0, tags_data->timestamp); } break; case 354: /* undernet WHOX: used as a reply for irc_away_status */ { unsigned int away = 0; session *who_sess; /* irc_away_status and irc_user_list sends out a "152" */ if (!strcmp (word[4], "152")) { who_sess = find_channel (serv, word[5]); if (*word[10] == 'G') away = 1; /* :server 354 yournick 152 #channel ~ident host servname nick H account :realname */ inbound_user_info (sess, word[5], word[6], word[7], word[8], word[9], word_eol[12]+1, word[11], away, tags_data); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0, tags_data->timestamp); } else goto def; } break; case 315: /* END OF WHO */ { session *who_sess; who_sess = find_channel (serv, word[4]); if (who_sess) { if (!who_sess->doing_who) EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0, tags_data->timestamp); who_sess->doing_who = FALSE; } else { if (!serv->doing_dns) EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0, tags_data->timestamp); serv->doing_dns = FALSE; } } break; case 346: /* +I-list entry */ if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346, tags_data)) goto def; break; case 347: /* end of invite list */ if (!fe_ban_list_end (sess, 347)) goto def; break; case 348: /* +e-list entry */ if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348, tags_data)) goto def; break; case 349: /* end of exemption list */ sess = find_channel (serv, word[4]); if (!sess) { sess = serv->front_session; goto def; } if (!fe_ban_list_end (sess, 349)) goto def; break; case 353: /* NAMES */ inbound_nameslist (serv, word[5], (word_eol[6][0] == ':') ? word_eol[6] + 1 : word_eol[6], tags_data); break; case 366: if (!inbound_nameslist_end (serv, word[4], tags_data)) goto def; break; case 367: /* banlist entry */ if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367, tags_data)) goto def; break; case 368: sess = find_channel (serv, word[4]); if (!sess) { sess = serv->front_session; goto def; } if (!fe_ban_list_end (sess, 368)) goto def; break; case 369: /* WHOWAS end */ case 406: /* WHOWAS error */ EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, whois_sess, text, word[1], word[2], NULL, 0, tags_data->timestamp); serv->inside_whois = 0; break; case 372: /* motd text */ case 375: /* motd start */ if (!prefs.hex_irc_skip_motd || serv->motd_skipped) EMIT_SIGNAL_TIMESTAMP (XP_TE_MOTD, serv->server_session, text, NULL, NULL, NULL, 0, tags_data->timestamp); break; case 376: /* end of motd */ case 422: /* motd file is missing */ inbound_login_end (sess, text, tags_data); break; case 432: /* erroneous nickname */ if (serv->end_of_motd) { goto def; } inbound_next_nick (sess, word[4], 1, tags_data); break; case 433: /* nickname in use */ if (serv->end_of_motd) { goto def; } inbound_next_nick (sess, word[4], 0, tags_data); break; case 437: if (serv->end_of_motd || is_channel (serv, word[4])) goto def; inbound_next_nick (sess, word[4], 0, tags_data); break; case 471: EMIT_SIGNAL_TIMESTAMP (XP_TE_USERLIMIT, sess, word[4], NULL, NULL, NULL, 0, tags_data->timestamp); break; case 473: EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITE, sess, word[4], NULL, NULL, NULL, 0, tags_data->timestamp); break; case 474: EMIT_SIGNAL_TIMESTAMP (XP_TE_BANNED, sess, word[4], NULL, NULL, NULL, 0, tags_data->timestamp); break; case 475: EMIT_SIGNAL_TIMESTAMP (XP_TE_KEYWORD, sess, word[4], NULL, NULL, NULL, 0, tags_data->timestamp); break; case 601: notify_set_offline (serv, word[4], FALSE, tags_data); break; case 605: notify_set_offline (serv, word[4], TRUE, tags_data); break; case 600: case 604: notify_set_online (serv, word[4], tags_data); break; case 728: /* +q-list entry */ /* NOTE: FREENODE returns these results inconsistent with e.g. +b */ /* Who else has imlemented MODE_QUIET, I wonder? */ if (!inbound_banlist (sess, atol (word[8]), word[4], word[6], word[7], 728, tags_data)) goto def; break; case 729: /* end of quiet list */ if (!fe_ban_list_end (sess, 729)) goto def; break; case 730: /* RPL_MONONLINE */ notify_set_online_list (serv, word[4] + 1, tags_data); break; case 731: /* RPL_MONOFFLINE */ notify_set_offline_list (serv, word[4] + 1, FALSE, tags_data); break; case 900: /* successful SASL 'logged in as ' */ EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, word_eol[6]+1, word[1], word[2], NULL, 0, tags_data->timestamp); break; case 903: /* successful SASL auth */ case 904: /* failed SASL auth */ if (inbound_sasl_error (serv)) break; /* might retry */ case 905: /* failed SASL auth */ case 906: /* aborted */ case 907: /* attempting to re-auth after a successful auth */ EMIT_SIGNAL_TIMESTAMP (XP_TE_SASLRESPONSE, serv->server_session, word[1], word[2], word[3], ++word_eol[4], 0, tags_data->timestamp); if (!serv->sent_capend) { serv->sent_capend = TRUE; tcp_send_len (serv, "CAP END\r\n", 9); } break; case 908: /* Supported SASL Mechs */ inbound_sasl_supportedmechs (serv, word[4]); break; default: if (serv->inside_whois && word[4][0]) { /* some unknown WHOIS reply, ircd coders make them up weekly */ if (!serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_SPECIAL, whois_sess, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], word[2], NULL, 0, tags_data->timestamp); return; } def: { session *sess; if (is_channel (serv, word[4])) { sess = find_channel (serv, word[4]); if (!sess) sess = serv->server_session; } else if ((sess=find_dialog (serv,word[4]))) /* user with an open dialog */ ; else sess=serv->server_session; EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, sess, text, word[1], word[2], NULL, 0, tags_data->timestamp); } } }
static void handle_single_mode (mode_run *mr, char sign, char mode, char *nick, char *chan, char *arg, int quiet, int is_324) { session *sess; server *serv = mr->serv; char outbuf[4]; char *cm = serv->chanmodes; gboolean supportsq = FALSE; outbuf[0] = sign; outbuf[1] = 0; outbuf[2] = mode; outbuf[3] = 0; sess = find_channel (serv, chan); if (!sess || !is_channel (serv, chan)) { /* got modes for a chan we're not in! probably nickmode +isw etc */ sess = serv->front_session; goto genmode; } /* is this a nick mode? */ if (strchr (serv->nick_modes, mode)) { /* update the user in the userlist */ userlist_update_mode (sess, /*nickname */ arg, mode, sign); } else { if (!is_324 && !sess->ignore_mode && mode_chanmode_type(serv, mode) >= 1) record_chan_mode (sess, sign, mode, arg); } /* Is q a chanmode on this server? */ if (cm) while (*cm) { if (*cm == ',') break; if (*cm == 'q') supportsq = TRUE; cm++; } switch (sign) { case '+': switch (mode) { case 'k': safe_strcpy (sess->channelkey, arg, sizeof (sess->channelkey)); fe_update_channel_key (sess); fe_update_mode_buttons (sess, mode, sign); if (!quiet) EMIT_SIGNAL (XP_TE_CHANSETKEY, sess, nick, arg, NULL, NULL, 0); return; case 'l': sess->limit = atoi (arg); fe_update_channel_limit (sess); fe_update_mode_buttons (sess, mode, sign); if (!quiet) EMIT_SIGNAL (XP_TE_CHANSETLIMIT, sess, nick, arg, NULL, NULL, 0); return; case 'o': if (!quiet) mr->op = mode_cat (mr->op, arg); return; case 'h': if (!quiet) EMIT_SIGNAL (XP_TE_CHANHOP, sess, nick, arg, NULL, NULL, 0); return; case 'v': if (!quiet) mr->voice = mode_cat (mr->voice, arg); return; case 'b': if (!quiet) EMIT_SIGNAL (XP_TE_CHANBAN, sess, nick, arg, NULL, NULL, 0); return; case 'e': if (!quiet) EMIT_SIGNAL (XP_TE_CHANEXEMPT, sess, nick, arg, NULL, NULL, 0); return; case 'I': if (!quiet) EMIT_SIGNAL (XP_TE_CHANINVITE, sess, nick, arg, NULL, NULL, 0); return; case 'q': if (!supportsq) break; /* +q is owner on this server */ if (!quiet) EMIT_SIGNAL (XP_TE_CHANQUIET, sess, nick, arg, NULL, NULL, 0); return; } break; case '-': switch (mode) { case 'k': sess->channelkey[0] = 0; fe_update_channel_key (sess); fe_update_mode_buttons (sess, mode, sign); if (!quiet) EMIT_SIGNAL (XP_TE_CHANRMKEY, sess, nick, NULL, NULL, NULL, 0); return; case 'l': sess->limit = 0; fe_update_channel_limit (sess); fe_update_mode_buttons (sess, mode, sign); if (!quiet) EMIT_SIGNAL (XP_TE_CHANRMLIMIT, sess, nick, NULL, NULL, NULL, 0); return; case 'o': if (!quiet) mr->deop = mode_cat (mr->deop, arg); return; case 'h': if (!quiet) EMIT_SIGNAL (XP_TE_CHANDEHOP, sess, nick, arg, NULL, NULL, 0); return; case 'v': if (!quiet) mr->devoice = mode_cat (mr->devoice, arg); return; case 'b': if (!quiet) EMIT_SIGNAL (XP_TE_CHANUNBAN, sess, nick, arg, NULL, NULL, 0); return; case 'e': if (!quiet) EMIT_SIGNAL (XP_TE_CHANRMEXEMPT, sess, nick, arg, NULL, NULL, 0); return; case 'I': if (!quiet) EMIT_SIGNAL (XP_TE_CHANRMINVITE, sess, nick, arg, NULL, NULL, 0); return; case 'q': if (!supportsq) break; /* -q is owner on this server */ if (!quiet) EMIT_SIGNAL (XP_TE_CHANUNQUIET, sess, nick, arg, NULL, NULL, 0); return; } } fe_update_mode_buttons (sess, mode, sign); genmode: /* Received umode +e. If we're waiting to send JOIN then send now! */ if (mode == 'e' && sign == '+' && !serv->p_cmp (chan, serv->nick)) inbound_identified (serv); if (!quiet) { if (*arg) { char *buf = malloc (strlen (chan) + strlen (arg) + 2); sprintf (buf, "%s %s", chan, arg); EMIT_SIGNAL (XP_TE_CHANMODEGEN, sess, nick, outbuf, outbuf + 2, buf, 0); free (buf); } else EMIT_SIGNAL (XP_TE_CHANMODEGEN, sess, nick, outbuf, outbuf + 2, chan, 0); } }
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip) { char *po,*ptr=to; session *sess = 0; int server_notice = FALSE; if (is_channel (serv, ptr)) sess = find_channel (serv, ptr); if (!sess && ptr[0] == '@') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '+') { ptr++; sess = find_channel (serv, ptr); } if (strcmp (nick, ip) == 0) server_notice = TRUE; if (!sess) { ptr = 0; if (prefs.notices_tabs) { int stype = server_notice ? SESS_SNOTICES : SESS_NOTICES; sess = find_session_from_type (stype, serv); if (!sess) { register unsigned int oldh = prefs.hideuserlist; prefs.hideuserlist = 1; if (stype == SESS_NOTICES) sess = new_ircwindow (serv, "(notices)", SESS_NOTICES); else sess = new_ircwindow (serv, "(snotices)", SESS_SNOTICES); prefs.hideuserlist = oldh; fe_set_channel (sess); fe_set_title (sess); fe_set_nonchannel (sess, FALSE); clear_user_list (sess); if (prefs.logging) log_open (sess); } /* Avoid redundancy with some Undernet notices */ if (!strncmp (msg, "*** Notice -- ", 14)) msg += 14; } else { sess = find_session_from_nick (nick, serv); } if (!sess) { if (server_notice) sess = serv->server_session; else sess = serv->front_session; } } if (msg[0] == 1) { msg++; if (!strncmp (msg, "PING", 4)) { inbound_ping_reply (sess, msg + 5, nick); return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (server_notice) EMIT_SIGNAL (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0); else if (ptr) EMIT_SIGNAL (XP_TE_CHANNOTICE, sess, nick, to, msg, NULL, 0); else EMIT_SIGNAL (XP_TE_NOTICE, sess, nick, msg, NULL, NULL, 0); }
/* * numbered_command: does (hopefully) the right thing with the numbered * responses from the server. I wasn't real careful to be sure I got them * all, but the default case should handle any I missed (sorry) */ void numbered_command(u_char *from, int comm, u_char **ArgList) { u_char *user; u_char none_of_these = 0; u_char blah[BIG_BUFFER_SIZE]; int flag, lastlog_level; const int from_server = parsing_server(); #if 0 int user_cnt, inv_cnt, server_cnt; #endif /* 0 */ if (!from || !*from) return; if (!*ArgList[0]) user = NULL; else user = ArgList[0]; if (!ArgList[1]) return; lastlog_level = set_lastlog_msg_level(LOG_CRAP); save_message_from(); message_from(NULL, LOG_CRAP); ArgList++; current_numeric_local = -comm; /* must be negative of numeric! */ switch (comm) { case 001: /* #define RPL_WELCOME 001 */ PasteArgs(ArgList, 0); if (my_strcmp(user, server_get_nickname(from_server)) != 0) { yell("=== Setting this servers nickname to \"%s\" from \"%s\"", user, server_get_nickname(from_server)); server_set_nickname(from_server, user); } if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); clean_whois_queue(); break; case 002: /* #define RPL_YOURHOST 002 */ PasteArgs(ArgList, 0); snprintf(CP(blah), sizeof blah, "*** %s", ArgList[0]); got_initial_version(blah); if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); break; /* should do something with this some day, 2.8 had channel/user mode switches */ case 004: /* #define RPL_MYINFO 004 */ PasteArgs(ArgList, 0); if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); break; /* * this part of ircii has been broken for most of ircd 2.7, so someday I'll * make it work for ircd 2.8 ... phone.. */ #if 0 case 251: /* #define RPL_LUSERCLIENT 251 */ display_msg(from, ArgList); if (is_server_connected(from_server)) break; if (from_server == get_primary_server() && ((sscanf(ArgList[1], "There are %d users and %d invisible on %d servers", &user_cnt, &inv_cnt, &server_cnt) == 3)||(sscanf(ArgList[1], "There are %d users and %d invisible on %d servers", &user_cnt, &inv_cnt, &server_cnt) == 3))) { user_cnt =+ inv_cnt; if ((server_cnt < get_int_var(MINIMUM_SERVERS_VAR)) || (user_cnt < get_int_var(MINIMUM_USERS_VAR))) { say("Trying better populated server..."); get_connected(from_server + 1); } } break; #endif /* 0 */ case 301: /* #define RPL_AWAY 301 */ user_is_away(from, ArgList); break; case 302: /* #define RPL_USERHOST 302 */ userhost_returned(from, ArgList); break; case 303: /* #define RPL_ISON 303 */ ison_returned(from, ArgList); break; case 311: /* #define RPL_WHOISUSER 311 */ whois_name(from, ArgList); break; case 312: /* #define RPL_WHOISSERVER 312 */ whois_server(from, ArgList); break; case 313: /* #define RPL_WHOISOPERATOR 313 */ whois_oper(from, ArgList); break; case 314: /* #define RPL_WHOWASUSER 314 */ whowas_name(from, ArgList); break; case 316: /* #define RPL_WHOISCHANOP 316 */ whois_chop(from, ArgList); break; case 317: /* #define RPL_WHOISIDLE 317 */ whois_lastcom(from, ArgList); break; case 318: /* #define RPL_ENDOFWHOIS 318 */ end_of_whois(from, ArgList); break; case 319: /* #define RPL_WHOISCHANNELS 319 */ whois_channels(from, ArgList); break; case 321: /* #define RPL_LISTSTART 321 */ ArgList[0] = UP("Channel\0Users\0Topic"); ArgList[1] = ArgList[0] + 8; ArgList[2] = ArgList[1] + 6; ArgList[3] = NULL; funny_list(from, ArgList); break; case 322: /* #define RPL_LIST 322 */ funny_list(from, ArgList); break; case 324: /* #define RPL_CHANNELMODEIS 324 */ funny_mode(from, ArgList); break; case 341: /* #define RPL_INVITING 341 */ invite(from, ArgList); break; case 352: /* #define RPL_WHOREPLY 352 */ whoreply(NULL, ArgList); break; case 353: /* #define RPL_NAMREPLY 353 */ funny_namreply(from, ArgList); break; case 366: /* #define RPL_ENDOFNAMES 366 */ { u_char *tmp = NULL, *chan; PasteArgs(ArgList, 0); malloc_strcpy(&tmp, ArgList[0]); chan = next_arg(tmp, 0); flag = do_hook(current_numeric(), "%s %s", from, ArgList[0]); if (flag && channel_mode_lookup(chan, CHAN_NAMES | CHAN_MODE, 0) && get_int_var(SHOW_END_OF_MSGS_VAR) && flag) display_msg(from, ArgList); new_free(&tmp); } break; case 381: /* #define RPL_YOUREOPER 381 */ PasteArgs(ArgList, 0); if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); server_set_operator(parsing_server(), 1); update_all_status(); /* fix the status line */ break; case 401: /* #define ERR_NOSUCHNICK 401 */ no_such_nickname(from, ArgList); break; case 405: /* #define ERR_TOOMANYCHANNELS 405 */ remove_channel(ArgList[0], parsing_server()); break; case 421: /* #define ERR_UNKNOWNCOMMAND 421 */ if (check_screen_redirect(ArgList[0])) break; if (check_wait_command(ArgList[0])) break; PasteArgs(ArgList, 0); flag = do_hook(current_numeric(), "%s %s", from, *ArgList); if (!my_strncmp("ISON", *ArgList, 4) || !my_strncmp("USERHOST", *ArgList, 8)) { server_set_2_6_2(parsing_server(), 0); convert_to_whois(); } else if (flag) display_msg(from, ArgList); break; case 432: /* #define ERR_ERRONEUSNICKNAME 432 */ case 433: /* #define ERR_NICKNAMEINUSE 433 */ PasteArgs(ArgList, 0); if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); reset_nickname(from); break; case 437: /* #define ERR_UNAVAILRESOURCE 437 */ PasteArgs(ArgList, 0); if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); if (!is_channel(*ArgList)) reset_nickname(from); break; case 463: /* #define ERR_NOPERMFORHOST 463 */ display_msg(from, ArgList); close_server(parsing_server(), empty_string()); window_check_servers(); if (!connected_to_server()) get_connected(parsing_server() + 1); break; case 464: /* #define ERR_PASSWDMISMATCH 464 */ PasteArgs(ArgList, 0); flag = do_hook(current_numeric(), "%s %s", from, ArgList[0]); if (server_get_oper_command()) { if (flag) display_msg(from, ArgList); } else get_password(); break; case 465: /* #define ERR_YOUREBANNEDCREEP 465 */ { int klined_server = parsing_server(); PasteArgs(ArgList, 0); if (do_hook(current_numeric(), "%s %s", from, ArgList[0])) display_msg(from, ArgList); close_server(parsing_server(), empty_string()); window_check_servers(); if (number_of_servers() > 1) remove_from_server_list(klined_server); if (!connected_to_server()) say("You are not connected to a server. Use /SERVER to connect."); break; } case 471: /* #define ERR_CHANNELISFULL 471 */ case 473: /* #define ERR_INVITEONLYCHAN 473 */ case 474: /* #define ERR_BANNEDFROMCHAN 474 */ case 475: /* #define ERR_BADCHANNELKEY 475 */ case 476: /* #define ERR_BADCHANMASK 476 */ cannot_join_channel(from, ArgList); break; case 484: /* #define ERR_RESTRICTED 484 */ if (do_hook(current_numeric(), "%s %s", from, *ArgList)) display_msg(from, ArgList); server_set_flag(parsing_server(), USER_MODE_R, 1); break; /* * The following accumulates the remaining arguments * in ArgSpace for hook detection. We can't use * PasteArgs here because we still need the arguments * separated for use elsewhere. */ default: { u_char *ArgSpace = NULL; int i, do_message_from = 0; size_t len; for (i = len = 0; ArgList[i]; len += my_strlen(ArgList[i++])) ; len += (i - 1); ArgSpace = new_malloc(len + 1); ArgSpace[0] = '\0'; /* this is cheating */ if (ArgList[0] && is_channel(ArgList[0])) do_message_from = 1; for (i = 0; ArgList[i]; i++) { if (i) my_strcat(ArgSpace, " "); my_strcat(ArgSpace, ArgList[i]); } if (do_message_from) message_from(ArgList[0], LOG_CRAP); i = do_hook(current_numeric(), "%s %s", from, ArgSpace); new_free(&ArgSpace); if (do_message_from) restore_message_from(); if (i == 0) goto done; none_of_these = 1; } } /* the following do not hurt the ircII if intercepted by a hook */ if (none_of_these) { switch (comm) { case 221: /* #define RPL_UMODEIS 221 */ put_it("%s Your user mode is \"%s\"", numeric_banner(), ArgList[0]); break; case 242: /* #define RPL_STATSUPTIME 242 */ PasteArgs(ArgList, 0); if (from && !my_strnicmp(server_get_itsname(parsing_server()), from, my_strlen(server_get_itsname(parsing_server())))) from = NULL; if (from) put_it("%s %s from (%s)", numeric_banner(), *ArgList, from); else put_it("%s %s", numeric_banner(), *ArgList); break; case 332: /* #define RPL_TOPIC 332 */ channel_topic(from, ArgList); break; case 351: /* #define RPL_VERSION 351 */ version(from, ArgList); break; case 364: /* #define RPL_LINKS 364 */ if (ArgList[2]) { PasteArgs(ArgList, 2); put_it("%s %-20s %-20s %s", numeric_banner(), ArgList[0], ArgList[1], ArgList[2]); } else { PasteArgs(ArgList, 1); put_it("%s %-20s %s", numeric_banner(), ArgList[0], ArgList[1]); } break; case 372: /* #define RPL_MOTD 372 */ if (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) || !server_get_motd(parsing_server())) { PasteArgs(ArgList, 0); put_it("%s %s", numeric_banner(), ArgList[0]); } break; case 375: /* #define RPL_MOTDSTART 375 */ if (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) || !server_get_motd(parsing_server())) { PasteArgs(ArgList, 0); put_it("%s %s", numeric_banner(), ArgList[0]); } break; case 376: /* #define RPL_ENDOFMOTD 376 */ if (server_get_attempting_to_connect(parsing_server())) got_initial_version(UP("*** Your host is broken and not running any version")); if (get_int_var(SHOW_END_OF_MSGS_VAR) && (!get_int_var(SUPPRESS_SERVER_MOTD_VAR) || !server_get_motd(parsing_server()))) { PasteArgs(ArgList, 0); put_it("%s %s", numeric_banner(), ArgList[0]); } server_set_motd(parsing_server(), 0); break; case 384: /* #define RPL_MYPORTIS 384 */ PasteArgs(ArgList, 0); put_it("%s %s %s", numeric_banner(), ArgList[0], user); break; case 385: /* #define RPL_NOTOPERANYMORE 385 */ server_set_operator(parsing_server(), 0); display_msg(from, ArgList); update_all_status(); break; case 403: /* #define ERR_NOSUCHCHANNEL 403 */ not_valid_channel(from, ArgList); break; case 451: /* #define ERR_NOTREGISTERED 451 */ /* * Sometimes the server doesn't catch the USER line, so * here we send a simplified version again -lynx */ send_to_server("USER %s %s . :%s", my_username(), irc_umode(), my_realname()); send_to_server("NICK %s", server_get_nickname(parsing_server())); break; case 462: /* #define ERR_ALREADYREGISTRED 462 */ display_msg(from, ArgList); break; #define RPL_CLOSEEND 363 #define RPL_SERVLISTEND 235 case 315: /* #define RPL_ENDOFWHO 315 */ case 323: /* #define RPL_LISTEND 323 */ funny_print_widelist(); case 219: /* #define RPL_ENDOFSTATS 219 */ case 232: /* #define RPL_ENDOFSERVICES 232 */ case 365: /* #define RPL_ENDOFLINKS 365 */ case 368: /* #define RPL_ENDOFBANLIST 368 */ case 369: /* #define RPL_ENDOFWHOWAS 369 */ case 374: /* #define RPL_ENDOFINFO 374 */ #if 0 /* this case needs special handing - see above */ case 376: /* #define RPL_ENDOFMOTD 376 */ #endif /* 0 */ case 394: /* #define RPL_ENDOFUSERS 394 */ if (!get_int_var(SHOW_END_OF_MSGS_VAR)) break; default: display_msg(from, ArgList); } } set_lastlog_msg_level(lastlog_level); done: restore_message_from(); }
/* irc_inline() - 1 single line received from serv */ static void irc_inline (server *serv, char *buf, int len) { session *sess, *tmp; char *type, *text; char *word[PDIWORDS+1]; char *word_eol[PDIWORDS+1]; char *pdibuf; message_tags_data tags_data = MESSAGE_TAGS_DATA_INIT; pdibuf = g_malloc (len + 1); sess = serv->front_session; /* Python relies on this */ word[PDIWORDS] = NULL; word_eol[PDIWORDS] = NULL; if (*buf == '@') { char *tags = buf + 1; /* skip the '@' */ char *sep = strchr (buf, ' '); if (!sep) goto xit; *sep = '\0'; buf = sep + 1; handle_message_tags(serv, tags, &tags_data); } url_check_line (buf); /* split line into words and words_to_end_of_line */ process_data_init (pdibuf, buf, word, word_eol, FALSE, FALSE); if (buf[0] == ':') { /* find a context for this message */ if (is_channel (serv, word[3])) { tmp = find_channel (serv, word[3]); if (tmp) sess = tmp; } /* for server messages, the 2nd word is the "message type" */ type = word[2]; word[0] = type; word_eol[1] = buf; /* keep the ":" for plugins */ if (plugin_emit_server (sess, type, word, word_eol, tags_data.timestamp)) goto xit; word[1]++; word_eol[1] = buf + 1; /* but not for HexChat internally */ } else { word[0] = type = word[1]; if (plugin_emit_server (sess, type, word, word_eol, tags_data.timestamp)) goto xit; } if (buf[0] != ':') { process_named_servermsg (sess, buf, word[0], word_eol, &tags_data); goto xit; } /* see if the second word is a numeric */ if (isdigit ((unsigned char) word[2][0])) { text = word_eol[4]; if (*text == ':') text++; process_numeric (sess, atoi (word[2]), word, word_eol, text, &tags_data); } else { process_named_msg (sess, type, word, word_eol, &tags_data); } xit: g_free (pdibuf); }
/* * The main handler for those wacky NOTICE commands... * This is as much like p_privmsg as i can get away with. */ void p_notice (const char *from, const char *comm, const char **ArgList) { const char *target, *message; int level, hook_type; const char * flood_channel = NULL; char * high; PasteArgs(ArgList, 1); if (!(target = ArgList[0])) { rfc1459_odd(from, comm, ArgList); return; } if (!(message = ArgList[1])) { rfc1459_odd(from, comm, ArgList); return; } set_server_doing_notice(from_server, 1); sed = 0; /* Do normal /CTCP reply handling */ /* XXX -- Casting "message" to (char *) is cheating. */ message = do_notice_ctcp(from, target, (char *) #ifdef HAVE_INTPTR_T (intptr_t) #endif message); if (!*message) { set_server_doing_notice(from_server, 0); return; } /* Check to see if it is a "Server Notice" */ if ((!from || !*from) || !strcmp(get_server_itsname(from_server), from)) { parse_local_server_notice(from, target, message); set_server_doing_notice(from_server, 0); return; } /* For pesky prefix-less NOTICEs substitute the server's name */ if (!from || !*from) from = get_server_name(from_server); /* * Note that NOTICEs from servers are not "server notices" unless * the target is not a channel (ie, it is sent to us). Any notice * that is sent to a channel is a normal NOTICE, notwithstanding * _who_ sent it. */ if (is_channel(target) && im_on_channel(target, from_server)) { flood_channel = target; hook_type = PUBLIC_NOTICE_LIST; } else if (!is_me(from_server, target)) { flood_channel = NULL; hook_type = NOTICE_LIST; } else { flood_channel = NULL; hook_type = NOTICE_LIST; target = from; } /* Check for /ignore's */ switch (check_ignore_channel(from, FromUserHost, target, IGNORE_NOTICES)) { case IGNORED: set_server_doing_notice(from_server, 0); return; case HIGHLIGHTED: high = highlight_char; break; /* oops! */ default: high = empty_string; } /* Let the user know if it is an encrypted notice */ /* Note that this is always hooked, even during a flood */ if (sed) { int do_return = 1; sed = 0; level = set_lastlog_msg_level(LOG_NOTICE); message_from(target, LOG_NOTICE); if (do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, target, message)) do_return = 0; set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); if (do_return) { set_server_doing_notice(from_server, 0); return; } } if (new_check_flooding(from, FromUserHost, flood_channel, message, NOTICE_FLOOD)) { set_server_doing_notice(from_server, 0); return; } /* Beep the user if they asked us to */ if (beep_on_level & LOG_NOTICE) beep_em(1); /* Go ahead and throw it to the user */ level = set_lastlog_msg_level(LOG_NOTICE); message_from(target, LOG_NOTICE); if (do_hook(GENERAL_NOTICE_LIST, "%s %s %s", from, target, message)) { if (hook_type == NOTICE_LIST) { if (do_hook(hook_type, "%s %s", from, message)) put_it("%s-%s-%s %s", high, from, high, message); } else { if (do_hook(hook_type, "%s %s %s", from, target, message)) put_it("%s-%s:%s-%s %s", high, from, target, high, message); } } /* Clean up and go home. */ set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); set_server_doing_notice(from_server, 0); /* Alas, this is not protected by protocol enforcement. :( */ notify_mark(from_server, from, 1, 0); }
static void process_named_msg (session *sess, char *type, char *word[], char *word_eol[], const message_tags_data *tags_data) { server *serv = sess->server; char ip[128], nick[NICKLEN]; char *text, *ex; int len = strlen (type); /* fill in the "ip" and "nick" buffers */ ex = strchr (word[1], '!'); if (!ex) /* no '!', must be a server message */ { safe_strcpy (ip, word[1], sizeof (ip)); safe_strcpy (nick, word[1], sizeof (nick)); } else { safe_strcpy (ip, ex + 1, sizeof (ip)); ex[0] = 0; safe_strcpy (nick, word[1], sizeof (nick)); ex[0] = '!'; } if (len == 4) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); /* this should compile to a bunch of: CMP.L, JE ... nice & fast */ switch (t) { case WORDL('J','O','I','N'): { char *chan = word[3]; char *account = word[4]; char *realname = word_eol[5]; if (account && strcmp (account, "*") == 0) account = NULL; if (realname && *realname == ':') realname++; if (*chan == ':') chan++; if (!serv->p_cmp (nick, serv->nick)) inbound_ujoin (serv, chan, nick, ip, tags_data); else inbound_join (serv, chan, nick, ip, account, realname, tags_data); } return; case WORDL('K','I','C','K'): { char *kicked = word[4]; char *reason = word_eol[5]; if (*kicked) { if (*reason == ':') reason++; if (!strcmp (kicked, serv->nick)) inbound_ukick (serv, word[3], nick, reason, tags_data); else inbound_kick (serv, word[3], kicked, nick, reason, tags_data); } } return; case WORDL('K','I','L','L'): { char *reason = word_eol[4]; if (*reason == ':') reason++; EMIT_SIGNAL_TIMESTAMP (XP_TE_KILL, sess, nick, reason, NULL, NULL, 0, tags_data->timestamp); } return; case WORDL('M','O','D','E'): handle_mode (serv, word, word_eol, nick, FALSE, tags_data); /* modes.c */ return; case WORDL('N','I','C','K'): inbound_newnick (serv, nick, (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3], FALSE, tags_data); return; case WORDL('P','A','R','T'): { char *chan = word[3]; char *reason = word_eol[4]; if (*chan == ':') chan++; if (*reason == ':') reason++; if (!strcmp (nick, serv->nick)) inbound_upart (serv, chan, ip, reason, tags_data); else inbound_part (serv, chan, nick, ip, reason, tags_data); } return; case WORDL('P','O','N','G'): inbound_ping_reply (serv->server_session, (word[4][0] == ':') ? word[4] + 1 : word[4], word[3], tags_data); return; case WORDL('Q','U','I','T'): inbound_quit (serv, nick, ip, (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3], tags_data); return; case WORDL('A','W','A','Y'): inbound_away_notify (serv, nick, (word_eol[3][0] == ':') ? word_eol[3] + 1 : NULL, tags_data); return; } goto garbage; } else if (len >= 5) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); /* this should compile to a bunch of: CMP.L, JE ... nice & fast */ switch (t) { case WORDL('A','C','C','O'): inbound_account (serv, nick, word[3], tags_data); return; case WORDL('I','N','V','I'): if (ignore_check (word[1], IG_INVI)) return; if (word[4][0] == ':') EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITED, sess, word[4] + 1, nick, serv->servername, NULL, 0, tags_data->timestamp); else EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITED, sess, word[4], nick, serv->servername, NULL, 0, tags_data->timestamp); return; case WORDL('N','O','T','I'): { int id = FALSE; /* identified */ text = word_eol[4]; if (*text == ':') { text++; } #ifdef USE_OPENSSL if (!strncmp (text, "CHALLENGE ", 10)) /* QuakeNet CHALLENGE upon our request */ { char *response = challengeauth_response (((ircnet *)serv->network)->user ? ((ircnet *)serv->network)->user : prefs.hex_irc_user_name, serv->password, word[5]); tcp_sendf (serv, "PRIVMSG %s :CHALLENGEAUTH %s %s %s\r\n", CHALLENGEAUTH_NICK, ((ircnet *)serv->network)->user ? ((ircnet *)serv->network)->user : prefs.hex_irc_user_name, response, CHALLENGEAUTH_ALGO); g_free (response); return; /* omit the CHALLENGE <hash> ALGOS message */ } #endif if (serv->have_idmsg) { if (*text == '+') { id = TRUE; text++; } else if (*text == '-') text++; } if (!ignore_check (word[1], IG_NOTI)) inbound_notice (serv, word[3], nick, text, ip, id, tags_data); } return; case WORDL('P','R','I','V'): { char *to = word[3]; int len; int id = FALSE; /* identified */ if (*to) { /* Handle limited channel messages, for now no special event */ if (strchr (serv->chantypes, to[0]) == NULL && strchr (serv->nick_prefixes, to[0]) != NULL) to++; text = word_eol[4]; if (*text == ':') text++; if (serv->have_idmsg) { if (*text == '+') { id = TRUE; text++; } else if (*text == '-') text++; } len = strlen (text); if (text[0] == 1 && text[len - 1] == 1) /* ctcp */ { text[len - 1] = 0; text++; if (g_ascii_strncasecmp (text, "ACTION", 6) != 0) flood_check (nick, ip, serv, sess, 0); if (g_ascii_strncasecmp (text, "DCC ", 4) == 0) /* redo this with handle_quotes TRUE */ process_data_init (word[1], word_eol[1], word, word_eol, TRUE, FALSE); ctcp_handle (sess, to, nick, ip, text, word, word_eol, id, tags_data); } else { if (is_channel (serv, to)) { if (ignore_check (word[1], IG_CHAN)) return; inbound_chanmsg (serv, NULL, to, nick, text, FALSE, id, tags_data); } else { if (ignore_check (word[1], IG_PRIV)) return; inbound_privmsg (serv, nick, ip, text, id, tags_data); } } } } return; case WORDL('T','O','P','I'): inbound_topicnew (serv, nick, word[3], (word_eol[4][0] == ':') ? word_eol[4] + 1 : word_eol[4], tags_data); return; case WORDL('W','A','L','L'): text = word_eol[3]; if (*text == ':') text++; EMIT_SIGNAL_TIMESTAMP (XP_TE_WALLOPS, sess, nick, text, NULL, NULL, 0, tags_data->timestamp); return; } } else if (len == 3) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); switch (t) { case WORDL('C','A','P','\0'): if (strncasecmp (word[4], "ACK", 3) == 0) { inbound_cap_ack (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } else if (strncasecmp (word[4], "LS", 2) == 0) { inbound_cap_ls (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } else if (strncasecmp (word[4], "NAK", 3) == 0) { inbound_cap_nak (serv, tags_data); } else if (strncasecmp (word[4], "LIST", 4) == 0) { inbound_cap_list (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } return; } } garbage: /* unknown message */ PrintTextTimeStampf (sess, tags_data->timestamp, "GARBAGE: %s\n", word_eol[1]); }
/* * do_ctcp: a re-entrant form of a CTCP parser. The old one was lame, * so i took a hatchet to it so it didnt suck. * * XXXX - important! The third argument -- 'str', is expected to be * 'BIG_BUFFER_SIZE + 1' or larger. If it isnt, chaos will probably * ensue if you get spammed with lots of CTCP UTC requests. * * UTC requests can be at minimum 5 bytes, and the expansion is always 24. * That means you can cram (510 - strlen("PRIVMSG x :") / 5) UTCs (100) * into a privmsg. That means itll expand to 2400 characters. We silently * limit the number of valid CTCPs to 4. Anything more than that we dont * even bother with. (4 * 24 + 11 -> 106), which is less than * IRCD_BUFFER_SIZE, which gives us plenty of safety. * * XXXX - The normal way of implementation required two copies -- once into a * temporary buffer, once back into the original buffer -- for the best case * scenario. This is horrendously inefficient, since most privmsgs dont * contain any CTCPs. So we check to see if there are any CTCPs in the * message before we bother doing anything. THIS IS AN INELEGANT HACK! * But the call to charcount() is less expensive than even one copy to * strlcpy() since they both evaluate *each* character, and charcount() * doesnt have to do a write unless the character is present. So it is * definitely worth the cost to save CPU time for 99% of the PRIVMSGs. */ char * do_ctcp (const char *from, const char *to, char *str) { int flag; int fflag; char local_ctcp_buffer [BIG_BUFFER_SIZE + 1], the_ctcp [IRCD_BUFFER_SIZE + 1], last [IRCD_BUFFER_SIZE + 1]; char *ctcp_command, *ctcp_argument; int i; char *ptr = NULL; int allow_ctcp_reply = 1; static time_t last_ctcp_parsed = 0; int l; char * extra = NULL; int delim_char = charcount(str, CTCP_DELIM_CHAR); if (delim_char < 2) return str; /* No CTCPs. */ if (delim_char > 8) allow_ctcp_reply = 0; /* Historical limit of 4 CTCPs */ flag = check_ignore_channel(from, FromUserHost, to, LEVEL_CTCP); fflag = new_check_flooding(from, FromUserHost, is_channel(to) ? to : NULL, str, LEVEL_CTCP); in_ctcp_flag++; strlcpy(local_ctcp_buffer, str, sizeof(local_ctcp_buffer) - 2); for (;;strlcat(local_ctcp_buffer, last, sizeof(local_ctcp_buffer) - 2)) { if (split_CTCP(local_ctcp_buffer, the_ctcp, last)) break; /* All done! */ if (!*the_ctcp) continue; /* Empty requests are ignored */ /* * Apply some integrety rules: * -- If we've already replied to a CTCP, ignore it. * -- If user is ignoring sender, ignore it. * -- If we're being flooded, ignore it. * -- If CTCP was a global msg, ignore it. */ /* * Yes, this intentionally ignores "unlimited" CTCPs like * UTC and SED. Ultimately, we have to make sure that * CTCP expansions dont overrun any buffers that might * contain this string down the road. So by allowing up to * 4 CTCPs, we know we cant overflow -- but if we have more * than 40, it might overflow, and its probably a spam, so * no need to shed tears over ignoring them. Also makes * the sanity checking much simpler. */ if (!allow_ctcp_reply) continue; /* * Check to see if the user is ignoring person. * Or if we're suppressing a flood. */ if (flag == IGNORED || fflag == 1) { if (x_debug & DEBUG_CTCPS) yell("CTCP from [%s] ignored", from); allow_ctcp_reply = 0; continue; } /* * Check for CTCP flooding */ if (get_int_var(NO_CTCP_FLOOD_VAR)) { if (time(NULL) - last_ctcp_parsed < 2) { /* * This extends the flood protection until * we dont get a CTCP for 2 seconds. */ last_ctcp_parsed = time(NULL); allow_ctcp_reply = 0; if (x_debug & DEBUG_CTCPS) say("CTCP flood from [%s] ignored", from); continue; } } /* * Check for global message */ if (*to == '$' || (*to == '#' && !im_on_channel(to, from_server))) { allow_ctcp_reply = 0; continue; } /* * Now its ok to parse the CTCP. * First we remove the argument. * XXX - CTCP spec says word delim MUST be space. */ ctcp_command = the_ctcp; ctcp_argument = strchr(the_ctcp, ' '); if (ctcp_argument) *ctcp_argument++ = 0; else ctcp_argument = endstr(the_ctcp); /* Set up the window level/logging */ if (im_on_channel(to, from_server)) l = message_from(to, LEVEL_CTCP); else l = message_from(from, LEVEL_CTCP); /* * Then we look for the correct CTCP. */ for (i = 0; i < NUMBER_OF_CTCPS; i++) if (!strcmp(ctcp_command, ctcp_cmd[i].name)) break; /* * We didnt find it? */ if (i == NUMBER_OF_CTCPS) { /* * Offer it to the user. * Maybe they know what to do with it. */ if (do_hook(CTCP_REQUEST_LIST, "%s %s %s %s", from, to, ctcp_command, ctcp_argument)) { if (do_hook(CTCP_LIST, "%s %s %s %s", from, to, ctcp_command, ctcp_argument)) { say("Unknown CTCP %s from %s to %s: %s%s", ctcp_command, from, to, *ctcp_argument ? ": " : empty_string, ctcp_argument); } } time(&last_ctcp_parsed); allow_ctcp_reply = 0; pop_message_from(l); continue; } /* * rfc1459_any_to_utf8 specifically ignores CTCPs, because * recoding binary data (such as an encrypted message) would * corrupt the message. * * So some CTCPs are "recodable" and some are not. * * The CTCP_NORECODE is set for any CTCPs which are NOT * to be recoded prior to handling. These are the encryption * CTCPS. * * All other CTCPs have not been recoded by the time they * reach here, so we must do it here! */ if (!(ctcp_cmd[i].flag & CTCP_NORECODE)) { /* * We must recode to UTF8 */ inbound_recode(from, from_server, to, ctcp_argument, &extra); if (extra) ctcp_argument = extra; } /* * We did find it. Acknowledge it. */ ptr = NULL; if (do_hook(CTCP_REQUEST_LIST, "%s %s %s %s", from, to, ctcp_command, ctcp_argument)) { ptr = ctcp_cmd[i].func(ctcp_cmd + i, from, to, ctcp_argument); } /* * If this isnt an 'unlimited' CTCP, set up flood protection. * * No, this wont allow users to flood any more than they * would normally. The UTC/SED gets converted into a * regular privmsg body, which is flagged via FLOOD_PUBLIC. */ if (!(ctcp_cmd[i].flag & CTCP_NOLIMIT)) { time(&last_ctcp_parsed); allow_ctcp_reply = 0; } /* * We've only gotten to this point if its a valid CTCP * query and we decided to parse it. */ /* * If its an ``INLINE'' CTCP, we paste it back in. */ if (ctcp_cmd[i].flag & CTCP_INLINE) strlcat(local_ctcp_buffer, ptr ? ptr : empty_string, sizeof local_ctcp_buffer); /* * If its ``INTERESTING'', tell the user. * Note that this isnt mutex with ``INLINE'' in theory, * even though it is in practice. Dont use 'else' here. */ if (ctcp_cmd[i].flag & CTCP_TELLUSER) { if (do_hook(CTCP_LIST, "%s %s %s %s", from, to, ctcp_command, ctcp_argument)) { if (is_me(from_server, to)) say("CTCP %s from %s%s%s", ctcp_command, from, *ctcp_argument ? ": " : empty_string, ctcp_argument); else say("CTCP %s from %s to %s%s%s", ctcp_command, from, to, *ctcp_argument ? ": " : empty_string, ctcp_argument); } } new_free(&extra); new_free(&ptr); pop_message_from(l); } in_ctcp_flag--; /* * 'str' is required to be BIG_BUFFER_SIZE + 1 or bigger per the API. */ strlcpy(str, local_ctcp_buffer, BIG_BUFFER_SIZE); return str; }
void ctcp_handle (session *sess, char *to, char *nick, char *msg, char *word[], char *word_eol[], int id) { char *po; session *chansess; server *serv = sess->server; char outbuf[1024]; /* consider DCC to be different from other CTCPs */ if (!strncasecmp (msg, "DCC", 3)) { /* but still let CTCP replies override it */ if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2)) { if (!ignore_check (word[1], IG_DCC)) handle_dcc (sess, nick, word, word_eol); } return; } /* consider ACTION to be different from other CTCPs. Check ignore as if it was a PRIV/CHAN. */ if (!strncasecmp (msg, "ACTION ", 7)) { if (is_channel (serv, to)) { /* treat a channel action as a CHAN */ if (ignore_check (word[1], IG_CHAN)) return; } else { /* treat a private action as a PRIV */ if (ignore_check (word[1], IG_PRIV)) return; } /* but still let CTCP replies override it */ if (ctcp_check (sess, nick, word, word_eol, word[4] + 2)) goto generic; inbound_action (sess, to, nick, msg + 7, FALSE, id); return; } if (ignore_check (word[1], IG_CTCP)) return; if (!strcasecmp (msg, "VERSION") && !prefs.hidever) { #ifdef FE_AQUA snprintf (outbuf, sizeof (outbuf), "VERSION X-Chat Aqua %s (xchat "PACKAGE_VERSION") %s", prefs.xchat_aqua_version, get_cpu_str ()); #else snprintf (outbuf, sizeof (outbuf), "VERSION xchat "PACKAGE_VERSION" %s", get_cpu_str ()); #endif serv->p_nctcp (serv, nick, outbuf); } if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2)) { if (!strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) po[0] = 0; if (is_channel (sess->server, to)) { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL (XP_TE_CTCPSNDC, chansess, word[5], nick, to, NULL, 0); } else { EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, NULL, NULL, 0); } /* don't let IRCers specify path */ #ifdef WIN32 if (strchr (word[5], '/') == NULL && strchr (word[5], '\\') == NULL) #else if (strchr (word[5], '/') == NULL) #endif sound_play (word[5], TRUE); return; } } generic: po = strchr (msg, '\001'); if (po) po[0] = 0; if (!is_channel (sess->server, to)) { EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, NULL, NULL, 0); } else { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0); } }
/* * do_notice_ctcp: a re-entrant form of a CTCP reply parser. * See the implementation notes in do_ctcp(). */ char * do_notice_ctcp (const char *from, const char *to, char *str) { int flag; char local_ctcp_buffer [BIG_BUFFER_SIZE + 1], the_ctcp [IRCD_BUFFER_SIZE + 1], last [IRCD_BUFFER_SIZE + 1]; char *ctcp_command, *ctcp_argument; int i; char *ptr; int allow_ctcp_reply = 1; int l; int delim_char = charcount(str, CTCP_DELIM_CHAR); if (delim_char < 2) return str; /* No CTCPs. */ if (delim_char > 8) allow_ctcp_reply = 0; /* Ignore all the CTCPs. */ /* We handle ignore, but not flooding (obviously) */ flag = check_ignore_channel(from, FromUserHost, to, LEVEL_CTCP); in_ctcp_flag++; strlcpy(local_ctcp_buffer, str, sizeof(local_ctcp_buffer) - 2); for (;;strlcat(local_ctcp_buffer, last, sizeof(local_ctcp_buffer) - 2)) { if (split_CTCP(local_ctcp_buffer, the_ctcp, last)) break; /* All done! */ if (!*the_ctcp) continue; /* Empty requests are ignored */ /* * The logic of all this is essentially the same as * do_ctcp */ if (!allow_ctcp_reply) continue; if (flag == IGNORED) { if (x_debug & DEBUG_CTCPS) yell("CTCP REPLY from [%s] ignored", from); allow_ctcp_reply = 0; continue; } /* But we don't check ctcp flooding (obviously) */ /* Global messages -- just drop the CTCP */ if (*to == '$' || (is_channel(to) && !im_on_channel(to, from_server))) { allow_ctcp_reply = 0; continue; } /* * Parse CTCP message * CTCP spec says word delim MUST be space */ ctcp_command = the_ctcp; ctcp_argument = strchr(the_ctcp, ' '); if (ctcp_argument) *ctcp_argument++ = 0; else ctcp_argument = endstr(the_ctcp); /* Set up the window level/logging */ if (is_channel(to)) l = message_from(to, LEVEL_CTCP); else l = message_from(from, LEVEL_CTCP); /* * Find the correct CTCP and run it. */ for (i = 0; i < NUMBER_OF_CTCPS; i++) if (!strcmp(ctcp_command, ctcp_cmd[i].name)) break; /* * If its a built in CTCP command, check to see if its * got a reply handler, call if appropriate. */ if (i < NUMBER_OF_CTCPS && ctcp_cmd[i].repl) { if ((ptr = ctcp_cmd[i].repl(ctcp_cmd + i, from, to, ctcp_argument))) { strlcat(local_ctcp_buffer, ptr, sizeof local_ctcp_buffer); new_free(&ptr); pop_message_from(l); continue; } } /* Toss it at the user. */ if (ctcp_cmd[i].flag & CTCP_TELLUSER) { if (do_hook(CTCP_REPLY_LIST, "%s %s %s %s", from, to, ctcp_command, ctcp_argument)) say("CTCP %s reply from %s: %s", ctcp_command, from, ctcp_argument); } if (!(ctcp_cmd[i].flag & CTCP_NOLIMIT)) allow_ctcp_reply = 0; pop_message_from(l); } in_ctcp_flag--; /* * local_ctcp_buffer is derived from 'str', so its always * smaller or equal in size to 'str', so this copy is safe. */ strlcpy(str, local_ctcp_buffer, BIG_BUFFER_SIZE); return str; }
void handle_ctcp (struct session *sess, char *outbuf, char *to, char *nick, char *msg, char *word[], char *word_eol[]) { char *po; session *chansess; if (!strncasecmp (msg, "VERSION", 7) && !prefs.hidever) { sprintf (outbuf, "NOTICE %s :\001VERSION xchat "VERSION" %s (PicoGUI)\001\r\n", nick, get_cpu_str ()); tcp_send (sess->server, outbuf); } if (!ctcp_check (sess, outbuf, nick, word, word_eol, word[4] + 2)) { if (!strncasecmp (msg, "ACTION", 6)) { po = strchr (msg + 7, '\001'); if (po) po[0] = 0; channel_action (sess, outbuf, to, nick, msg + 7, FALSE); return; } if (!strncasecmp (msg, "DCC", 3)) { handle_dcc (sess, outbuf, nick, word, word_eol); return; } if (!strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) po[0] = 0; EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, NULL, NULL, 0); sprintf (outbuf, "%s/%s", prefs.sounddir, word[5]); if (strchr (word[5], '/') == 0 && access (outbuf, R_OK) == 0) { sprintf (outbuf, "%s %s/%s", prefs.soundcmd, prefs.sounddir, word[5]); xchat_exec (outbuf); } return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (!is_channel (sess->server, to)) { EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, NULL, NULL, 0); } else { chansess = find_session_from_channel (to, sess->server); if (chansess) { EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0); return; } EMIT_SIGNAL (XP_TE_CTCPGENC, sess->server->front_session, msg, nick, to, NULL, 0); } }
void ctcp_handle (session *sess, char *to, char *nick, char *ip, char *msg, char *word[], char *word_eol[], int id, const message_tags_data *tags_data) { char *po; session *chansess; server *serv = sess->server; char outbuf[1024]; int ctcp_offset = 2; if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') ) ctcp_offset = 3; /* consider DCC to be different from other CTCPs */ if (!g_ascii_strncasecmp (msg, "DCC", 3)) { /* but still let CTCP replies override it */ if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) { if (!ignore_check (word[1], IG_DCC)) handle_dcc (sess, nick, word, word_eol, tags_data); } return; } /* consider ACTION to be different from other CTCPs. Check ignore as if it was a PRIV/CHAN. */ if (!g_ascii_strncasecmp (msg, "ACTION ", 7)) { if (is_channel (serv, to)) { /* treat a channel action as a CHAN */ if (ignore_check (word[1], IG_CHAN)) return; } else { /* treat a private action as a PRIV */ if (ignore_check (word[1], IG_PRIV)) return; } /* but still let CTCP replies override it */ if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) goto generic; inbound_action (sess, to, nick, ip, msg + 7, FALSE, id, tags_data); return; } if (ignore_check (word[1], IG_CTCP)) return; if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.pchat_irc_hide_version) { #ifdef _WIN32 g_snprintf (outbuf, sizeof (outbuf), "VERSION PChat "PACKAGE_VERSION" [x%d] / %s", get_cpu_arch (), get_sys_str (1)); #else g_snprintf (outbuf, sizeof (outbuf), "VERSION PChat "PACKAGE_VERSION" / %s", get_sys_str (1)); #endif serv->p_nctcp (serv, nick, outbuf); } if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) { if (!g_ascii_strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) po[0] = 0; if (is_channel (sess->server, to)) { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSNDC, chansess, word[5], nick, to, NULL, 0, tags_data->timestamp); } else { EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSND, sess->server->front_session, word[5], nick, NULL, NULL, 0, tags_data->timestamp); } /* don't let IRCers specify path */ #ifdef _WIN32 if (strchr (word[5], '/') == NULL && strchr (word[5], '\\') == NULL) #else if (strchr (word[5], '/') == NULL) #endif sound_play (word[5], TRUE); return; } } generic: po = strchr (msg, '\001'); if (po) po[0] = 0; if (!is_channel (sess->server, to)) { EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGEN, sess->server->front_session, msg, nick, NULL, NULL, 0, tags_data->timestamp); } else { chansess = find_channel (sess->server, to); if (!chansess) chansess = sess; EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0, tags_data->timestamp); } }
static void irc_inline (server *serv, char *buf, int len) { session *sess, *tmp; char *type, *text; char *word[PDIWORDS+1]; char *word_eol[PDIWORDS+1]; char pdibuf_static[522]; /* 1 line can potentially be 512*6 in utf8 */ char *pdibuf = pdibuf_static; /* need more than 522? fall back to malloc */ if (len >= sizeof (pdibuf_static)) pdibuf = malloc (len + 1); sess = serv->front_session; /* Python relies on this */ word[PDIWORDS] = NULL; word_eol[PDIWORDS] = NULL; if (buf[0] == ':') { /* split line into words and words_to_end_of_line */ process_data_init (pdibuf, buf, word, word_eol, FALSE, FALSE); /* find a context for this message */ if (is_channel (serv, word[3])) { tmp = find_channel (serv, word[3]); if (tmp) sess = tmp; } /* for server messages, the 2nd word is the "message type" */ type = word[2]; word[0] = type; word_eol[1] = buf; /* keep the ":" for plugins */ if (plugin_emit_server (sess, type, word, word_eol)) goto xit; word[1]++; word_eol[1] = buf + 1; /* but not for xchat internally */ } else { process_data_init (pdibuf, buf, word, word_eol, FALSE, FALSE); word[0] = type = word[1]; if (plugin_emit_server (sess, type, word, word_eol)) goto xit; } if (buf[0] != ':') { process_named_servermsg (sess, buf, word[0], word_eol); goto xit; } /* see if the second word is a numeric */ if (isdigit ((unsigned char) word[2][0])) { text = word_eol[4]; if (*text == ':') text++; process_numeric (sess, atoi (word[2]), word, word_eol, text); } else { process_named_msg (sess, type, word, word_eol); } xit: if (pdibuf != pdibuf_static) free (pdibuf); }
static void p_privmsg(char *from, char **Args) { int level, list_type, flood_type, log_type, no_flood = 1, do_beep = 1; unsigned char ignore_type; char *ptr = NULL, *to; char *high; struct channel *channel = NULL; struct nick_list *tmpnick = NULL; if (!from) return; PasteArgs(Args, 1); to = Args[0]; ptr = Args[1]; if (!to || !ptr) { fake(); return; } doing_privmsg = 1; if (is_channel(to) && im_on_channel(to)) { message_from(to, LOG_MSG); malloc_strcpy(&public_nick, from); log_type = LOG_PUBLIC; ignore_type = IGNORE_PUBLIC; flood_type = PUBLIC_FLOOD; if (!is_on_channel(to, from_server, from)) list_type = PUBLIC_MSG_LIST; else { if (is_current_channel(to, from_server, 0)) list_type = PUBLIC_LIST; else list_type = PUBLIC_OTHER_LIST; channel = lookup_channel(to, from_server, CHAN_NOUNLINK); if (channel) tmpnick = find_nicklist_in_channellist(from, channel, 0); } } else { message_from(from, LOG_MSG); flood_type = MSG_FLOOD; if (my_stricmp(to, get_server_nickname(from_server))) { log_type = LOG_WALL; ignore_type = IGNORE_WALLS; list_type = MSG_GROUP_LIST; } else { log_type = LOG_MSG; ignore_type = IGNORE_MSGS; list_type = MSG_LIST; } } switch (check_ignore(from, FromUserHost, to, ignore_type, ptr)) { case IGNORED: if ((list_type == MSG_LIST) && get_int_var(SEND_IGNORE_MSG_VAR)) send_to_server(SERVER(from_server), "NOTICE %s :%s is ignoring you", from, get_server_nickname(from_server)); doing_privmsg = 0; return; case HIGHLIGHTED: high = highlight_char; break; case CHANNEL_GREP: high = highlight_char; break; default: high = empty_str; break; } ptr = do_ctcp(from, to, ptr); if (!ptr || !*ptr) { doing_privmsg = 0; return; } level = set_lastlog_msg_level(log_type); if (flood_type == PUBLIC_FLOOD) { int blah = 0; if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah)) { no_flood = 0; flood_prot(tmpnick->nick, FromUserHost, "PUBLIC", flood_type, get_int_var(PUBFLOOD_TIME_VAR), channel->channel); } } else no_flood = check_flooding(from, flood_type, ptr, NULL); { switch (list_type) { case PUBLIC_MSG_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_MSG_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_GROUP_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_GROUP_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_LIST: { if (!no_flood) break; malloc_strcpy(&recv_nick, from); if (away_set) { do_beep = 0; beep_em(get_int_var(BEEP_WHEN_AWAY_VAR)); set_int_var(MSGCOUNT_VAR, get_int_var(MSGCOUNT_VAR) + 1); } logmsg(LOG_MSG, from, ptr, 0); addtabkey(from, "msg"); if (do_hook(list_type, "%s %s", from, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); if (from_server > -1 && get_server_away(from_server) && get_int_var(SEND_AWAY_MSG_VAR)) { send_to_server(SERVER(from_server), "NOTICE %s :%s", from, stripansicodes(convert_output_format (get_format(FORMAT_SEND_AWAY_FSET), "%l %l %s", time(NULL), server_list[from_server].awaytime, get_int_var(MSGLOG_VAR) ? "On" : "Off"))); } break; } case PUBLIC_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } case PUBLIC_OTHER_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } /* case */ } /* switch */ } if (beep_on_level & log_type && do_beep) beep_em(1); set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); doing_privmsg = 0; }
static void process_named_msg (session *sess, char *type, char *word[], char *word_eol[]) { server *serv = sess->server; char ip[128], nick[NICKLEN]; char *text, *ex; int len = strlen (type); /* fill in the "ip" and "nick" buffers */ ex = strchr (word[1], '!'); if (!ex) /* no '!', must be a server message */ { safe_strcpy (ip, word[1], sizeof (ip)); safe_strcpy (nick, word[1], sizeof (nick)); } else { safe_strcpy (ip, ex + 1, sizeof (ip)); ex[0] = 0; safe_strcpy (nick, word[1], sizeof (nick)); ex[0] = '!'; } if (len == 4) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); /* this should compile to a bunch of: CMP.L, JE ... nice & fast */ switch (t) { case WORDL('J','O','I','N'): { char *chan = word[3]; if (*chan == ':') chan++; if (!serv->p_cmp (nick, serv->nick)) inbound_ujoin (serv, chan, nick, ip); else inbound_join (serv, chan, nick, ip); } return; case WORDL('K','I','C','K'): { char *kicked = word[4]; char *reason = word_eol[5]; if (*kicked) { if (*reason == ':') reason++; if (!strcmp (kicked, serv->nick)) inbound_ukick (serv, word[3], nick, reason); else inbound_kick (serv, word[3], kicked, nick, reason); } } return; case WORDL('K','I','L','L'): EMIT_SIGNAL (XP_TE_KILL, sess, nick, word_eol[5], NULL, NULL, 0); return; case WORDL('M','O','D','E'): handle_mode (serv, word, word_eol, nick, FALSE); /* modes.c */ return; case WORDL('N','I','C','K'): inbound_newnick (serv, nick, (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3], FALSE); return; case WORDL('P','A','R','T'): { char *chan = word[3]; char *reason = word_eol[4]; if (*chan == ':') chan++; if (*reason == ':') reason++; if (!strcmp (nick, serv->nick)) inbound_upart (serv, chan, ip, reason); else inbound_part (serv, chan, nick, ip, reason); } return; case WORDL('P','O','N','G'): inbound_ping_reply (serv->server_session, (word[4][0] == ':') ? word[4] + 1 : word[4], word[3]); return; case WORDL('Q','U','I','T'): inbound_quit (serv, nick, ip, (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3]); return; } goto garbage; } else if (len >= 5) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); /* this should compile to a bunch of: CMP.L, JE ... nice & fast */ switch (t) { case WORDL('I','N','V','I'): if (ignore_check (word[1], IG_INVI)) return; if (word[4][0] == ':') EMIT_SIGNAL (XP_TE_INVITED, sess, word[4] + 1, nick, serv->servername, NULL, 0); else EMIT_SIGNAL (XP_TE_INVITED, sess, word[4], nick, serv->servername, NULL, 0); return; case WORDL('N','O','T','I'): { int id = FALSE; /* identified */ text = word_eol[4]; if (*text == ':') text++; if (serv->have_idmsg) { if (*text == '+') { id = TRUE; text++; } else if (*text == '-') text++; } if (!ignore_check (word[1], IG_NOTI)) inbound_notice (serv, word[3], nick, text, ip, id); } return; case WORDL('P','R','I','V'): { char *to = word[3]; int len; int id = FALSE; /* identified */ if (*to) { text = word_eol[4]; if (*text == ':') text++; if (serv->have_idmsg) { if (*text == '+') { id = TRUE; text++; } else if (*text == '-') text++; } len = strlen (text); if (text[0] == 1 && text[len - 1] == 1) /* ctcp */ { text[len - 1] = 0; text++; if (strncasecmp (text, "ACTION", 6) != 0) flood_check (nick, ip, serv, sess, 0); if (strncasecmp (text, "DCC ", 4) == 0) /* redo this with handle_quotes TRUE */ process_data_init (word[1], word_eol[1], word, word_eol, TRUE, FALSE); ctcp_handle (sess, to, nick, ip, text, word, word_eol, id); } else { if (is_channel (serv, to)) { if (ignore_check (word[1], IG_CHAN)) return; inbound_chanmsg (serv, NULL, to, nick, text, FALSE, id); } else { if (ignore_check (word[1], IG_PRIV)) return; inbound_privmsg (serv, nick, ip, text, id); } } } } return; case WORDL('T','O','P','I'): inbound_topicnew (serv, nick, word[3], (word_eol[4][0] == ':') ? word_eol[4] + 1 : word_eol[4]); return; case WORDL('W','A','L','L'): text = word_eol[3]; if (*text == ':') text++; EMIT_SIGNAL (XP_TE_WALLOPS, sess, nick, text, NULL, NULL, 0); return; } } else if (len == 3) { guint32 t; t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]); switch (t) { case WORDL('C','A','P','\0'): if (strncasecmp(word[4], "ACK", 3) == 0) { if (strncasecmp(word[5][0]==':' ? word[5]+1 : word[5], "identify-msg", 12) == 0) { serv->have_idmsg = TRUE; tcp_send_len(serv, "CAP END\r\n", 9); } } else if (strncasecmp(word[4], "LS", 2) == 0) { if (strstr(word_eol[5], "identify-msg") != 0) tcp_send_len(serv, "CAP REQ :identify-msg\r\n", 23); else tcp_send_len(serv, "CAP END\r\n", 9); } else if (strncasecmp(word[4], "NAK",3) == 0) { tcp_send_len(serv, "CAP END\r\n", 9); } return; } } garbage: /* unknown message */ PrintTextf (sess, "GARBAGE: %s\n", word_eol[1]); }
static void p_mode(char *from, char **ArgList) { char *channel; char *line; int flag; struct channel *chan = NULL; char buffer[BIG_BUFFER_SIZE + 1]; char *smode; #ifdef COMPRESS_MODES char *tmpbuf = NULL; #endif PasteArgs(ArgList, 1); channel = ArgList[0]; line = ArgList[1]; smode = strchr(from, '.'); flag = check_ignore(from, FromUserHost, channel, (smode ? IGNORE_SMODES : IGNORE_MODES) | IGNORE_CRAP, NULL); message_from(channel, LOG_CRAP); if (channel && line) { strcpy(buffer, line); if (get_int_var(MODE_STRIPPER_VAR)) strip_modes(from, channel, line); if (is_channel(channel)) { #ifdef COMPRESS_MODES chan = (struct channel *) find_in_list((struct list **) &server_list[from_server].chan_list, channel, 0); if (get_int_var(COMPRESS_MODES_VAR)) { tmpbuf = compress_modes(from_server, channel, line); if (tmpbuf) strcpy(line, tmpbuf); else goto end_p_mode; } #endif /* CDE handle mode protection here instead of later */ update_channel_mode(from, channel, from_server, buffer, chan); if (flag != IGNORED && do_hook(MODE_LIST, "%s %s %s", from, channel, line)) put_it("%s", convert_output_format(get_format(smode ? FORMAT_SMODE_FSET : FORMAT_MODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } else { if (flag != IGNORED && do_hook(MODE_LIST, "%s %s %s", from, channel, line)) { if (!my_stricmp(from, channel)) { if (!my_stricmp(from, get_server_nickname(from_server))) put_it("%s", convert_output_format(get_format(FORMAT_USERMODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, "*", channel, line)); else put_it("%s", convert_output_format(get_format(FORMAT_USERMODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } else put_it("%s", convert_output_format(get_format(FORMAT_MODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } update_user_mode(line); } #ifdef COMPRESS_MODES end_p_mode: #endif update_all_status(curr_scr_win, NULL, 0); } message_from(NULL, LOG_CRAP); }
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id) { char *po,*ptr=to; session *sess = 0; int server_notice = FALSE; if (is_channel (serv, ptr)) sess = find_channel (serv, ptr); if (!sess && ptr[0] == '@') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '%') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '+') { ptr++; sess = find_channel (serv, ptr); } if (strcmp (nick, ip) == 0) server_notice = TRUE; if (!sess) { ptr = 0; if (prefs.hex_gui_tab_notices) { int stype = server_notice ? SESS_SNOTICES : SESS_NOTICES; sess = find_session_from_type (stype, serv); if (!sess) { if (stype == SESS_NOTICES) sess = new_ircwindow (serv, "(notices)", SESS_NOTICES, 0); else sess = new_ircwindow (serv, "(snotices)", SESS_SNOTICES, 0); fe_set_channel (sess); fe_set_title (sess); fe_set_nonchannel (sess, FALSE); userlist_clear (sess); log_open_or_close (sess); } /* Avoid redundancy with some Undernet notices */ if (!strncmp (msg, "*** Notice -- ", 14)) msg += 14; } else { /* paranoia check */ if (msg[0] == '[' && (!serv->have_idmsg || id)) { /* guess where chanserv meant to post this -sigh- */ if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) { char *dest = strdup (msg + 1); char *end = strchr (dest, ']'); if (end) { *end = 0; sess = find_channel (serv, dest); } free (dest); } } if (!sess) sess = find_session_from_nick (nick, serv); } if (!sess) { if (server_notice) sess = serv->server_session; else sess = serv->front_session; } } if (msg[0] == 1) { msg++; if (!strncmp (msg, "PING", 4)) { inbound_ping_reply (sess, msg + 5, nick); return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (server_notice) EMIT_SIGNAL (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0); else if (ptr) EMIT_SIGNAL (XP_TE_CHANNOTICE, sess, nick, to, msg, NULL, 0); else EMIT_SIGNAL (XP_TE_NOTICE, sess, nick, msg, NULL, NULL, 0); }
static void strip_modes(char *from, char *channel, char *line) { char *mode; char *pointer; char mag = '+'; /* XXXX Bogus */ char *copy = NULL; #ifdef __GNUC__ char free_copy[strlen(line) + 1]; strcpy(free_copy, line); #else char *free_copy = NULL; malloc_strcpy(&free_copy, line); #endif copy = free_copy; mode = next_arg(copy, ©); if (is_channel(channel)) { for (pointer = mode; *pointer; pointer++) { char c = *pointer; switch (c) { case '+': case '-': mag = c; break; case 'l': if (mag == '+') do_hook(MODE_STRIPPED_LIST, "%s %s %c%c %s", from, channel, mag, c, next_arg(copy, ©)); else do_hook(MODE_STRIPPED_LIST, "%s %s %c%c", from, channel, mag, c); break; case 'a': case 'i': case 'm': case 'n': case 'p': case 's': case 't': do_hook(MODE_STRIPPED_LIST, "%s %s %c%c", from, channel, mag, c); break; case 'b': case 'k': case 'o': case 'v': do_hook(MODE_STRIPPED_LIST, "%s %s %c%c %s", from, channel, mag, c, next_arg(copy, ©)); break; } } } else /* User mode */ { for (pointer = mode; *pointer; pointer++) { char c = *pointer; switch (c) { case '+': case '-': mag = c; break; default: do_hook(MODE_STRIPPED_LIST, "%s %s %c%c", from, channel, mag, c); break; } } } #ifndef __GNUC__ new_free(&free_copy); #endif }