1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

Add numeric codes for low chars (< 32) in irc and jabber debug buffers

This commit is contained in:
Sebastien Helleu
2009-02-07 18:49:12 +01:00
parent 1491699706
commit 94aa12d8ff
2 changed files with 64 additions and 4 deletions
+32 -2
View File
@@ -55,7 +55,9 @@ void
irc_debug_printf (struct t_irc_server *server, int send, int modified,
const char *message)
{
char *buf;
char *buf, *buf2;
const char *ptr_buf;
int pos_buf, pos_buf2, char_size, i;
if (!weechat_irc_plugin->debug || !message)
return;
@@ -87,6 +89,32 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
}
buf = weechat_iconv_to_internal (NULL, message);
buf2 = malloc ((strlen (buf) * 3) + 1);
if (buf2)
{
ptr_buf = (buf) ? buf : message;
pos_buf = 0;
pos_buf2 = 0;
while (ptr_buf[pos_buf])
{
if (ptr_buf[pos_buf] < 32)
{
buf2[pos_buf2++] = '\\';
buf2[pos_buf2++] = (ptr_buf[pos_buf] / 10) + '0';
buf2[pos_buf2++] = (ptr_buf[pos_buf] % 10) + '0';
pos_buf++;
}
else
{
char_size = weechat_utf8_char_size (ptr_buf + pos_buf);
for (i = 0; i < char_size; i++)
{
buf2[pos_buf2++] = ptr_buf[pos_buf++];
}
}
}
buf2[pos_buf2] = '\0';
}
weechat_printf (irc_debug_buffer,
"%s%s%s%s%s\t%s",
@@ -99,9 +127,11 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
(send) ?
((modified) ? IRC_DEBUG_PREFIX_SEND_MOD : IRC_DEBUG_PREFIX_SEND) :
((modified) ? IRC_DEBUG_PREFIX_RECV_MOD : IRC_DEBUG_PREFIX_RECV),
(buf) ? buf : message);
(buf2) ? buf2 : ((buf) ? buf : message));
if (buf)
free (buf);
if (buf2)
free (buf2);
}
/*
+32 -2
View File
@@ -56,7 +56,9 @@ void
jabber_debug_printf (struct t_jabber_server *server, int send, int modified,
const char *message)
{
char *buf;
char *buf, *buf2;
const char *ptr_buf;
int pos_buf, pos_buf2, char_size, i;
if (!weechat_jabber_plugin->debug || !message)
return;
@@ -89,6 +91,32 @@ jabber_debug_printf (struct t_jabber_server *server, int send, int modified,
}
buf = weechat_iconv_to_internal (NULL, message);
buf2 = malloc ((strlen (buf) * 3) + 1);
if (buf2)
{
ptr_buf = (buf) ? buf : message;
pos_buf = 0;
pos_buf2 = 0;
while (ptr_buf[pos_buf])
{
if (ptr_buf[pos_buf] < 32)
{
buf2[pos_buf2++] = '\\';
buf2[pos_buf2++] = (ptr_buf[pos_buf] / 10) + '0';
buf2[pos_buf2++] = (ptr_buf[pos_buf] % 10) + '0';
pos_buf++;
}
else
{
char_size = weechat_utf8_char_size (ptr_buf + pos_buf);
for (i = 0; i < char_size; i++)
{
buf2[pos_buf2++] = ptr_buf[pos_buf++];
}
}
}
buf2[pos_buf2] = '\0';
}
weechat_printf (jabber_debug_buffer,
"%s%s%s%s%s%s\t%s",
@@ -102,9 +130,11 @@ jabber_debug_printf (struct t_jabber_server *server, int send, int modified,
(send) ?
((modified) ? JABBER_DEBUG_PREFIX_SEND_MOD : JABBER_DEBUG_PREFIX_SEND) :
((modified) ? JABBER_DEBUG_PREFIX_RECV_MOD : JABBER_DEBUG_PREFIX_RECV),
(buf) ? buf : message);
(buf2) ? buf2 : ((buf) ? buf : message));
if (buf)
free (buf);
if (buf2)
free (buf2);
}
/*