Ejemplo n.º 1
0
static	void parse_server_notice(char *from, char *line)
{
	int	flag = 0;
	int	up_status = 0;
const	char	*f;	
				
	f = from;
	if (!f || !*f)
		if (!(f = get_server_itsname(from_server)))
			f = get_server_name(from_server);
			
	if (*line != '*'  && *line != '#' && strncmp(line, "MOTD ", 4))
		flag = 1;
	else
		flag = 0;

	if (do_hook(SERVER_NOTICE_LIST, flag?"%s *** %s":"%s %s", f, line))
	{
#ifdef WANT_OPERVIEW
		if (handle_oper_vision(f, line, &up_status))
			reset_display_target();
		else 
#endif
		if (strstr(line, "***"))
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
			{
				char *for_;
				for_ = next_arg(line,&line);
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
				add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
			}
		}
		else
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
			add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
		}
	}
	if (up_status)
		update_all_status(current_window, NULL, 0);
done1:
	reset_display_target();
}
Ejemplo n.º 2
0
/*
 * add_to_log: add the given line to the log file.  If no log file is open
 * this function does nothing. 
 */
void add_to_log(FILE * fp, time_t t, const char *line)
{
    if (fp) {
	fprintf(fp, "%s\n", !get_int_var(LASTLOG_ANSI_VAR) ? stripansicodes((char *) line) : line);
	fflush(fp);
    }
}
Ejemplo n.º 3
0
void input_msgreply(char dumb, char *dumber)
{
    char *cmdchar;
    char *line, *cmd, *t;
    char *snick;
    NickTab *nick = NULL;
    int got_space = 0;

    if (!(cmdchar = get_string_var(CMDCHARS_VAR)))
	cmdchar = DEFAULT_CMDCHARS;

    t = line = m_strdup(get_input());
    if (t)
	got_space = strchr(t, ' ') ? 1 : 0;
    cmd = next_arg(line, &line);
    snick = next_arg(line, &line);
    if ((cmd && *cmd == *cmdchar && got_space) || !cmd) {

	if (cmd && *cmd == *cmdchar)
	    cmd++;
	if (in_completion == STATE_NORMAL && snick)
	    strncpy(new_nick, snick, sizeof(new_nick) - 1);

	if ((nick = getnextnick(new_nick, input_lastmsg, snick))) {
	    if (nick->nick && *(nick->nick)) {
		snick = nick->nick;
		malloc_strcpy(&input_lastmsg, nick->nick);
	    }
	}
	if (nick) {
	    char *tmp = NULL;

	    input_clear_line('\0', NULL);
	    if (get_fset_var(FORMAT_NICK_MSG_FSET))
		malloc_strcpy(&tmp,
			      stripansicodes(convert_output_format
					     (get_fset_var(FORMAT_NICK_MSG_FSET), "%s%s %s %s", cmdchar,
					      nick->type ? nick->type : cmd ? cmd : "msg", nick->nick, line ? line : empty_str)));
	    else
		malloc_sprintf(&tmp, "%s%s %s %s", cmdchar, nick->type ? nick->type : cmd ? cmd : "msg", nick->nick,
			       line ? line : empty_str);
	    set_input(tmp);
	    new_free(&tmp);
	} else
	    command_completion(0, NULL);
    } else
	command_completion(0, NULL);
    update_input(UPDATE_ALL);
    new_free(&t);
}
Ejemplo n.º 4
0
void add_autonick_input(char *nick, char *line)
{
    char *tmp1 = NULL;

    input_clear_line('\0', NULL);
    if ((do_hook(AR_REPLY_LIST, "%s", nick))) {
	if (get_fset_var(FORMAT_NICK_AUTO_FSET))
	    malloc_strcpy(&tmp1,
			  stripansicodes(convert_output_format
					 (get_fset_var(FORMAT_NICK_AUTO_FSET), "%s %s", nick, line ? line : empty_str)));
	else
	    malloc_sprintf(&tmp1, "%s: %s", nick, line);
	set_input(tmp1);
	new_free(&tmp1);
    }
    update_input(UPDATE_ALL);
}
Ejemplo n.º 5
0
static	int  handle_oper_vision(const char *from, char *cline, int *up_status)
{
	char *fr, *for_, *temp, *temp2;
	char *p;
	int done_one = 0;
	char *line;
	unsigned long flags;
	int dcount;
			
	p = fr = for_ = temp = temp2 = NULL;

	if (from_server == -1 || !(flags = get_server_ircop_flags(from_server)))
		return 0;

	line = LOCAL_COPY(cline);
	if (!strncmp(line, "*** Notice -- ", 13)) line += 14, dcount = 14;
	else if (!strncmp(line, "*** \002Notice\002 --", 15)) line += 16, dcount = 16;

	done_one++;
/*
[ss]!irc.cs.cmu.edu D-line active for think[[email protected]]
*/
	set_display_target(NULL, LOG_SNOTE);	
	
	if (!strncmp(line, "Received KILL message for ", 26))
	{
		char *q = line + 26;
		int loc_check = 0;

		for_ = next_arg(q, &q);
		if (!end_strcmp(for_, ".", 1))
			chop(for_, 1);
		q += 5;
		fr = next_arg(q, &q);
		q += 6; 
		check_orig_nick(for_);

		
		if (strchr(fr, '.'))
		{
			nick_collisions++;
			if (!(flags & NICK_COLLIDE))
				goto done;  	
			serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_NICK_COLLISION_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q));
		}
		else 
		{
			oper_kills++;
			if (!(flags & NICK_KILL))
				goto done;  	

			if ((temp2 = next_arg(q, &q)))
				loc_check = charcount(temp2, '!');
			if (q && *q)
				q++; chop(q, 1);
			if (loc_check <= 2)		
				serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KILL_LOCAL_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q));
			else
				serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KILL_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q));
		}
		(*up_status)++;
	}
	else if (!strncmp(line, "Nick collision on", 17) || !strncmp(line, "Nick change collision on", 24))
	{
#if 0
irc.BitchX.com *** Notice -- Nick collision on nickserv(irc.distracted.net <-
               irc.distracted.net[[email protected]])(both killed)
[BitchX]  Nick collision llision killed on
#endif               
		nick_collisions++;
		if (!(flags & NICK_COLLIDE))
			goto done;  	
		if (!strncmp(line+5, "change", 6))
			p = line + 24;
		else
			p = line + 18;
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_NICK_COLLISION_FSET), "%s %s", update_clock(GET_TIME), p));
		(*up_status)++;
	}
	else if (!strncmp(line, "IP# Mismatch:", 13))
	{
		if (!(flags & IP_MISMATCH))
			goto done;  	
		for_ = line + 14;
		serversay(1, from_server, "%s", convert_output_format(" IP Mismatch %C$1-", "%s %s", update_clock(GET_TIME), for_));
	}
	else if (!strncmp(line, "Hacked ops on opless channel:", 29))
	{
		if (!(flags & HACK_OPS))
			goto done;  	
		for_ = line + 29;
		serversay(1, from_server, "%s", convert_output_format(" Hacked ops on $0", "%s", for_));
	}
	else if (!strncmp(line, "connect failure:", 16))
	{
		client_connects++;
		client_exits++;
		if (!(flags & SERVER_CRAP))
			goto done;  	
		for_ = line + 16;
		serversay(1, from_server, "%s", convert_output_format(" Connect failure %K[%n$0-%K]", "%s", for_));
	} 
	else if (!strncmp(line, "Identd response differs", 22))
	{
		if (!(flags & IDENTD))
			goto done;  	
		for_ = line + 24;
		serversay(1, from_server, "%s", convert_output_format(" Identd response differs %K[%C$1-%K]", "%s %s", update_clock(GET_TIME), for_));
	}
  	else if (!strncmp(line, "Fake: ", 6)) /* MODE */
  	{
		serv_fakes++;
		if (!(flags & FAKE_MODE))
			goto done;  	
		p = line + 6;
		if ((fr = next_arg(p, &temp)))
		{
			if (lookup_channel(fr, from_server, CHAN_NOUNLINK))
				serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FAKE_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp));
			else 
				serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FAKE_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp));
		}
  	}
  	else if (!strncmp(line, "Unauthorized connection from",28))
  	{
		serv_unauth++;
		if (!(flags & UNAUTHS))
			goto done;  	
		for_ = line + 28;
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_UNAUTH_FSET), "%s %s", update_clock(GET_TIME), for_));
	}
  	else if (!strncmp(line, "Too many connections from",25))
  	{
		serv_unauth++;
		if (!(flags & TOO_MANY))
			goto done;  	
		for_ = line + 25;
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_UNAUTH_FSET), "%s %s", update_clock(GET_TIME), for_));
	}
	else if (strstr(line, "Entering high-traffic mode -") || !strncmp(line, "still high-traffic mode -", 25))
	{
		char *q;
 		serv_split++;
		if (!(flags & TRAFFIC))
			goto done;  	
		if (!strncmp(line, "Entering", 8))
		{
			p = line + 28;
			for_ = next_arg(p, &p);
			q = temp2 = p;
			if (temp2)
			{
				chop(temp2, 1);
				q = temp2+2;
			}
		}
		else if (!strncmp(line+10, "Entering", 8))
		{
			p = line + 38;
			for_ = next_arg(p, &p);
			q = temp2 = p;
			if (temp2)
			{
				chop(temp2, 1);
				q = temp2+2;
			}
		}
		else
		{
			p = line + 25;
			for_ = next_arg(p, &p);
			q = temp2 = p;
			if (temp2)
			{
				chop(temp2, 1);
				q = temp2+2;
			}
		}
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_TRAFFIC_HIGH_FSET), "%s %s %s", update_clock(GET_TIME), for_, q));
	}
	else if (!strncmp(line, "Resuming standard operation", 27))
	{
		serv_rejoin++;
		if (!(flags & TRAFFIC))
			goto done;  	
		p = line + 27;
		for_ = next_arg(p, &p);
		if (for_ && *for_ == '-')
			for_ = next_arg(p, &p); 
		temp = next_arg(p, &temp2);
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_TRAFFIC_NORM_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, temp, temp2));
	}
	else if (wild_match("% is rehashing Server config*", line))
	{
		serv_rehash++;
		if (!(flags & REHASH))
			goto done;  	
		p = line;
		for_ = next_arg(p, &p);
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_REHASH_FSET), "%s %s", update_clock(GET_TIME), for_));
	}
	else if (wild_match("% added K-Line for *", line))
	{
		char *serv = NULL;
		serv_klines++;

		if (!(flags & KLINE))
			goto done;  	

		p = line;
		for_ = next_arg(p, &p);
		if (!strncmp(p, "from", 4))
		{
			next_arg(p, &p);
			serv = next_arg(p, &p);
		}
		p += 17;
		temp2 = next_arg(p, &temp);
		if (++temp2)
			chop(temp2, 1);
		if (serv)
			serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_GLINE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), for_, temp2, serv, temp));
		else
			serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KLINE_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, temp2, temp));
	}
	else if (!strncmp(line, "Rejecting vlad/joh/com bot:", 27) || !strncmp(line+14, "Rejecting eggdrop bot:", 20) || !strncmp(line, "Rejecting ojnk/annoy bot", 24))
	{
		client_bot++;
		if (!(flags & POSSIBLE_BOT))
			goto done;
		p = line + 10;
		temp2 = next_arg(p, &p);
		for_ = p + 4;
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2));
	}
	else if (!strncmp(line, "Possible bot ", 13))
	{
		client_bot++;
		if (!(flags & POSSIBLE_BOT))
			goto done;  	
		p = line + 13;
		for_ = next_arg(p, &p);
		if ((temp2 = next_arg(p, &p)))
			chop(temp2, 1);
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2));
	}
	else if (wild_match("Possible % bot *", line))
	{
		char *possible = NULL;
		client_bot++;
		if (!(flags & POSSIBLE_BOT))
			goto done;  	
		p = line;
		possible = next_arg(p, &p);
		next_arg(p, &p);
		for_ = next_arg(p, &p);
		if ((temp2 = next_arg(p, &p)))
		{
			chop(temp2, 1);
			*temp2 = ' ';
		}
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT1_FSET), "%s %s %s %s", update_clock(GET_TIME), possible?possible:"Unknown", for_, temp2));
	}
	else if (wild_match("% % is now operator*", line))
	{
		oper_requests++;
		if (!(flags & OPER_MODE))
			goto done;  	
		p = line;
		fr = next_arg(p, &p);
		if ((temp2 = next_arg(p, &p)))
		{
			chop(temp2, 1);
			if (*temp2 == '(')
				*temp2 = ' ';
		}
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_OPER_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp2));
	} 
	else if (!strncmp(line, "Received SQUIT", 14))
	{
		serv_squits++;
		if (!(flags & SQUIT))
			goto done;  	
		p = line + 14;
		fr = next_arg(p, &p);
		p += 5;
		for_ = next_arg(p, &temp2);
		if (temp2)
		{
			chop(temp2, 1);
			if (*temp2 == '(')
				temp2++;
		}
		serversay(1, from_server, "%s", convert_output_format(" SQUIT of $1 from $2 %K[%R$3-%K]", "%s %s %s %s", update_clock(GET_TIME), for_, fr, temp2));
	} 
	else if (!strncmp(line, "Received SERVER", 15))
	{
		serv_squits++;
		if (!(flags & SERVER_CONNECT))
			goto done;  	
		p = line + 15;
		fr = next_arg(p, &p);
		p += 5;
		for_ = next_arg(p, &temp2);
		if (temp2)
		{
			chop(temp2, 1);
			if (*temp2 == '(')
				temp2++;
		}
		serversay(1, from_server, "%s", convert_output_format(" Received SERVER %c$1%n from %c$2%n %K[%W$3-%K]", "%s %s %s %s", update_clock(GET_TIME), fr, for_, temp2));
	} 
	else if (!strncmp(line, "Sending SQUIT", 13))
	{
	    serv_squits++;
	    if (!(flags & SQUIT)) goto done;
	    p = line + 13;
	    fr = next_arg(p, &temp2);
	    if (temp2)
	    {
		chop(temp2, 1);
		if (*temp2 == '(') temp2++;
	    }
	    serversay(1, from_server, "%s", convert_output_format(" Sending SQUIT %c$1%n %K[%R$2-%K]", "%s %s %s", update_clock(GET_TIME), fr, temp2));
	}
	else if (!strncmp(line, "Sending SERVER", 14))
	{
	    serv_squits++;
	    if (!(flags & SERVER_CONNECT)) goto done;
	    p = line + 14;
	    fr = next_arg(p, &temp2);
	    if (temp2)
	    {
		chop(temp2, 1);
		if (*temp2 == '(') temp2++;
	    }
	    serversay(1, from_server, "%s", convert_output_format(" Sending SERVER %c$1%n %K[%W$2-%K]", "%s %s %s", update_clock(GET_TIME), fr, temp2));
	}
	else if (!strncmp(line, "WALLOPS :Remote CONNECT", 23))
	{
		serv_connects++;
		if (!(flags & SERVER_CONNECT))
			goto done;  	
		p = line + 23;
		for_ = next_arg(p, &p);
		fr = next_arg(p, &p);
		next_arg(p, &temp2);
		serversay(1, from_server, "%s", convert_output_format(" Remote Connect of $1:$2 from $3", "%s %s %s %s", update_clock(GET_TIME), for_, fr, temp2));
	}
	else if (!strncmp(line, "Client connecting", 17) || !strncmp(line, "Client exiting", 14))
	{
		char *q = strchr(line, ':');
		char *port = empty_string;
		int conn = !strncmp(line+7, "connect", 7) ? 1 : 0;
		int dalnet = 0, ircnet = 0;

		if (strlen(line) >= 19 && line[18] == ':')
			q = NULL;
		else
			dalnet = (q == NULL);

		if (!dalnet)
		{
		    if ((q = strchr(q + 1, ' ')))
		    {
			    q++;
			    if (conn)
				ircnet = !strcmp(q, "is ");
			    else
				ircnet = !strcmp(q, "was ");
		    }
		}

		if (conn)
			client_connects++;
		else 
			client_exits++;

		if (!(flags & CLIENT_CONNECT))
			goto done;  	
		p = line;
		next_arg(p, &p); next_arg(p, &p);
		if (ircnet)
		{
		    for_ = LOCAL_COPY(p);
		    fr = LOCAL_COPY(p);
		    temp = LOCAL_COPY(p);
		    temp2 = LOCAL_COPY(p);

		    if (conn) sscanf(p, "%s is %s from %s", for_, fr, temp);
		    else sscanf(p, "%s was %s from %s", for_, fr, temp);

		    q = p;
		    sprintf(q, "%s@%s", fr, temp);
		    if (!conn) 
		    {
			port = strstr(temp2, "reason:");
			port += 8;
		    }
		} 
		else if (dalnet && !conn)
		{
			for_ = next_arg(p, &p);			
			q = temp2 = p;
			if (temp2)
			{
				chop(temp2, 1);
				q = temp2+1;
			}
		} 
		else if (conn && dalnet)
		{
			next_arg(p, &p); next_arg(p, &p); 
			port = next_arg(p, &p);
			if (!(for_ = next_arg(p, &p)))
				for_ = port;
			{
				q = temp2 = p;
				chop(port, 1);
				if (temp2)
				{
					chop(temp2, 1);
					q = temp2+1;
				}
			}
		}
		else /* hybrid */
		{
		    for_ = q;
		    if ((q = strchr(q, ' ')))
		    {
			    *q = 0;
			    q += 2;
		    }
		    if ((port = strchr(q, ' ')))
		    {
			    *port = 0;
			    port++;
			    chop(q, 1);
		    }
		}
		
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(conn ? FORMAT_SERVER_NOTICE_CLIENT_CONNECT_FSET : FORMAT_SERVER_NOTICE_CLIENT_EXIT_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, q ? q : empty_string, port ? port : empty_string));
	}
	else if (!strncmp(line, "Terminating client for excess", 29))
	{
		char *q;

		client_floods++;
		if (!(flags & TERM_FLOOD))
			goto done;  	

		p = line + 29;
		for_ = next_arg(p, &p);
		q = temp2 = p;
		if (temp2)
		{
			chop(temp2, 1);
			q = temp2+1;
		}
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_CLIENT_TERM_FSET), "%s %s %s", update_clock(GET_TIME), for_, q));
	}
	else if (!strncmp(line, "Invalid username:"******"%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_CLIENT_INVALID_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2));
	}
	else if (!strncmp(line, "STATS ", 6))
	{

		stats_req++;
		if (!(flags & STATS_REQUEST))
			goto done;  	
		p = line + 6;
		temp = next_arg(p, &p);
		p += 12;
		for_ = next_arg(p, &p);
		if ( (temp2 = ++p) )
			chop(temp2, 1);
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_STATS_FSET), "%s %s %s %s", update_clock(GET_TIME), temp, for_, temp2));
	}
	else if (!strncmp(line, "Nick flooding detected by:", 26))
	{

		if (!(flags & NICK_FLOODING))
			goto done;  	
		p = line + 26;
		serversay(1, from_server, "%s", convert_output_format(" Nick Flooding %K[%B$1-%K]", "%s %s", update_clock(GET_TIME), for_));
	}
	else if (!strncmp(line, "Kill line active for", 20) || !strncmp(line+14, "K-line active for", 17))
	{

		if (!(flags & KILL_ACTIVE))
			goto done;  	
		if (!strncmp(line + 14,"Kill", 4))
			for_ = line + 20;
		else
			for_ = line + 17;
		serversay(1, from_server, "%s", convert_output_format(" Kill line for $1 active", "%s %s", update_clock(GET_TIME), for_));
	}
	else 
	{
		if (!(flags & SERVER_CRAP))
			goto done;  	
		serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), from, stripansicodes(line)));
		add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
	} 
done:
	reset_display_target();
	return done_one;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
void send_line(char dumb, char *dumber)
{
    int server;
    WaitPrompt *OldPrompt;

    server = from_server;
    from_server = get_window_server(0);
    unhold_a_window(curr_scr_win);
    if (current_screen->promptlist && current_screen->promptlist->type == WAIT_PROMPT_LINE) {
	OldPrompt = current_screen->promptlist;
	(*OldPrompt->func) (OldPrompt->data, get_input());
	set_input(empty_str);
	current_screen->promptlist = OldPrompt->next;
	new_free(&OldPrompt->data);
	new_free(&OldPrompt->prompt);
	new_free(&OldPrompt);
	change_input_prompt(-1);
    } else {
	char *line, *tmp = NULL;

	line = get_input();
	if (line && (*line != get_int_var(CMDCHARS_VAR)) && get_int_var(NICK_COMPLETION_VAR)) {
	    char auto_comp_char = ':';

	    if (!(auto_comp_char = (char) get_int_var(NICK_COMPLETION_CHAR_VAR)))
		auto_comp_char = ':';

	    /* possible nick completion */
	    if (strchr(line, auto_comp_char)) {
		char *p;
		struct channel *chan;
		struct nick_list *nick;
		char *channel;

		malloc_strcpy(&tmp, line);
		p = strchr(tmp, auto_comp_char);
		*p++ = 0;
		if (*tmp && *p && (channel = get_current_channel_by_refnum(0))) {
		    chan = lookup_channel(channel, from_server, 0);
		    for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
			if (!my_strnicmp(tmp, nick->nick, strlen(tmp)))
			    break;
		    if (nick) {
			if (get_fset_var(FORMAT_NICK_COMP_FSET))
			    malloc_strcpy(&tmp,
					  stripansicodes(convert_output_format
							 (get_fset_var(FORMAT_NICK_COMP_FSET), "%s %s", nick->nick, p)));
			else
			    malloc_sprintf(&tmp, "%s%c %s", nick->nick, auto_comp_char, p);
		    } else
			malloc_strcpy(&tmp, line);
		} else
		    malloc_strcpy(&tmp, line);
	    } else
		malloc_strcpy(&tmp, line);
	} else
	    malloc_strcpy(&tmp, line);
	if (do_hook(INPUT_LIST, "%s", tmp)) {
	    if (get_int_var(INPUT_ALIASES_VAR))
		parse_line(NULL, tmp, empty_str, 1, 0);
	    else
		parse_line(NULL, tmp, NULL, 1, 0);
	}
	update_input(UPDATE_ALL);
	new_free(&tmp);
    }
    new_free(&input_lastmsg);
    *new_nick = 0;
    in_completion = STATE_NORMAL;
    from_server = server;
}
Ejemplo n.º 8
0
/*
 * update_input: does varying amount of updating on the input line depending
 * upon the position of the cursor and the update flag.  If the cursor has
 * move toward one of the edge boundaries on the screen, update_cursor()
 * flips the input line to the next (previous) line of text. The update flag
 * may be: 
 *
 * NO_UPDATE - only do the above bounds checking. 
 *
 * UPDATE_JUST_CURSOR - do bounds checking and position cursor where is should
 * be. 
 *
 * UPDATE_FROM_CURSOR - does all of the above, and makes sure everything from
 * the cursor to the right edge of the screen is current (by redrawing it). 
 *
 * UPDATE_ALL - redraws the entire line 
 */
void update_input(int update)
{
    int old_start;
    static int co = 0, li = 0;
    char *ptr;
    int len, free_it = 1, cnt, ansi_count, max;

    char *prompt;

    cursor_to_input();

    if (current_screen->promptlist)
	prompt = current_screen->promptlist->prompt;
    else
	prompt = input_prompt;
    if (prompt) {
	if (update != NO_UPDATE) {
	    char *inp_ptr = NULL;
	    int args_used;

	    if (is_process(get_target_by_refnum(0))) {
		ptr = (char *) get_prompt_by_refnum(0);
		free_it = 0;
	    } else if (!get_int_var(DISPLAY_ANSI_VAR))
		ptr = expand_alias(stripansicodes(prompt), empty_str, &args_used, NULL);
	    else
		ptr = expand_alias(prompt, empty_str, &args_used, NULL);
	    if (*ptr && ((my_strnicmp(ptr, "Password:"******"Operator Password:"******"Server Password:", 16) == 0)))
		term_echo(0);
	    else
		term_echo(1);
	    len = strlen(ptr);
	    if (strncmp(ptr, current_screen->input_buffer, len) || !len) {
		malloc_strcpy(&inp_ptr, INPUT_BUFFER + MIN_POS);
		strmcpy(INPUT_BUFFER, ptr, INPUT_BUFFER_SIZE);
		THIS_POS += (len - MIN_POS);
		MIN_POS = strlen(ptr);
		ADD_TO_INPUT(inp_ptr);
		new_free(&inp_ptr);
		update = UPDATE_ALL;
	    }

	    if (free_it)
		new_free(&ptr);
	}
    } else
	term_echo(1);

    if ((li != term_rows) || (co != term_cols)) {
	/* resized? Keep it simple and reset everything */
	input_line = term_rows - 1;
	zone = term_cols - (WIDTH * 2) + 4;
	lower_mark = WIDTH;
	upper_mark = term_cols - WIDTH;
	cursor = current_screen->buffer_min_pos;
	current_screen->buffer_pos = current_screen->buffer_min_pos;
	str_start = 0;
	li = term_rows;
	co = term_cols;
    }
    old_start = str_start;
    ansi_count = count_ansi(current_screen->input_buffer, zone);
    if (old_ansi != ansi_count || current_screen->buffer_pos - ansi_count > zone) {
	lower_mark = WIDTH;
	upper_mark = term_cols - WIDTH;
	str_start = 0;
    }
    ansi_count = count_ansi(&(current_screen->input_buffer[str_start]), zone);

    while ((current_screen->buffer_pos - ansi_count < lower_mark) && lower_mark > WIDTH) {
	upper_mark = lower_mark - ansi_count;
	lower_mark -= (zone + ansi_count);
	str_start -= (zone + ansi_count);
	if (str_start < zone) {
	    str_start = 0;
	    ansi_count = count_ansi(&(current_screen->input_buffer[str_start]), zone);
	    lower_mark -= ansi_count;
	    upper_mark -= ansi_count;
	}
    }
    while (current_screen->buffer_pos - ansi_count >= upper_mark) {
	lower_mark = upper_mark + ansi_count;
	upper_mark += zone + ansi_count;
	str_start += zone + ansi_count;
	if (ansi_count)
	    ansi_count = 0;
    }

    /* we need to count ansi characters again, this time in the part of the string we are gonna display in a few moments */
    ansi_count = count_ansi(&(current_screen->input_buffer[str_start]), zone);
    old_ansi = count_ansi(current_screen->input_buffer, zone);
    /* we need to substract number of ansi characters from cursor position since those are not visible, otherwise we'd display cursor
     * in wrong place */
    cursor = current_screen->buffer_pos - str_start - ansi_count;
    if ((old_start != str_start) || (update == UPDATE_ALL)) {
	term_move_cursor(0, input_line);
	if ((str_start == 0) && (MIN_POS > 0)) {
	    int echo;

	    echo = term_echo(1);
	    if (MIN_POS > (term_cols - WIDTH))
		len = term_cols - WIDTH - 1 /* + ansi_count */ ;
	    else
		len = MIN_POS;
	    cnt = /* term_puts */ safe_puts(&(INPUT_BUFFER[str_start]), len);
	    term_echo(echo);
	    cnt += /* term_puts */ safe_puts(&(current_screen->input_buffer[
									       str_start + len]), term_cols - len + ansi_count);
	} else
	    cnt = /* term_puts */ safe_puts(&(INPUT_BUFFER[str_start]), term_cols);
	term_clear_to_eol();
	term_move_cursor(cursor, input_line);
    } else if (update == UPDATE_FROM_CURSOR) {
	term_move_cursor(cursor, input_line);
	cnt = cursor;
	max = term_cols - (current_screen->buffer_pos - str_start) + ansi_count;
	if ((len = strlen(&(THIS_CHAR))) > max)
	    len = max;
	cnt += /* term_puts */ safe_puts(&(THIS_CHAR), len);
	term_clear_to_eol();
	term_move_cursor(cursor, input_line);
    } else if (update == UPDATE_JUST_CURSOR)
	term_move_cursor(cursor, input_line);
    term_flush();
}
Ejemplo n.º 9
0
/*
 * do_processes: given a set of read-descriptors (as returned by a call to
 * select()), this will determine which of the process has produced output
 * and will hadle it appropriately
 */
void do_processes(fd_set * rd)
{
    int i, flag;
    char exec_buffer[INPUT_BUFFER_SIZE + 1];
    char *ptr;
    Process *proc;
    int old_timeout;

    if (process_list == NULL)
        return;
    old_timeout = dgets_timeout(1);
    for (i = 0; i < process_list_size; i++) {
        if ((proc = process_list[i]) && proc->p_stdout != -1) {
            if (FD_ISSET(proc->p_stdout, rd)) {

                /*
                 * This switch case indented back to allow for 80 columns,
                 * phone, jan 1993.
                 */
                switch (dgets(exec_buffer, INPUT_BUFFER_SIZE, proc->p_stdout, NULL)) {
                case 0:
                    if (proc->p_stderr == -1) {
                        proc->p_stdin = exec_close(proc->p_stdin);
                        proc->p_stdout = exec_close(proc->p_stdout);
                        if (proc->exited)
                            delete_process(i);
                    } else
                        proc->p_stdout = exec_close(proc->p_stdout);
                    break;
                case -1:
                    if (proc->logical)
                        flag = do_hook(EXEC_PROMPT_LIST, "%s %s", proc->logical, exec_buffer);
                    else
                        flag = do_hook(EXEC_PROMPT_LIST, "%d %s", i, exec_buffer);
                    set_prompt_by_refnum(proc->refnum, exec_buffer);
                    update_input(UPDATE_ALL);
                    /* if (flag == 0) */
                    break;
                default:
                    message_to(proc->refnum);
                    proc->counter++;
                    ptr = exec_buffer + strlen(exec_buffer) - 1;
                    if ((*ptr == '\n') || (*ptr == '\r')) {
                        *ptr = (char) 0;
                        ptr = exec_buffer + strlen(exec_buffer) - 1;
                        if ((*ptr == '\n') || (*ptr == '\r'))
                            *ptr = (char) 0;
                    }

                    if (proc->logical)
                        flag = do_hook(EXEC_LIST, "%s %s", proc->logical, exec_buffer);
                    else
                        flag = do_hook(EXEC_LIST, "%d %s", i, exec_buffer);

                    if (flag) {
                        if (proc->redirect) {
                            int server;

                            server = from_server;
                            from_server = proc->server;
                            send_text(proc->who, stripansicodes(exec_buffer), proc->redirect, 1, 1);
                            from_server = server;
                        } else
                            put_it("%s", stripansicodes(exec_buffer));
                    }
                    message_to(0);
                    break;
                }

                /* end of special intendation */

            }
        }
        if (process_list && i < process_list_size && (proc = process_list[i]) && proc->p_stderr != -1) {
            if (FD_ISSET(proc->p_stderr, rd)) {

                /* Do the intendation on this switch as well */

                switch (dgets(exec_buffer, INPUT_BUFFER_SIZE, proc->p_stderr, NULL)) {
                case 0:
                    if (proc->p_stdout == -1) {
                        proc->p_stderr = exec_close(proc->p_stderr);
                        proc->p_stdin = exec_close(proc->p_stdin);
                        if (proc->exited)
                            delete_process(i);
                    } else
                        proc->p_stderr = exec_close(proc->p_stderr);
                    break;
                case -1:
                    if (proc->logical)
                        flag = do_hook(EXEC_PROMPT_LIST, "%s %s", proc->logical, exec_buffer);
                    else
                        flag = do_hook(EXEC_PROMPT_LIST, "%d %s", i, exec_buffer);
                    set_prompt_by_refnum(proc->refnum, exec_buffer);
                    update_input(UPDATE_ALL);
                    if (flag == 0)
                        break;
                default:
                    message_to(proc->refnum);
                    (proc->counter)++;
                    ptr = exec_buffer + strlen(exec_buffer) - 1;
                    if ((*ptr == '\n') || (*ptr == '\r')) {
                        *ptr = (char) 0;
                        ptr = exec_buffer + strlen(exec_buffer) - 1;
                        if ((*ptr == '\n') || (*ptr == '\r'))
                            *ptr = (char) 0;
                    }

                    if (proc->logical)
                        flag = do_hook(EXEC_ERRORS_LIST, "%s %s", proc->logical, exec_buffer);
                    else
                        flag = do_hook(EXEC_ERRORS_LIST, "%d %s", i, exec_buffer);

                    if (flag) {
                        if (proc->redirect) {
                            int server;

                            server = from_server;
                            from_server = proc->server;
                            send_text(proc->who, stripansicodes(exec_buffer), process_list[i]->redirect, 1, 1);
                            from_server = server;
                        } else
                            put_it("%s", stripansicodes(exec_buffer));
                    }
                    message_to(0);
                    break;
                }

                /* End of indentation for 80 columns */

            }
        }
    }

    check_process_limits();
    (void) dgets_timeout(old_timeout);
}