diff options
author | stoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68> | 2000-02-21 16:41:41 +0000 |
---|---|---|
committer | stoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68> | 2000-02-21 16:41:41 +0000 |
commit | 69639be07f29701615760935d046321520f7070c (patch) | |
tree | b34f6659f9905cfff3898c835cdbaf13b6f3d77a /file_io | |
parent | 75a20b5137b0b5ff6e32d49623450f05a595e980 (diff) | |
download | libapr-69639be07f29701615760935d046321520f7070c.tar.gz |
Make file I/O and network I/O writev/sendv APIs consistent.
Eliminate use of ap_iovec_t and use Posix struct iovec. I never
did hear a case (much less a strong case) supporting the need
for ap_iovec_t, so out it goes.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59663 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/beos/readwrite.c | 18 | ||||
-rw-r--r-- | file_io/os2/fileio.h | 5 | ||||
-rw-r--r-- | file_io/os2/readwrite.c | 17 | ||||
-rw-r--r-- | file_io/unix/fileio.h | 5 | ||||
-rw-r--r-- | file_io/unix/readwrite.c | 22 | ||||
-rw-r--r-- | file_io/win32/fileio.h | 5 | ||||
-rw-r--r-- | file_io/win32/readwrite.c | 16 |
7 files changed, 12 insertions, 76 deletions
diff --git a/file_io/beos/readwrite.c b/file_io/beos/readwrite.c index 662426660..2fe4ca170 100644 --- a/file_io/beos/readwrite.c +++ b/file_io/beos/readwrite.c @@ -127,7 +127,7 @@ ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) } /* ***APRDOC******************************************************** - * ap_status_t ap_writev(ap_file_t *, ap_iovec_t *, ap_ssize_t *) + * ap_status_t ap_writev(ap_file_t *, iovec *, ap_ssize_t *) * Write data from ap_iovec array to the specified file. * arg 1) The file descriptor to write to. * arg 2) The array from which to get the data to write to the file. @@ -138,22 +138,10 @@ ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) * written on function exit. */ #ifdef HAVE_WRITEV - -ap_status_t ap_make_iov(struct iovec_t **new, struct iovec *iova, ap_context_t *cntxt) -{ - (*new) = ap_palloc(cntxt, sizeof(struct iovec_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->cntxt = cntxt; - (*new)->theiov = iova; - return APR_SUCCESS; -} - -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) +ap_status_t ap_writev(struct file_t *thefile, const struct iovec *vec, ap_ssize_t *iocnt) { int bytes; - if ((bytes = writev(thefile->filedes, vec->theiov, *iocnt)) < 0) { + if ((bytes = writev(thefile->filedes, vec, *iocnt)) < 0) { *iocnt = bytes; return errno; } diff --git a/file_io/os2/fileio.h b/file_io/os2/fileio.h index 202c5b946..3541ac5d0 100644 --- a/file_io/os2/fileio.h +++ b/file_io/os2/fileio.h @@ -91,11 +91,6 @@ struct dir_t { int validentry; }; -struct iovec_t { - ap_context_t *cntxt; - struct iovec *theiov; -}; - ap_status_t file_cleanup(void *); ap_status_t ap_os2_time_to_ap_time(ap_time_t *result, FDATE os2date, FTIME os2time); int os2errno( ULONG oserror ); diff --git a/file_io/os2/readwrite.c b/file_io/os2/readwrite.c index fa4fdb949..fad71a972 100644 --- a/file_io/os2/readwrite.c +++ b/file_io/os2/readwrite.c @@ -183,23 +183,10 @@ ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) #ifdef HAVE_WRITEV -ap_status_t ap_make_iov(struct iovec_t **new, struct iovec *iova, ap_context_t *cntxt) -{ - (*new) = ap_palloc(cntxt, sizeof(struct iovec_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->cntxt = cntxt; - (*new)->theiov = iova; - return APR_SUCCESS; -} - - - -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt) +ap_status_t ap_writev(struct file_t *thefile, const struct iovec *vec, ap_ssize_t *iocnt) { int bytes; - if ((bytes = writev(thefile->filedes, vec->theiov, *iocnt)) < 0) { + if ((bytes = writev(thefile->filedes, vec, *iocnt)) < 0) { *iocnt = bytes; return errno; } diff --git a/file_io/unix/fileio.h b/file_io/unix/fileio.h index 2f2a0957b..a124eb556 100644 --- a/file_io/unix/fileio.h +++ b/file_io/unix/fileio.h @@ -120,11 +120,6 @@ struct dir_t { struct dirent *entry; }; -struct iovec_t { - ap_context_t *cntxt; - struct iovec *theiov; -}; - ap_status_t file_cleanup(void *); mode_t get_fileperms(ap_fileperms_t); diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c index f84383a63..ef678edd7 100644 --- a/file_io/unix/readwrite.c +++ b/file_io/unix/readwrite.c @@ -201,34 +201,22 @@ ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) } /* ***APRDOC******************************************************** - * ap_status_t ap_writev(ap_file_t *, ap_iovec_t *, ap_ssize_t *) - * Write data from ap_iovec array to the specified file. + * ap_status_t ap_writev(ap_file_t *, struct iovec *, ap_ssize_t *) + * Write data from iovec array to the specified file. * arg 1) The file descriptor to write to. * arg 2) The array from which to get the data to write to the file. - * arg 3) The number of elements in the ap_iovec array. This must be + * arg 3) The number of elements in the struct iovec array. This must be * smaller than AP_MAX_IOVEC_SIZE. If it isn't, the function will * fail with APR_EINVAL. * NOTE: The third arguement is updated with the number of bytes actually * written on function exit. */ #ifdef HAVE_WRITEV - -ap_status_t ap_make_iov(struct iovec_t **new, const struct iovec *iova, ap_context_t *cntxt) -{ - (*new) = ap_palloc(cntxt, sizeof(struct iovec_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->cntxt = cntxt; - (*new)->theiov = iova; - return APR_SUCCESS; -} - -ap_status_t ap_writev(struct file_t *thefile, const ap_iovec_t *vec, +ap_status_t ap_writev(struct file_t *thefile, const struct iovec *vec, ap_size_t nvec, ap_ssize_t *nbytes) { int bytes; - if ((bytes = writev(thefile->filedes, vec->theiov, nvec)) < 0) { + if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) { *nbytes = 0; return errno; } diff --git a/file_io/win32/fileio.h b/file_io/win32/fileio.h index 09dee67d7..b137be6bb 100644 --- a/file_io/win32/fileio.h +++ b/file_io/win32/fileio.h @@ -120,11 +120,6 @@ struct dir_t { WIN32_FIND_DATA *entry; }; -struct iovec_t { - ap_context_t *cntxt; - struct iovec *theiov; -}; - ap_status_t file_cleanup(void *); /*mode_t get_fileperms(ap_fileperms_t); */ diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index 9350f9495..8005ca2c2 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -63,17 +63,6 @@ #define GetFilePointer(hfile) SetFilePointer(hfile,0,NULL, FILE_CURRENT) -ap_status_t ap_make_iov(struct iovec_t **new, const struct iovec *iova, ap_context_t *cntxt) -{ - (*new) = ap_palloc(cntxt, sizeof(struct iovec_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - (*new)->cntxt = cntxt; - (*new)->theiov = iova; - return APR_SUCCESS; -} - ap_status_t ap_read(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) { DWORD bread; @@ -128,17 +117,16 @@ ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes) /* * Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2) */ -ap_status_t ap_writev(struct file_t *thefile, const ap_iovec_t *vec, ap_size_t nvec, +ap_status_t ap_writev(struct file_t *thefile, const struct iovec *vec, ap_size_t nvec, ap_ssize_t *nbytes) { int i; DWORD bwrote = 0; - struct iovec *iov = vec->theiov; *nbytes = 0; for (i = 0; i < nvec; i++) { if (!WriteFile(thefile->filehand, - iov[i].iov_base, iov[i].iov_len, &bwrote, NULL)) { + vec[i].iov_base, vec[i].iov_len, &bwrote, NULL)) { return GetLastError(); } *nbytes += bwrote; |