clipboard: enabled module logging

ulab-next
Laxmikant Rashinkar 11 years ago
parent 6381941c78
commit 09dd58c5e1

File diff suppressed because it is too large Load Diff

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

Loading…
Cancel
Save