Add buffer_full format variable, from Mohammad AlSaleh in GitHub issue

4630.
This commit is contained in:
nicm
2025-10-13 07:29:53 +00:00
parent feb3b90596
commit 21d890e6df
2 changed files with 19 additions and 0 deletions

View File

@@ -1369,6 +1369,21 @@ format_cb_buffer_sample(struct format_tree *ft)
return (NULL);
}
/* Callback for buffer_full. */
static void *
format_cb_buffer_full(struct format_tree *ft)
{
size_t size;
const char *s;
if (ft->pb != NULL) {
s = paste_buffer_data(ft->pb, &size);
if (s != NULL)
return (xstrndup(s, size));
}
return (NULL);
}
/* Callback for buffer_size. */
static void *
format_cb_buffer_size(struct format_tree *ft)
@@ -3004,6 +3019,9 @@ static const struct format_table_entry format_table[] = {
{ "buffer_created", FORMAT_TABLE_TIME,
format_cb_buffer_created
},
{ "buffer_full", FORMAT_TABLE_STRING,
format_cb_buffer_full
},
{ "buffer_mode_format", FORMAT_TABLE_STRING,
format_cb_buffer_mode_format
},