Migrating logging to LOG() and LOG_DEVEL() in xup/*

This commit is contained in:
Alexandre Quesnel
2021-02-09 02:43:44 +00:00
parent 59a8ab3e1b
commit 4ec4292898
2 changed files with 175 additions and 183 deletions
+43 -52
View File
@@ -27,12 +27,6 @@
#include "trans.h"
#include "string_calls.h"
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { g_write _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { g_writeln _args ; } } while (0)
static int
lib_mod_process_message(struct mod *mod, struct stream *s);
@@ -48,11 +42,11 @@ lib_send_copy(struct mod *mod, struct stream *s)
int
lib_mod_start(struct mod *mod, int w, int h, int bpp)
{
LIB_DEBUG(mod, "in lib_mod_start");
LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_start");
mod->width = w;
mod->height = h;
mod->bpp = bpp;
LIB_DEBUG(mod, "out lib_mod_start");
LOG_DEVEL(LOG_LEVEL_TRACE, "out lib_mod_start");
return 0;
}
@@ -68,17 +62,17 @@ lib_mod_log_peer(struct mod *mod)
my_pid = g_getpid();
if (g_sck_get_peer_cred(mod->trans->sck, &pid, &uid, &gid) == 0)
{
log_message(LOG_LEVEL_INFO, "lib_mod_log_peer: xrdp_pid=%d connected "
"to X11rdp_pid=%d X11rdp_uid=%d X11rdp_gid=%d "
"client_ip=%s client_port=%s",
my_pid, pid, uid, gid,
mod->client_info.client_addr,
mod->client_info.client_port);
LOG(LOG_LEVEL_INFO, "lib_mod_log_peer: xrdp_pid=%d connected "
"to X11rdp_pid=%d X11rdp_uid=%d X11rdp_gid=%d "
"client_ip=%s client_port=%s",
my_pid, pid, uid, gid,
mod->client_info.client_addr,
mod->client_info.client_port);
}
else
{
log_message(LOG_LEVEL_ERROR, "lib_mod_log_peer: g_sck_get_peer_cred "
"failed");
LOG(LOG_LEVEL_ERROR, "lib_mod_log_peer: g_sck_get_peer_cred "
"failed");
}
return 0;
}
@@ -91,7 +85,7 @@ lib_data_in(struct trans *trans)
struct stream *s;
int len;
LLOGLN(10, ("lib_data_in:"));
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_data_in:");
if (trans == 0)
{
return 1;
@@ -113,7 +107,7 @@ lib_data_in(struct trans *trans)
in_uint32_le(s, len);
if (len < 0 || len > 128 * 1024)
{
g_writeln("lib_data_in: bad size");
LOG(LOG_LEVEL_ERROR, "lib_data_in: bad size");
return 1;
}
if (len > 0)
@@ -122,12 +116,12 @@ lib_data_in(struct trans *trans)
trans->extra_flags = 2;
break;
}
/* fall through */
/* fall through */
case 2:
s->p = s->data;
if (lib_mod_process_message(self, s) != 0)
{
g_writeln("lib_data_in: lib_mod_process_message failed");
LOG(LOG_LEVEL_ERROR, "lib_data_in: lib_mod_process_message failed");
return 1;
}
init_stream(s, 0);
@@ -151,8 +145,6 @@ lib_mod_connect(struct mod *mod)
struct stream *s;
char con_port[256];
LIB_DEBUG(mod, "in lib_mod_connect");
mod->server_msg(mod, "started connecting", 0);
/* only support 8, 15, 16, 24, and 32 bpp connections from rdp client */
@@ -160,14 +152,12 @@ lib_mod_connect(struct mod *mod)
{
mod->server_msg(mod,
"error - only supporting 8, 15, 16, 24, and 32 bpp rdp connections", 0);
LIB_DEBUG(mod, "out lib_mod_connect error");
return 1;
}
if (g_strcmp(mod->ip, "") == 0)
{
mod->server_msg(mod, "error - no ip set", 0);
LIB_DEBUG(mod, "out lib_mod_connect error");
return 1;
}
@@ -186,6 +176,7 @@ lib_mod_connect(struct mod *mod)
if (use_uds)
{
LOG(LOG_LEVEL_INFO, "lib_mod_connect: connecting via UNIX socket");
mod->trans = trans_create(TRANS_MODE_UNIX, 8 * 8192, 8192);
if (mod->trans == 0)
{
@@ -195,6 +186,7 @@ lib_mod_connect(struct mod *mod)
}
else
{
LOG(LOG_LEVEL_INFO, "lib_mod_connect: connecting via TCP socket");
mod->trans = trans_create(TRANS_MODE_TCP, 8 * 8192, 8192);
if (mod->trans == 0)
{
@@ -214,9 +206,9 @@ lib_mod_connect(struct mod *mod)
error = -1;
if (trans_connect(mod->trans, mod->ip, con_port, 3000) == 0)
{
LLOGLN(0, ("lib_mod_connect: connected to Xserver "
"(Xorg or X11rdp) sck %lld",
(long long) (mod->trans->sck)));
LOG_DEVEL(LOG_LEVEL_INFO, "lib_mod_connect: connected to Xserver "
"(Xorg or X11rdp) sck %lld",
(long long) (mod->trans->sck));
error = 0;
}
@@ -314,7 +306,6 @@ lib_mod_connect(struct mod *mod)
trans_delete(mod->trans);
mod->trans = 0;
mod->server_msg(mod, "some problem", 0);
LIB_DEBUG(mod, "out lib_mod_connect error");
return 1;
}
else
@@ -327,7 +318,7 @@ lib_mod_connect(struct mod *mod)
mod->trans->extra_flags = 1;
}
LIB_DEBUG(mod, "out lib_mod_connect");
LOG_DEVEL(LOG_LEVEL_TRACE, "out lib_mod_connect");
return 0;
}
@@ -342,7 +333,7 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2,
int key;
int rv;
LIB_DEBUG(mod, "in lib_mod_event");
LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_event");
make_stream(s);
if ((msg >= 15) && (msg <= 16)) /* key events */
@@ -355,7 +346,7 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2,
{
if (mod->shift_state)
{
g_writeln("special");
LOG_DEVEL(LOG_LEVEL_TRACE, "special");
/* fix for mstsc sending left control down with altgr */
/* control down / up
msg param1 param2 param3 param4
@@ -398,7 +389,7 @@ lib_mod_event(struct mod *mod, int msg, tbus param1, tbus param2,
out_uint32_le(s, len);
rv = lib_send_copy(mod, s);
free_stream(s);
LIB_DEBUG(mod, "out lib_mod_event");
LOG_DEVEL(LOG_LEVEL_TRACE, "out lib_mod_event");
return rv;
}
@@ -783,7 +774,7 @@ process_server_window_delete(struct mod *mod, struct stream *s)
/******************************************************************************/
/* return error */
static int
process_server_window_show(struct mod* mod, struct stream* s)
process_server_window_show(struct mod *mod, struct stream *s)
{
int window_id;
int rv;
@@ -1098,7 +1089,7 @@ process_server_paint_rect_shmem(struct mod *amod, struct stream *s)
{
amod->screen_shmem_id = shmem_id;
amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1)
if (amod->screen_shmem_pixels == (void *) -1)
{
/* failed */
amod->screen_shmem_id = 0;
@@ -1115,7 +1106,7 @@ process_server_paint_rect_shmem(struct mod *amod, struct stream *s)
amod->screen_shmem_id = shmem_id;
g_shmdt(amod->screen_shmem_pixels);
amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1)
if (amod->screen_shmem_pixels == (void *) -1)
{
/* failed */
amod->screen_shmem_id = 0;
@@ -1249,7 +1240,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s)
{
amod->screen_shmem_id = shmem_id;
amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1)
if (amod->screen_shmem_pixels == (void *) -1)
{
/* failed */
amod->screen_shmem_id = 0;
@@ -1266,7 +1257,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s)
amod->screen_shmem_id = shmem_id;
g_shmdt(amod->screen_shmem_pixels);
amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
if (amod->screen_shmem_pixels == (void*)-1)
if (amod->screen_shmem_pixels == (void *) -1)
{
/* failed */
amod->screen_shmem_id = 0;
@@ -1292,7 +1283,7 @@ process_server_paint_rect_shmem_ex(struct mod *amod, struct stream *s)
rv = 1;
}
//g_writeln("frame_id %d", frame_id);
//LOG_DEVEL(LOG_LEVEL_TRACE, "frame_id %d", frame_id);
//send_paint_rect_ex_ack(amod, flags, frame_id);
g_free(lcrects);
@@ -1308,7 +1299,7 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s)
{
int rv;
LLOGLN(10, ("lib_mod_process_orders: type %d", type));
LOG_DEVEL(LOG_LEVEL_DEBUG, "lib_mod_process_orders: type %d", type);
rv = 0;
switch (type)
{
@@ -1403,7 +1394,7 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s)
rv = process_server_paint_rect_shmem_ex(mod, s);
break;
default:
g_writeln("lib_mod_process_orders: unknown order type %d", type);
LOG_DEVEL(LOG_LEVEL_WARNING, "lib_mod_process_orders: unknown order type %d", type);
rv = 0;
break;
}
@@ -1418,7 +1409,7 @@ lib_send_client_info(struct mod *mod)
struct stream *s;
int len;
g_writeln("lib_send_client_info:");
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_send_client_info:");
make_stream(s);
init_stream(s, 8192);
s_push_layer(s, iso_hdr, 4);
@@ -1446,14 +1437,14 @@ lib_mod_process_message(struct mod *mod, struct stream *s)
int type;
char *phold;
LLOGLN(10, ("lib_mod_process_message:"));
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_process_message:");
rv = 0;
if (rv == 0)
{
in_uint16_le(s, type);
in_uint16_le(s, num_orders);
in_uint32_le(s, len);
LLOGLN(10, ("lib_mod_process_message: type %d", type));
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_process_message: type %d", type);
if (type == 1) /* original order list */
{
@@ -1470,7 +1461,7 @@ lib_mod_process_message(struct mod *mod, struct stream *s)
}
else if (type == 2) /* caps */
{
g_writeln("lib_mod_process_message: type 2 len %d", len);
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_process_message: type 2 len %d", len);
for (index = 0; index < num_orders; index++)
{
phold = s->p;
@@ -1480,7 +1471,7 @@ lib_mod_process_message(struct mod *mod, struct stream *s)
switch (type)
{
default:
g_writeln("lib_mod_process_message: unknown cap type %d len %d",
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_process_message: unknown cap type %d len %d",
type, len);
break;
}
@@ -1509,7 +1500,7 @@ lib_mod_process_message(struct mod *mod, struct stream *s)
}
else
{
g_writeln("unknown type %d", type);
LOG_DEVEL(LOG_LEVEL_TRACE, "unknown type %d", type);
}
}
@@ -1521,7 +1512,7 @@ lib_mod_process_message(struct mod *mod, struct stream *s)
int
lib_mod_signal(struct mod *mod)
{
g_writeln("lib_mod_signal: not used");
// no-op
return 0;
}
@@ -1545,11 +1536,11 @@ lib_mod_set_param(struct mod *mod, const char *name, const char *value)
{
if (g_strcasecmp(name, "username") == 0)
{
g_strncpy(mod->username, value, INFO_CLIENT_MAX_CB_LEN-1);
g_strncpy(mod->username, value, INFO_CLIENT_MAX_CB_LEN - 1);
}
else if (g_strcasecmp(name, "password") == 0)
{
g_strncpy(mod->password, value, INFO_CLIENT_MAX_CB_LEN-1);
g_strncpy(mod->password, value, INFO_CLIENT_MAX_CB_LEN - 1);
}
else if (g_strcasecmp(name, "ip") == 0)
{
@@ -1608,7 +1599,7 @@ lib_mod_check_wait_objs(struct mod *mod)
int
lib_mod_frame_ack(struct mod *amod, int flags, int frame_id)
{
LLOGLN(10, ("lib_mod_frame_ack: flags 0x%8.8x frame_id %d", flags, frame_id));
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_frame_ack: flags 0x%8.8x frame_id %d", flags, frame_id);
send_paint_rect_ex_ack(amod, flags, frame_id);
return 0;
}
@@ -1619,8 +1610,8 @@ int
lib_mod_suppress_output(struct mod *amod, int suppress,
int left, int top, int right, int bottom)
{
LLOGLN(10, ("lib_mod_suppress_output: suppress 0x%8.8x left %d top %d "
"right %d bottom %d", suppress, left, top, right, bottom));
LOG_DEVEL(LOG_LEVEL_TRACE, "lib_mod_suppress_output: suppress 0x%8.8x left %d top %d "
"right %d bottom %d", suppress, left, top, right, bottom);
send_suppress_output(amod, suppress, left, top, right, bottom);
return 0;
}