Pass STXT_NOTICE flag instead of command string to functions downstream of send_text()
This uses another bit in the existing flags argument in place of the command argument, and avoids
having to re-compare against fixed strings ("PRIVMSG", "NOTICE").
This commit is contained in:
@@ -141,9 +141,9 @@ struct dcc_offer {
|
||||
int dcc_activechat(char *); /* identify all active chat dcc's */
|
||||
int dcc_activebot(char *); /* identify all active bot's */
|
||||
int dcc_activeraw(char *); /* identify all active raw connects */
|
||||
void dcc_chat_transmit(char *, char *, char *, char *, unsigned);
|
||||
void dcc_bot_transmit(char *, char *, char *);
|
||||
void dcc_raw_transmit(char *, char *, char *);
|
||||
void dcc_chat_transmit(char *, char *, char *, unsigned);
|
||||
void dcc_bot_transmit(char *, char *, unsigned);
|
||||
void dcc_raw_transmit(char *, char *, unsigned);
|
||||
|
||||
void handle_dcc_offer(struct dcc_offer *);
|
||||
|
||||
|
||||
@@ -3752,7 +3752,7 @@ static int recursion = 0;
|
||||
from_server = old_from_server;
|
||||
}
|
||||
|
||||
static int try_send_special_target(char *target, const char *text, char *command, unsigned stxt_flags)
|
||||
static int try_send_special_target(char *target, const char *text, unsigned stxt_flags)
|
||||
{
|
||||
/*
|
||||
* It is legal to send an empty line to a process, but not legal
|
||||
@@ -3816,14 +3816,14 @@ static int try_send_special_target(char *target, const char *text, char *command
|
||||
from_server = -1;
|
||||
if (dcc_activechat(target+1))
|
||||
{
|
||||
dcc_chat_transmit(target + 1, line, line, command, stxt_flags);
|
||||
dcc_chat_transmit(target + 1, line, line, stxt_flags);
|
||||
if (!(stxt_flags & STXT_QUIET))
|
||||
addtabkey(target, "msg", 0);
|
||||
}
|
||||
else if (dcc_activebot(target + 1))
|
||||
dcc_bot_transmit(target + 1, line, command);
|
||||
dcc_bot_transmit(target + 1, line, stxt_flags);
|
||||
else
|
||||
dcc_raw_transmit(target + 1, line, command);
|
||||
dcc_raw_transmit(target + 1, line, stxt_flags);
|
||||
|
||||
add_last_type(&last_sent_dcc[0], MAX_LAST_MSG, NULL, NULL, target+1, text);
|
||||
from_server = old_server;
|
||||
@@ -3906,6 +3906,10 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
|
||||
sent_text_recursion++;
|
||||
|
||||
window_display = !(flags & STXT_QUIET);
|
||||
|
||||
if (command && !strcmp(command, "NOTICE"))
|
||||
flags |= STXT_NOTICE;
|
||||
|
||||
free_nick = next_nick = m_strdup(nick_list);
|
||||
|
||||
while ((current_nick = next_nick))
|
||||
@@ -3918,7 +3922,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
|
||||
if (!*current_nick)
|
||||
continue;
|
||||
|
||||
if (try_send_special_target(current_nick, text, command, flags))
|
||||
if (try_send_special_target(current_nick, text, flags))
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -3938,7 +3942,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
|
||||
if (!(i = is_channel(current_nick)) && !(flags & STXT_QUIET))
|
||||
addtabkey(current_nick, "msg", 0);
|
||||
|
||||
if (command && !strcmp(command, "NOTICE"))
|
||||
if (flags & STXT_NOTICE)
|
||||
i += 2;
|
||||
|
||||
if ((key = is_crypted(current_nick)))
|
||||
|
||||
27
source/dcc.c
27
source/dcc.c
@@ -955,7 +955,7 @@ SocketList *sl;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void new_dcc_message_transmit (char *user, char *text, char *text_display, int type, unsigned stxt_flags, char *cmd, int check_host)
|
||||
static void new_dcc_message_transmit (char *user, char *text, char *text_display, int type, unsigned stxt_flags, int check_host)
|
||||
{
|
||||
SocketList *s = NULL;
|
||||
DCC_int *n = NULL;
|
||||
@@ -996,12 +996,12 @@ char thing = 0;
|
||||
/*
|
||||
* Check for CTCPs... whee.
|
||||
*/
|
||||
if (cmd && *text == CTCP_DELIM_CHAR && !strbegins(text+1, "ACTION"))
|
||||
if (*text == CTCP_DELIM_CHAR && !strbegins(text+1, "ACTION"))
|
||||
{
|
||||
if (!strcmp(cmd, "PRIVMSG"))
|
||||
strlcpy(tmp, DCC_CTCP_MESSAGE, sizeof tmp);
|
||||
else
|
||||
if (stxt_flags & STXT_NOTICE)
|
||||
strlcpy(tmp, DCC_CTCP_REPLY, sizeof tmp);
|
||||
else
|
||||
strlcpy(tmp, DCC_CTCP_MESSAGE, sizeof tmp);
|
||||
}
|
||||
|
||||
strmcat(tmp, text, n->blocksize-3);
|
||||
@@ -1028,7 +1028,7 @@ char thing = 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern void dcc_chat_transmit (char *user, char *text, char *orig, char *type, unsigned stxt_flags)
|
||||
extern void dcc_chat_transmit (char *user, char *text, char *orig, unsigned stxt_flags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -1056,25 +1056,20 @@ extern void dcc_chat_transmit (char *user, char *text, char *orig, char *type, u
|
||||
strcat(bogus, space);
|
||||
strcat(bogus, text);
|
||||
|
||||
new_dcc_message_transmit(user, bogus, orig, DCC_RAW, stxt_flags, type, 0);
|
||||
new_dcc_message_transmit(user, bogus, orig, DCC_RAW, stxt_flags, 0);
|
||||
}
|
||||
else
|
||||
new_dcc_message_transmit(user, text, orig, DCC_CHAT, stxt_flags, type, 0);
|
||||
new_dcc_message_transmit(user, text, orig, DCC_CHAT, stxt_flags, 0);
|
||||
reset_display_target();
|
||||
}
|
||||
|
||||
extern void dcc_bot_transmit (char *user, char *text, char *type)
|
||||
extern void dcc_bot_transmit (char *user, char *text, unsigned stxt_flags)
|
||||
{
|
||||
set_display_target(user, LOG_DCC);
|
||||
new_dcc_message_transmit(user, text, NULL, DCC_BOTMODE, STXT_QUIET, type, 1);
|
||||
new_dcc_message_transmit(user, text, NULL, DCC_BOTMODE, stxt_flags | STXT_QUIET, 1);
|
||||
reset_display_target();
|
||||
}
|
||||
|
||||
extern void dcc_chat_transmit_quiet (char *user, char *text, char *type)
|
||||
{
|
||||
new_dcc_message_transmit(user, text, NULL, DCC_CHAT, STXT_QUIET, type, 0);
|
||||
}
|
||||
|
||||
int dcc_activechat(char *user)
|
||||
{
|
||||
return find_dcc(user, NULL, NULL, DCC_CHAT, 0, 1, -1) ? 1 : 0;
|
||||
@@ -4353,7 +4348,7 @@ char *get_dcc_info(SocketList *s, DCC_int *n, int i)
|
||||
n->filename, i, n->server);
|
||||
}
|
||||
|
||||
void dcc_raw_transmit (char *user, char *text, char *type)
|
||||
void dcc_raw_transmit (char *user, char *text, unsigned stxt_flags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1250,7 +1250,7 @@ char *new_str;
|
||||
else
|
||||
put_it("%s", convert_output_format(fget_string_var(FORMAT_SEND_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), to, get_server_nickname(from_server), new_str));
|
||||
if ((*to == '=') && dcc_activechat(to+1))
|
||||
dcc_chat_transmit(to+2, new_str, new_str, "PRIVMSG", 0);
|
||||
dcc_chat_transmit(to + 3, new_str, new_str, 0);
|
||||
else
|
||||
send_to_server("PRIVMSG %s :%s", to, new_str);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user