makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / winhttp / main.c
blob3b570fee6d52d5e17cf91d80fb049a3d63509fc7
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 #include <stdarg.h>
21 #define COBJMACROS
22 #include "windef.h"
23 #include "winbase.h"
24 #include "ws2tcpip.h"
25 #include "objbase.h"
26 #include "rpcproxy.h"
27 #include "httprequest.h"
28 #include "winhttp.h"
30 #include "wine/debug.h"
31 #include "winhttp_private.h"
33 HINSTANCE winhttp_instance;
35 WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
37 /******************************************************************
38 * DllMain (winhttp.@)
40 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
42 switch(fdwReason)
44 case DLL_PROCESS_ATTACH:
45 winhttp_instance = hInstDLL;
46 DisableThreadLibraryCalls(hInstDLL);
47 break;
48 case DLL_PROCESS_DETACH:
49 if (lpv) break;
50 netconn_unload();
51 release_typelib();
52 break;
54 return TRUE;
57 typedef HRESULT (*fnCreateInstance)( void **obj );
59 struct winhttp_cf
61 IClassFactory IClassFactory_iface;
62 fnCreateInstance pfnCreateInstance;
65 static inline struct winhttp_cf *impl_from_IClassFactory( IClassFactory *iface )
67 return CONTAINING_RECORD( iface, struct winhttp_cf, IClassFactory_iface );
70 static HRESULT WINAPI requestcf_QueryInterface(
71 IClassFactory *iface,
72 REFIID riid,
73 void **obj )
75 if (IsEqualGUID( riid, &IID_IUnknown ) ||
76 IsEqualGUID( riid, &IID_IClassFactory ))
78 IClassFactory_AddRef( iface );
79 *obj = iface;
80 return S_OK;
82 FIXME("interface %s not implemented\n", debugstr_guid(riid));
83 return E_NOINTERFACE;
86 static ULONG WINAPI requestcf_AddRef(
87 IClassFactory *iface )
89 return 2;
92 static ULONG WINAPI requestcf_Release(
93 IClassFactory *iface )
95 return 1;
98 static HRESULT WINAPI requestcf_CreateInstance(
99 IClassFactory *iface,
100 LPUNKNOWN outer,
101 REFIID riid,
102 void **obj )
104 struct winhttp_cf *cf = impl_from_IClassFactory( iface );
105 IUnknown *unknown;
106 HRESULT hr;
108 TRACE("%p, %s, %p\n", outer, debugstr_guid(riid), obj);
110 *obj = NULL;
111 if (outer)
112 return CLASS_E_NOAGGREGATION;
114 hr = cf->pfnCreateInstance( (void **)&unknown );
115 if (FAILED(hr))
116 return hr;
118 hr = IUnknown_QueryInterface( unknown, riid, obj );
119 IUnknown_Release( unknown );
120 return hr;
123 static HRESULT WINAPI requestcf_LockServer(
124 IClassFactory *iface,
125 BOOL dolock )
127 FIXME("%p, %d\n", iface, dolock);
128 return S_OK;
131 static const struct IClassFactoryVtbl winhttp_cf_vtbl =
133 requestcf_QueryInterface,
134 requestcf_AddRef,
135 requestcf_Release,
136 requestcf_CreateInstance,
137 requestcf_LockServer
140 static struct winhttp_cf request_cf = { { &winhttp_cf_vtbl }, WinHttpRequest_create };
142 /******************************************************************
143 * DllGetClassObject (winhttp.@)
145 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
147 IClassFactory *cf = NULL;
149 TRACE("%s, %s, %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
151 if (IsEqualGUID( rclsid, &CLSID_WinHttpRequest ))
153 cf = &request_cf.IClassFactory_iface;
155 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
156 return IClassFactory_QueryInterface( cf, riid, ppv );
159 /******************************************************************
160 * DllCanUnloadNow (winhttp.@)
162 HRESULT WINAPI DllCanUnloadNow(void)
164 return S_FALSE;
167 /***********************************************************************
168 * DllRegisterServer (winhttp.@)
170 HRESULT WINAPI DllRegisterServer(void)
172 return __wine_register_resources( winhttp_instance );
175 /***********************************************************************
176 * DllUnregisterServer (winhttp.@)
178 HRESULT WINAPI DllUnregisterServer(void)
180 return __wine_unregister_resources( winhttp_instance );