From a74b52cf38402b4dc082e19eea880f7afd83881b Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 3 Sep 2008 12:31:24 +0200 Subject: [PATCH] winhttp: Add an initial implementation of WinHttpQueryOption and WinHttpSetOption. --- dlls/winhttp/main.c | 22 --------- dlls/winhttp/session.c | 85 ++++++++++++++++++++++++++++++++++ dlls/winhttp/winhttp_private.h | 2 +- 3 files changed, 86 insertions(+), 23 deletions(-) diff --git a/dlls/winhttp/main.c b/dlls/winhttp/main.c index 5ea39948b32..4a4aea8f65a 100644 --- a/dlls/winhttp/main.c +++ b/dlls/winhttp/main.c @@ -85,28 +85,6 @@ HRESULT WINAPI DllUnregisterServer(void) return S_OK; } -/*********************************************************************** - * WinHttpQueryOption (winhttp.@) - */ -BOOL WINAPI WinHttpQueryOption (HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength) -{ - FIXME("(%d): stub\n", dwOption); - - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} - -/*********************************************************************** - * WinHttpSetOption (winhttp.@) - */ -BOOL WINAPI WinHttpSetOption (HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength) -{ - FIXME("stub\n"); - - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; -} - #define SCHEME_HTTP 3 #define SCHEME_HTTPS 4 diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index 885a4a41f4a..d044d900860 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -303,6 +303,91 @@ BOOL WINAPI WinHttpCloseHandle( HINTERNET handle ) return TRUE; } +static BOOL query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen ) +{ + BOOL ret = FALSE; + + switch (option) + { + case WINHTTP_OPTION_CONTEXT_VALUE: + { + *(DWORD_PTR *)buffer = hdr->context; + *buflen = sizeof(DWORD_PTR); + return TRUE; + } + default: + { + if (hdr->vtbl->query_option) ret = hdr->vtbl->query_option( hdr, option, buffer, buflen ); + else FIXME("unimplemented option %u\n", option); + } + } + return ret; +} + +/*********************************************************************** + * WinHttpQueryOption (winhttp.@) + */ +BOOL WINAPI WinHttpQueryOption( HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen ) +{ + BOOL ret = FALSE; + object_header_t *hdr; + + TRACE("%p, %u, %p, %p\n", handle, option, buffer, buflen); + + if (!(hdr = grab_object( handle ))) + { + set_last_error( ERROR_INVALID_HANDLE ); + return FALSE; + } + + ret = query_option( hdr, option, buffer, buflen ); + + release_object( hdr ); + return ret; +} + +static BOOL set_option( object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen ) +{ + BOOL ret = FALSE; + + switch (option) + { + case WINHTTP_OPTION_CONTEXT_VALUE: + { + hdr->context = *(DWORD_PTR *)buffer; + return TRUE; + } + default: + { + if (hdr->vtbl->set_option) ret = hdr->vtbl->set_option( hdr, option, buffer, buflen ); + else FIXME("unimplemented option %u\n", option); + } + } + return ret; +} + +/*********************************************************************** + * WinHttpSetOption (winhttp.@) + */ +BOOL WINAPI WinHttpSetOption( HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen ) +{ + BOOL ret = FALSE; + object_header_t *hdr; + + TRACE("%p, %u, %p, %u\n", handle, option, buffer, buflen); + + if (!(hdr = grab_object( handle ))) + { + set_last_error( ERROR_INVALID_HANDLE ); + return FALSE; + } + + ret = set_option( hdr, option, buffer, buflen ); + + release_object( hdr ); + return ret; +} + /*********************************************************************** * WinHttpDetectAutoProxyConfigUrl (winhttp.@) */ diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 6bd6949da47..04dd7dc4588 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -41,7 +41,7 @@ typedef struct _object_header_t object_header_t; typedef struct { void (*destroy)( object_header_t * ); - BOOL (*query_option)( object_header_t *, DWORD, void *, DWORD *, BOOL ); + BOOL (*query_option)( object_header_t *, DWORD, void *, DWORD * ); BOOL (*set_option)( object_header_t *, DWORD, void *, DWORD ); } object_vtbl_t;