diff options
| author | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
|---|---|---|
| committer | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
| commit | 1123323fda6d128fb98b0427e0ea5f6a2dc9e632 (patch) | |
| tree | 3407a3771a069f812554312ce7c36db625139cc2 /xrdpapi/simple.c | |
| parent | 3cedfae76a2351bc8b1e5bd2ee33bbf8630dbacf (diff) | |
| download | xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.tar.gz xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.zip | |
o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files
o moved some files around
Diffstat (limited to 'xrdpapi/simple.c')
| -rw-r--r-- | xrdpapi/simple.c | 181 |
1 files changed, 103 insertions, 78 deletions
diff --git a/xrdpapi/simple.c b/xrdpapi/simple.c index a2c0f875..7f309ab8 100644 --- a/xrdpapi/simple.c +++ b/xrdpapi/simple.c @@ -1,6 +1,24 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2004-2012 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ - -// xrdp_chan_test.cpp : Basic test for virtual channel use. +/* + * Basic test for virtual channel use + */ // These headers are required for the windows terminal services calls. #include "xrdpapi.h" @@ -15,80 +33,87 @@ int main() { - // Initialize the data for send/receive - void* hFile; - char* data; - char* data1; - data = (char*)malloc(DSIZE); - data1 = (char*)malloc(DSIZE); - int ret; - void* vcFileHandlePtr = NULL; - memset(data, 0xca, DSIZE); - memset(data1, 0, DSIZE); - unsigned int written = 0; - - // Open the skel channel in current session - - //void* channel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "skel", 0); - void* channel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "TSMF", WTS_CHANNEL_OPTION_DYNAMIC); - ret = WTSVirtualChannelQuery(channel, WTSVirtualFileHandle, vcFileHandlePtr, &written); - - // Write the data to the channel - ret = WTSVirtualChannelWrite(channel, data, DSIZE, &written); - if (!ret) - { - - long err = errno; - printf("error 1 0x%8.8x\n", err); - usleep(100000); - return 1; - } - else - { - printf("Sent bytes!\n"); - } - if (written != DSIZE) - { - long err = errno; - printf("error 2 0x%8.8x\n", err); - usleep(100000); - return 1; - } - else - { - printf("Read bytes!\n"); - } - ret = WTSVirtualChannelRead(channel, 100, data1, DSIZE, &written); - if (!ret) - { - long err = errno; - printf("error 3 0x%8.8x\n", err); - usleep(100000); - return 1; - } - if (written != DSIZE) - { - long err = errno; - printf("error 4 0x%8.8x\n", err); - usleep(100000); - return 1; - } - else - { - printf("Read bytes!\n"); - } - ret = WTSVirtualChannelClose(channel); - if (memcmp(data, data1, DSIZE) == 0) - { - } - else - { - printf("error data no match\n"); - return 1; - } - - printf("Done!\n"); - - usleep(100000); - return 0; + // Initialize the data for send/receive + void *hFile; + char *data; + char *data1; + data = (char *)malloc(DSIZE); + data1 = (char *)malloc(DSIZE); + int ret; + void *vcFileHandlePtr = NULL; + memset(data, 0xca, DSIZE); + memset(data1, 0, DSIZE); + unsigned int written = 0; + + // Open the skel channel in current session + + //void* channel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "skel", 0); + void *channel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "TSMF", WTS_CHANNEL_OPTION_DYNAMIC); + ret = WTSVirtualChannelQuery(channel, WTSVirtualFileHandle, vcFileHandlePtr, &written); + + // Write the data to the channel + ret = WTSVirtualChannelWrite(channel, data, DSIZE, &written); + + if (!ret) + { + + long err = errno; + printf("error 1 0x%8.8x\n", err); + usleep(100000); + return 1; + } + else + { + printf("Sent bytes!\n"); + } + + if (written != DSIZE) + { + long err = errno; + printf("error 2 0x%8.8x\n", err); + usleep(100000); + return 1; + } + else + { + printf("Read bytes!\n"); + } + + ret = WTSVirtualChannelRead(channel, 100, data1, DSIZE, &written); + + if (!ret) + { + long err = errno; + printf("error 3 0x%8.8x\n", err); + usleep(100000); + return 1; + } + + if (written != DSIZE) + { + long err = errno; + printf("error 4 0x%8.8x\n", err); + usleep(100000); + return 1; + } + else + { + printf("Read bytes!\n"); + } + + ret = WTSVirtualChannelClose(channel); + + if (memcmp(data, data1, DSIZE) == 0) + { + } + else + { + printf("error data no match\n"); + return 1; + } + + printf("Done!\n"); + + usleep(100000); + return 0; } |
