New option "--extra-display" (#3, #4).

This commit is contained in:
Andrew Wood
2024-12-01 19:39:59 +00:00
parent 7e51fb8371
commit dccc7345ab
26 changed files with 1106 additions and 708 deletions
+3
View File
@@ -112,6 +112,9 @@
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE
/* Define to 1 if you have the `shmget' function. */
#undef HAVE_SHMGET
+1
View File
@@ -37,6 +37,7 @@ struct opts_s {
/*@keep@*/ /*@null@*/ char *format; /* output format, if any */
/*@keep@*/ /*@null@*/ char *pidfile; /* PID file, if any */
/*@keep@*/ /*@null@*/ char *store_and_forward_file; /* store and forward file, if any */
/*@keep@*/ /*@null@*/ char *extra_display; /* extra display specifier, if any */
/*@keep@*/ /*@null@*/ const char **argv; /* array of non-option arguments */
size_t lastwritten; /* show N bytes last written */
off_t rate_limit; /* rate limit, in bytes per second */
+12 -2
View File
@@ -64,6 +64,9 @@ typedef enum {
#define PV_SIZEOF_FILE_FDPATH 4096
#define PV_SIZEOF_DISPLAY_NAME 512
#define PV_DISPLAY_WINDOWTITLE 1
#define PV_DISPLAY_PROCESSTITLE 2
/*
* Structure for data shared between multiple "pv -c" instances.
@@ -107,6 +110,7 @@ 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 */
/*@null@*/ char *output_name; /* name of the output, for diagnostics */
off_t error_skip_block; /* skip block size, 0 for adaptive */
off_t rate_limit; /* rate limit, in bytes per second */
@@ -120,6 +124,7 @@ struct pvstate_s {
unsigned int history_interval; /* seconds between each average rate calc history entry */
unsigned int width; /* screen width */
unsigned int height; /* screen height */
unsigned int extra_displays; /* bitmask of extra display destinations */
bool force; /* display even if not on terminal */
bool cursor; /* use cursor positioning */
bool numeric; /* numeric output only */
@@ -182,7 +187,7 @@ struct pvstate_s {
/*****************
* Display state *
*****************/
struct {
struct pvdisplay_s {
struct { /* format string broken into display components */
size_t str_start; /* for strings: start offset */
@@ -211,6 +216,9 @@ struct pvstate_s {
} display;
/* Extra display for alternate outputs like a window title. */
struct pvdisplay_s extra_display;
/************************************
* Calculated state of the transfer *
************************************/
@@ -358,11 +366,13 @@ struct pvwatchfd_s {
};
typedef struct pvwatchfd_s *pvwatchfd_t;
typedef struct pvdisplay_s *pvdisplay_t;
void pv_error(pvstate_t, char *, ...);
int pv_main_loop(pvstate_t);
void pv_calculate_transfer_rate(pvstate_t, bool);
bool pv_format(pvstate_t, bool);
bool pv_format(pvstate_t, /*@null@*/ const char *, pvdisplay_t, bool, bool);
void pv_display(pvstate_t, bool);
ssize_t pv_transfer(pvstate_t, int, bool *, bool *, off_t, long *);
int pv_next_file(pvstate_t, unsigned int, int);
+5
View File
@@ -210,6 +210,7 @@ extern void pv_state_width_set(pvstate_t, unsigned int, bool);
extern void pv_state_height_set(pvstate_t, unsigned int, bool);
extern void pv_state_name_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_format_string_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_extra_display_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_watch_pid_set(pvstate_t, pid_t);
extern void pv_state_watch_fd_set(pvstate_t, int);
extern void pv_state_output_set(pvstate_t, int, const char *);
@@ -269,6 +270,10 @@ extern void pv_sig_fini(pvstate_t);
*/
extern void pv_state_free(/*@only@*/ pvstate_t);
#if ! HAVE_SETPROCTITLE
void initproctitle(int, char **);
void setproctitle(const char *, ...);
#endif
#ifdef ENABLE_DEBUGGING
# if __STDC_VERSION__ < 199901L && !defined(__func__)