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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
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
FileProtocol_Construct(IUnknown
*pUnkOuter
, LPVOID
*ppobj
);
42 extern HRESULT
HttpProtocol_Construct(IUnknown
*pUnkOuter
, LPVOID
*ppobj
);
43 extern HRESULT
HttpSProtocol_Construct(IUnknown
*pUnkOuter
, LPVOID
*ppobj
);
44 extern HRESULT
FtpProtocol_Construct(IUnknown
*pUnkOuter
, LPVOID
*ppobj
);
45 extern HRESULT
MkProtocol_Construct(IUnknown
*pUnkOuter
, LPVOID
*ppobj
);
47 /**********************************************************************
48 * Dll lifetime tracking declaration for urlmon.dll
50 extern LONG URLMON_refCount
;
51 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount
); }
52 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount
); }
54 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
55 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
56 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
60 const IStreamVtbl
*lpVtbl
;
68 HRESULT
UMCreateStreamOnCacheFile(LPCWSTR pszURL
, DWORD dwSize
, LPWSTR pszFileName
, HANDLE
*phfile
, IUMCacheStream
**ppstr
);
69 void UMCloseCacheFileStream(IUMCacheStream
*pstr
);
71 IInternetProtocolInfo
*get_protocol_info(LPCWSTR url
);
72 HRESULT
get_protocol_handler(LPCWSTR url
, CLSID
*clsid
, IClassFactory
**ret
);
73 BOOL
is_registered_protocol(LPCWSTR
);
74 void register_urlmon_namespace(IClassFactory
*,REFIID
,LPCWSTR
,BOOL
);
76 HRESULT
bind_to_storage(LPCWSTR url
, IBindCtx
*pbc
, REFIID riid
, void **ppv
);
77 HRESULT
bind_to_object(IMoniker
*mon
, LPCWSTR url
, IBindCtx
*pbc
, REFIID riid
, void **ppv
);
79 HRESULT
create_binding_protocol(LPCWSTR url
, BOOL from_urlmon
, IInternetProtocol
**protocol
);
80 void set_binding_sink(IInternetProtocol
*bind_protocol
, IInternetProtocolSink
*sink
);
82 typedef struct ProtocolVtbl ProtocolVtbl
;
85 const ProtocolVtbl
*vtbl
;
87 IInternetProtocol
*protocol
;
88 IInternetProtocolSink
*protocol_sink
;
99 ULONG current_position
;
100 ULONG content_length
;
101 ULONG available_bytes
;
106 struct ProtocolVtbl
{
107 HRESULT (*open_request
)(Protocol
*,LPCWSTR
,DWORD
,IInternetBindInfo
*);
108 HRESULT (*start_downloading
)(Protocol
*);
109 void (*close_connection
)(Protocol
*);
112 HRESULT
protocol_start(Protocol
*,IInternetProtocol
*,LPCWSTR
,IInternetProtocolSink
*,IInternetBindInfo
*);
113 HRESULT
protocol_continue(Protocol
*,PROTOCOLDATA
*);
114 HRESULT
protocol_read(Protocol
*,void*,ULONG
,ULONG
*);
115 HRESULT
protocol_lock_request(Protocol
*);
116 HRESULT
protocol_unlock_request(Protocol
*);
117 void protocol_close_connection(Protocol
*);
119 static inline void *heap_alloc(size_t len
)
121 return HeapAlloc(GetProcessHeap(), 0, len
);
124 static inline void *heap_alloc_zero(size_t len
)
126 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
129 static inline void *heap_realloc(void *mem
, size_t len
)
131 return HeapReAlloc(GetProcessHeap(), 0, mem
, len
);
134 static inline BOOL
heap_free(void *mem
)
136 return HeapFree(GetProcessHeap(), 0, mem
);
139 static inline LPWSTR
heap_strdupW(LPCWSTR str
)
146 size
= (strlenW(str
)+1)*sizeof(WCHAR
);
147 ret
= heap_alloc(size
);
148 memcpy(ret
, str
, size
);
154 static inline LPWSTR
heap_strndupW(LPCWSTR str
, int len
)
159 ret
= heap_alloc((len
+1)*sizeof(WCHAR
));
161 memcpy(ret
, str
, len
*sizeof(WCHAR
));
169 static inline LPWSTR
heap_strdupAtoW(const char *str
)
174 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
175 ret
= heap_alloc(len
*sizeof(WCHAR
));
176 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
182 #endif /* __WINE_URLMON_MAIN_H */