summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-01-04 22:25:13 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-01-04 22:25:13 +0100
commit89517d44a553582e2d25d3a3796e111aa3b7a1f1 (patch)
treedf6ca5f82afe46f82554f64f54a7f8f3488ef337 /src/plugins
parent18752175099d9a4449436848714b5a3953330ecd (diff)
downloadweechat-89517d44a553582e2d25d3a3796e111aa3b7a1f1.zip
relay: add microseconds in relay raw messages (issue #649)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/relay/relay-raw.c23
-rw-r--r--src/plugins/relay/relay-raw.h2
-rw-r--r--src/plugins/relay/relay-upgrade.c8
3 files changed, 22 insertions, 11 deletions
diff --git a/src/plugins/relay/relay-raw.c b/src/plugins/relay/relay-raw.c
index eec648228..89aa19e14 100644
--- a/src/plugins/relay/relay-raw.c
+++ b/src/plugins/relay/relay-raw.c
@@ -49,11 +49,12 @@ relay_raw_message_print (struct t_relay_raw_message *raw_message)
{
if (relay_raw_buffer && raw_message)
{
- weechat_printf_date_tags (relay_raw_buffer,
- raw_message->date, NULL,
- "%s\t%s",
- raw_message->prefix,
- raw_message->message);
+ weechat_printf_datetime_tags (relay_raw_buffer,
+ raw_message->date,
+ raw_message->date_usec,
+ "%s\t%s",
+ raw_message->prefix,
+ raw_message->message);
}
}
@@ -199,8 +200,8 @@ relay_raw_message_remove_old ()
*/
struct t_relay_raw_message *
-relay_raw_message_add_to_list (time_t date, const char *prefix,
- const char *message)
+relay_raw_message_add_to_list (time_t date, int date_usec,
+ const char *prefix, const char *message)
{
struct t_relay_raw_message *new_raw_message;
@@ -213,6 +214,7 @@ relay_raw_message_add_to_list (time_t date, const char *prefix,
if (new_raw_message)
{
new_raw_message->date = date;
+ new_raw_message->date_usec = date_usec;
new_raw_message->prefix = strdup (prefix);
new_raw_message->message = strdup (message);
@@ -246,6 +248,7 @@ relay_raw_message_add (struct t_relay_client *client,
const char *hexa = "0123456789ABCDEF";
int pos_buf, pos_buf2, char_size, i, length;
struct t_relay_raw_message *new_raw_message;
+ struct timeval tv_now;
buf = NULL;
buf2 = NULL;
@@ -356,8 +359,10 @@ relay_raw_message_add (struct t_relay_client *client,
(buf2) ? buf2 : ((buf) ? buf : data));
}
+ gettimeofday (&tv_now, NULL);
new_raw_message = relay_raw_message_add_to_list (
- time (NULL),
+ tv_now.tv_sec,
+ tv_now.tv_usec,
prefix,
(buf3) ? buf3 : ((buf2) ? buf2 : ((buf) ? buf : data)));
@@ -416,6 +421,8 @@ relay_raw_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "date_usec", raw_message->date_usec))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix", raw_message->prefix))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "message", raw_message->message))
diff --git a/src/plugins/relay/relay-raw.h b/src/plugins/relay/relay-raw.h
index 3f06a0656..e830d7f92 100644
--- a/src/plugins/relay/relay-raw.h
+++ b/src/plugins/relay/relay-raw.h
@@ -35,6 +35,7 @@
struct t_relay_raw_message
{
time_t date; /* date/time of message */
+ int date_usec; /* microseconds of date */
char *prefix; /* prefix */
char *message; /* message */
struct t_relay_raw_message *prev_message; /* pointer to prev. message */
@@ -49,6 +50,7 @@ extern struct t_relay_raw_message *relay_raw_messages, *last_relay_raw_message;
extern void relay_raw_open (int switch_to_buffer);
extern struct t_relay_raw_message *relay_raw_message_add_to_list (time_t date,
+ int date_usec,
const char *prefix,
const char *message);
extern void relay_raw_print (struct t_relay_client *client,
diff --git a/src/plugins/relay/relay-upgrade.c b/src/plugins/relay/relay-upgrade.c
index fd23f1242..e45c3e579 100644
--- a/src/plugins/relay/relay-upgrade.c
+++ b/src/plugins/relay/relay-upgrade.c
@@ -217,9 +217,11 @@ relay_upgrade_read_cb (const void *pointer, void *data,
relay_client_new_with_infolist (infolist);
break;
case RELAY_UPGRADE_TYPE_RAW_MESSAGE:
- relay_raw_message_add_to_list (weechat_infolist_time (infolist, "date"),
- weechat_infolist_string (infolist, "prefix"),
- weechat_infolist_string (infolist, "message"));
+ relay_raw_message_add_to_list (
+ weechat_infolist_time (infolist, "date"),
+ weechat_infolist_integer (infolist, "date_usec"),
+ weechat_infolist_string (infolist, "prefix"),
+ weechat_infolist_string (infolist, "message"));
break;
}
}