blob: 0c61cb7ea6671634032380ec71f7de1de6e48b54 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002 * Copyright 2020,2023 Thomas E. Dickey *
3 * Copyright 1998-2012,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304 * *
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 *
Steve Kondikae271bc2015-11-15 02:50:53 +010034 * and: Juergen Pfeifer 2008 *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053035 ****************************************************************************/
36
37/*
38 * Terminfo-only terminal setup routines:
39 *
40 * int restartterm(const char *, int, int *)
41 */
42
43#include <curses.priv.h>
44
micky3879b9f5e72025-07-08 18:04:53 -040045MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $")
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053046
47NCURSES_EXPORT(int)
Steve Kondikae271bc2015-11-15 02:50:53 +010048NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
49 NCURSES_CONST char *termp,
50 int filenum,
51 int *errret)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053052{
53 int result;
Steve Kondikae271bc2015-11-15 02:50:53 +010054#ifdef USE_TERM_DRIVER
55 TERMINAL *new_term = 0;
56#endif
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053057
Steve Kondikae271bc2015-11-15 02:50:53 +010058 START_TRACE();
59 T((T_CALLED("restartterm(%p,%s,%d,%p)"),
60 (void *) SP_PARM,
61 termp,
62 filenum,
63 (void *) errret));
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053064
Steve Kondikae271bc2015-11-15 02:50:53 +010065 if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) {
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066 result = ERR;
Steve Kondikae271bc2015-11-15 02:50:53 +010067 } else if (SP_PARM != 0) {
micky3879b9f5e72025-07-08 18:04:53 -040068 TTY_FLAGS save_flags = SP_PARM->_tty_flags;
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053069
Steve Kondikae271bc2015-11-15 02:50:53 +010070#ifdef USE_TERM_DRIVER
71 SP_PARM->_term = new_term;
72#endif
micky3879b9f5e72025-07-08 18:04:53 -040073 if (save_flags._echo) {
Steve Kondikae271bc2015-11-15 02:50:53 +010074 NCURSES_SP_NAME(echo) (NCURSES_SP_ARG);
75 } else {
76 NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
77 }
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078
micky3879b9f5e72025-07-08 18:04:53 -040079 if (save_flags._cbreak) {
Steve Kondikae271bc2015-11-15 02:50:53 +010080 NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
81 NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
micky3879b9f5e72025-07-08 18:04:53 -040082 } else if (save_flags._raw) {
Steve Kondikae271bc2015-11-15 02:50:53 +010083 NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
84 NCURSES_SP_NAME(raw) (NCURSES_SP_ARG);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053085 } else {
Steve Kondikae271bc2015-11-15 02:50:53 +010086 NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
87 NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053088 }
micky3879b9f5e72025-07-08 18:04:53 -040089 if (save_flags._nl) {
Steve Kondikae271bc2015-11-15 02:50:53 +010090 NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
91 } else {
92 NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG);
93 }
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053094
Steve Kondikae271bc2015-11-15 02:50:53 +010095 NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053096
97#if USE_SIZECHANGE
Steve Kondikae271bc2015-11-15 02:50:53 +010098 _nc_update_screensize(SP_PARM);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053099#endif
100
101 result = OK;
102 } else {
103 result = ERR;
104 }
105 returnCode(result);
106}
Steve Kondikae271bc2015-11-15 02:50:53 +0100107
108#if NCURSES_SP_FUNCS
109NCURSES_EXPORT(int)
110restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
111{
112 START_TRACE();
113 return NCURSES_SP_NAME(restartterm) (CURRENT_SCREEN, termp, filenum, errret);
114}
115#endif