Hans Leidekker : winhttp: Add an initial implementation of WinHttpQueryOption and WinHttpSetOption.

Alexandre Julliard julliard at winehq.org
Wed Sep 3 07:44:04 CDT 2008


Module: wine
Branch: master
Commit: a74b52cf38402b4dc082e19eea880f7afd83881b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a74b52cf38402b4dc082e19eea880f7afd83881b

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Sep  3 12:31:24 2008 +0200

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 5ea3994..4a4aea8 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 885a4a4..d044d90 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 6bd6949..04dd7dc 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;
 




More information about the wine-cvs mailing list