libwine: Do not restrict base address of main thread on 64 bit mac os.
[wine.git] / dlls / winhttp / main.c
blobe6c084b979bacd448166263bdfd3232e0f6c287c
1 /*
2 * Copyright 2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #include "config.h"
21 #include "ws2tcpip.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "rpcproxy.h"
28 #include "httprequest.h"
29 #include "winhttp.h"
31 #include "wine/debug.h"
32 #include "winhttp_private.h"
34 HINSTANCE winhttp_instance;
36 WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
38 /******************************************************************
39 * DllMain (winhttp.@)
41 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
43 switch(fdwReason)
45 case DLL_PROCESS_ATTACH:
46 winhttp_instance = hInstDLL;
47 DisableThreadLibraryCalls(hInstDLL);
48 break;
49 case DLL_PROCESS_DETACH:
50 if (lpv) break;
51 netconn_unload();
52 release_typelib();
53 break;
55 return TRUE;
58 typedef HRESULT (*fnCreateInstance)( void **obj );
60 struct winhttp_cf
62 IClassFactory IClassFactory_iface;
63 fnCreateInstance pfnCreateInstance;
66 static inline struct winhttp_cf *impl_from_IClassFactory( IClassFactory *iface )
68 return CONTAINING_RECORD( iface, struct winhttp_cf, IClassFactory_iface );
71 static HRESULT WINAPI requestcf_QueryInterface(
72 IClassFactory *iface,
73 REFIID riid,
74 void **obj )
76 if (IsEqualGUID( riid, &IID_IUnknown ) ||
77 IsEqualGUID( riid, &IID_IClassFactory ))
79 IClassFactory_AddRef( iface );
80 *obj = iface;
81 return S_OK;
83 FIXME("interface %s not implemented\n", debugstr_guid(riid));
84 return E_NOINTERFACE;
87 static ULONG WINAPI requestcf_AddRef(
88 IClassFactory *iface )
90 return 2;
93 static ULONG WINAPI requestcf_Release(
94 IClassFactory *iface )
96 return 1;
99 static HRESULT WINAPI requestcf_CreateInstance(
100 IClassFactory *iface,
101 LPUNKNOWN outer,
102 REFIID riid,
103 void **obj )
105 struct winhttp_cf *cf = impl_from_IClassFactory( iface );
106 IUnknown *unknown;
107 HRESULT hr;
109 TRACE("%p, %s, %p\n", outer, debugstr_guid(riid), obj);
111 *obj = NULL;
112 if (outer)
113 return CLASS_E_NOAGGREGATION;
115 hr = cf->pfnCreateInstance( (void **)&unknown );
116 if (FAILED(hr))
117 return hr;
119 hr = IUnknown_QueryInterface( unknown, riid, obj );
120 IUnknown_Release( unknown );
121 return hr;
124 static HRESULT WINAPI requestcf_LockServer(
125 IClassFactory *iface,
126 BOOL dolock )
128 FIXME("%p, %d\n", iface, dolock);
129 return S_OK;
132 static const struct IClassFactoryVtbl winhttp_cf_vtbl =
134 requestcf_QueryInterface,
135 requestcf_AddRef,
136 requestcf_Release,
137 requestcf_CreateInstance,
138 requestcf_LockServer
141 static struct winhttp_cf request_cf = { { &winhttp_cf_vtbl }, WinHttpRequest_create };
143 /******************************************************************
144 * DllGetClassObject (winhttp.@)
146 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
148 IClassFactory *cf = NULL;
150 TRACE("%s, %s, %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
152 if (IsEqualGUID( rclsid, &CLSID_WinHttpRequest ))
154 cf = &request_cf.IClassFactory_iface;
156 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
157 return IClassFactory_QueryInterface( cf, riid, ppv );
160 /******************************************************************
161 * DllCanUnloadNow (winhttp.@)
163 HRESULT WINAPI DllCanUnloadNow(void)
165 return S_FALSE;
168 /***********************************************************************
169 * DllRegisterServer (winhttp.@)
171 HRESULT WINAPI DllRegisterServer(void)
173 return __wine_register_resources( winhttp_instance );
176 /***********************************************************************
177 * DllUnregisterServer (winhttp.@)
179 HRESULT WINAPI DllUnregisterServer(void)
181 return __wine_unregister_resources( winhttp_instance );