Merge branch 'master' of github.com:neutrinolabs/xrdp

ulab-next
Jay Sorg 11 years ago
commit fa40106a69

File diff suppressed because it is too large Load Diff

@ -36,17 +36,45 @@
#include "xcommon.h"
#include "chansrv_fuse.h"
#define LLOG_LEVEL 1
#define LLOGLN(_level, _args) \
do \
{ \
if (_level < LLOG_LEVEL) \
{ \
g_write("chansrv:clip [%10.10u]: ", g_time3()); \
g_writeln _args ; \
} \
} \
while (0)
/* module based logging */
#define LOG_ERROR 0
#define LOG_INFO 1
#define LOG_DEBUG 2
#define LOG_LVL LOG_ERROR
#define log_error(_params...) \
{ \
g_write("[%10.10u]: CLIPFILE %s: %d : ERROR: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
}
#define log_always(_params...) \
{ \
g_write("[%10.10u]: CLIPFILE %s: %d : ALWAYS: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
}
#define log_info(_params...) \
{ \
if (LOG_INFO <= LOG_LVL) \
{ \
g_write("[%10.10u]: CLIPFILE %s: %d : ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
}
#define log_debug(_params...) \
{ \
if (LOG_DEBUG <= LOG_LVL) \
{ \
g_write("[%10.10u]: CLIPFILE %s: %d : ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
}
extern int g_cliprdr_chan_id; /* in chansrv.c */
@ -117,7 +145,7 @@ clipboard_check_file(char *filename)
index++;
}
}
LLOGLN(10, ("[%s] [%s]", filename, lfilename));
log_debug("[%s] [%s]", filename, lfilename);
g_strcpy(filename, lfilename);
return 0;
}
@ -173,15 +201,15 @@ clipboard_get_file(char* file, int bytes)
g_snprintf(full_fn, 255, "%s/%s", pathname, filename);
if (g_directory_exist(full_fn))
{
LLOGLN(0, ("clipboard_get_file: file [%s] is a directory, "
"not supported", 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))
{
LLOGLN(0, ("clipboard_get_file: file [%s] does not exist",
full_fn));
log_error("clipboard_get_file: file [%s] does not exist",
full_fn);
return 1;
}
else
@ -193,8 +221,8 @@ clipboard_get_file(char* file, int bytes)
cfi->size = g_file_get_size(full_fn);
cfi->flags = flags;
cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
LLOGLN(10, ("ok filename [%s] pathname [%s] size [%d]",
cfi->filename, cfi->pathname, cfi->size));
log_debug("ok filename [%s] pathname [%s] size [%d]",
cfi->filename, cfi->pathname, cfi->size);
}
return 0;
}
@ -256,8 +284,8 @@ clipboard_send_data_response_for_file(char *data, int data_size)
char fn[256];
struct cb_file_info *cfi;
LLOGLN(10, ("clipboard_send_data_response_for_file: data_size %d",
data_size));
log_debug("clipboard_send_data_response_for_file: data_size %d",
data_size);
//g_hexdump(data, data_size);
if (g_files_list == 0)
{
@ -319,18 +347,18 @@ clipboard_send_file_size(int streamId, int lindex)
if (g_files_list == 0)
{
LLOGLN(10, ("clipboard_send_file_size: error g_files_list is nil"));
log_error("clipboard_send_file_size: error g_files_list is nil");
return 1;
}
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
if (cfi == 0)
{
LLOGLN(10, ("clipboard_send_file_size: error cfi is nil"));
log_error("clipboard_send_file_size: error cfi is nil");
return 1;
}
file_size = cfi->size;
LLOGLN(10, ("clipboard_send_file_size: streamId %d file_size %d",
streamId, file_size));
log_debug("clipboard_send_file_size: streamId %d file_size %d",
streamId, file_size);
make_stream(s);
init_stream(s, 8192);
out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
@ -356,11 +384,11 @@ clipboard_request_file_size(int stream_id, int lindex)
int size;
int rv;
LLOGLN(10, ("clipboard_request_file_size:"));
log_debug("clipboard_request_file_size:");
if (g_file_request_sent_type != 0)
{
LLOGLN(0, ("clipboard_request_file_size: warning, still waiting "
"for CB_FILECONTENTS_RESPONSE"));
log_error("clipboard_request_file_size: warning, still waiting "
"for CB_FILECONTENTS_RESPONSE");
}
make_stream(s);
init_stream(s, 8192);
@ -398,24 +426,24 @@ clipboard_send_file_data(int streamId, int lindex,
if (g_files_list == 0)
{
LLOGLN(10, ("clipboard_send_file_data: error g_files_list is nil"));
log_error("clipboard_send_file_data: error g_files_list is nil");
return 1;
}
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
if (cfi == 0)
{
LLOGLN(10, ("clipboard_send_file_data: error cfi is nil"));
log_error("clipboard_send_file_data: error cfi is nil");
return 1;
}
LLOGLN(10, ("clipboard_send_file_data: streamId %d lindex %d "
log_debug("clipboard_send_file_data: streamId %d lindex %d "
"nPositionLow %d cbRequested %d", streamId, lindex,
nPositionLow, cbRequested));
nPositionLow, cbRequested);
g_snprintf(full_fn, 255, "%s/%s", cfi->pathname, cfi->filename);
fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
if (fd == -1)
{
LLOGLN(0, ("clipboard_send_file_data: file open [%s] failed",
full_fn));
log_error("clipboard_send_file_data: file open [%s] failed",
full_fn);
return 1;
}
g_file_seek(fd, nPositionLow);
@ -424,8 +452,8 @@ clipboard_send_file_data(int streamId, int lindex,
size = g_file_read(fd, s->data + 12, cbRequested);
if (size < 1)
{
LLOGLN(0, ("clipboard_send_file_data: read error, want %d got %d",
cbRequested, size));
log_error("clipboard_send_file_data: read error, want %d got %d",
cbRequested, size);
free_stream(s);
g_file_close(fd);
return 1;
@ -454,13 +482,13 @@ clipboard_request_file_data(int stream_id, int lindex, int offset,
int size;
int rv;
LLOGLN(10, ("clipboard_request_file_data: stream_id=%d lindex=%d off=%d request_bytes=%d",
stream_id, lindex, offset, request_bytes));
log_debug("clipboard_request_file_data: stream_id=%d lindex=%d off=%d request_bytes=%d",
stream_id, lindex, offset, request_bytes);
if (g_file_request_sent_type != 0)
{
LLOGLN(0, ("clipboard_request_file_data: warning, still waiting "
"for CB_FILECONTENTS_RESPONSE"));
log_error("clipboard_request_file_data: warning, still waiting "
"for CB_FILECONTENTS_RESPONSE");
}
make_stream(s);
init_stream(s, 8192);
@ -498,7 +526,7 @@ clipboard_process_file_request(struct stream *s, int clip_msg_status,
int cbRequested;
//int clipDataId;
LLOGLN(10, ("clipboard_process_file_request:"));
log_debug("clipboard_process_file_request:");
//g_hexdump(s->p, clip_msg_len);
in_uint32_le(s, streamId);
in_uint32_le(s, lindex);
@ -528,14 +556,14 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
int streamId;
int file_size;
LLOGLN(10, ("clipboard_process_file_response:"));
log_debug("clipboard_process_file_response:");
if (g_file_request_sent_type == CB_FILECONTENTS_SIZE)
{
g_file_request_sent_type = 0;
in_uint32_le(s, streamId);
in_uint32_le(s, file_size);
LLOGLN(10, ("clipboard_process_file_response: streamId %d "
"file_size %d", streamId, file_size));
log_debug("clipboard_process_file_response: streamId %d "
"file_size %d", streamId, file_size);
xfuse_file_contents_size(streamId, file_size);
}
else if (g_file_request_sent_type == CB_FILECONTENTS_RANGE)
@ -546,7 +574,7 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
}
else
{
LLOGLN(0, ("clipboard_process_file_response: error"));
log_error("clipboard_process_file_response: error");
g_file_request_sent_type = 0;
}
return 0;
@ -574,14 +602,14 @@ clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
ex_bytes -= 2;
in_uint8s(s, ex_bytes);
in_uint8s(s, 8); /* pad */
LLOGLN(10, ("clipboard_c2s_in_file_info:"));
LLOGLN(10, (" flags 0x%8.8x", cfd->flags));
LLOGLN(10, (" fileAttributes 0x%8.8x", cfd->fileAttributes));
LLOGLN(10, (" lastWriteTime 0x%8.8x%8.8x", cfd->lastWriteTimeHigh,
cfd->lastWriteTimeLow));
LLOGLN(10, (" fileSize 0x%8.8x%8.8x", cfd->fileSizeHigh,
cfd->fileSizeLow));
LLOGLN(10, (" num_chars %d cFileName [%s]", num_chars, cfd->cFileName));
log_debug("clipboard_c2s_in_file_info:");
log_debug(" flags 0x%8.8x", cfd->flags);
log_debug(" fileAttributes 0x%8.8x", cfd->fileAttributes);
log_debug(" lastWriteTime 0x%8.8x%8.8x", cfd->lastWriteTimeHigh,
cfd->lastWriteTimeLow);
log_debug(" fileSize 0x%8.8x%8.8x", cfd->fileSizeHigh,
cfd->fileSizeLow);
log_debug(" num_chars %d cFileName [%s]", num_chars, cfd->cFileName);
return 0;
}
@ -597,17 +625,17 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
if (!s_check_rem(s, 4))
{
LLOGLN(0, ("clipboard_c2s_in_files: parse error"));
log_error("clipboard_c2s_in_files: parse error");
return 1;
}
in_uint32_le(s, cItems);
if (cItems > 64 * 1024) /* sanity check */
{
LLOGLN(0, ("clipboard_c2s_in_files: error cItems %d too big", cItems));
log_error("clipboard_c2s_in_files: error cItems %d too big", cItems);
return 1;
}
xfuse_clear_clip_dir();
LLOGLN(10, ("clipboard_c2s_in_files: cItems %d", cItems));
log_debug("clipboard_c2s_in_files: cItems %d", cItems);
cfd = (struct clip_file_desc *)
g_malloc(sizeof(struct clip_file_desc), 0);
ptr = file_list;
@ -618,8 +646,8 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
if ((g_pos(cfd->cFileName, "\\") >= 0) ||
(cfd->fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
{
LLOGLN(0, ("clipboard_c2s_in_files: skipping directory not "
"supported [%s]", cfd->cFileName));
log_error("clipboard_c2s_in_files: skipping directory not "
"supported [%s]", cfd->cFileName);
continue;
}
xfuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex);

Loading…
Cancel
Save