diff options
author | jsorg71 <jsorg71> | 2006-12-30 05:04:13 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2006-12-30 05:04:13 +0000 |
commit | 4b3b83044a29e89d958c3bf0ea2660b978e3c027 (patch) | |
tree | 0bbc878fef02fd1a4192eb45a9c032984f196253 /libxrdp/libxrdp.c | |
parent | 0dc679e2dc3ddf71735585cf53c4b717ab5b11a9 (diff) | |
download | xrdp-proprietary-4b3b83044a29e89d958c3bf0ea2660b978e3c027.tar.gz xrdp-proprietary-4b3b83044a29e89d958c3bf0ea2660b978e3c027.zip |
more work on channel support
Diffstat (limited to 'libxrdp/libxrdp.c')
-rw-r--r-- | libxrdp/libxrdp.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 79c93278..d3c600a4 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -600,3 +600,105 @@ libxrdp_orders_send_bitmap2(struct xrdp_session* session, width, height, bpp, data, cache_id, cache_idx); } + +/*****************************************************************************/ +/* returns error */ +/* this function gets the channel name and its flags, index is zero + based. either channel_name or channel_flags can be passed in nil if + they are not needed */ +int EXPORT_CC +libxrdp_query_channel(struct xrdp_session* session, int index, + char* channel_name, int* channel_flags) +{ + int count; + struct xrdp_rdp* rdp; + struct xrdp_mcs* mcs; + struct mcs_channel_item* channel_item; + + rdp = (struct xrdp_rdp*)session->rdp; + mcs = rdp->sec_layer->mcs_layer; + count = mcs->channel_list->count; + if (index < 0 || index >= count) + { + return 1; + } + channel_item = (struct mcs_channel_item*) + list_get_item(mcs->channel_list, index); + if (channel_item == 0) + { + /* this should not happen */ + return 1; + } + if (channel_name != 0) + { + g_strncpy(channel_name, channel_item->name, 8); + } + if (channel_flags != 0) + { + *channel_flags = channel_item->flags; + } + return 0; +} + +/*****************************************************************************/ +/* returns a zero based index of the channel, -1 if error or it dosen't + exist */ +int EXPORT_CC +libxrdp_get_channel_id(struct xrdp_session* session, char* name) +{ + int index; + int count; + struct xrdp_rdp* rdp; + struct xrdp_mcs* mcs; + struct mcs_channel_item* channel_item; + + rdp = (struct xrdp_rdp*)session->rdp; + mcs = rdp->sec_layer->mcs_layer; + count = mcs->channel_list->count; + for (index = 0; index < count; index++) + { + channel_item = (struct mcs_channel_item*) + list_get_item(mcs->channel_list, index); + if (channel_item != 0) + { + if (g_strcasecmp(name, channel_item->name) == 0) + { + return index; + } + } + } + return -1; +} + +/*****************************************************************************/ +int EXPORT_CC +libxrdp_send_to_channel(struct xrdp_session* session, int channel_id, + char* data, int data_len) +{ + struct xrdp_rdp* rdp; + struct xrdp_sec* sec; + struct xrdp_channel* chan; + struct stream* s; + + rdp = (struct xrdp_rdp*)session->rdp; + sec = rdp->sec_layer; + chan = sec->chan_layer; + make_stream(s); + init_stream(s, data_len + 1024); /* this should be big enough */ + if (xrdp_channel_init(chan, s) != 0) + { + free_stream(s); + return 1; + } + /* here we make a copy of the data, xrdp_channel_send is + going to alter it if its bigger that 8192 or something */ + out_uint8a(s, data, data_len); + s_mark_end(s); + if (xrdp_channel_send(chan, s, channel_id) != 0) + { + free_stream(s); + return 1; + } + free_stream(s); + return 0; +} |