mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 17:47:33 -05:00
First half of `pageant-async' work. agent_query() is now passed a
callback function; it may return 0 to indicate that it doesn't have an answer _yet_, in which case it will call the callback later on when it does, or it may return 1 to indicate that it's got an answer right now. The Windows agent_query() implementation is functionally unchanged and still synchronous, but the Unix one is async (since that one was really easy to do via uxsel). ssh.c copes cheerfully with either return value, so other ports are at liberty to be sync or async as they choose. [originally from svn r3153]
This commit is contained in:
@ -33,7 +33,8 @@ int agent_exists(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void agent_query(void *in, int inlen, void **out, int *outlen)
|
||||
int agent_query(void *in, int inlen, void **out, int *outlen,
|
||||
void (*callback)(void *, void *, int), void *callback_ctx)
|
||||
{
|
||||
HWND hwnd;
|
||||
char mapname[64];
|
||||
@ -48,12 +49,12 @@ void agent_query(void *in, int inlen, void **out, int *outlen)
|
||||
hwnd = FindWindow("Pageant", "Pageant");
|
||||
debug(("hwnd is %p\n", hwnd));
|
||||
if (!hwnd)
|
||||
return;
|
||||
return 1; /* *out == NULL, so failure */
|
||||
sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId());
|
||||
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
|
||||
0, AGENT_MAX_MSGLEN, mapname);
|
||||
if (!filemap)
|
||||
return;
|
||||
return 1; /* *out == NULL, so failure */
|
||||
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0);
|
||||
memcpy(p, in, inlen);
|
||||
cds.dwData = AGENT_COPYDATA_ID;
|
||||
@ -73,6 +74,8 @@ void agent_query(void *in, int inlen, void **out, int *outlen)
|
||||
}
|
||||
UnmapViewOfFile(p);
|
||||
CloseHandle(filemap);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef TESTMODE
|
||||
|
Reference in New Issue
Block a user