summaryrefslogtreecommitdiff
path: root/ratox.c
diff options
context:
space:
mode:
authorpranomostro <pranomostro@posteo.net>2017-07-09 13:39:34 +0200
committerpranomostro <pranomostro@posteo.net>2017-07-09 13:39:34 +0200
commitf7a953ff973a632f4afa4914482052c2ad8ee300 (patch)
tree8c6a75af07195b3cf40de235bd097d44a6c67716 /ratox.c
parent254e8e62498d0099bdf939624d7b9d4bc67ef49f (diff)
Make the behaviour symetric.
Since ratox writes to text_out in friend conversations, this should also happen in conferences.
Diffstat (limited to 'ratox.c')
-rw-r--r--ratox.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ratox.c b/ratox.c
index ef92300..1117805 100644
--- a/ratox.c
+++ b/ratox.c
@@ -1077,10 +1077,10 @@ sendfriendtext(struct friend *f)
ssize_t n;
time_t t;
char buft[64];
- uint8_t buf[TOX_MAX_MESSAGE_LENGTH];
+ uint8_t buf[TOX_MAX_MESSAGE_LENGTH + 1];
TOX_ERR_FRIEND_SEND_MESSAGE err;
- n = fiforead(f->dirfd, &f->fd[FTEXT_IN], ffiles[FTEXT_IN], buf, sizeof(buf));
+ n = fiforead(f->dirfd, &f->fd[FTEXT_IN], ffiles[FTEXT_IN], buf, sizeof(buf) - 1);
if (n <= 0)
return;
if (buf[n - 1] == '\n' && n > 1)
@@ -1143,9 +1143,11 @@ static void
sendconftext(struct conference *c)
{
ssize_t n;
- uint8_t buf[TOX_MAX_MESSAGE_LENGTH];
+ time_t t;
+ char buft[64];
+ uint8_t buf[TOX_MAX_MESSAGE_LENGTH + 1], me[TOX_MAX_NAME_LENGTH + 1];
- n = fiforead(c->dirfd, &c->fd[CTEXT_IN], cfiles[CTEXT_IN], buf, sizeof(buf));
+ n = fiforead(c->dirfd, &c->fd[CTEXT_IN], cfiles[CTEXT_IN], buf, sizeof(buf) - 1);
if (n <= 0)
return;
if (buf[n - 1] == '\n' && n > 1)
@@ -1153,6 +1155,13 @@ sendconftext(struct conference *c)
if (!tox_conference_send_message(tox, c->num, TOX_MESSAGE_TYPE_NORMAL,
buf, n, NULL))
weprintf("Failed to send message to %s\n", c->numstr);
+
+ buf[n] = '\0';
+ t = time(NULL);
+ strftime(buft, sizeof(buft), "%F %R", localtime(&t));
+ tox_self_get_name(tox, me);
+ me[tox_self_get_name_size(tox)] = '\0';
+ dprintf(c->fd[CTEXT_OUT], "%s <%s> %s\n", buft, me, buf);
}
static void