diff options
author | Luke Leighton <lkcl@samba.org> | 1999-12-01 02:15:14 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-12-01 02:15:14 +0000 |
commit | 6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d (patch) | |
tree | 2f8a0996fe269f79e86d6336e4520d3278b442ed /source3/lib | |
parent | 7e42174792298c8815acd1ebf34c357aff0de7c3 (diff) | |
download | samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.tar.gz samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.tar.bz2 samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.zip |
sys_select added one more argument (read, write selectors).
(This used to be commit e4d92ff9dfc51735e6932748f66a7c20b2c1cb6a)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/system.c | 7 | ||||
-rw-r--r-- | source3/lib/util.c | 2 | ||||
-rw-r--r-- | source3/lib/util_array.c | 71 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 2 |
4 files changed, 73 insertions, 9 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c index 5a5f853bda..f9de800bd3 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -60,7 +60,7 @@ static int pollfd(int fd) return(r); } -int sys_select(int maxfd, fd_set *fds,struct timeval *tval) +int sys_select(int maxfd, fd_set *fds, fd_set *w_fds, struct timeval *tval) { fd_set fds2; int counter=0; @@ -90,7 +90,7 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval) } #else /* !NO_SELECT */ -int sys_select(int maxfd, fd_set *fds,struct timeval *tval) +int sys_select(int maxfd, fd_set *r_fds, fd_set *w_fds, struct timeval *tval) { #ifdef USE_POLL struct pollfd pfd[256]; @@ -131,7 +131,8 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval) do { if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2)); errno = 0; - selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL); + selrtn = select(maxfd,SELECT_CAST r_fds,SELECT_CAST w_fds, + NULL,tval?&t2:NULL); } while (selrtn<0 && errno == EINTR); return(selrtn); diff --git a/source3/lib/util.c b/source3/lib/util.c index 26f0482162..9bcbe1a9c7 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1148,7 +1148,7 @@ void msleep(int t) FD_ZERO(&fds); errno = 0; - sys_select(0,&fds,&tval); + sys_select(0,&fds,NULL, &tval); GetTimeOfDay(&t2); tdiff = TvalDiff(&t1,&t2); diff --git a/source3/lib/util_array.c b/source3/lib/util_array.c index 62be3f17bd..71cd19e65d 100644 --- a/source3/lib/util_array.c +++ b/source3/lib/util_array.c @@ -77,6 +77,69 @@ void* add_item_to_array(uint32 *len, void ***array, void *item) return NULL; } +static void use_info_free(struct use_info *item) +{ + if (item != NULL) + { + if (item->srv_name != NULL) + { + free(item->srv_name); + } + if (item->user_name != NULL) + { + free(item->user_name); + } + if (item->domain != NULL) + { + free(item->domain); + } + free(item); + } +} + +static struct use_info *use_info_dup(const struct use_info *from) +{ + if (from != NULL) + { + struct use_info *copy = (struct use_info *) + malloc(sizeof(struct use_info)); + if (copy != NULL) + { + ZERO_STRUCTP(copy); + copy->connected = from->connected; + if (from->srv_name != NULL) + { + copy->srv_name = strdup(from->srv_name ); + } + if (from->user_name != NULL) + { + copy->user_name = strdup(from->user_name); + } + if (from->domain != NULL) + { + copy->domain = strdup(from->domain ); + } + } + return copy; + } + return NULL; +} + +void free_use_array(uint32 num_entries, struct use_info **entries) +{ + void(*fn)(void*) = (void(*)(void*))&use_info_free; + free_void_array(num_entries, (void**)entries, *fn); +} + +struct use_info* add_use_to_array(uint32 *len, struct use_info ***array, + const struct use_info *name) +{ + void*(*fn)(const void*) = (void*(*)(const void*))&use_info_dup; + return (struct use_info*)add_copy_to_array(len, + (void***)array, (const void*)name, *fn, False); + +} + void free_char_array(uint32 num_entries, char **entries) { void(*fn)(void*) = (void(*)(void*))&free; @@ -175,7 +238,7 @@ static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -206,7 +269,7 @@ static PRINTER_INFO_1 *prt1_dup(const PRINTER_INFO_1* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -237,7 +300,7 @@ static JOB_INFO_1 *job1_dup(const JOB_INFO_1* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -268,7 +331,7 @@ static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 50c295f2bd..fc5c2958e4 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -287,7 +287,7 @@ ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned FD_ZERO(&fds); FD_SET(fd,&fds); - selrtn = sys_select(fd+1,&fds,&timeout); + selrtn = sys_select(fd+1,&fds,NULL, &timeout); /* Check if error */ if(selrtn == -1) { |