mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
New facility, platform_start_subprocess.
We already have the ability to start a subprocess and hook it up to a Socket, for running local proxy commands. Now the same facility is available as an auxiliary feature, so that a backend can start another subcommand for a different purpose, and make a separate Socket to communicate with it. Just like the local proxy system, this facility captures the subprocess's stderr, and passes it back to the caller via plug_log. To make that not look silly, I had to add a system where the "proxy:" prefix on the usual plug_log messages is reconfigurable, and when you call platform_start_subprocess(), you get to pass the prefix you want to use in this case.
This commit is contained in:
@ -7,6 +7,12 @@
|
||||
void psb_init(ProxyStderrBuf *psb)
|
||||
{
|
||||
psb->size = 0;
|
||||
psb->prefix = "proxy";
|
||||
}
|
||||
|
||||
void psb_set_prefix(ProxyStderrBuf *psb, const char *prefix)
|
||||
{
|
||||
psb->prefix = prefix;
|
||||
}
|
||||
|
||||
void log_proxy_stderr(Plug *plug, ProxyStderrBuf *psb,
|
||||
@ -58,7 +64,7 @@ void log_proxy_stderr(Plug *plug, ProxyStderrBuf *psb,
|
||||
psb->buf[endpos-1] == '\r'))
|
||||
endpos--;
|
||||
char *msg = dupprintf(
|
||||
"proxy: %.*s", (int)(endpos - pos), psb->buf + pos);
|
||||
"%s: %.*s", psb->prefix, (int)(endpos - pos), psb->buf + pos);
|
||||
plug_log(plug, PLUGLOG_PROXY_MSG, NULL, 0, msg, 0);
|
||||
sfree(msg);
|
||||
|
||||
@ -73,7 +79,8 @@ void log_proxy_stderr(Plug *plug, ProxyStderrBuf *psb,
|
||||
*/
|
||||
if (pos == 0 && psb->size == lenof(psb->buf)) {
|
||||
char *msg = dupprintf(
|
||||
"proxy (partial line): %.*s", (int)psb->size, psb->buf);
|
||||
"%s (partial line): %.*s", psb->prefix, (int)psb->size,
|
||||
psb->buf);
|
||||
plug_log(plug, PLUGLOG_PROXY_MSG, NULL, 0, msg, 0);
|
||||
sfree(msg);
|
||||
|
||||
|
Reference in New Issue
Block a user