Record all old-style formatting options, and the full string for the extra display spec, in the control structure; make pv_remote_set only use internal pv state structures so it can be part of the internal pv library where it belongs, and not need to know about main()'s options array.

This commit is contained in:
Andrew Wood
2025-10-26 12:53:51 +00:00
parent 528889888c
commit b1cac9b78d
7 changed files with 103 additions and 72 deletions
+1
View File
@@ -31,6 +31,7 @@ typedef enum {
PV_ACTION_TRANSFER, /* transfer data */
PV_ACTION_STORE_AND_FORWARD, /* store to file, then output from it */
PV_ACTION_WATCHFD, /* watch process file descriptors */
PV_ACTION_REMOTE_CONTROL, /* remotely control another pv */
PV_ACTION_QUERY /* watch the state of another pv */
} pvaction_t;
+13 -1
View File
@@ -179,7 +179,8 @@ struct pvstate_s {
double delay_start; /* delay before first display */
/*@only@*/ /*@null@*/ char *name; /* display name */
/*@only@*/ /*@null@*/ char *format_string; /* output format string */
/*@only@*/ /*@null@*/ char *extra_format_string; /* extra format string */
/*@only@*/ /*@null@*/ char *extra_display_spec; /* full spec for extra displays */
/*@only@*/ /*@null@*/ char *extra_format_string; /* extra format string alone */
/*@null@*/ char *output_name; /* name of the output, for diagnostics */
/*@null@*/ char *default_bar_style; /* which bar style to use by default */
off_t error_skip_block; /* skip block size, 0 for adaptive */
@@ -193,6 +194,17 @@ struct pvstate_s {
pvdisplay_width_t width; /* screen width */
unsigned int height; /* screen height */
unsigned int extra_displays; /* bitmask of extra display destinations */
struct { /* old-style format options (used by -R) */
size_t lastwritten; /* --last-written (amount) */
bool progress; /* --progress */
bool timer; /* --timer */
bool eta; /* --eta */
bool fineta; /* --fineta */
bool rate; /* --rate */
bool average_rate; /* --average-rate */
bool bytes; /* --bytes */
bool bufpercent; /* --buffer-percent */
} format_option;
bool force; /* display even if not on terminal */
bool cursor; /* use cursor positioning */
bool numeric; /* numeric output only */
+13
View File
@@ -297,6 +297,19 @@ extern int pv_watchfd_loop(pvstate_t);
*/
extern int pv_query_loop(pvstate_t, pid_t);
/*
* Set the options of another pv process.
*/
int pv_remote_set(pvstate_t, pid_t);
/*
* Query another pv process for its elapsed transfer time, amount
* transferred, and total size, and update the local state with those
* values. Optionally also return the total size separately. Reports
* errors unless "silent" is true.
*/
int pv_remote_transferstate_fetch(pvstate_t state, pid_t query, /*@null@ */ off_t *sizeptr, bool silent);
/*
* Shut down signal handlers after running the main loop.
*/