コード例 #1
0
ファイル: channel.c プロジェクト: GYGit/reactos
NTSTATUS
NTAPI
ChannelSetLockEvent(IN PSAC_CHANNEL Channel)
{
    NTSTATUS Status;

    /* Set the event */
    ChannelSetEvent(Channel, LockEvent);
    return Status;
}
コード例 #2
0
ファイル: vtutf8chan.c プロジェクト: hoangduit/reactos
NTSTATUS
NTAPI
VTUTF8ChannelIWrite(IN PSAC_CHANNEL Channel,
                    IN PCHAR Buffer,
                    IN ULONG BufferSize)
{
    NTSTATUS Status;
    BOOLEAN IsFull;
    ULONG Index, i;
    CHECK_PARAMETER1(Channel);
    CHECK_PARAMETER2(Buffer);
    CHECK_PARAMETER_WITH_STATUS(BufferSize > 0, STATUS_INVALID_BUFFER_SIZE);

    /* First, check if the input buffer still has space */
    Status = VTUTF8ChannelIBufferIsFull(Channel, &IsFull);
    if (!NT_SUCCESS(Status)) return Status;
    if (IsFull) return STATUS_UNSUCCESSFUL;

    /* Get the current buffer index */
    Index = VTUTF8ChannelGetIBufferIndex(Channel);
    if ((SAC_VTUTF8_IBUFFER_SIZE - Index) < BufferSize)
    {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    /* Copy the new data */
    for (i = 0; i < BufferSize; i++)
    {
        /* Convert the character */
        if (SacTranslateUtf8ToUnicode(Buffer[i],
                                      IncomingUtf8ConversionBuffer,
                                      &IncomingUnicodeValue))
        {
            /* Write it into the buffer */
            *(PWCHAR)&Channel->IBuffer[VTUTF8ChannelGetIBufferIndex(Channel)] =
                IncomingUnicodeValue;

            /* Update the index */
            Index = VTUTF8ChannelGetIBufferIndex(Channel);
            VTUTF8ChannelSetIBufferIndex(Channel, Index + sizeof(WCHAR));
        }
    }

    /* Signal the event, if one was set */
    if (Channel->Flags & SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT)
    {
        ChannelSetEvent(Channel, HasNewDataEvent);
    }

    /* All done */
    return STATUS_SUCCESS;
}
コード例 #3
0
ファイル: channel.c プロジェクト: GYGit/reactos
NTSTATUS
NTAPI
ChannelClose(IN PSAC_CHANNEL Channel)
{
    NTSTATUS Status;
    CHECK_PARAMETER(Channel);

    /* Set the channel inactive */
    ChannelSetStatus(Channel, Inactive);

    /* Set the close event */
    if (Channel->Flags & SAC_CHANNEL_FLAG_CLOSE_EVENT)
    {
        ChannelSetEvent(Channel, CloseEvent);
    }

    /* Close all the handles */
    Status = ChannelDereferenceHandles(Channel);
    return Status;
}
コード例 #4
0
ファイル: rawchan.c プロジェクト: GYGit/reactos
NTSTATUS
NTAPI
RawChannelIWrite(IN PSAC_CHANNEL Channel,
                 IN PCHAR Buffer,
                 IN ULONG BufferSize)
{
    NTSTATUS Status;
    BOOLEAN IsFull;
    ULONG Index;
    CHECK_PARAMETER1(Channel);
    CHECK_PARAMETER2(Buffer);
    CHECK_PARAMETER_WITH_STATUS(BufferSize > 0, STATUS_INVALID_BUFFER_SIZE);

    /* First, check if the input buffer still has space */
    Status = RawChannelIBufferIsFull(Channel, &IsFull);
    if (!NT_SUCCESS(Status)) return Status;
    if (IsFull) return STATUS_UNSUCCESSFUL;

    /* Get the current buffer index */
    Index = RawChannelGetIBufferIndex(Channel);
    if ((SAC_RAW_IBUFFER_SIZE - Index) < BufferSize)
    {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    /* Copy the new data */
    RtlCopyMemory(&Channel->IBuffer[Index], Buffer, BufferSize);

    /* Update the index */
    RawChannelSetIBufferIndex(Channel, BufferSize + Index);

    /* Signal the event, if one was set */
    if (Channel->Flags & SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT)
    {
        ChannelSetEvent(Channel, HasNewDataEvent);
    }

    /* All done */
    return STATUS_SUCCESS;
}