summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv/chansrv.c
diff options
context:
space:
mode:
Diffstat (limited to 'sesman/chansrv/chansrv.c')
-rw-r--r--sesman/chansrv/chansrv.c94
1 files changed, 82 insertions, 12 deletions
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index 86c50960..01c6a43d 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -72,16 +72,18 @@ tbus g_exec_mutex;
tbus g_exec_sem;
int g_exec_pid = 0;
+#define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x)))
+
/* each time we create a DVC we need a unique DVC channel id */
/* this variable gets bumped up once per DVC we create */
tui32 g_dvc_chan_id = 100;
struct timeout_obj
{
- tui32 mstime;
- void* data;
- void (*callback)(void* data);
- struct timeout_obj* next;
+ tui32 mstime;
+ void *data;
+ void (*callback)(void *data);
+ struct timeout_obj *next;
};
static struct timeout_obj *g_timeout_head = 0;
@@ -93,7 +95,7 @@ add_timeout(int msoffset, void (*callback)(void *data), void *data)
{
struct timeout_obj *tobj;
tui32 now;
-
+
LOG(10, ("add_timeout:"));
now = g_time3();
tobj = g_malloc(sizeof(struct timeout_obj), 1);
@@ -374,6 +376,31 @@ send_channel_data(int chan_id, char *data, int size)
/*****************************************************************************/
/* returns error */
+int APP_CC
+send_rail_drawing_orders(char* data, int size)
+{
+ LOGM((LOG_LEVEL_DEBUG, "chansrv::send_rail_drawing_orders: size %d", size));
+
+ struct stream* s;
+ int error;
+
+ s = trans_get_out_s(g_con_trans, 8192);
+ out_uint32_le(s, 0); /* version */
+ out_uint32_le(s, 8 + 8 + size); /* size */
+ out_uint32_le(s, 10); /* msg id */
+ out_uint32_le(s, 8 + size); /* size */
+ out_uint8a(s, data, size);
+ s_mark_end(s);
+ error = trans_force_write(g_con_trans);
+ if (error != 0)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns error */
static int APP_CC
send_init_response_message(void)
{
@@ -1326,6 +1353,47 @@ read_ini(void)
}
/*****************************************************************************/
+static char* APP_CC
+get_log_path()
+{
+ char* log_path = 0;
+
+ log_path = g_getenv("CHANSRV_LOG_PATH");
+ if (log_path == 0)
+ {
+ log_path = g_getenv("HOME");
+ }
+ return log_path;
+}
+
+/*****************************************************************************/
+static unsigned int APP_CC
+get_log_level(const char* level_str, unsigned int default_level)
+{
+ static const char* levels[] = {
+ "LOG_LEVEL_ALWAYS",
+ "LOG_LEVEL_ERROR",
+ "LOG_LEVEL_WARNING",
+ "LOG_LEVEL_INFO",
+ "LOG_LEVEL_DEBUG"
+ };
+ unsigned int i;
+
+ if (level_str == NULL || level_str[0] == 0)
+ {
+ return default_level;
+ }
+ for (i = 0; i < ARRAYSIZE(levels); ++i)
+ {
+ if (g_strcasecmp(levels[i], level_str) == 0)
+ {
+ return i;
+ }
+ }
+ return default_level;
+}
+
+/*****************************************************************************/
static int APP_CC
run_exec(void)
{
@@ -1359,19 +1427,19 @@ main(int argc, char **argv)
tbus waiters[4];
int pid = 0;
char text[256];
- char *home_text;
+ char* log_path;
char *display_text;
char log_file[256];
enum logReturns error;
struct log_config logconfig;
+ unsigned int log_level;
g_init("xrdp-chansrv"); /* os_calls */
- home_text = g_getenv("HOME");
-
- if (home_text == 0)
+ log_path = get_log_path();
+ if (log_path == 0)
{
- g_writeln("error reading HOME environment variable");
+ g_writeln("error reading CHANSRV_LOG_PATH and HOME environment variable");
g_deinit();
return 1;
}
@@ -1379,10 +1447,12 @@ main(int argc, char **argv)
read_ini();
pid = g_getpid();
+ log_level = get_log_level(g_getenv("CHANSRV_LOG_LEVEL"), LOG_LEVEL_ERROR);
+
/* starting logging subsystem */
g_memset(&logconfig, 0, sizeof(struct log_config));
logconfig.program_name = "XRDP-Chansrv";
- g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", home_text);
+ g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", log_path);
g_writeln("chansrv::main: using log file [%s]", log_file);
if (g_file_exist(log_file))
@@ -1392,7 +1462,7 @@ main(int argc, char **argv)
logconfig.log_file = log_file;
logconfig.fd = -1;
- logconfig.log_level = LOG_LEVEL_ERROR;
+ logconfig.log_level = log_level;
logconfig.enable_syslog = 0;
logconfig.syslog_level = 0;
error = log_start_from_param(&logconfig);