apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/win32 open.c filedup.c
Date Sat, 28 Dec 2002 20:36:22 GMT
wrowe       2002/12/28 12:36:22

  Modified:    file_io/win32 open.c filedup.c
  Log:
    Several StdHandles may be defined as the same handle, handle that case.
  
  Revision  Changes    Path
  1.113     +2 -2      apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- open.c	28 Dec 2002 20:29:12 -0000	1.112
  +++ open.c	28 Dec 2002 20:36:21 -0000	1.113
  @@ -272,10 +272,10 @@
           if (file->filehand == GetStdHandle(STD_ERROR_HANDLE)) {
               SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
           }
  -        else if (file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
  +        if (file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
               SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
           }
  -        else if (file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
  +        if (file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
               SetStdHandle(STD_INPUT_HANDLE, INVALID_HANDLE_VALUE);
           }
   
  
  
  
  1.51      +13 -8     apr/file_io/win32/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filedup.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- filedup.c	29 Oct 2002 01:28:32 -0000	1.50
  +++ filedup.c	28 Dec 2002 20:36:21 -0000	1.51
  @@ -89,6 +89,9 @@
   #endif /* !defined(_WIN32_WCE) */
   }
   
  +#define stdin_handle 0x01
  +#define stdout_handle 0x02
  +#define stderr_handle 0x04
   
   APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
                                           apr_file_t *old_file, apr_pool_t *p)
  @@ -96,7 +99,7 @@
   #ifdef _WIN32_WCE
       return APR_ENOTIMPL;
   #else
  -    DWORD stdhandle = -1;
  +    DWORD stdhandle = 0;
       HANDLE hproc = GetCurrentProcess();
       HANDLE newhand = NULL;
       apr_int32_t newflags;
  @@ -107,22 +110,24 @@
        * The os_handle will change, however.
        */
       if (new_file->filehand == GetStdHandle(STD_ERROR_HANDLE)) {
  -        stdhandle = STD_ERROR_HANDLE;
  +        stdhandle |= stderr_handle;
       }
  -    else if (new_file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
  -        stdhandle = STD_OUTPUT_HANDLE;
  +    if (new_file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
  +        stdhandle |= stdout_handle;
       }
  -    else if (new_file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
  -        stdhandle = STD_INPUT_HANDLE;
  +    if (new_file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
  +        stdhandle |= stdin_handle;
       }
   
  -    if (stdhandle != -1) {
  +    if (stdhandle) {
           if (!DuplicateHandle(hproc, old_file->filehand, 
                                hproc, &newhand, 0,
                                TRUE, DUPLICATE_SAME_ACCESS)) {
               return apr_get_os_error();
           }
  -        if (!SetStdHandle(stdhandle, newhand)) {
  +        if (((stdhandle & stderr_handle) && !SetStdHandle(STD_ERROR_HANDLE,
newhand)) ||
  +            ((stdhandle & stdout_handle) && !SetStdHandle(STD_OUTPUT_HANDLE,
newhand)) ||
  +            ((stdhandle & stdin_handle) && !SetStdHandle(STD_INPUT_HANDLE,
newhand))) {
               return apr_get_os_error();
           }
           newflags = old_file->flags | APR_INHERIT;
  
  
  

Mime
View raw message