1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 20:42:48 -05:00

Factor out common code from Unix CLI main loops.

Unix Plink, Unix Pageant in server mode, Uppity, and the post-
connection form of PSFTP's command-line reading code all had very
similar loops in them, which run a pollwrapper and mediate between
that, timers, and toplevel callbacks. It's long past time the common
code between all of those became a reusable shared routine.

So, this commit introduces uxcliloop.c, and turns all the previous
copies of basically the same loop into a call to cli_main_loop with
various callback functions to configure the parts that differ.
This commit is contained in:
Simon Tatham
2020-02-07 19:14:32 +00:00
parent 78974fce89
commit 586dc96f5f
7 changed files with 373 additions and 560 deletions

View File

@ -444,4 +444,20 @@ static inline bool pollwrap_check_fd_rwx(pollwrapper *pw, int fd, int rwx)
return (pollwrap_get_fd_rwx(pw, fd) & rwx) != 0;
}
/*
* uxcliloop.c.
*/
typedef bool (*cliloop_pw_setup_t)(void *ctx, pollwrapper *pw);
typedef void (*cliloop_pw_check_t)(void *ctx, pollwrapper *pw);
typedef bool (*cliloop_continue_t)(void *ctx, bool found_any_fd,
bool ran_any_callback);
void cli_main_loop(cliloop_pw_setup_t pw_setup,
cliloop_pw_check_t pw_check,
cliloop_continue_t cont, void *ctx);
bool cliloop_no_pw_setup(void *ctx, pollwrapper *pw);
void cliloop_no_pw_check(void *ctx, pollwrapper *pw);
bool cliloop_always_continue(void *ctx, bool, bool);
#endif /* PUTTY_UNIX_H */