home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sources / misc / 4086 / portable / newterm.c
Encoding:
C/C++ Source or Header  |  1992-11-18  |  3.2 KB  |  130 lines

  1. #include <stdlib.h>
  2. #ifndef NO_MEMORY_H
  3. #include <memory.h>
  4. #endif
  5. #define    CURSES_LIBRARY    1
  6. #include <curses.h>
  7. #undef    newterm
  8.  
  9. #ifndef    NDEBUG
  10. char *rcsid_newterm = "$Header: c:/curses/portable/RCS/newterm.c%v 2.0 1992/11/15 03:29:03 MH Rel $";
  11. #endif
  12.  
  13. #if    EMALLOC
  14. void*    emalloc( size_t );
  15. void*    ecalloc( size_t, size_t );
  16. void    efree( void* );
  17. #endif
  18.  
  19.  
  20.  
  21.  
  22. #if 0
  23. /*man-start*********************************************************************
  24.  
  25.   newterm()    - open new terminal
  26.  
  27.   X/Open Description:
  28.      A program which outputs to more than one terminal should use
  29.      for each terminal instead of initscr().  The newterm() function
  30.      should be called once for each terminal.  It returns a value of
  31.      type SCREEN* which should be saved as a reference to that terminal.
  32.      The arguments are the type of of terminal to be used in place of
  33.      TERM (environment variable), a file pointer for output to the
  34.      terminal and another file pointer for input from the terminal.  The
  35.      program must also call endwin() for each terminal no longer being
  36.      used.
  37.  
  38.   PDCurses Description:
  39.      This routine is a quick hack.  It is basically a copy of initscr()
  40.      with the appropriate arguments being passed.  There is no formal
  41.      support yet for dual monitor systems.  This is almost, but not
  42.      quiet, a NOP.
  43.  
  44.      outfd and infd are ignored, but required for portability.
  45.  
  46.   X/Open Return Value:
  47.      The newterm() function returns stdscr on success otherwise ERR is
  48.      returned.
  49.  
  50.   X/Open Errors:
  51.      No errors are defined for this function.
  52.  
  53.   PDCurses Errors:
  54.      It is an error to open the same SCREEN more than once.
  55.  
  56.   Portability:
  57.      PDCurses    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  58.      X/Open Dec '88    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  59.      BSD Curses    
  60.      SYS V Curses    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  61.  
  62. **man-end**********************************************************************/
  63.  
  64. SCREEN*    newterm( char *type, FILE *outfd, FILE *infd )
  65. {
  66. #ifdef    TC
  67. #  pragma argsused
  68. #endif
  69. extern    void*    mallc();    /* malloc(size)        */
  70. extern    void*    callc();    /* calloc(num,size)    */
  71. extern    void    fre();        /* free(ptr)        */
  72.  
  73. extern    void*    malloc();
  74. extern    void*    calloc();
  75. extern    void    free();
  76.  
  77.     if  (_cursvar.alive)
  78.         return( ERR );
  79.  
  80.     if  (_cursvar.emalloc == EMALLOC_MAGIC)
  81.     {
  82. #if    EMALLOC
  83.         memset(&_cursvar, 0, sizeof(SCREEN));
  84.         _cursvar.emalloc = TRUE;
  85.         mallc = emalloc;
  86.         callc = ecalloc;
  87.         fre   = efree;
  88. #endif
  89.     }
  90.     else
  91.     {
  92.         memset(&_cursvar, 0, sizeof(SCREEN));
  93.         mallc = malloc;
  94.         callc = calloc;
  95.         fre   = free;
  96.     }
  97.     PDC_scr_open(&_cursvar, 0);
  98.     _cursvar.orig_cursor = _cursvar.cursor;
  99.     _cursvar.orig_font = PDC_get_font();
  100.     _cursvar.orgcbr = PDC_get_ctrl_break();
  101.     _cursvar.blank = ' ';
  102. #ifdef    FLEXOS
  103.     _flexos_16bitmode();
  104. #endif
  105.     savetty();
  106.     LINES = PDC_get_rows();
  107.     COLS = PDC_get_columns();
  108.  
  109.     if ((tmpwin = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR)
  110.     {
  111.         return( ERR );
  112.     }
  113.     if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR)
  114.     {
  115.         return( ERR );
  116.     }
  117.     if ((stdscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR)
  118.     {
  119.         return( ERR );
  120.     }
  121.     curscr->_clear = FALSE;
  122. #ifdef    REGISTERWINDOWS
  123.     _cursvar.refreshall = FALSE;
  124.     _inswin(stdscr, (WINDOW *)NULL);
  125. #endif
  126.     _cursvar.alive = TRUE;
  127.     return( &_cursvar );
  128. }
  129. #endif
  130.