home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XS.ZIP / LIB / SAFEOUT.C < prev    next >
C/C++ Source or Header  |  1992-11-27  |  3KB  |  83 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    s a f e o u t . c                                               */
  3. /*                                                                    */
  4. /*    Console I/O functions for use during interrupt processing       */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Since C I/O functions are not safe inside signal routines,      */
  9. /*    the code uses conditionals to use system-level DOS and OS/2     */
  10. /*    services.  Another option is to set global flags and do any     */
  11. /*    I/O operations outside the signal handler.                      */
  12. /*--------------------------------------------------------------------*/
  13.  
  14. #define __MSC                 /* Make Borland C++ 2.0 act like MS C  */
  15.  
  16. #include <stdio.h>
  17.  
  18. #if defined( FAMILYAPI )
  19. #ifdef WIN32
  20. #include <windows.h>
  21. #include <string.h>
  22. #else
  23.     #define INCL_NOCOMMON
  24.     #define INCL_NOPM
  25.     #define INCL_VIO
  26.     #define INCL_KBD
  27.     #include <os2.h>
  28.     #include <string.h>
  29. #endif
  30. #else
  31.     #include <dos.h>
  32.     #include <bios.h>
  33.     #include <conio.h>
  34. #endif
  35.  
  36. /*--------------------------------------------------------------------*/
  37. /*                    UUPC/extended include files                     */
  38. /*--------------------------------------------------------------------*/
  39.  
  40. #include "lib.h"
  41. #include "safeio.h"
  42.  
  43. /*--------------------------------------------------------------------*/
  44. /*    s a f e o u t                                                   */
  45. /*                                                                    */
  46. /*    Outputs a string using system level calls. from MicroSoft       */
  47. /*    Programmer's Workbench QuickHelp samples                        */
  48. /*--------------------------------------------------------------------*/
  49.  
  50. void safeout( char *str )
  51. {
  52.  
  53. #ifdef _Windows
  54.    fputs( str , stdout );
  55.    return;
  56. #else
  57. #if defined( FAMILYAPI )
  58. #if defined( WIN32 )
  59.    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  60.    DWORD dwBytesWritten;
  61.  
  62.    WriteFile(hStdOut, str, (DWORD)strlen(str), &dwBytesWritten, NULL);
  63.    return;
  64.    
  65. #else
  66.    VioWrtTTY( str, strlen( str ), 0 );
  67. #endif /* WIN32 */
  68. #else
  69.     union REGS inregs, outregs;
  70.  
  71.     inregs.h.ah = 0x0e;
  72.     while( *str )
  73.     {
  74.         inregs.h.al = *str++;
  75.         int86( 0x10, &inregs, &outregs );
  76.     }
  77.  
  78.     safeflush();              /* Flush keyboard                      */
  79.  
  80. #endif
  81. #endif
  82. } /* safeout */
  83.