Add an alias for the name for %N to the display sub-structure, so that the name can be varied between displays without having to alter the control value (#165).

This commit is contained in:
Andrew Wood
2025-07-27 19:53:28 +01:00
parent e04f50f0dc
commit 6a2b9a2788
5 changed files with 29 additions and 4 deletions
+10
View File
@@ -245,6 +245,14 @@ struct pvstate_s {
/*****************
* Display state *
*****************/
/*
* Note that the "name" pointer is an alias - it should point to
* some other string that's allocated and freed separately, such as
* control.name. It is used here so that the name can be changed
* for different display structures without having to also change
* the control structure, for example when watching multiple file
* descriptors with --watchfd.
*/
struct pvdisplay_s {
struct pvdisplay_segment_s { /* format string broken into segments */
@@ -273,6 +281,8 @@ struct pvstate_s {
off_t initial_offset; /* offset when first opened (when watching fds) */
size_t next_line_len; /* length of currently receiving line so far */
/*@dependent@*/ /*@null@*/ const char *name; /* copy of pointer to string for %N */
size_t format_segment_count; /* number of format string segments */
pvtransfercount_t count_type; /* type of count for transfer, rate, etc */