summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorArvidNorr <norrarvid@gmail.com>2012-06-17 23:14:40 -0700
committerArvidNorr <norrarvid@gmail.com>2012-06-17 23:14:40 -0700
commit1011b4a25656fed871ddb6e8d782f65fa0e97d9f (patch)
treeb67ba22d0ca3151c24eaa4409b3cbe1e49af6c85 /common
parent4ba8cdc343d96cd449c18c107f623e8e73d2d470 (diff)
parent31a5dd33ddfa86e195469dff776e7ca1cf4d7b06 (diff)
downloadxrdp-proprietary-1011b4a25656fed871ddb6e8d782f65fa0e97d9f.tar.gz
xrdp-proprietary-1011b4a25656fed871ddb6e8d782f65fa0e97d9f.zip
Merge pull request #22 from ArvidNorr/moduleload
Moduleload
Diffstat (limited to 'common')
-rw-r--r--common/os_calls.c74
-rw-r--r--common/os_calls.h2
-rw-r--r--common/trans.c2
-rw-r--r--common/trans.h2
4 files changed, 61 insertions, 19 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index 4387f8f9..c713bfaa 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -1077,29 +1077,44 @@ g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
ptime = &time;
}
FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- for (i = 0; i < rcount; i++)
- {
- sck = (int)(read_objs[i]);
- if (sck > 0) {
- FD_SET(sck, &rfds);
- if (sck > max)
- {
- max = sck;
+ FD_ZERO(&wfds);
+ /*Find the highest descriptor number in read_obj */
+ if(read_objs!=NULL){
+ for (i = 0; i < rcount; i++)
+ {
+ sck = (int)(read_objs[i]);
+ if (sck > 0) {
+ FD_SET(sck, &rfds);
+ if (sck > max)
+ {
+ max = sck; /*max holds the highest socket/descriptor number */
+ }
}
}
}
- for (i = 0; i < wcount; i++)
+ else if(rcount>0)
{
- sck = (int)(write_objs[i]);
- if (sck > 0) {
- FD_SET(sck, &wfds);
- if (sck > max)
- {
- max = sck;
+ g_writeln("Programming error read_objs is null");
+ return 1; /*error*/
+ }
+ if(write_objs!=NULL){
+ for (i = 0; i < wcount; i++)
+ {
+ sck = (int)(write_objs[i]);
+ if (sck > 0) {
+ FD_SET(sck, &wfds);
+ if (sck > max)
+ {
+ max = sck; /*max holds the highest socket/descriptor number */
+ }
}
}
}
+ else if(wcount>0)
+ {
+ g_writeln("Programming error write_objs is null");
+ return 1; /*error*/
+ }
res = select(max + 1, &rfds, &wfds, 0, ptime);
if (res < 0)
{
@@ -1111,7 +1126,7 @@ g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
{
return 0;
}
- return 1;
+ return 1; /*error*/
}
return 0;
#endif
@@ -1576,7 +1591,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)
diff --git a/common/os_calls.h b/common/os_calls.h
index ddcb59d8..7be659d6 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -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
diff --git a/common/trans.c b/common/trans.c
index 377b90ba..6b762d00 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -69,7 +69,7 @@ trans_delete(struct trans* self)
/*****************************************************************************/
int APP_CC
-trans_get_wait_objs(struct trans* self, tbus* objs, int* count, int* timeout)
+trans_get_wait_objs(struct trans* self, tbus* objs, int* count)
{
if (self == 0)
{
diff --git a/common/trans.h b/common/trans.h
index bb0f42c0..8e8d942a 100644
--- a/common/trans.h
+++ b/common/trans.h
@@ -64,7 +64,7 @@ trans_create(int mode, int in_size, int out_size);
void APP_CC
trans_delete(struct trans* self);
int APP_CC
-trans_get_wait_objs(struct trans* self, tbus* objs, int* count, int* timeout);
+trans_get_wait_objs(struct trans* self, tbus* objs, int* count);
int APP_CC
trans_check_wait_objs(struct trans* self);
int APP_CC