urlmon_main.h 3.98 KB
Newer Older
1
/*
2
 * Copyright 2002 Huw D M Davies for CodeWeavers
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
17 18 19 20 21
 */

#ifndef __WINE_URLMON_MAIN_H
#define __WINE_URLMON_MAIN_H

22 23
#include <stdarg.h>

Jacek Caban's avatar
Jacek Caban committed
24 25 26 27
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT

28
#include "windef.h"
29
#include "winbase.h"
Jacek Caban's avatar
Jacek Caban committed
30 31 32
#include "winuser.h"
#include "ole2.h"
#include "urlmon.h"
33

34 35
#include "wine/unicode.h"

36
extern HINSTANCE URLMON_hInstance;
37
extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
38
extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
39
extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
40
extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
41
extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
42
extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
43
extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
44

45 46 47 48
/**********************************************************************
 * Dll lifetime tracking declaration for urlmon.dll
 */
extern LONG URLMON_refCount;
49 50
static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
51

52
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
53
#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
54

55 56 57
typedef struct
{	
	const IStreamVtbl	*lpVtbl;
58
	LONG		ref;
59 60 61 62 63 64 65 66 67
	HANDLE		handle;
	BOOL		closed;
	WCHAR		*pszFileName;
	WCHAR		*pszURL;
} IUMCacheStream;

HRESULT	UMCreateStreamOnCacheFile(LPCWSTR pszURL, DWORD dwSize, LPWSTR pszFileName, HANDLE *phfile, IUMCacheStream **ppstr);
void	UMCloseCacheFileStream(IUMCacheStream *pstr);

68
IInternetProtocolInfo *get_protocol_info(LPCWSTR url);
69
HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
70
BOOL is_registered_protocol(LPCWSTR);
71
void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
72

73
HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
74
HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
75

76
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
77
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
78

79
static inline void *heap_alloc(size_t len)
80 81 82 83
{
    return HeapAlloc(GetProcessHeap(), 0, len);
}

84
static inline void *heap_alloc_zero(size_t len)
85 86 87 88
{
    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}

89
static inline void *heap_realloc(void *mem, size_t len)
90 91 92 93
{
    return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}

94
static inline BOOL heap_free(void *mem)
95 96 97 98
{
    return HeapFree(GetProcessHeap(), 0, mem);
}

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
static inline LPWSTR heap_strdupW(LPCWSTR str)
{
    LPWSTR ret = NULL;

    if(str) {
        DWORD size;

        size = (strlenW(str)+1)*sizeof(WCHAR);
        ret = heap_alloc(size);
        memcpy(ret, str, size);
    }

    return ret;
}

114 115 116 117 118 119 120 121 122 123 124 125 126
static inline LPWSTR heap_strdupAtoW(const char *str)
{
    LPWSTR ret = NULL;

    if(str) {
        DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
        ret = heap_alloc(len*sizeof(WCHAR));
        MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
    }

    return ret;
}

127
#endif /* __WINE_URLMON_MAIN_H */