Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /****************************************************************************
  2. *
  3. *                            Open Watcom Project
  4. *
  5. *    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
  6. *
  7. *  ========================================================================
  8. *
  9. *    This file contains Original Code and/or Modifications of Original
  10. *    Code as defined in and that are subject to the Sybase Open Watcom
  11. *    Public License version 1.0 (the 'License'). You may not use this file
  12. *    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
  13. *    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
  14. *    provided with the Original Code and Modifications, and is also
  15. *    available at www.sybase.com/developer/opensource.
  16. *
  17. *    The Original Code and all software distributed under the License are
  18. *    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  19. *    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
  20. *    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
  21. *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
  22. *    NON-INFRINGEMENT. Please see the License for the specific language
  23. *    governing rights and limitations under the License.
  24. *
  25. *  ========================================================================
  26. *
  27. * Description:  Standard stream/file accessor routines.
  28. *
  29. ****************************************************************************/
  30.  
  31.  
  32. #include "variety.h"
  33. #include <stdio.h>
  34. #include "rtdata.h"
  35.  
  36.  
  37. #if !defined( __NETWARE__ ) && !defined( _THIN_LIB )
  38.  
  39. _WCRTLINK FILE *__get_std_stream( unsigned handle )
  40. {
  41.     if( handle > NUM_STD_STREAMS ) {
  42.         return( NULL );
  43.     } else {
  44.         return( &_RWD_iob[handle] );
  45.     }
  46. }
  47.  
  48. _WCRTLINK FILE *__get_std_file( unsigned handle )
  49. {
  50.     return( __get_std_stream( handle ) );
  51. }
  52.  
  53. #else
  54.  
  55. #include <io.h>
  56.  
  57. #if defined( _NETWARE_LIBC )
  58.     extern FILE   **___stdin ( void );
  59.     extern FILE   **___stdout( void );
  60.     extern FILE   **___stderr( void );
  61.     extern FILE   **___cin   ( void );
  62.     extern FILE   **___cout  ( void );
  63.  
  64.     _WCRTLINK FILE *__get_std_stream( unsigned handle )
  65.     {
  66.         FILE    *pFile = NULL;
  67.  
  68.         switch( handle ) {
  69.         case STDIN_FILENO:
  70.             pFile = *___stdin();
  71.             break;
  72.         case STDOUT_FILENO:
  73.             pFile = *___stdout();
  74.             break;
  75.         case STDERR_FILENO:
  76.             pFile = *___stderr();
  77.             break;
  78.         default:
  79.             break;
  80.         }
  81.         return( pFile );
  82.     }
  83. #elif defined( _NETWARE_CLIB )
  84.     extern FILE   **__get_stdin ( void );
  85.     extern FILE   **__get_stdout( void );
  86.     extern FILE   **__get_stderr( void );
  87.  
  88.     _WCRTLINK FILE *__get_std_stream( unsigned handle )
  89.     {
  90.         FILE    *pFile = NULL;
  91.  
  92.         switch( handle ) {
  93.         case STDIN_FILENO:
  94.             pFile = *__get_stdin();
  95.             break;
  96.         case STDOUT_FILENO:
  97.             pFile = *__get_stdout();
  98.             break;
  99.         case STDERR_FILENO:
  100.             pFile = *__get_stderr();
  101.             break;
  102.         default:
  103.             break;
  104.         }
  105.         return( pFile );
  106.     }
  107. #endif
  108.  
  109. #endif
  110.  
  111.  
  112. #if defined( __NETWARE__ ) && !defined( _THIN_LIB )
  113.  
  114. #include <io.h>
  115.  
  116. FILE **__get_stdin( void )
  117. {
  118.     static FILE         *stdin_ptr;
  119.  
  120.     stdin_ptr = __get_std_stream( STDIN_FILENO );
  121.     return( &stdin_ptr );
  122. }
  123.  
  124. FILE **__get_stdout( void )
  125. {
  126.     static FILE         *stdout_ptr;
  127.  
  128.     stdout_ptr = __get_std_stream( STDOUT_FILENO );
  129.     return( &stdout_ptr );
  130. }
  131.  
  132. FILE **__get_stderr( void )
  133. {
  134.     static FILE         *stderr_ptr;
  135.  
  136.     stderr_ptr = __get_std_stream( STDERR_FILENO );
  137.     return( &stderr_ptr );
  138. }
  139.  
  140. #endif
  141.