Remove unused pv_remote_init, pv_remote_fini functions; add initial stubs for -Q (#101).

This commit is contained in:
Andrew Wood
2025-10-21 23:17:23 +01:00
parent 4f82525c39
commit b34bba8b4a
4 changed files with 101 additions and 38 deletions
+2 -11
View File
@@ -24,10 +24,7 @@
#endif
int pv_remote_set(opts_t, pvstate_t);
void pv_remote_init(void);
void pv_remote_fini(void);
// TODO
// int pv_remote_transferstate_fetch(pvstate_t, pid_t, /*@null@ */ off_t *);
int pv_remote_transferstate_fetch(pvstate_t, pid_t, /*@null@ */ off_t *);
/*
* Write a PID file, returning nonzero on error. Write it atomically, such
@@ -503,7 +500,7 @@ int main(int argc, char **argv)
*/
if (PV_ACTION_QUERY == opts->action) {
opts->size = 0;
// TODO retcode = pv_remote_transferstate_fetch(state, opts->query, &(opts->size));
retcode = pv_remote_transferstate_fetch(state, opts->query, &(opts->size));
if (0 != retcode) {
pv_sig_fini(state);
pv_state_free(state);
@@ -565,15 +562,11 @@ int main(int argc, char **argv)
break;
case PV_ACTION_TRANSFER:
/* Normal "transfer data" mode. */
pv_remote_init();
retcode = pv_main_loop(state);
pv_remote_fini();
break;
case PV_ACTION_STORE_AND_FORWARD:
/* Store-and-forward transfer mode. */
pv_remote_init();
retcode = pv__store_and_forward(state, opts, can_have_eta);
pv_remote_fini();
break;
case PV_ACTION_WATCHFD:
/* "Watch file descriptor(s) of another process" mode. */
@@ -581,9 +574,7 @@ int main(int argc, char **argv)
break;
case PV_ACTION_QUERY:
/* "Watch progress of another pv" mode. */
pv_remote_init();
/* TODO: loop watching transfer progress until finished. */
pv_remote_fini();
break;
}
+36 -24
View File
@@ -21,9 +21,10 @@
#include <sys/time.h>
#include <sys/stat.h>
#ifdef PV_REMOTE_CONTROL
void pv_error(char *, ...);
#ifdef PV_REMOTE_CONTROL
struct remote_msg {
bool progress; /* progress bar flag */
bool timer; /* timer flag */
@@ -324,40 +325,51 @@ bool pv_remote_check(pvstate_t state)
}
/*
* Initialise remote message reception handling.
*/
void pv_remote_init(void)
{
}
/*
* Clean up after remote message reception handling.
*/
void pv_remote_fini(void)
{
}
#else /* !PV_REMOTE_CONTROL */
/*
* Dummy stubs for remote control when we don't have PV_REMOTE_CONTROL.
*/
void pv_remote_init(void)
{
}
void pv_remote_check( /*@unused@ */ __attribute__((unused)) pvstate_t state)
{
}
void pv_remote_fini(void)
{
}
int pv_remote_set( /*@unused@ */
__attribute__((unused)) opts_t opts, /*@unused@ */ __attribute__((unused)) pvstate_t state)
{
/*@-mustfreefresh@ *//* splint - see above */
pv_error("%s", _("SA_SIGINFO not supported on this system"));
/*@+mustfreefresh@ */
return PV_ERROREXIT_REMOTE_OR_PID;
}
#endif /* PV_REMOTE_CONTROL */
#ifdef PV_REMOTE_QUERY
/*
* Replace the transfer state with that of the given process, populating
* *sizeptr with that process's idea of the total transfer size if sizeptr
* isn't NULL.
*
* Returns nonzero on error, after reporting the error.
*/
int pv_remote_transferstate_fetch(pvstate_t state, pid_t query, /*@null@ */ off_t * sizeptr)
{
/* TODO: write this */
return PV_ERROREXIT_REMOTE_OR_PID;
}
#else /* !PV_REMOTE_QUERY */
/*
* Dummy stubs for remote querying when we don't have PV_REMOTE_QUERY.
*/
int pv_remote_transferstate_fetch( /*@unused@ */
__attribute__((unused)) pvstate_t state, /*@unused@ */
__attribute__((unused)) pid_t query, /*@null@ *//*@unused@ */
__attribute__((unused)) off_t * sizeptr)
{
/*@-mustfreefresh@ *//* splint - see above */
fprintf(stderr, "%s\n", _("SA_SIGINFO not supported on this system"));
@@ -365,4 +377,4 @@ int pv_remote_set( /*@unused@ */
return PV_ERROREXIT_REMOTE_OR_PID;
}
#endif /* PV_REMOTE_CONTROL */
#endif /* PV_REMOTE_QUERY */