Improved error handling for module load and init, fixed bug in logwindow
This commit is contained in:
parent
2109d7a044
commit
02f3fe1e2a
@ -1579,7 +1579,32 @@ g_strdup(const char* in)
|
||||
}
|
||||
return p;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/* if in = 0, return 0 else return newly alloced copy of input string
|
||||
* if the input string is larger than maxlen the returned string will be
|
||||
* truncated. All strings returned will include null termination*/
|
||||
char* APP_CC
|
||||
g_strndup(const char* in, const unsigned int maxlen)
|
||||
{
|
||||
int len;
|
||||
char* p;
|
||||
|
||||
if (in == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
len = g_strlen(in);
|
||||
if(len>maxlen)
|
||||
{
|
||||
len = maxlen-1 ;
|
||||
}
|
||||
p = (char*)g_malloc(len + 2, 0);
|
||||
if (p != NULL)
|
||||
{
|
||||
g_strncpy(p, in,len+1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
g_strcmp(const char* c1, const char* c2)
|
||||
|
@ -178,6 +178,8 @@ char* APP_CC
|
||||
g_strcat(char* dest, const char* src);
|
||||
char* APP_CC
|
||||
g_strdup(const char* in);
|
||||
char* APP_CC
|
||||
g_strndup(const char* in, const unsigned int maxlen);
|
||||
int APP_CC
|
||||
g_strcmp(const char* c1, const char* c2);
|
||||
int APP_CC
|
||||
|
@ -317,6 +317,8 @@ xrdp_mm_setup_mod1(struct xrdp_mm* self)
|
||||
g_writeln("loaded module '%s' ok, interface size %d, version %d", lib,
|
||||
self->mod->size, self->mod->version);
|
||||
}
|
||||
}else{
|
||||
g_writeln("no mod_init or mod_exit address found") ;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -324,6 +326,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm* self)
|
||||
g_snprintf(text, 255, "error loading %s specified in xrdp.ini, please "
|
||||
"add a valid entry like lib=libxrdp-vnc.so or similar", lib);
|
||||
xrdp_wm_log_msg(self->wm, text);
|
||||
return 1 ;
|
||||
}
|
||||
if (self->mod != 0)
|
||||
{
|
||||
@ -1043,20 +1046,25 @@ xrdp_mm_connect(struct xrdp_mm* self)
|
||||
if (xrdp_mm_setup_mod2(self) == 0)
|
||||
{
|
||||
xrdp_wm_set_login_mode(self->wm, 10);
|
||||
rv = 0 ; /*sucess*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* connect error */
|
||||
g_snprintf(errstr, 255, "Failure to connect to: %s port: %s",
|
||||
ip, port);
|
||||
g_writeln(errstr);
|
||||
xrdp_wm_log_msg(self->wm, errstr);
|
||||
rv = 1 ; /* failure */
|
||||
}
|
||||
}else{
|
||||
g_writeln("Failure setting up module");
|
||||
}
|
||||
if (self->wm->login_mode != 10)
|
||||
{
|
||||
xrdp_wm_set_login_mode(self->wm, 11);
|
||||
xrdp_mm_module_cleanup(self);
|
||||
rv = 1 ; /* failure */
|
||||
}
|
||||
}
|
||||
self->sesman_controlled = use_sesman;
|
||||
@ -1067,6 +1075,7 @@ xrdp_mm_connect(struct xrdp_mm* self)
|
||||
/* if sesman controlled, this will connect later */
|
||||
xrdp_mm_connect_chansrv(self, "", chansrvport);
|
||||
}
|
||||
g_writeln("returnvalue from xrdp_mm_connect %d",rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
types
|
||||
|
||||
*/
|
||||
#define DEFAULT_STRING_LEN 255
|
||||
#define LOG_WINDOW_CHAR_PER_LINE 60
|
||||
|
||||
/* lib */
|
||||
struct xrdp_mod
|
||||
|
@ -1556,6 +1556,21 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap* wnd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void add_string_to_logwindow(char *msg,struct list* log)
|
||||
{
|
||||
|
||||
char *new_part_message;
|
||||
char *current_pointer = msg ;
|
||||
int processedlen ;
|
||||
do{
|
||||
new_part_message = g_strndup(current_pointer,LOG_WINDOW_CHAR_PER_LINE) ;
|
||||
g_writeln(new_part_message);
|
||||
list_add_item(log, (long)new_part_message);
|
||||
processedlen = processedlen + g_strlen(new_part_message);
|
||||
current_pointer = current_pointer + g_strlen(new_part_message) ;
|
||||
}while((processedlen<g_strlen(msg)) && (processedlen<DEFAULT_STRING_LEN));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_wm_log_msg(struct xrdp_wm* self, char* msg)
|
||||
@ -1570,7 +1585,7 @@ xrdp_wm_log_msg(struct xrdp_wm* self, char* msg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
list_add_item(self->log, (long)g_strdup(msg));
|
||||
add_string_to_logwindow(msg,self->log);
|
||||
if (self->log_wnd == 0)
|
||||
{
|
||||
w = DEFAULT_WND_LOG_W;
|
||||
|
Loading…
Reference in New Issue
Block a user