1 /**************************************************************************** 2 * Copyright 2020 Thomas E. Dickey * 3 * Copyright 1998-2012,2015 Free Software Foundation, Inc. * 4 * * 5 * Permission is hereby granted, free of charge, to any person obtaining a * 6 * copy of this software and associated documentation files (the * 7 * "Software"), to deal in the Software without restriction, including * 8 * without limitation the rights to use, copy, modify, merge, publish, * 9 * distribute, distribute with modifications, sublicense, and/or sell * 10 * copies of the Software, and to permit persons to whom the Software is * 11 * furnished to do so, subject to the following conditions: * 12 * * 13 * The above copyright notice and this permission notice shall be included * 14 * in all copies or substantial portions of the Software. * 15 * * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 23 * * 24 * Except as contained in this notice, the name(s) of the above copyright * 25 * holders shall not be used in advertising or otherwise to promote the * 26 * sale, use or other dealings in this Software without prior written * 27 * authorization. * 28 ****************************************************************************/ 29 30 /**************************************************************************** 31 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 32 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 33 * and: Thomas E. Dickey 1996-on * 34 * and: Juergen Pfeifer 2008 * 35 ****************************************************************************/ 36 37 /* 38 * Terminfo-only terminal setup routines: 39 * 40 * int restartterm(const char *, int, int *) 41 */ 42 43 #include <curses.priv.h> 44 45 MODULE_ID("$Id: lib_restart.c,v 1.17 2020/02/02 23:34:34 tom Exp $") 46 47 NCURSES_EXPORT(int) 48 NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx 49 NCURSES_CONST char *termp, 50 int filenum, 51 int *errret) 52 { 53 int result; 54 #ifdef USE_TERM_DRIVER 55 TERMINAL *new_term = 0; 56 #endif 57 58 START_TRACE(); 59 T((T_CALLED("restartterm(%p,%s,%d,%p)"), 60 (void *) SP_PARM, 61 termp, 62 filenum, 63 (void *) errret)); 64 65 if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) { 66 result = ERR; 67 } else if (SP_PARM != 0) { 68 int saveecho = SP_PARM->_echo; 69 int savecbreak = SP_PARM->_cbreak; 70 int saveraw = SP_PARM->_raw; 71 int savenl = SP_PARM->_nl; 72 73 #ifdef USE_TERM_DRIVER 74 SP_PARM->_term = new_term; 75 #endif 76 if (saveecho) { 77 NCURSES_SP_NAME(echo) (NCURSES_SP_ARG); 78 } else { 79 NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); 80 } 81 82 if (savecbreak) { 83 NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); 84 NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); 85 } else if (saveraw) { 86 NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); 87 NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); 88 } else { 89 NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); 90 NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); 91 } 92 if (savenl) { 93 NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); 94 } else { 95 NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG); 96 } 97 98 NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG); 99 100 #if USE_SIZECHANGE 101 _nc_update_screensize(SP_PARM); 102 #endif 103 104 result = OK; 105 } else { 106 result = ERR; 107 } 108 returnCode(result); 109 } 110 111 #if NCURSES_SP_FUNCS 112 NCURSES_EXPORT(int) 113 restartterm(NCURSES_CONST char *termp, int filenum, int *errret) 114 { 115 START_TRACE(); 116 return NCURSES_SP_NAME(restartterm) (CURRENT_SCREEN, termp, filenum, errret); 117 } 118 #endif 119