diff options
author | Gerald Carter <jerry@samba.org> | 2003-01-15 18:57:41 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-01-15 18:57:41 +0000 |
commit | 99cdb462083381c88689a4e698ca48b6ed4cf5ac (patch) | |
tree | 7ea530c74c8fd1ef65eec52410b7843e63d89f8f /source3/lib | |
parent | 35fa2e5975f9b380e6e63471413df6f4182c164b (diff) | |
download | samba-99cdb462083381c88689a4e698ca48b6ed4cf5ac.tar.gz samba-99cdb462083381c88689a4e698ca48b6ed4cf5ac.tar.bz2 samba-99cdb462083381c88689a4e698ca48b6ed4cf5ac.zip |
*lots of small merges form HEAD
*sync up configure.in
*don't build torture tools in make all
*make sure to remove torture tools as part of make clean
(This used to be commit 0fb724b3216eeeb97e61ff12755ca3a31bcad6ef)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_sock.c | 82 | ||||
-rw-r--r-- | source3/lib/util_str.c | 22 |
2 files changed, 18 insertions, 86 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e162e5cd77..3a7899df3d 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -186,30 +186,6 @@ ssize_t read_udp_socket(int fd,char *buf,size_t len) return(ret); } -/******************************************************************* - checks if read data is outstanding. - ********************************************************************/ -static int read_data_outstanding(int fd, unsigned int time_out) -{ - int selrtn; - fd_set fds; - struct timeval timeout; - - FD_ZERO(&fds); - FD_SET(fd, &fds); - - timeout.tv_sec = (time_t) (time_out / 1000); - timeout.tv_usec = (long)(1000 * (time_out % 1000)); - - selrtn = sys_select_intr(fd + 1, &fds, NULL, NULL, &timeout); - - if (selrtn <= 0) - { - return selrtn; - } - return FD_ISSET(fd, &fds) ? 1 : 0; -} - /**************************************************************************** Read data from a socket with a timout in msec. mincount = if timeout, minimum to read before returning @@ -217,7 +193,7 @@ static int read_data_outstanding(int fd, unsigned int time_out) time_out = timeout in milliseconds ****************************************************************************/ -static ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out) +ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out) { fd_set fds; int selrtn; @@ -309,62 +285,6 @@ static ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t ma } /**************************************************************************** - Read data from a fd with a timout in msec. - mincount = if timeout, minimum to read before returning - maxcount = number to be read. - time_out = timeout in milliseconds -****************************************************************************/ - -ssize_t read_with_timeout(int fd, char *buf, size_t mincnt, size_t maxcnt, - unsigned int time_out) -{ - ssize_t readret; - size_t nread = 0; - - /* just checking .... */ - if (maxcnt <= 0) - return(0); - - /* Blocking read */ - if (time_out <= 0) { - if (mincnt == 0) mincnt = maxcnt; - - while (nread < mincnt) { - readret = sys_read(fd, buf + nread, maxcnt - nread); - - if (readret <= 0) - return readret; - - nread += readret; - } - return((ssize_t)nread); - } - - /* Most difficult - timeout read */ - /* If this is ever called on a disk file and - mincnt is greater then the filesize then - system performance will suffer severely as - select always returns true on disk files */ - - for (nread=0; nread < mincnt; ) { - int selrtn = read_data_outstanding(fd, time_out); - - if(selrtn <= 0) - return selrtn; - - readret = sys_read(fd, buf+nread, maxcnt-nread); - - if (readret <= 0) - return readret; - - nread += readret; - } - - /* Return the number we got */ - return((ssize_t)nread); -} - -/**************************************************************************** read data from the client, reading exactly N bytes. ****************************************************************************/ diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 7ffd71bde9..148181fddd 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -308,8 +308,22 @@ char *skip_string(char *buf,size_t n) size_t str_charnum(const char *s) { - push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE); - return strlen_w(tmpbuf); + uint16 tmpbuf2[sizeof(pstring)]; + push_ucs2(NULL, tmpbuf2,s, sizeof(tmpbuf2), STR_TERMINATE); + return strlen_w(tmpbuf2); +} + +/******************************************************************* + Count the number of characters in a string. Normally this will + be the same as the number of bytes in a string for single byte strings, + but will be different for multibyte. +********************************************************************/ + +size_t str_ascii_charnum(const char *s) +{ + pstring tmpbuf2; + push_ascii(tmpbuf2, s, sizeof(tmpbuf2), STR_TERMINATE); + return strlen(tmpbuf2); } /******************************************************************* @@ -655,13 +669,11 @@ static BOOL string_init(char **dest,const char *src) } *dest = null_string; } else { - (*dest) = (char *)malloc(l+1); + (*dest) = strdup(src); if ((*dest) == NULL) { DEBUG(0,("Out of memory in string_init\n")); return False; } - - pstrcpy(*dest,src); } return(True); } |