You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by co...@apache.org on 2005/10/15 10:22:49 UTC

svn commit: r321314 - in /apr/apr/trunk: CHANGES file_io/os2/open.c file_io/unix/open.c file_io/win32/open.c include/apr_file_io.h

Author: colm
Date: Sat Oct 15 01:22:41 2005
New Revision: 321314

URL: http://svn.apache.org/viewcvs?rev=321314&view=rev
Log:
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.

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/file_io/os2/open.c
    apr/apr/trunk/file_io/unix/open.c
    apr/apr/trunk/file_io/win32/open.c
    apr/apr/trunk/include/apr_file_io.h

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?rev=321314&r1=321313&r2=321314&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Sat Oct 15 01:22:41 2005
@@ -1,5 +1,11 @@
 Changes for APR 1.3.0
 
+  *) Add apr_file_open_flags_std[err|out|in]() functions.
+     [Colm MacCarthaigh]
+
+  *) stdio: apr_file_open_std[err|out|in]() functions now set the APR_WRITE
+     or APR_READ flag as appropriate. [Colm MacCarthaigh]
+
   *) multicast: apr_mcast_*() no longer return APR_ENOTIMPL when invoked
      for non-UDP/RAW sockets. The caller is expected to ensure that the
      socket-type is suitable for multicast. [Colm MacCarthaigh]

Modified: apr/apr/trunk/file_io/os2/open.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/os2/open.c?rev=321314&r1=321313&r2=321314&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/open.c (original)
+++ apr/apr/trunk/file_io/os2/open.c Sat Oct 15 01:22:41 2005
@@ -213,28 +213,51 @@
 }   
 
 
-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);

Modified: apr/apr/trunk/file_io/unix/open.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/open.c?rev=321314&r1=321313&r2=321314&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/open.c (original)
+++ apr/apr/trunk/file_io/unix/open.c Sat Oct 15 01:22:41 2005
@@ -262,28 +262,49 @@
     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)

Modified: apr/apr/trunk/file_io/win32/open.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/win32/open.c?rev=321314&r1=321313&r2=321314&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/open.c (original)
+++ apr/apr/trunk/file_io/win32/open.c Sat Oct 15 01:22:41 2005
@@ -564,7 +564,9 @@
     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 @@
         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 @@
         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,8 +629,23 @@
         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);

Modified: apr/apr/trunk/include/apr_file_io.h
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/include/apr_file_io.h?rev=321314&r1=321313&r2=321314&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_file_io.h (original)
+++ apr/apr/trunk/include/apr_file_io.h Sat Oct 15 01:22:41 2005
@@ -325,6 +325,51 @@
                                               apr_pool_t *pool);
 
 /**
+ * open standard error as an apr file pointer, with flags.
+ * @param thefile The apr file to use as stderr.
+ * @param flags The flags to open the file with. Only the APR_EXCL,
+ *              APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, 
+ *              APR_SENDFILE_ENABLED and APR_LARGEFILE flags should
+ *              be used. The APR_WRITE flag will be set unconditionally.
+ * @param pool The pool to allocate the file out of.
+ * 
+ * @remark See remarks for apr_file_open_stderr.
+ */
+APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile,
+                                                     apr_int32_t flags,
+                                                     apr_pool_t *pool);
+
+/**
+ * open standard output as an apr file pointer, with flags.
+ * @param thefile The apr file to use as stdout.
+ * @param flags The flags to open the file with. Only the APR_EXCL,
+ *              APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, 
+ *              APR_SENDFILE_ENABLED and APR_LARGEFILE flags should
+ *              be used. The APR_WRITE flag will be set unconditionally.
+ * @param pool The pool to allocate the file out of.
+ * 
+ * @remark See remarks for apr_file_open_stderr.
+ */
+APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile,
+                                                     apr_int32_t flags,
+                                                     apr_pool_t *pool);
+
+/**
+ * open standard input as an apr file pointer, with flags.
+ * @param thefile The apr file to use as stdin.
+ * @param flags The flags to open the file with. Only the APR_EXCL,
+ *              APR_BUFFERED, APR_XTHREAD, APR_SHARELOCK, 
+ *              APR_SENDFILE_ENABLED and APR_LARGEFILE flags should
+ *              be used. The APR_READ flag will be set unconditionally.
+ * @param pool The pool to allocate the file out of.
+ * 
+ * @remark See remarks for apr_file_open_stderr.
+ */
+APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile,
+                                                     apr_int32_t flags,
+                                                     apr_pool_t *pool);
+
+/**
  * Read data from the specified file.
  * @param thefile The file descriptor to read from.
  * @param buf The buffer to store the data to.