diff --git a/channels/rdpdr/CMakeLists.txt b/channels/rdpdr/CMakeLists.txt index b0019f45b..6501b2177 100644 --- a/channels/rdpdr/CMakeLists.txt +++ b/channels/rdpdr/CMakeLists.txt @@ -34,3 +34,5 @@ set_target_properties(rdpdr PROPERTIES PREFIX "") target_link_libraries(rdpdr freerdp-utils) install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) + +add_subdirectory(disk) diff --git a/channels/rdpdr/disk/CMakeLists.txt b/channels/rdpdr/disk/CMakeLists.txt new file mode 100644 index 000000000..654621279 --- /dev/null +++ b/channels/rdpdr/disk/CMakeLists.txt @@ -0,0 +1,31 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# 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. + +set(DISK_SRCS + disk_main.c +) + +include_directories(..) + +add_library(disk SHARED ${DISK_SRCS}) +set_target_properties(disk PROPERTIES PREFIX "") + +target_link_libraries(disk freerdp-utils) + +install(TARGETS disk DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/rdpdr/disk/disk_main.c b/channels/rdpdr/disk/disk_main.c new file mode 100644 index 000000000..1ed92cc38 --- /dev/null +++ b/channels/rdpdr/disk/disk_main.c @@ -0,0 +1,111 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * File System Virtual Channel + * + * Copyright 2010-2011 Marc-Andre Moreau + * Copyright 2010-2011 Vic Lee + * + * 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. + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rdpdr_constants.h" +#include "rdpdr_types.h" + +typedef struct _FILE_INFO FILE_INFO; +struct _FILE_INFO +{ + uint32 file_id; + uint32 file_attr; + boolean is_dir; + int fd; + DIR* dir; + char* fullpath; + char* pattern; + boolean delete_pending; +}; + +typedef struct _DISK_DEVICE DISK_DEVICE; +struct _DISK_DEVICE +{ + DEVICE device; + + char* path; + LIST* files; +}; + +void disk_irp_request(DEVICE* device, IRP* irp) +{ + DISK_DEVICE* disk = (DISK_DEVICE*)device; + + irp->Discard(irp); +} + +void disk_free(DEVICE* device) +{ + DISK_DEVICE* disk = (DISK_DEVICE*)device; + + list_free(disk->files); + xfree(disk); +} + +int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +{ + DISK_DEVICE* disk; + char* name; + char* path; + int i, len; + + name = (char*)pEntryPoints->plugin_data->data[1]; + path = (char*)pEntryPoints->plugin_data->data[2]; + + if (name[0] && path[0]) + { + disk = xnew(DISK_DEVICE); + + disk->device.type = RDPDR_DTYP_FILESYSTEM; + disk->device.name = name; + disk->device.IRPRequest = disk_irp_request; + disk->device.Free = disk_free; + + len = strlen(name); + disk->device.data = stream_new(len + 1); + for (i = 0; i <= len; i++) + stream_write_uint8(disk->device.data, name[i] < 0 ? '_' : name[i]); + + disk->path = path; + disk->files = list_new(); + + pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)disk); + } + + return 0; +}