secur32: Handle EOF from gnutls_record_recv.
[wine.git] / dlls / urlmon / urlmon_main.h
blob21b93430a60bfd01d89eed2578571c0d3a16e7ec
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"
37 #include "wine/list.h"
39 extern HINSTANCE URLMON_hInstance;
40 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
41 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
42 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
43 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
44 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
45 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
46 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
47 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
48 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
49 extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
51 /**********************************************************************
52 * Dll lifetime tracking declaration for urlmon.dll
54 extern LONG URLMON_refCount;
55 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
56 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
58 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
59 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
61 IInternetProtocolInfo *get_protocol_info(LPCWSTR);
62 HRESULT get_protocol_handler(LPCWSTR,CLSID*,BOOL*,IClassFactory**);
63 IInternetProtocol *get_mime_filter(LPCWSTR);
64 BOOL is_registered_protocol(LPCWSTR);
65 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
66 HINTERNET get_internet_session(IInternetBindInfo*);
67 LPWSTR get_useragent(void);
68 void free_session(void);
70 HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
71 HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
73 HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
74 void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
75 IWinInetInfo *get_wininet_info(IInternetProtocol*);
77 typedef struct ProtocolVtbl ProtocolVtbl;
79 typedef struct {
80 const ProtocolVtbl *vtbl;
82 IInternetProtocol *protocol;
83 IInternetProtocolSink *protocol_sink;
85 DWORD bindf;
86 BINDINFO bind_info;
88 HINTERNET request;
89 HINTERNET connection;
90 DWORD flags;
91 HANDLE lock;
93 ULONG current_position;
94 ULONG content_length;
95 ULONG available_bytes;
97 LONG priority;
98 } Protocol;
100 struct ProtocolVtbl {
101 HRESULT (*open_request)(Protocol*,LPCWSTR,DWORD,HINTERNET,IInternetBindInfo*);
102 HRESULT (*start_downloading)(Protocol*);
103 void (*close_connection)(Protocol*);
106 HRESULT protocol_start(Protocol*,IInternetProtocol*,LPCWSTR,IInternetProtocolSink*,IInternetBindInfo*);
107 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
108 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
109 HRESULT protocol_lock_request(Protocol*);
110 HRESULT protocol_unlock_request(Protocol*);
111 void protocol_close_connection(Protocol*);
113 typedef struct {
114 const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
115 const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
117 LONG ref;
119 IInternetProtocolSink *protocol_sink;
120 IInternetProtocol *protocol;
121 } ProtocolProxy;
123 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolVtbl)
124 #define PROTSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl)
126 HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**);
128 typedef struct {
129 HWND notif_hwnd;
130 DWORD notif_hwnd_cnt;
132 struct list entry;
133 } tls_data_t;
135 tls_data_t *get_tls_data(void);
137 HWND get_notif_hwnd(void);
138 void release_notif_hwnd(HWND);
140 static inline void *heap_alloc(size_t len)
142 return HeapAlloc(GetProcessHeap(), 0, len);
145 static inline void *heap_alloc_zero(size_t len)
147 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
150 static inline void *heap_realloc(void *mem, size_t len)
152 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
155 static inline void *heap_realloc_zero(void *mem, size_t len)
157 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
160 static inline BOOL heap_free(void *mem)
162 return HeapFree(GetProcessHeap(), 0, mem);
165 static inline LPWSTR heap_strdupW(LPCWSTR str)
167 LPWSTR ret = NULL;
169 if(str) {
170 DWORD size;
172 size = (strlenW(str)+1)*sizeof(WCHAR);
173 ret = heap_alloc(size);
174 memcpy(ret, str, size);
177 return ret;
180 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
182 LPWSTR ret = NULL;
184 if(str) {
185 ret = heap_alloc((len+1)*sizeof(WCHAR));
186 if(ret) {
187 memcpy(ret, str, len*sizeof(WCHAR));
188 ret[len] = 0;
192 return ret;
195 static inline LPWSTR heap_strdupAtoW(const char *str)
197 LPWSTR ret = NULL;
199 if(str) {
200 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
201 ret = heap_alloc(len*sizeof(WCHAR));
202 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
205 return ret;
208 #endif /* __WINE_URLMON_MAIN_H */