ReactOS  0.4.15-dev-2956-g61e7ea5
protocol.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "ole2.h"
#include "urlmon.h"
#include "shlwapi.h"
#include "itsstor.h"
#include "chm_lib.h"
#include "wine/debug.h"
Include dependency graph for protocol.c:

Go to the source code of this file.

Classes

struct  ITSProtocol
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (itss)
 
static ITSProtocolimpl_from_IUnknown (IUnknown *iface)
 
static ITSProtocolimpl_from_IInternetProtocol (IInternetProtocol *iface)
 
static ITSProtocolimpl_from_IInternetProtocolInfo (IInternetProtocolInfo *iface)
 
static void release_chm (ITSProtocol *This)
 
static HRESULT WINAPI ITSProtocol_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ITSProtocol_AddRef (IUnknown *iface)
 
static ULONG WINAPI ITSProtocol_Release (IUnknown *iface)
 
static HRESULT WINAPI ITSInternetProtocol_QueryInterface (IInternetProtocol *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ITSInternetProtocol_AddRef (IInternetProtocol *iface)
 
static ULONG WINAPI ITSInternetProtocol_Release (IInternetProtocol *iface)
 
static LPCWSTR skip_schema (LPCWSTR url)
 
static void remove_dot_segments (WCHAR *path)
 
static HRESULT report_result (IInternetProtocolSink *sink, HRESULT hres)
 
static HRESULT WINAPI ITSProtocol_Start (IInternetProtocol *iface, LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
 
static HRESULT WINAPI ITSProtocol_Continue (IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
 
static HRESULT WINAPI ITSProtocol_Abort (IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions)
 
static HRESULT WINAPI ITSProtocol_Terminate (IInternetProtocol *iface, DWORD dwOptions)
 
static HRESULT WINAPI ITSProtocol_Suspend (IInternetProtocol *iface)
 
static HRESULT WINAPI ITSProtocol_Resume (IInternetProtocol *iface)
 
static HRESULT WINAPI ITSProtocol_Read (IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI ITSProtocol_Seek (IInternetProtocol *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI ITSProtocol_LockRequest (IInternetProtocol *iface, DWORD dwOptions)
 
static HRESULT WINAPI ITSProtocol_UnlockRequest (IInternetProtocol *iface)
 
static HRESULT WINAPI ITSProtocolInfo_QueryInterface (IInternetProtocolInfo *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ITSProtocolInfo_AddRef (IInternetProtocolInfo *iface)
 
static ULONG WINAPI ITSProtocolInfo_Release (IInternetProtocolInfo *iface)
 
static HRESULT WINAPI ITSProtocolInfo_ParseUrl (IInternetProtocolInfo *iface, LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
 
static HRESULT WINAPI ITSProtocolInfo_CombineUrl (IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
 
static HRESULT WINAPI ITSProtocolInfo_CompareUrl (IInternetProtocolInfo *iface, LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
 
static HRESULT WINAPI ITSProtocolInfo_QueryInfo (IInternetProtocolInfo *iface, LPCWSTR pwzUrl, QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
 
HRESULT ITSProtocol_create (IUnknown *outer, void **ppv)
 

Variables

static const IUnknownVtbl ITSProtocolUnkVtbl
 
static const IInternetProtocolVtbl ITSProtocolVtbl
 
static const IInternetProtocolInfoVtbl ITSProtocolInfoVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file protocol.c.

Function Documentation

◆ impl_from_IInternetProtocol()

static ITSProtocol* impl_from_IInternetProtocol ( IInternetProtocol iface)
inlinestatic

Definition at line 55 of file protocol.c.

56 {
57  return CONTAINING_RECORD(iface, ITSProtocol, IInternetProtocol_iface);
58 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by ITSInternetProtocol_AddRef(), ITSInternetProtocol_QueryInterface(), ITSInternetProtocol_Release(), ITSProtocol_Abort(), ITSProtocol_Continue(), ITSProtocol_LockRequest(), ITSProtocol_Read(), ITSProtocol_Resume(), ITSProtocol_Seek(), ITSProtocol_Start(), ITSProtocol_Suspend(), ITSProtocol_Terminate(), and ITSProtocol_UnlockRequest().

◆ impl_from_IInternetProtocolInfo()

static ITSProtocol* impl_from_IInternetProtocolInfo ( IInternetProtocolInfo iface)
inlinestatic

Definition at line 60 of file protocol.c.

61 {
62  return CONTAINING_RECORD(iface, ITSProtocol, IInternetProtocolInfo_iface);
63 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by ITSProtocolInfo_AddRef(), ITSProtocolInfo_CombineUrl(), ITSProtocolInfo_CompareUrl(), ITSProtocolInfo_ParseUrl(), ITSProtocolInfo_QueryInfo(), ITSProtocolInfo_QueryInterface(), and ITSProtocolInfo_Release().

◆ impl_from_IUnknown()

static ITSProtocol* impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 50 of file protocol.c.

51 {
52  return CONTAINING_RECORD(iface, ITSProtocol, IUnknown_inner);
53 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by ITSProtocol_AddRef(), ITSProtocol_QueryInterface(), and ITSProtocol_Release().

◆ ITSInternetProtocol_AddRef()

static ULONG WINAPI ITSInternetProtocol_AddRef ( IInternetProtocol iface)
static

Definition at line 137 of file protocol.c.

138 {
140  return IUnknown_AddRef(This->outer);
141 }
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSInternetProtocol_QueryInterface()

static HRESULT WINAPI ITSInternetProtocol_QueryInterface ( IInternetProtocol iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 131 of file protocol.c.

132 {
134  return IUnknown_QueryInterface(This->outer, riid, ppv);
135 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSInternetProtocol_Release()

static ULONG WINAPI ITSInternetProtocol_Release ( IInternetProtocol iface)
static

Definition at line 143 of file protocol.c.

144 {
146  return IUnknown_Release(This->outer);
147 }
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_Abort()

static HRESULT WINAPI ITSProtocol_Abort ( IInternetProtocol iface,
HRESULT  hrReason,
DWORD  dwOptions 
)
static

Definition at line 344 of file protocol.c.

346 {
348  FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
349  return E_NOTIMPL;
350 }
DWORD dwOptions
Definition: solitaire.cpp:24
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_AddRef()

static ULONG WINAPI ITSProtocol_AddRef ( IUnknown iface)
static

Definition at line 100 of file protocol.c.

101 {
104  TRACE("(%p) ref=%d\n", This, ref);
105  return ref;
106 }
Definition: send.c:48
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static ITSProtocol * impl_from_IUnknown(IUnknown *iface)
Definition: protocol.c:50

◆ ITSProtocol_Continue()

static HRESULT WINAPI ITSProtocol_Continue ( IInternetProtocol iface,
PROTOCOLDATA *  pProtocolData 
)
static

Definition at line 337 of file protocol.c.

338 {
340  FIXME("(%p)->(%p)\n", This, pProtocolData);
341  return E_NOTIMPL;
342 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_create()

HRESULT ITSProtocol_create ( IUnknown outer,
void **  ppv 
)

Definition at line 551 of file protocol.c.

552 {
553  ITSProtocol *ret;
554 
555  TRACE("(%p %p)\n", outer, ppv);
556 
557  ITSS_LockModule();
558 
560  if(!ret)
561  return E_OUTOFMEMORY;
562 
563  ret->IUnknown_inner.lpVtbl = &ITSProtocolUnkVtbl;
564  ret->IInternetProtocol_iface.lpVtbl = &ITSProtocolVtbl;
565  ret->IInternetProtocolInfo_iface.lpVtbl = &ITSProtocolInfoVtbl;
566  ret->ref = 1;
567  ret->outer = outer ? outer : &ret->IUnknown_inner;
568 
569  *ppv = &ret->IUnknown_inner;
570  return S_OK;
571 }
static const IUnknownVtbl ITSProtocolUnkVtbl
Definition: protocol.c:125
static void ITSS_LockModule(void)
Definition: itsstor.h:41
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
static const IInternetProtocolInfoVtbl ITSProtocolInfoVtbl
Definition: protocol.c:541
#define S_OK
Definition: intsafe.h:52
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const IInternetProtocolVtbl ITSProtocolVtbl
Definition: protocol.c:417

◆ ITSProtocol_LockRequest()

static HRESULT WINAPI ITSProtocol_LockRequest ( IInternetProtocol iface,
DWORD  dwOptions 
)
static

Definition at line 399 of file protocol.c.

400 {
402 
403  TRACE("(%p)->(%08x)\n", This, dwOptions);
404 
405  return S_OK;
406 }
DWORD dwOptions
Definition: solitaire.cpp:24
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_QueryInterface()

static HRESULT WINAPI ITSProtocol_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 74 of file protocol.c.

75 {
77 
79  TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
80  *ppv = &This->IUnknown_inner;
81  }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
82  TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
83  *ppv = &This->IInternetProtocol_iface;
84  }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
85  TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
86  *ppv = &This->IInternetProtocol_iface;
87  }else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
88  TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
89  *ppv = &This->IInternetProtocolInfo_iface;
90  }else {
91  *ppv = NULL;
92  WARN("not supported interface %s\n", debugstr_guid(riid));
93  return E_NOINTERFACE;
94  }
95 
96  IUnknown_AddRef((IUnknown*)*ppv);
97  return S_OK;
98 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static ITSProtocol * impl_from_IUnknown(IUnknown *iface)
Definition: protocol.c:50

◆ ITSProtocol_Read()

static HRESULT WINAPI ITSProtocol_Read ( IInternetProtocol iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 375 of file protocol.c.

377 {
379 
380  TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
381 
382  if(!This->chm_file)
383  return INET_E_DATA_NOT_AVAILABLE;
384 
385  *pcbRead = chm_retrieve_object(This->chm_file, &This->chm_object, pv, This->offset, cb);
386  This->offset += *pcbRead;
387 
388  return *pcbRead ? S_OK : S_FALSE;
389 }
#define S_FALSE
Definition: winerror.h:2357
LONGINT64 chm_retrieve_object(struct chmFile *h, struct chmUnitInfo *ui, unsigned char *buf, LONGUINT64 addr, LONGINT64 len)
Definition: chm_lib.c:1342
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_Release()

static ULONG WINAPI ITSProtocol_Release ( IUnknown iface)
static

Definition at line 108 of file protocol.c.

109 {
112 
113  TRACE("(%p) ref=%d\n", This, ref);
114 
115  if(!ref) {
116  release_chm(This);
118 
120  }
121 
122  return ref;
123 }
static void release_chm(ITSProtocol *This)
Definition: protocol.c:65
static void ITSS_UnlockModule(void)
Definition: itsstor.h:42
Definition: send.c:48
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
#define InterlockedDecrement
Definition: armddk.h:52
static ITSProtocol * impl_from_IUnknown(IUnknown *iface)
Definition: protocol.c:50
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ ITSProtocol_Resume()

static HRESULT WINAPI ITSProtocol_Resume ( IInternetProtocol iface)
static

Definition at line 368 of file protocol.c.

369 {
371  FIXME("(%p)\n", This);
372  return E_NOTIMPL;
373 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_Seek()

static HRESULT WINAPI ITSProtocol_Seek ( IInternetProtocol iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 391 of file protocol.c.

393 {
395  FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
396  return E_NOTIMPL;
397 }
struct _LARGE_INTEGER::@2270 u
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_Start()

static HRESULT WINAPI ITSProtocol_Start ( IInternetProtocol iface,
LPCWSTR  szUrl,
IInternetProtocolSink pOIProtSink,
IInternetBindInfo pOIBindInfo,
DWORD  grfPI,
HANDLE_PTR  dwReserved 
)
static

Definition at line 220 of file protocol.c.

223 {
225  BINDINFO bindinfo;
226  DWORD bindf = 0, len;
227  LPWSTR file_name, mime, object_name, p;
228  LPCWSTR ptr;
229  struct chmFile *chm_file;
230  struct chmUnitInfo chm_object;
231  int res;
232  HRESULT hres;
233 
234  static const WCHAR separator[] = {':',':',0};
235 
236  TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
237  pOIBindInfo, grfPI, dwReserved);
238 
239  ptr = skip_schema(szUrl);
240  if(!ptr)
241  return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
242 
243  memset(&bindinfo, 0, sizeof(bindinfo));
244  bindinfo.cbSize = sizeof(BINDINFO);
245  hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
246  if(FAILED(hres)) {
247  WARN("GetBindInfo failed: %08x\n", hres);
248  return hres;
249  }
250 
251  ReleaseBindInfo(&bindinfo);
252 
253  len = lstrlenW(ptr)+3;
254  file_name = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
255  memcpy(file_name, ptr, len*sizeof(WCHAR));
257  if(FAILED(hres)) {
258  WARN("UrlUnescape failed: %08x\n", hres);
260  return hres;
261  }
262 
264  if(!p) {
265  WARN("invalid url\n");
267  return report_result(pOIProtSink, STG_E_FILENOTFOUND);
268  }
269 
270  *p = 0;
271  chm_file = chm_openW(file_name);
272  if(!chm_file) {
273  WARN("Could not open chm file\n");
275  return report_result(pOIProtSink, STG_E_FILENOTFOUND);
276  }
277 
278  object_name = p+2;
279  len = lstrlenW(object_name);
280 
281  if(*object_name != '/' && *object_name != '\\') {
282  memmove(object_name+1, object_name, (len+1)*sizeof(WCHAR));
283  *object_name = '/';
284  len++;
285  }
286 
287  if(object_name[len-1] == '/')
288  object_name[--len] = 0;
289 
290  for(p=object_name; *p; p++) {
291  if(*p == '\\')
292  *p = '/';
293  }
294 
295  remove_dot_segments(object_name);
296 
297  TRACE("Resolving %s\n", debugstr_w(object_name));
298 
299  memset(&chm_object, 0, sizeof(chm_object));
300  res = chm_resolve_object(chm_file, object_name, &chm_object);
301  if(res != CHM_RESOLVE_SUCCESS) {
302  WARN("Could not resolve chm object\n");
304  chm_close(chm_file);
305  return report_result(pOIProtSink, STG_E_FILENOTFOUND);
306  }
307 
308  IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST,
309  wcsrchr(object_name, '/')+1);
310 
311  /* FIXME: Native doesn't use FindMimeFromData */
312  hres = FindMimeFromData(NULL, object_name, NULL, 0, NULL, 0, &mime, 0);
314  if(SUCCEEDED(hres)) {
315  IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
317  }
318 
319  release_chm(This); /* Native leaks handle here */
320  This->chm_file = chm_file;
321  This->chm_object = chm_object;
322 
323  hres = IInternetProtocolSink_ReportData(pOIProtSink,
324  BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE,
325  chm_object.length, chm_object.length);
326  if(FAILED(hres)) {
327  WARN("ReportData failed: %08x\n", hres);
328  release_chm(This);
329  return report_result(pOIProtSink, hres);
330  }
331 
332  hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
333 
334  return report_result(pOIProtSink, hres);
335 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static const WCHAR separator[]
Definition: asmname.c:65
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
const WCHAR * mime
Definition: mimefilter.c:512
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:1224
void WINAPI ReleaseBindInfo(BINDINFO *pbindinfo)
Definition: urlmon_main.c:572
static void release_chm(ITSProtocol *This)
Definition: protocol.c:65
#define WARN(fmt,...)
Definition: debug.h:112
#define lstrlenW
Definition: compat.h:609
HRESULT WINAPI UrlUnescapeW(LPWSTR pszUrl, LPWSTR pszUnescaped, LPDWORD pcchUnescaped, DWORD dwFlags)
Definition: url.c:1367
void chm_close(struct chmFile *h)
Definition: chm_lib.c:863
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
static LPCWSTR skip_schema(LPCWSTR url)
Definition: protocol.c:149
static PVOID ptr
Definition: dispmode.c:27
int chm_resolve_object(struct chmFile *h, const WCHAR *objPath, struct chmUnitInfo *ui)
Definition: chm_lib.c:1048
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define CHM_RESOLVE_SUCCESS
Definition: chm_lib.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
struct chmFile * chm_openW(const WCHAR *filename)
Definition: chm_lib.c:678
#define STG_E_FILENOTFOUND
Definition: winerror.h:2565
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define wcsrchr
Definition: compat.h:16
#define NULL
Definition: types.h:112
static LPCWSTR file_name
Definition: protocol.c:147
GLuint res
Definition: glext.h:9613
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55
static HRESULT report_result(IInternetProtocolSink *sink, HRESULT hres)
Definition: protocol.c:214
static void remove_dot_segments(WCHAR *path)
Definition: protocol.c:166
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
HRESULT WINAPI FindMimeFromData(LPBC pBC, LPCWSTR pwzUrl, LPVOID pBuffer, DWORD cbSize, LPCWSTR pwzMimeProposed, DWORD dwMimeFlags, LPWSTR *ppwzMimeOut, DWORD dwReserved)
Definition: mimefilter.c:680
#define HeapFree(x, y, z)
Definition: compat.h:594
static DWORD bindf
Definition: protocol.c:70

◆ ITSProtocol_Suspend()

static HRESULT WINAPI ITSProtocol_Suspend ( IInternetProtocol iface)
static

Definition at line 361 of file protocol.c.

362 {
364  FIXME("(%p)\n", This);
365  return E_NOTIMPL;
366 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_Terminate()

static HRESULT WINAPI ITSProtocol_Terminate ( IInternetProtocol iface,
DWORD  dwOptions 
)
static

Definition at line 352 of file protocol.c.

353 {
355 
356  TRACE("(%p)->(%08x)\n", This, dwOptions);
357 
358  return S_OK;
359 }
DWORD dwOptions
Definition: solitaire.cpp:24
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocol_UnlockRequest()

static HRESULT WINAPI ITSProtocol_UnlockRequest ( IInternetProtocol iface)
static

Definition at line 408 of file protocol.c.

409 {
411 
412  TRACE("(%p)\n", This);
413 
414  return S_OK;
415 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
static ITSProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:55

◆ ITSProtocolInfo_AddRef()

static ULONG WINAPI ITSProtocolInfo_AddRef ( IInternetProtocolInfo iface)
static

Definition at line 440 of file protocol.c.

441 {
443  return IInternetProtocol_AddRef(&This->IInternetProtocol_iface);
444 }
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60

◆ ITSProtocolInfo_CombineUrl()

static HRESULT WINAPI ITSProtocolInfo_CombineUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzBaseUrl,
LPCWSTR  pwzRelativeUrl,
DWORD  dwCombineFlags,
LPWSTR  pwzResult,
DWORD  cchResult,
DWORD pcchResult,
DWORD  dwReserved 
)
static

Definition at line 475 of file protocol.c.

478 {
480  LPCWSTR base_end, ptr;
481  DWORD rel_len;
482 
483  static const WCHAR separator[] = {':',':',0};
484 
485  TRACE("(%p)->(%s %s %08x %p %d %p %d)\n", This, debugstr_w(pwzBaseUrl),
486  debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
487  pcchResult, dwReserved);
488 
489  base_end = wcsstr(pwzBaseUrl, separator);
490  if(!base_end)
491  return 0x80041001;
492  base_end += 2;
493 
494  if(!skip_schema(pwzBaseUrl))
495  return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
496 
497  if(wcschr(pwzRelativeUrl, ':'))
498  return STG_E_INVALIDNAME;
499 
500  if(pwzRelativeUrl[0] == '#') {
501  base_end += lstrlenW(base_end);
502  }else if(pwzRelativeUrl[0] != '/') {
503  ptr = wcsrchr(base_end, '/');
504  if(ptr)
505  base_end = ptr+1;
506  else
507  base_end += lstrlenW(base_end);
508  }
509 
510  rel_len = lstrlenW(pwzRelativeUrl)+1;
511 
512  *pcchResult = rel_len + (base_end-pwzBaseUrl);
513 
514  if(*pcchResult > cchResult)
515  return E_OUTOFMEMORY;
516 
517  memcpy(pwzResult, pwzBaseUrl, (base_end-pwzBaseUrl)*sizeof(WCHAR));
518  lstrcpyW(pwzResult + (base_end-pwzBaseUrl), pwzRelativeUrl);
519 
520  return S_OK;
521 }
#define STG_E_INVALIDNAME
Definition: winerror.h:2584
static const WCHAR separator[]
Definition: asmname.c:65
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60
#define lstrlenW
Definition: compat.h:609
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define debugstr_w
Definition: kernel32.h:32
static LPCWSTR skip_schema(LPCWSTR url)
Definition: protocol.c:149
static PVOID ptr
Definition: dispmode.c:27
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define wcsrchr
Definition: compat.h:16
#define S_OK
Definition: intsafe.h:52
#define lstrcpyW
Definition: compat.h:608

◆ ITSProtocolInfo_CompareUrl()

static HRESULT WINAPI ITSProtocolInfo_CompareUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl1,
LPCWSTR  pwzUrl2,
DWORD  dwCompareFlags 
)
static

Definition at line 523 of file protocol.c.

525 {
527  FIXME("%p)->(%s %s %08x)\n", This, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
528  return E_NOTIMPL;
529 }
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ITSProtocolInfo_ParseUrl()

static HRESULT WINAPI ITSProtocolInfo_ParseUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl,
PARSEACTION  ParseAction,
DWORD  dwParseFlags,
LPWSTR  pwzResult,
DWORD  cchResult,
DWORD pcchResult,
DWORD  dwReserved 
)
static

Definition at line 452 of file protocol.c.

455 {
457 
458  TRACE("(%p)->(%s %x %08x %p %d %p %d)\n", This, debugstr_w(pwzUrl), ParseAction,
459  dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
460 
461  switch(ParseAction) {
462  case PARSE_CANONICALIZE:
463  FIXME("PARSE_CANONICALIZE\n");
464  return E_NOTIMPL;
465  case PARSE_SECURITY_URL:
466  FIXME("PARSE_SECURITY_URL\n");
467  return E_NOTIMPL;
468  default:
469  return INET_E_DEFAULT_ACTION;
470  }
471 
472  return S_OK;
473 }
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ITSProtocolInfo_QueryInfo()

static HRESULT WINAPI ITSProtocolInfo_QueryInfo ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl,
QUERYOPTION  QueryOption,
DWORD  dwQueryFlags,
LPVOID  pBuffer,
DWORD  cbBuffer,
DWORD pcbBuf,
DWORD  dwReserved 
)
static

Definition at line 531 of file protocol.c.

534 {
536  FIXME("(%p)->(%s %08x %08x %p %d %p %d)\n", This, debugstr_w(pwzUrl), QueryOption,
537  dwQueryFlags, pBuffer, cbBuffer, pcbBuf, dwReserved);
538  return E_NOTIMPL;
539 }
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
PVOID pBuffer
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ITSProtocolInfo_QueryInterface()

static HRESULT WINAPI ITSProtocolInfo_QueryInterface ( IInternetProtocolInfo iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 433 of file protocol.c.

435 {
437  return IInternetProtocol_QueryInterface(&This->IInternetProtocol_iface, riid, ppv);
438 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60

◆ ITSProtocolInfo_Release()

static ULONG WINAPI ITSProtocolInfo_Release ( IInternetProtocolInfo iface)
static

Definition at line 446 of file protocol.c.

447 {
449  return IInternetProtocol_Release(&This->IInternetProtocol_iface);
450 }
static ITSProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:60

◆ release_chm()

static void release_chm ( ITSProtocol This)
static

Definition at line 65 of file protocol.c.

66 {
67  if(This->chm_file) {
68  chm_close(This->chm_file);
69  This->chm_file = NULL;
70  }
71  This->offset = 0;
72 }
void chm_close(struct chmFile *h)
Definition: chm_lib.c:863
#define NULL
Definition: types.h:112

Referenced by ITSProtocol_Release(), and ITSProtocol_Start().

◆ remove_dot_segments()

static void remove_dot_segments ( WCHAR path)
static

Definition at line 166 of file protocol.c.

166  {
167  const WCHAR *in = path;
168  WCHAR *out = path;
169 
170  while(1) {
171  /* Move the first path segment in the input buffer to the end of
172  * the output buffer, and any subsequent characters up to, including
173  * the next "/" character (if any) or the end of the input buffer.
174  */
175  while(*in != '/') {
176  if(!(*out++ = *in++))
177  return;
178  }
179 
180  *out++ = *in++;
181 
182  while(*in) {
183  if(*in != '.')
184  break;
185 
186  /* Handle ending "/." */
187  if(!in[1]) {
188  ++in;
189  break;
190  }
191 
192  /* Handle "/./" */
193  if(in[1] == '/') {
194  in += 2;
195  continue;
196  }
197 
198  /* If we don't have "/../" or ending "/.." */
199  if(in[1] != '.' || (in[2] && in[2] != '/'))
200  break;
201 
202  in += *in ? 3 : 2;
203 
204  /* Find the slash preceding out pointer and move out pointer to it */
205  if(out > path+1 && *--out == '/')
206  --out;
207  while(out > path && *(--out) != '/');
208  if(*out == '/')
209  ++out;
210  }
211  }
212 }
GLsizei const GLchar ** path
Definition: glext.h:7234
__wchar_t WCHAR
Definition: xmlstorage.h:180
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by ITSProtocol_Start().

◆ report_result()

static HRESULT report_result ( IInternetProtocolSink sink,
HRESULT  hres 
)
static

Definition at line 214 of file protocol.c.

215 {
216  IInternetProtocolSink_ReportResult(sink, hres, 0, NULL);
217  return hres;
218 }
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
HRESULT hres
Definition: protocol.c:465
#define NULL
Definition: types.h:112

Referenced by ITSProtocol_Start().

◆ skip_schema()

static LPCWSTR skip_schema ( LPCWSTR  url)
static

Definition at line 149 of file protocol.c.

150 {
151  static const WCHAR its_schema[] = {'i','t','s',':'};
152  static const WCHAR msits_schema[] = {'m','s','-','i','t','s',':'};
153  static const WCHAR mk_schema[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':'};
154 
155  if(!_wcsnicmp(its_schema, url, ARRAY_SIZE(its_schema)))
156  return url + ARRAY_SIZE(its_schema);
157  if(!_wcsnicmp(msits_schema, url, ARRAY_SIZE(msits_schema)))
158  return url + ARRAY_SIZE(msits_schema);
159  if(!_wcsnicmp(mk_schema, url, ARRAY_SIZE(mk_schema)))
160  return url + ARRAY_SIZE(mk_schema);
161 
162  return NULL;
163 }
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112

Referenced by ITSProtocol_Start(), and ITSProtocolInfo_CombineUrl().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( itss  )

Variable Documentation

◆ ITSProtocolInfoVtbl

const IInternetProtocolInfoVtbl ITSProtocolInfoVtbl
static
Initial value:
= {
}
static HRESULT WINAPI ITSProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
Definition: protocol.c:523
static HRESULT WINAPI ITSProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
Definition: protocol.c:531
static ULONG WINAPI ITSProtocolInfo_AddRef(IInternetProtocolInfo *iface)
Definition: protocol.c:440
static HRESULT WINAPI ITSProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
Definition: protocol.c:433
static HRESULT WINAPI ITSProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: protocol.c:452
static ULONG WINAPI ITSProtocolInfo_Release(IInternetProtocolInfo *iface)
Definition: protocol.c:446
static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: protocol.c:475

Definition at line 541 of file protocol.c.

Referenced by ITSProtocol_create().

◆ ITSProtocolUnkVtbl

const IUnknownVtbl ITSProtocolUnkVtbl
static
Initial value:
= {
}
static ULONG WINAPI ITSProtocol_Release(IUnknown *iface)
Definition: protocol.c:108
static ULONG WINAPI ITSProtocol_AddRef(IUnknown *iface)
Definition: protocol.c:100
static HRESULT WINAPI ITSProtocol_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: protocol.c:74

Definition at line 125 of file protocol.c.

Referenced by ITSProtocol_create().

◆ ITSProtocolVtbl

const IInternetProtocolVtbl ITSProtocolVtbl
static
Initial value:
= {
}
static ULONG WINAPI ITSInternetProtocol_AddRef(IInternetProtocol *iface)
Definition: protocol.c:137
static HRESULT WINAPI ITSInternetProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
Definition: protocol.c:131
static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
Definition: protocol.c:220
static HRESULT WINAPI ITSProtocol_UnlockRequest(IInternetProtocol *iface)
Definition: protocol.c:408
static HRESULT WINAPI ITSProtocol_Suspend(IInternetProtocol *iface)
Definition: protocol.c:361
static HRESULT WINAPI ITSProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
Definition: protocol.c:337
static HRESULT WINAPI ITSProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions)
Definition: protocol.c:344
static HRESULT WINAPI ITSProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
Definition: protocol.c:352
static ULONG WINAPI ITSInternetProtocol_Release(IInternetProtocol *iface)
Definition: protocol.c:143
static HRESULT WINAPI ITSProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: protocol.c:391
static HRESULT WINAPI ITSProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
Definition: protocol.c:399
static HRESULT WINAPI ITSProtocol_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: protocol.c:375
static HRESULT WINAPI ITSProtocol_Resume(IInternetProtocol *iface)
Definition: protocol.c:368

Definition at line 417 of file protocol.c.

Referenced by ITSProtocol_create().