refactor and use test2bool instead of duplicated code testing for on,yes,true, non zero

ulab-next
LawrenceK 12 years ago
parent e47a9cea97
commit 266db3150b

@ -19,6 +19,7 @@
*/ */
#include "libxrdp.h" #include "libxrdp.h"
#include "log.h"
#if defined(XRDP_FREERDP1) #if defined(XRDP_FREERDP1)
#include <freerdp/codec/rfx.h> #include <freerdp/codec/rfx.h>
@ -87,30 +88,15 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
if (g_strcasecmp(item, "bitmap_cache") == 0) if (g_strcasecmp(item, "bitmap_cache") == 0)
{ {
if ((g_strcasecmp(value, "yes") == 0) || client_info->use_bitmap_cache = text2bool(value);
(g_strcasecmp(value, "true") == 0) ||
(g_strcasecmp(value, "1") == 0))
{
client_info->use_bitmap_cache = 1;
}
} }
else if (g_strcasecmp(item, "bitmap_compression") == 0) else if (g_strcasecmp(item, "bitmap_compression") == 0)
{ {
if (g_strcasecmp(value, "yes") == 0 || client_info->use_bitmap_comp = text2bool(value);
g_strcasecmp(value, "true") == 0 ||
g_strcasecmp(value, "1") == 0)
{
client_info->use_bitmap_comp = 1;
}
} }
else if (g_strcasecmp(item, "bulk_compression") == 0) else if (g_strcasecmp(item, "bulk_compression") == 0)
{ {
if (g_strcasecmp(value, "yes") == 0 || client_info->use_bulk_comp = text2bool(value);
g_strcasecmp(value, "true") == 0 ||
g_strcasecmp(value, "1") == 0)
{
client_info->use_bulk_comp = 1;
}
} }
else if (g_strcasecmp(item, "crypt_level") == 0) else if (g_strcasecmp(item, "crypt_level") == 0)
{ {
@ -135,13 +121,8 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
} }
else if (g_strcasecmp(item, "channel_code") == 0) else if (g_strcasecmp(item, "channel_code") == 0)
{ {
if ((g_strcasecmp(value, "yes") == 0) || client_info->channel_code = text2bool(value);
(g_strcasecmp(value, "1") == 0) || if (client_info->channel_code == 0)
(g_strcasecmp(value, "true") == 0))
{
client_info->channel_code = 1;
}
else
{ {
g_writeln("Info: All channels are disabled"); g_writeln("Info: All channels are disabled");
} }

@ -19,6 +19,7 @@
*/ */
#include "xrdp.h" #include "xrdp.h"
#include "log.h"
/* 'g_process' is protected by the semaphore 'g_process_sem'. One thread sets /* 'g_process' is protected by the semaphore 'g_process_sem'. One thread sets
g_process and waits for the other to process it */ g_process and waits for the other to process it */
@ -198,40 +199,19 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
if (g_strcasecmp(val, "fork") == 0) if (g_strcasecmp(val, "fork") == 0)
{ {
val = (char *)list_get_item(values, index); val = (char *)list_get_item(values, index);
startup_param->fork = text2bool(val);
if ((g_strcasecmp(val, "yes") == 0) ||
(g_strcasecmp(val, "on") == 0) ||
(g_strcasecmp(val, "true") == 0) ||
(g_atoi(val) != 0))
{
startup_param->fork = 1;
}
} }
if (g_strcasecmp(val, "tcp_nodelay") == 0) if (g_strcasecmp(val, "tcp_nodelay") == 0)
{ {
val = (char *)list_get_item(values, index); val = (char *)list_get_item(values, index);
*tcp_nodelay = text2bool(val);
if ((g_strcasecmp(val, "yes") == 0) ||
(g_strcasecmp(val, "on") == 0) ||
(g_strcasecmp(val, "true") == 0) ||
(g_atoi(val) != 0))
{
*tcp_nodelay = 1 ;
}
} }
if (g_strcasecmp(val, "tcp_keepalive") == 0) if (g_strcasecmp(val, "tcp_keepalive") == 0)
{ {
val = (char *)list_get_item(values, index); val = (char *)list_get_item(values, index);
*tcp_keepalive = text2bool(val);
if ((g_strcasecmp(val, "yes") == 0) ||
(g_strcasecmp(val, "on") == 0) ||
(g_strcasecmp(val, "true") == 0) ||
(g_atoi(val) != 0))
{
*tcp_keepalive = 1 ;
}
} }
} }
} }

@ -2034,15 +2034,8 @@ is_channel_enabled(char *inName, struct list *names, struct list *values)
if ( index >= 0 ) if ( index >= 0 )
{ {
val = (char *)list_get_item(values, index); val = (char *)list_get_item(values, index);
reply = text2bool(val);
if ((g_strcasecmp(val, "yes") == 0) || if (reply == 0)
(g_strcasecmp(val, "on") == 0) ||
(g_strcasecmp(val, "true") == 0) ||
(g_atoi(val) != 0))
{
reply = 1;
}
else
{ {
g_writeln("This channel is disabled: %s", name); g_writeln("This channel is disabled: %s", name);
} }

@ -444,13 +444,7 @@ xrdp_wm_load_static_colors_plus(struct xrdp_wm *self, char *autorun_name)
else if (g_strcasecmp(val, "hidelogwindow") == 0) else if (g_strcasecmp(val, "hidelogwindow") == 0)
{ {
val = (char *)list_get_item(values, index); val = (char *)list_get_item(values, index);
self->hide_log_window = text2bool(val);
if ((g_strcasecmp(val, "yes") == 0) ||
(g_strcasecmp(val, "1") == 0) ||
(g_strcasecmp(val, "true") == 0))
{
self->hide_log_window = 1;
}
} }
} }
} }

Loading…
Cancel
Save