/* this function should be prefered over file_read_sections because it can read any file size */ int APP_CC file_by_name_read_sections(const char *file_name, struct list *names) { int fd; int file_size; int rv; file_size = g_file_get_size(file_name); if (file_size < 1) { return 1; } fd = g_file_open(file_name); if (fd < 0) { return 1; } rv = l_file_read_sections(fd, file_size, names); g_file_close(fd); return rv; }
/* this function should be prefered over file_read_section because it can read any file size */ int file_by_name_read_section(const char *file_name, const char *section, xrdpList *names, xrdpList *values) { int fd; int file_size; int rv; file_size = g_file_get_size(file_name); if (file_size < 1) { return 1; } fd = g_file_open(file_name); if (fd < 1) { return 1; } rv = l_file_read_section(fd, file_size, section, names, values); g_file_close(fd); return rv; }
static int clipboard_get_file(const char *file, int bytes) { int sindex; int pindex; int flags; char full_fn[256]; /* /etc/xrdp/xrdp.ini */ char filename[256]; /* xrdp.ini */ char pathname[256]; /* /etc/xrdp */ struct cb_file_info *cfi; /* x-special/gnome-copied-files */ if ((g_strncmp(file, "copy", 4) == 0) && (bytes == 4)) { return 0; } if ((g_strncmp(file, "cut", 3) == 0) && (bytes == 3)) { return 0; } sindex = 0; flags = CB_FILE_ATTRIBUTE_ARCHIVE; /* text/uri-list */ /* x-special/gnome-copied-files */ if (g_strncmp(file, "file://", 7) == 0) { sindex = 7; } pindex = bytes; while (pindex > sindex) { if (file[pindex] == '/') { break; } pindex--; } g_memset(pathname, 0, 256); g_memset(filename, 0, 256); g_memcpy(pathname, file + sindex, pindex - sindex); if (pathname[0] == 0) { pathname[0] = '/'; } g_memcpy(filename, file + pindex + 1, (bytes - 1) - pindex); /* this should replace %20 with space */ clipboard_check_file(pathname); clipboard_check_file(filename); g_snprintf(full_fn, 255, "%s/%s", pathname, filename); if (g_directory_exist(full_fn)) { log_error("clipboard_get_file: file [%s] is a directory, " "not supported", full_fn); flags |= CB_FILE_ATTRIBUTE_DIRECTORY; return 1; } if (!g_file_exist(full_fn)) { log_error("clipboard_get_file: file [%s] does not exist", full_fn); return 1; } else { cfi = (struct cb_file_info*)g_malloc(sizeof(struct cb_file_info), 1); list_add_item(g_files_list, (tintptr)cfi); g_strcpy(cfi->filename, filename); g_strcpy(cfi->pathname, pathname); cfi->size = g_file_get_size(full_fn); cfi->flags = flags; cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL; log_debug("ok filename [%s] pathname [%s] size [%d]", cfi->filename, cfi->pathname, cfi->size); } return 0; }