Commit 5a66eab7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

scrrun: Add a stub for pipe-based text stream.

parent 259557cd
......@@ -706,20 +706,21 @@ static HRESULT WINAPI textstream_SkipLine(ITextStream *iface)
static HRESULT WINAPI textstream_Close(ITextStream *iface)
{
struct textstream *This = impl_from_ITextStream(iface);
struct textstream *stream = impl_from_ITextStream(iface);
HRESULT hr = S_OK;
TRACE("(%p)\n", This);
TRACE("%p.\n", iface);
if(!CloseHandle(This->file))
if (!CloseHandle(stream->file))
hr = S_FALSE;
This->file = NULL;
stream->file = NULL;
return hr;
}
static const ITextStreamVtbl textstreamvtbl = {
static const ITextStreamVtbl textstreamvtbl =
{
textstream_QueryInterface,
textstream_AddRef,
textstream_Release,
......@@ -742,6 +743,114 @@ static const ITextStreamVtbl textstreamvtbl = {
textstream_Close
};
static HRESULT WINAPI pipestream_get_Line(ITextStream *iface, LONG *line)
{
FIXME("%p, %p.\n", iface, line);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_get_Column(ITextStream *iface, LONG *column)
{
FIXME("%p, %p.\n", iface, column);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_get_AtEndOfStream(ITextStream *iface, VARIANT_BOOL *eos)
{
FIXME("%p, %p.\n", iface, eos);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_get_AtEndOfLine(ITextStream *iface, VARIANT_BOOL *eol)
{
FIXME("%p, %p.\n", iface, eol);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_Read(ITextStream *iface, LONG len, BSTR *text)
{
FIXME("%p, %ld, %p.\n", iface, len, text);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_ReadLine(ITextStream *iface, BSTR *text)
{
FIXME("%p, %p.\n", iface, text);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_ReadAll(ITextStream *iface, BSTR *text)
{
FIXME("%p, %p.\n", iface, text);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_Write(ITextStream *iface, BSTR text)
{
FIXME("%p, %s.\n", iface, debugstr_w(text));
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_WriteLine(ITextStream *iface, BSTR text)
{
FIXME("%p, %s.\n", iface, debugstr_w(text));
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_WriteBlankLines(ITextStream *iface, LONG lines)
{
FIXME("%p, %ld.\n", iface, lines);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_Skip(ITextStream *iface, LONG count)
{
FIXME("%p, %ld.\n", iface, count);
return E_NOTIMPL;
}
static HRESULT WINAPI pipestream_SkipLine(ITextStream *iface)
{
FIXME("%p.\n", iface);
return E_NOTIMPL;
}
static const ITextStreamVtbl pipestreamvtbl =
{
textstream_QueryInterface,
textstream_AddRef,
textstream_Release,
textstream_GetTypeInfoCount,
textstream_GetTypeInfo,
textstream_GetIDsOfNames,
textstream_Invoke,
pipestream_get_Line,
pipestream_get_Column,
pipestream_get_AtEndOfStream,
pipestream_get_AtEndOfLine,
pipestream_Read,
pipestream_ReadLine,
pipestream_ReadAll,
pipestream_Write,
pipestream_WriteLine,
pipestream_WriteBlankLines,
pipestream_Skip,
pipestream_SkipLine,
textstream_Close
};
static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMode mode, Tristate format, ITextStream **ret)
{
static const unsigned short utf16bom = 0xfeff;
......@@ -839,11 +948,24 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod
return S_OK;
}
HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream)
HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **ret)
{
FIXME("%p, %d, %p.\n", pipe, mode, stream);
struct textstream *stream;
return E_NOTIMPL;
TRACE("%p, %d, %p.\n", pipe, mode, ret);
if (!(stream = calloc(1, sizeof(*stream))))
return E_OUTOFMEMORY;
stream->ITextStream_iface.lpVtbl = &pipestreamvtbl;
stream->ref = 1;
stream->mode = mode;
stream->file = pipe;
init_classinfo(&CLSID_TextStream, (IUnknown *)&stream->ITextStream_iface, &stream->classinfo);
*ret = &stream->ITextStream_iface;
return S_OK;
}
static HRESULT WINAPI drive_QueryInterface(IDrive *iface, REFIID riid, void **obj)
......
......@@ -2613,7 +2613,6 @@ static void test_DoOpenPipeStream(void)
ok(ret, "Failed to create pipes.\n");
hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
......@@ -2624,9 +2623,13 @@ static void test_DoOpenPipeStream(void)
ok(written == sizeof(testdata), "Write to anonymous pipe wrote %ld bytes.\n", written);
hr = ITextStream_Read(stream_read, 4, &str);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
ok(!wcscmp(str, L"test"), "Unexpected data read %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
}
ITextStream_Release(stream_read);
}
......@@ -2635,7 +2638,6 @@ static void test_DoOpenPipeStream(void)
ok(ret, "Unexpected return value.\n");
/* Stream takes ownership. */
ret = CloseHandle(piperead);
todo_wine
ok(!ret, "Unexpected return value.\n");
/* Streams on both ends. */
......@@ -2644,33 +2646,38 @@ static void test_DoOpenPipeStream(void)
stream_read = NULL;
hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
stream_write = NULL;
hr = pDoOpenPipeStream(pipewrite, ForWriting, &stream_write);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
str = SysAllocString(L"data");
hr = ITextStream_Write(stream_write, str);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = ITextStream_Write(stream_read, str);
todo_wine
ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#lx.\n", hr);
SysFreeString(str);
hr = ITextStream_Read(stream_write, 1, &str);
todo_wine
ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#lx.\n", hr);
hr = ITextStream_Read(stream_read, 4, &str);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
ok(!wcscmp(str, L"data"), "Unexpected data.\n");
SysFreeString(str);
}
}
if (stream_read)
ITextStream_Release(stream_read);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment