mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
Merge pull request #43 from ailin-nemui/server-outgoing
remove newline from "server outgoing modify"
This commit is contained in:
commit
ea961623f5
@ -151,7 +151,7 @@ irc.c:
|
|||||||
"whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address
|
"whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address
|
||||||
|
|
||||||
"server incoming", SERVER_REC, char *data
|
"server incoming", SERVER_REC, char *data
|
||||||
"server outgoing modify", SERVER_REC, GString *data
|
"server outgoing modify", SERVER_REC, GString *data, int crlf
|
||||||
|
|
||||||
(for perl parser..)
|
(for perl parser..)
|
||||||
"redir "<cmd>, SERVER_REC, char *args, char *sender_nick, char *sender_address
|
"redir "<cmd>, SERVER_REC, char *args, char *sender_nick, char *sender_address
|
||||||
|
@ -718,6 +718,7 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
|
|||||||
GString *str;
|
GString *str;
|
||||||
long usecs;
|
long usecs;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
int crlf;
|
||||||
|
|
||||||
if (!IS_IRC_SERVER(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return 0;
|
return 0;
|
||||||
@ -741,15 +742,29 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
|
|||||||
|
|
||||||
/* send command */
|
/* send command */
|
||||||
str = g_string_new(cmd);
|
str = g_string_new(cmd);
|
||||||
signal_emit("server outgoing modify", 2, server, str);
|
|
||||||
|
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
||||||
|
crlf = 2;
|
||||||
|
else if (str->len > 1 && str->str[str->len - 1] == '\n')
|
||||||
|
crlf = 1;
|
||||||
|
else
|
||||||
|
crlf = 0;
|
||||||
|
|
||||||
|
if (crlf)
|
||||||
|
g_string_truncate(str, str->len - crlf);
|
||||||
|
|
||||||
|
signal_emit("server outgoing modify", 3, server, str, crlf);
|
||||||
if (str->len) {
|
if (str->len) {
|
||||||
|
if (crlf == 2)
|
||||||
|
g_string_append(str, "\r\n");
|
||||||
|
else if (crlf == 1)
|
||||||
|
g_string_append(str, "\n");
|
||||||
|
|
||||||
irc_server_send_data(server, str->str, str->len);
|
irc_server_send_data(server, str->str, str->len);
|
||||||
|
|
||||||
/* add to rawlog without [CR+]LF */
|
/* add to rawlog without [CR+]LF */
|
||||||
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
if (crlf)
|
||||||
str->str[str->len - 2] = '\0';
|
g_string_truncate(str, str->len - crlf);
|
||||||
else if (str->str[str->len - 1] == '\n')
|
|
||||||
str->str[str->len - 1] = '\0';
|
|
||||||
rawlog_output(server->rawlog, str->str);
|
rawlog_output(server->rawlog, str->str);
|
||||||
server_redirect_command(server, str->str, redirect);
|
server_redirect_command(server, str->str, redirect);
|
||||||
}
|
}
|
||||||
|
@ -115,20 +115,34 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, int irc_send_whe
|
|||||||
|
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
/* Add CR+LF to command */
|
/* Add CR+LF to command */
|
||||||
g_string_append_c(str, 13);
|
g_string_append(str, "\r\n");
|
||||||
g_string_append_c(str, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irc_send_when == IRC_SEND_NOW) {
|
if (irc_send_when == IRC_SEND_NOW) {
|
||||||
signal_emit("server outgoing modify", 2, server, str);
|
int crlf;
|
||||||
|
|
||||||
|
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
||||||
|
crlf = 2;
|
||||||
|
else if (str->len > 1 && str->str[str->len - 1] == '\n')
|
||||||
|
crlf = 1;
|
||||||
|
else
|
||||||
|
crlf = 0;
|
||||||
|
|
||||||
|
if (crlf)
|
||||||
|
g_string_truncate(str, str->len - crlf);
|
||||||
|
|
||||||
|
signal_emit("server outgoing modify", 3, server, str, crlf);
|
||||||
if (str->len) {
|
if (str->len) {
|
||||||
|
if (crlf == 2)
|
||||||
|
g_string_append(str, "\r\n");
|
||||||
|
else if (crlf == 1)
|
||||||
|
g_string_append(str, "\n");
|
||||||
|
|
||||||
irc_server_send_data(server, str->str, str->len);
|
irc_server_send_data(server, str->str, str->len);
|
||||||
|
|
||||||
/* add to rawlog without [CR+]LF */
|
/* add to rawlog without [CR+]LF */
|
||||||
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
if (crlf)
|
||||||
str->str[str->len - 2] = '\0';
|
g_string_truncate(str, str->len - crlf);
|
||||||
else if (str->str[str->len - 1] == '\n')
|
|
||||||
str->str[str->len - 1] = '\0';
|
|
||||||
rawlog_output(server->rawlog, str->str);
|
rawlog_output(server->rawlog, str->str);
|
||||||
server_redirect_command(server, str->str, server->redirect_next);
|
server_redirect_command(server, str->str, server->redirect_next);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user