diff options
author | colm <colm@13f79535-47bb-0310-9956-ffa450edef68> | 2005-10-15 08:22:41 +0000 |
---|---|---|
committer | colm <colm@13f79535-47bb-0310-9956-ffa450edef68> | 2005-10-15 08:22:41 +0000 |
commit | 29a9c91a6b358fb87dfc26194705313d29aef81a (patch) | |
tree | c745d2f42b6e3986351dcdffdd485208803a0012 /file_io | |
parent | 7996a0c00e316848468a7eddf2400cda7e44d834 (diff) | |
download | libapr-29a9c91a6b358fb87dfc26194705313d29aef81a.tar.gz |
Add apr_file_open_flags_std[err|out|in]() functions, to allow the opening of
the standard file descriptors with specific flags set. As a consequence we now
also set APR_WRITE and APR_READ as appropriate when using the plain old
apr_file_open_std[err|out|in]() functions.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@321314 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/os2/open.c | 37 | ||||
-rw-r--r-- | file_io/unix/open.c | 39 | ||||
-rw-r--r-- | file_io/win32/open.c | 33 |
3 files changed, 87 insertions, 22 deletions
diff --git a/file_io/os2/open.c b/file_io/os2/open.c index 3b9760425..ef3bc06ec 100644 --- a/file_io/os2/open.c +++ b/file_io/os2/open.c @@ -213,28 +213,51 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { apr_os_file_t fd = 2; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_WRITE, pool); } - -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { apr_os_file_t fd = 1; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_WRITE, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { apr_os_file_t fd = 0; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_READ, pool); +} + + +APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stderr(thefile, 0, pool); +} + + +APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stdout(thefile, 0, pool); +} + + +APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stdin(thefile, 0, pool); } APR_POOL_IMPLEMENT_ACCESSOR(file); diff --git a/file_io/unix/open.c b/file_io/unix/open.c index 589c85314..3e3904ec0 100644 --- a/file_io/unix/open.c +++ b/file_io/unix/open.c @@ -262,28 +262,49 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { int fd = STDERR_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_WRITE, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { int fd = STDOUT_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_WRITE, pool); } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, - apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { int fd = STDIN_FILENO; - return apr_os_file_put(thefile, &fd, 0, pool); + return apr_os_file_put(thefile, &fd, flags | APR_READ, pool); +} + +APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, + apr_pool_t *pool) +{ + return apr_file_open_flags_stderr(thefile, 0, pool); +} + +APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, + apr_pool_t *pool) +{ + return apr_file_open_flags_stdout(thefile, 0, pool); +} + +APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, + apr_pool_t *pool) +{ + return apr_file_open_flags_stdin(thefile, 0, pool); } APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup) diff --git a/file_io/win32/open.c b/file_io/win32/open.c index 21b4ba766..83beb977a 100644 --- a/file_io/win32/open.c +++ b/file_io/win32/open.c @@ -564,7 +564,9 @@ APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr) return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -581,11 +583,13 @@ APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return apr_os_file_put(thefile, &file_handle, flags | APR_WRITE, pool); #endif } -APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -602,11 +606,13 @@ APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return apr_os_file_put(thefile, &file_handle, flags | APR_WRITE, pool); #endif } -APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile, + apr_int32_t flags, + apr_pool_t *pool) { #ifdef _WIN32_WCE return APR_ENOTIMPL; @@ -623,10 +629,25 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t * return rv; } - return apr_os_file_put(thefile, &file_handle, 0, pool); + return apr_os_file_put(thefile, &file_handle, flags | APR_READ, pool); #endif } +APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stderr(thefile, 0, pool); +} + +APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stdout(thefile, 0, pool); +} + +APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool) +{ + return apr_file_open_flags_stdin(thefile, 0, pool); +} + APR_POOL_IMPLEMENT_ACCESSOR(file); APR_IMPLEMENT_INHERIT_SET(file, flags, pool, file_cleanup) |