diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-05-18 15:47:37 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-05-18 15:47:37 +0000 |
commit | 1cc51bab7988f0411485f3abbd7cbbc44ced19f3 (patch) | |
tree | 704be6fbfdb662e488f526aba2335568e3e8f17c /ace | |
parent | 1b9cd84eae2d0deb4f7f53b3cb78e13659ae7e8f (diff) | |
download | ATCD-1cc51bab7988f0411485f3abbd7cbbc44ced19f3.tar.gz |
.
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ARGV.i | 4 | ||||
-rw-r--r-- | ace/FILE_IO.cpp | 33 | ||||
-rw-r--r-- | ace/FILE_IO.h | 29 | ||||
-rw-r--r-- | ace/FILE_IO.i | 32 | ||||
-rw-r--r-- | ace/SOCK_IO.cpp | 10 |
5 files changed, 100 insertions, 8 deletions
diff --git a/ace/ARGV.i b/ace/ARGV.i index 3619a4e742c..b14d0963274 100644 --- a/ace/ARGV.i +++ b/ace/ARGV.i @@ -44,10 +44,10 @@ ACE_ARGV::argv (void) // Convert buf_ to argv_ if (this->string_to_argv () == -1) - return 0; + return (ASYS_TCHAR **) 0; } - return this->argv_; + return (ASYS_TCHAR **) this->argv_; } // Subscript operator. diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 594f59d6ca1..3486629e491 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -55,7 +55,9 @@ ACE_FILE_IO::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::writev (this->get_handle (), + iovp, + total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -90,7 +92,9 @@ ACE_FILE_IO::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, int); } - ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::readv (this->get_handle (), + iovp, + total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -98,4 +102,29 @@ ACE_FILE_IO::recv (size_t n, ...) const return result; } +// Allows a client to read from a file without having to provide a +// buffer to read. This method determines how much data is in the +// file, allocates a buffer of this size, reads in the data, and +// returns the number of bytes read. + +ssize_t +ACE_FILE_IO::recvv (iovec *io_vec) +{ + ACE_TRACE ("ACE_FILE_IO::recvv"); + + io_vec->iov_base = 0; + long length = ACE_OS::filesize (this->get_handle ()); + + if (length > 0) + { + ACE_NEW_RETURN (io_vec->iov_base, + char[length], + -1); + io_vec->iov_len = this->recv_n (io_vec->iov_base, + length); + return io_vec->iov_len; + } + else + return length; +} diff --git a/ace/FILE_IO.h b/ace/FILE_IO.h index 37bd120df2e..808bb76f730 100644 --- a/ace/FILE_IO.h +++ b/ace/FILE_IO.h @@ -92,12 +92,37 @@ public: // *total* number of trailing arguments, *not* a couple of the // number of tuple pairs! - ssize_t send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; + ssize_t send (const void *buf, + size_t n, + ACE_OVERLAPPED *overlapped) const; // Send <n> bytes via Win32 WriteFile using overlapped I/O. - ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; + ssize_t recv (void *buf, + size_t n, + ACE_OVERLAPPED *overlapped) const; // Recv <n> bytes via Win32 ReadFile using overlapped I/O. + ssize_t sendv (const iovec iov[], + size_t n) const; + // Send an <iovec> of size <n> to the file. + + ssize_t recvv (iovec *io_vec); + // Allows a client to read from a file without having to provide a + // buffer to read. This method determines how much data is in the + // file, allocates a buffer of this size, reads in the data, and + // returns the number of bytes read. The caller is responsible for + // deleting the member in the <iov_base> field of <io_vec> using + // delete [] io_vec->iov_base. + + ssize_t sendv_n (const iovec iov[], + size_t n) const; + // Send an <iovec> of size <n> to the file. Will block until all + // bytes are sent or an error occurs. + + ssize_t recvv_n (iovec iov[], + size_t n) const; + // Receive an <iovec> of size <n> to the file. + void dump (void) const; // Dump the state of an object. diff --git a/ace/FILE_IO.i b/ace/FILE_IO.i index 36cc4fd01d6..ab5956c468c 100644 --- a/ace/FILE_IO.i +++ b/ace/FILE_IO.i @@ -3,6 +3,37 @@ // FILE_IO.i +ASYS_INLINE ssize_t +ACE_FILE_IO::sendv_n (const iovec iov[], size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::sendv_n"); + return ACE::writev_n (this->get_handle (), + iov, + n); +} + +// Recv an n byte message from the file. + +ASYS_INLINE ssize_t +ACE_FILE_IO::recvv_n (iovec iov[], size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::recvv_n"); + // @@ Carlos, can you please update this to call the + // new ACE::recvv_n() method that you write? + return ACE_OS::readv (this->get_handle (), + iov, + n); +} + +// Send an <iovec> of size <n> to the file. + +ASYS_INLINE ssize_t +ACE_FILE_IO::sendv (const iovec iov[], size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::sendv"); + return ACE_OS::writev (this->get_handle (), iov, n); +} + // Send exactly N bytes from BUF to this file. Keeping trying until // this many bytes are sent. @@ -98,4 +129,5 @@ ACE_FILE_IO::recv (void *buf, size_t n, return ACE_OS::read (this->get_handle (), (char *) buf, n, overlapped); } + #endif /* ACE_HAS_STREAM_PIPES */ diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp index 677f4b81ad4..abf00af3559 100644 --- a/ace/SOCK_IO.cpp +++ b/ace/SOCK_IO.cpp @@ -34,6 +34,8 @@ ACE_SOCK_IO::recvv (iovec *io_vec, handle_set.reset (); handle_set.set_bit (this->get_handle ()); + io_vec->iov_base = 0; + // Check the status of the current socket. switch (ACE_OS::select (int (this->get_handle ()) + 1, handle_set, @@ -103,7 +105,9 @@ ACE_SOCK_IO::send (size_t n, ...) const iovp[i].iov_len = va_arg (argp, ssize_t); } - ssize_t result = ACE_OS::sendv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::sendv (this->get_handle (), + iovp, + total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ @@ -139,7 +143,9 @@ ACE_SOCK_IO::recv (size_t n, ...) const iovp[i].iov_len = va_arg (argp, ssize_t); } - ssize_t result = ACE_OS::recvv (this->get_handle (), iovp, total_tuples); + ssize_t result = ACE_OS::recvv (this->get_handle (), + iovp, + total_tuples); #if !defined (ACE_HAS_ALLOCA) delete [] iovp; #endif /* !defined (ACE_HAS_ALLOCA) */ |