summaryrefslogtreecommitdiffstats
path: root/common/os_calls.c
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/os_calls.c
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/os_calls.c')
-rw-r--r--common/os_calls.c74
1 files changed, 57 insertions, 17 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)