kernel32: Add stub for GetSystemTimes.
[wine.git] / dlls / urlmon / urlmon_main.h
blob54c0435de8ded96c79cbead930a94e95a1067280
1 /*
2 * Copyright 2002 Huw D M Davies for CodeWeavers
3 * Copyright 2009 Jacek Caban for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_URLMON_MAIN_H
21 #define __WINE_URLMON_MAIN_H
23 #include <stdarg.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "urlmon.h"
34 #include "wininet.h"
36 #include "wine/unicode.h"
38 extern HINSTANCE URLMON_hInstance;
39 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
40 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
41 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
42 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
43 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
44 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
45 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
46 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
47 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
49 /**********************************************************************
50 * Dll lifetime tracking declaration for urlmon.dll
52 extern LONG URLMON_refCount;
53 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
54 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
56 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
57 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
58 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
60 IInternetProtocolInfo *get_protocol_info(LPCWSTR url);
61 HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
62 BOOL is_registered_protocol(LPCWSTR);
63 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
65 HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
66 HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
68 HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
69 void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
71 typedef struct ProtocolVtbl ProtocolVtbl;
73 typedef struct {
74 const ProtocolVtbl *vtbl;
76 IInternetProtocol *protocol;
77 IInternetProtocolSink *protocol_sink;
79 DWORD bindf;
80 BINDINFO bind_info;
82 HINTERNET internet;
83 HINTERNET request;
84 HINTERNET connection;
85 DWORD flags;
86 HANDLE lock;
88 ULONG current_position;
89 ULONG content_length;
90 ULONG available_bytes;
92 LONG priority;
93 } Protocol;
95 struct ProtocolVtbl {
96 HRESULT (*open_request)(Protocol*,LPCWSTR,DWORD,IInternetBindInfo*);
97 HRESULT (*start_downloading)(Protocol*);
98 void (*close_connection)(Protocol*);
101 HRESULT protocol_start(Protocol*,IInternetProtocol*,LPCWSTR,IInternetProtocolSink*,IInternetBindInfo*);
102 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
103 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
104 HRESULT protocol_lock_request(Protocol*);
105 HRESULT protocol_unlock_request(Protocol*);
106 void protocol_close_connection(Protocol*);
108 static inline void *heap_alloc(size_t len)
110 return HeapAlloc(GetProcessHeap(), 0, len);
113 static inline void *heap_alloc_zero(size_t len)
115 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
118 static inline void *heap_realloc(void *mem, size_t len)
120 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
123 static inline BOOL heap_free(void *mem)
125 return HeapFree(GetProcessHeap(), 0, mem);
128 static inline LPWSTR heap_strdupW(LPCWSTR str)
130 LPWSTR ret = NULL;
132 if(str) {
133 DWORD size;
135 size = (strlenW(str)+1)*sizeof(WCHAR);
136 ret = heap_alloc(size);
137 memcpy(ret, str, size);
140 return ret;
143 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
145 LPWSTR ret = NULL;
147 if(str) {
148 ret = heap_alloc((len+1)*sizeof(WCHAR));
149 if(ret) {
150 memcpy(ret, str, len*sizeof(WCHAR));
151 ret[len] = 0;
155 return ret;
158 static inline LPWSTR heap_strdupAtoW(const char *str)
160 LPWSTR ret = NULL;
162 if(str) {
163 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
164 ret = heap_alloc(len*sizeof(WCHAR));
165 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
168 return ret;
171 #endif /* __WINE_URLMON_MAIN_H */