mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Small tweak to the new handle API: provide a `privdata' field in
each handle structure, set on initialisation and readable by an API call. [originally from svn r6798]
This commit is contained in:
parent
291533d3f9
commit
52cdcc6a7c
@ -18,13 +18,6 @@
|
||||
* when one completes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* - could do with some sort of private-data field in each handle
|
||||
* structure.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "putty.h"
|
||||
@ -58,6 +51,7 @@ struct handle_generic {
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -78,6 +72,7 @@ struct handle_input {
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
|
||||
/*
|
||||
* Data set by the input thread before signalling ev_to_main,
|
||||
@ -165,6 +160,7 @@ struct handle_output {
|
||||
int done; /* request subthread to terminate */
|
||||
int defunct; /* has the subthread already gone? */
|
||||
int busy; /* operation currently in progress? */
|
||||
void *privdata; /* for client to remember who they are */
|
||||
|
||||
/*
|
||||
* Data set by the main thread before signalling ev_from_main,
|
||||
@ -267,7 +263,8 @@ static int handle_find_evtomain(void *av, void *bv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata)
|
||||
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
|
||||
void *privdata)
|
||||
{
|
||||
struct handle *h = snew(struct handle);
|
||||
|
||||
@ -280,6 +277,7 @@ struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata)
|
||||
h->u.i.defunct = FALSE;
|
||||
h->u.i.moribund = FALSE;
|
||||
h->u.i.done = FALSE;
|
||||
h->u.i.privdata = privdata;
|
||||
|
||||
if (!handles_by_evtomain)
|
||||
handles_by_evtomain = newtree234(handle_cmp_evtomain);
|
||||
@ -293,7 +291,8 @@ struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata)
|
||||
return h;
|
||||
}
|
||||
|
||||
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata)
|
||||
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata,
|
||||
void *privdata)
|
||||
{
|
||||
struct handle *h = snew(struct handle);
|
||||
|
||||
@ -305,6 +304,7 @@ struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata)
|
||||
h->u.o.defunct = FALSE;
|
||||
h->u.o.moribund = FALSE;
|
||||
h->u.o.done = FALSE;
|
||||
h->u.o.privdata = privdata;
|
||||
bufchain_init(&h->u.o.queued_data);
|
||||
h->u.o.sentdata = sentdata;
|
||||
|
||||
@ -484,3 +484,8 @@ int handle_backlog(struct handle *h)
|
||||
assert(h->output);
|
||||
return bufchain_size(&h->u.o.queued_data);
|
||||
}
|
||||
|
||||
void *handle_get_privdata(struct handle *h)
|
||||
{
|
||||
return h->u.g.privdata;
|
||||
}
|
||||
|
@ -577,8 +577,8 @@ int main(int argc, char **argv)
|
||||
* (The input one we leave until we're through the
|
||||
* authentication process.)
|
||||
*/
|
||||
stdout_handle = handle_output_new(outhandle, stdouterr_sent);
|
||||
stderr_handle = handle_output_new(errhandle, stdouterr_sent);
|
||||
stdout_handle = handle_output_new(outhandle, stdouterr_sent, NULL);
|
||||
stderr_handle = handle_output_new(errhandle, stdouterr_sent, NULL);
|
||||
|
||||
main_thread_id = GetCurrentThreadId();
|
||||
|
||||
@ -593,7 +593,7 @@ int main(int argc, char **argv)
|
||||
DWORD ticks;
|
||||
|
||||
if (!sending && back->sendok(backhandle)) {
|
||||
stdin_handle = handle_input_new(inhandle, stdin_gotdata);
|
||||
stdin_handle = handle_input_new(inhandle, stdin_gotdata, NULL);
|
||||
sending = TRUE;
|
||||
}
|
||||
|
||||
|
@ -411,14 +411,17 @@ void init_ucs(Config *, struct unicode_data *);
|
||||
struct handle;
|
||||
typedef int (*handle_inputfn_t)(struct handle *h, void *data, int len);
|
||||
typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog);
|
||||
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata);
|
||||
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata);
|
||||
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
|
||||
void *privdata);
|
||||
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata,
|
||||
void *privdata);
|
||||
int handle_write(struct handle *h, const void *data, int len);
|
||||
HANDLE *handle_get_events(int *nevents);
|
||||
void handle_free(struct handle *h);
|
||||
void handle_got_event(HANDLE event);
|
||||
void handle_unthrottle(struct handle *h, int backlog);
|
||||
int handle_backlog(struct handle *h);
|
||||
void *handle_get_privdata(struct handle *h);
|
||||
|
||||
/*
|
||||
* pageantc.c needs to schedule callbacks for asynchronous agent
|
||||
|
Loading…
Reference in New Issue
Block a user