FreeRDP
posix.c File Reference
#include <winpr/config.h>
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <winpr/crt.h>
#include <winpr/clipboard.h>
#include <winpr/collections.h>
#include <winpr/file.h>
#include <winpr/shell.h>
#include <winpr/string.h>
#include <winpr/wlog.h>
#include <winpr/print.h>
#include "clipboard.h"
#include "posix.h"
#include "../log.h"

Macros

#define _FILE_OFFSET_BITS   64
 
#define WIN32_FILETIME_TO_UNIX_EPOCH   UINT64_C(11644473600)
 
#define TAG   WINPR_TAG("clipboard.posix")
 

Functions

static struct posix_file * make_posix_file (const char *local_name, const WCHAR *remote_name)
 
static UINT posix_file_read_close (struct posix_file *file, BOOL force)
 
static void free_posix_file (void *the_file)
 
static unsigned char hex_to_dec (char c, BOOL *valid)
 
static BOOL decode_percent_encoded_byte (const char *str, const char *end, char *value)
 
static char * decode_percent_encoded_string (const char *str, size_t len)
 
static WCHAR * convert_local_name_component_to_remote (wClipboard *clipboard, const char *local_name)
 
static char * concat_local_name (const char *dir, const char *file)
 
static WCHAR * concat_remote_name (const WCHAR *dir, const WCHAR *file)
 
static BOOL add_file_to_list (wClipboard *clipboard, const char *local_name, const WCHAR *remote_name, wArrayList *files)
 
static BOOL add_directory_entry_to_list (wClipboard *clipboard, const char *local_dir_name, const WCHAR *remote_dir_name, const struct dirent *entry, wArrayList *files)
 
static BOOL do_add_directory_contents_to_list (wClipboard *clipboard, const char *local_name, const WCHAR *remote_name, DIR *dirp, wArrayList *files)
 
static BOOL add_directory_contents_to_list (wClipboard *clipboard, const char *local_name, const WCHAR *remote_name, wArrayList *files)
 
static const char * get_basename (const char *name)
 
static BOOL process_file_name (wClipboard *clipboard, const char *local_name, wArrayList *files)
 
static BOOL process_uri (wClipboard *clipboard, const char *uri, size_t uri_len)
 
static BOOL process_uri_list (wClipboard *clipboard, const char *data, size_t length)
 
static BOOL convert_local_file_to_filedescriptor (const struct posix_file *file, FILEDESCRIPTORW *descriptor)
 
static FILEDESCRIPTORWconvert_local_file_list_to_filedescriptors (wArrayList *files)
 
static void * convert_any_uri_list_to_filedescriptors (wClipboard *clipboard, UINT32 formatId, UINT32 *pSize)
 
static void * convert_uri_list_to_filedescriptors (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static BOOL process_files (wClipboard *clipboard, const char *data, UINT32 pSize, const char *prefix)
 
static BOOL process_gnome_copied_files (wClipboard *clipboard, const char *data, UINT32 pSize)
 
static BOOL process_mate_copied_files (wClipboard *clipboard, const char *data, UINT32 pSize)
 
static BOOL process_nautilus_clipboard (wClipboard *clipboard, const char *data, UINT32 pSize)
 
static void * convert_gnome_copied_files_to_filedescriptors (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static void * convert_mate_copied_files_to_filedescriptors (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static void * convert_nautilus_clipboard_to_filedescriptors (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static size_t count_special_chars (const WCHAR *str)
 
static const char * stop_at_special_chars (const char *str)
 
static void * convert_filedescriptors_to_file_list (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize, const char *header, const char *lineprefix, const char *lineending, BOOL skip_last_lineending)
 
static void * convert_filedescriptors_to_uri_list (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static void * convert_filedescriptors_to_gnome_copied_files (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static void * convert_filedescriptors_to_nautilus_clipboard (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static void * convert_filedescriptors_to_mate_copied_files (wClipboard *clipboard, UINT32 formatId, const void *data, UINT32 *pSize)
 
static BOOL register_file_formats_and_synthesizers (wClipboard *clipboard)
 
static UINT posix_file_get_size (const struct posix_file *file, INT64 *size)
 
static UINT posix_file_request_size (wClipboardDelegate *delegate, const wClipboardFileSizeRequest *request)
 
static UINT posix_file_read_open (struct posix_file *file)
 
static UINT posix_file_read_seek (struct posix_file *file, UINT64 offset)
 
static UINT posix_file_read_perform (struct posix_file *file, UINT32 size, BYTE **actual_data, UINT32 *actual_size)
 
static UINT posix_file_get_range (struct posix_file *file, UINT64 offset, UINT32 size, BYTE **actual_data, UINT32 *actual_size)
 
static UINT posix_file_request_range (wClipboardDelegate *delegate, const wClipboardFileRangeRequest *request)
 
static UINT dummy_file_size_success (wClipboardDelegate *delegate, const wClipboardFileSizeRequest *request, UINT64 fileSize)
 
static UINT dummy_file_size_failure (wClipboardDelegate *delegate, const wClipboardFileSizeRequest *request, UINT errorCode)
 
static UINT dummy_file_range_success (wClipboardDelegate *delegate, const wClipboardFileRangeRequest *request, const BYTE *data, UINT32 size)
 
static UINT dummy_file_range_failure (wClipboardDelegate *delegate, const wClipboardFileRangeRequest *request, UINT errorCode)
 
static void setup_delegate (wClipboardDelegate *delegate)
 
BOOL ClipboardInitPosixFileSubsystem (wClipboard *clipboard)
 

Variables

const char * mime_uri_list = "text/uri-list"
 
const char * mime_FileGroupDescriptorW = "FileGroupDescriptorW"
 
const char * mime_nautilus_clipboard = "x-special/nautilus-clipboard"
 
const char * mime_gnome_copied_files = "x-special/gnome-copied-files"
 
const char * mime_mate_copied_files = "x-special/mate-copied-files"
 

Macro Definition Documentation

◆ _FILE_OFFSET_BITS

#define _FILE_OFFSET_BITS   64

WinPR: Windows Portable Runtime Clipboard Functions: POSIX file handling

Copyright 2017 Alexei Lozovsky a.loz.nosp@m.ovsk.nosp@m.y@gma.nosp@m.il.c.nosp@m.om

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.

◆ TAG

#define TAG   WINPR_TAG("clipboard.posix")

◆ WIN32_FILETIME_TO_UNIX_EPOCH

#define WIN32_FILETIME_TO_UNIX_EPOCH   UINT64_C(11644473600)

Function Documentation

◆ add_directory_contents_to_list()

static BOOL add_directory_contents_to_list ( wClipboard *  clipboard,
const char *  local_name,
const WCHAR *  remote_name,
wArrayList *  files 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_directory_entry_to_list()

static BOOL add_directory_entry_to_list ( wClipboard *  clipboard,
const char *  local_dir_name,
const WCHAR *  remote_dir_name,
const struct dirent *  entry,
wArrayList *  files 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_file_to_list()

static BOOL add_file_to_list ( wClipboard *  clipboard,
const char *  local_name,
const WCHAR *  remote_name,
wArrayList *  files 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClipboardInitPosixFileSubsystem()

BOOL ClipboardInitPosixFileSubsystem ( wClipboard *  clipboard)

WinPR: Windows Portable Runtime Clipboard Functions: POSIX file handling

Copyright 2017 Alexei Lozovsky a.loz.nosp@m.ovsk.nosp@m.y@gma.nosp@m.il.c.nosp@m.om

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ concat_local_name()

static char* concat_local_name ( const char *  dir,
const char *  file 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ concat_remote_name()

static WCHAR* concat_remote_name ( const WCHAR *  dir,
const WCHAR *  file 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_any_uri_list_to_filedescriptors()

static void* convert_any_uri_list_to_filedescriptors ( wClipboard *  clipboard,
UINT32  formatId,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_filedescriptors_to_file_list()

static void* convert_filedescriptors_to_file_list ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize,
const char *  header,
const char *  lineprefix,
const char *  lineending,
BOOL  skip_last_lineending 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_filedescriptors_to_gnome_copied_files()

static void* convert_filedescriptors_to_gnome_copied_files ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_filedescriptors_to_mate_copied_files()

static void* convert_filedescriptors_to_mate_copied_files ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_filedescriptors_to_nautilus_clipboard()

static void* convert_filedescriptors_to_nautilus_clipboard ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_filedescriptors_to_uri_list()

static void* convert_filedescriptors_to_uri_list ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_gnome_copied_files_to_filedescriptors()

static void* convert_gnome_copied_files_to_filedescriptors ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_local_file_list_to_filedescriptors()

static FILEDESCRIPTORW* convert_local_file_list_to_filedescriptors ( wArrayList *  files)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_local_file_to_filedescriptor()

static BOOL convert_local_file_to_filedescriptor ( const struct posix_file *  file,
FILEDESCRIPTORW descriptor 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_local_name_component_to_remote()

static WCHAR* convert_local_name_component_to_remote ( wClipboard *  clipboard,
const char *  local_name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_mate_copied_files_to_filedescriptors()

static void* convert_mate_copied_files_to_filedescriptors ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_nautilus_clipboard_to_filedescriptors()

static void* convert_nautilus_clipboard_to_filedescriptors ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_uri_list_to_filedescriptors()

static void* convert_uri_list_to_filedescriptors ( wClipboard *  clipboard,
UINT32  formatId,
const void *  data,
UINT32 *  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ count_special_chars()

static size_t count_special_chars ( const WCHAR *  str)
static
Here is the caller graph for this function:

◆ decode_percent_encoded_byte()

static BOOL decode_percent_encoded_byte ( const char *  str,
const char *  end,
char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode_percent_encoded_string()

static char* decode_percent_encoded_string ( const char *  str,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_add_directory_contents_to_list()

static BOOL do_add_directory_contents_to_list ( wClipboard *  clipboard,
const char *  local_name,
const WCHAR *  remote_name,
DIR *  dirp,
wArrayList *  files 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dummy_file_range_failure()

static UINT dummy_file_range_failure ( wClipboardDelegate *  delegate,
const wClipboardFileRangeRequest request,
UINT  errorCode 
)
static
Here is the caller graph for this function:

◆ dummy_file_range_success()

static UINT dummy_file_range_success ( wClipboardDelegate *  delegate,
const wClipboardFileRangeRequest request,
const BYTE data,
UINT32  size 
)
static
Here is the caller graph for this function:

◆ dummy_file_size_failure()

static UINT dummy_file_size_failure ( wClipboardDelegate *  delegate,
const wClipboardFileSizeRequest request,
UINT  errorCode 
)
static
Here is the caller graph for this function:

◆ dummy_file_size_success()

static UINT dummy_file_size_success ( wClipboardDelegate *  delegate,
const wClipboardFileSizeRequest request,
UINT64  fileSize 
)
static
Here is the caller graph for this function:

◆ free_posix_file()

static void free_posix_file ( void *  the_file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_basename()

static const char* get_basename ( const char *  name)
static
Here is the caller graph for this function:

◆ hex_to_dec()

static unsigned char hex_to_dec ( char  c,
BOOL *  valid 
)
static
Here is the caller graph for this function:

◆ make_posix_file()

static struct posix_file* make_posix_file ( const char *  local_name,
const WCHAR *  remote_name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_get_range()

static UINT posix_file_get_range ( struct posix_file *  file,
UINT64  offset,
UINT32  size,
BYTE **  actual_data,
UINT32 *  actual_size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_get_size()

static UINT posix_file_get_size ( const struct posix_file *  file,
INT64 *  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_read_close()

UINT posix_file_read_close ( struct posix_file *  file,
BOOL  force 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_read_open()

static UINT posix_file_read_open ( struct posix_file *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_read_perform()

static UINT posix_file_read_perform ( struct posix_file *  file,
UINT32  size,
BYTE **  actual_data,
UINT32 *  actual_size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_read_seek()

static UINT posix_file_read_seek ( struct posix_file *  file,
UINT64  offset 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_request_range()

static UINT posix_file_request_range ( wClipboardDelegate *  delegate,
const wClipboardFileRangeRequest request 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ posix_file_request_size()

static UINT posix_file_request_size ( wClipboardDelegate *  delegate,
const wClipboardFileSizeRequest request 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_file_name()

static BOOL process_file_name ( wClipboard *  clipboard,
const char *  local_name,
wArrayList *  files 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_files()

static BOOL process_files ( wClipboard *  clipboard,
const char *  data,
UINT32  pSize,
const char *  prefix 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_gnome_copied_files()

static BOOL process_gnome_copied_files ( wClipboard *  clipboard,
const char *  data,
UINT32  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_mate_copied_files()

static BOOL process_mate_copied_files ( wClipboard *  clipboard,
const char *  data,
UINT32  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_nautilus_clipboard()

static BOOL process_nautilus_clipboard ( wClipboard *  clipboard,
const char *  data,
UINT32  pSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_uri()

static BOOL process_uri ( wClipboard *  clipboard,
const char *  uri,
size_t  uri_len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_uri_list()

static BOOL process_uri_list ( wClipboard *  clipboard,
const char *  data,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_file_formats_and_synthesizers()

static BOOL register_file_formats_and_synthesizers ( wClipboard *  clipboard)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_delegate()

static void setup_delegate ( wClipboardDelegate *  delegate)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_at_special_chars()

static const char* stop_at_special_chars ( const char *  str)
static
Here is the caller graph for this function:

Variable Documentation

◆ mime_FileGroupDescriptorW

const char* mime_FileGroupDescriptorW = "FileGroupDescriptorW"

◆ mime_gnome_copied_files

const char* mime_gnome_copied_files = "x-special/gnome-copied-files"

◆ mime_mate_copied_files

const char* mime_mate_copied_files = "x-special/mate-copied-files"

◆ mime_nautilus_clipboard

const char* mime_nautilus_clipboard = "x-special/nautilus-clipboard"

◆ mime_uri_list

const char* mime_uri_list = "text/uri-list"