1 /* $OpenBSD: capdefaults.c,v 1.4 2023/10/17 09:52:08 nicm Exp $ */ 2 3 /**************************************************************************** 4 * Copyright 2020,2021 Thomas E. Dickey * 5 * Copyright 1998-2000,2008 Free Software Foundation, Inc. * 6 * * 7 * Permission is hereby granted, free of charge, to any person obtaining a * 8 * copy of this software and associated documentation files (the * 9 * "Software"), to deal in the Software without restriction, including * 10 * without limitation the rights to use, copy, modify, merge, publish, * 11 * distribute, distribute with modifications, sublicense, and/or sell * 12 * copies of the Software, and to permit persons to whom the Software is * 13 * furnished to do so, subject to the following conditions: * 14 * * 15 * The above copyright notice and this permission notice shall be included * 16 * in all copies or substantial portions of the Software. * 17 * * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 25 * * 26 * Except as contained in this notice, the name(s) of the above copyright * 27 * holders shall not be used in advertising or otherwise to promote the * 28 * sale, use or other dealings in this Software without prior written * 29 * authorization. * 30 ****************************************************************************/ 31 32 /**************************************************************************** 33 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 34 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 35 * and: Thomas E. Dickey 1996-on * 36 ****************************************************************************/ 37 38 /* $Id: capdefaults.c,v 1.4 2023/10/17 09:52:08 nicm Exp $ */ 39 40 /* 41 * Compute obsolete capabilities. The reason this is an include file is 42 * that the two places where it is needed require the macros to generate 43 * offsets to different structures. See the file Caps for explanations of 44 * these conversions. 45 * 46 * Note: This code is the functional inverse of the first part of 47 * postprocess_termcap(). 48 */ 49 { 50 char *strp; 51 short capval; 52 53 #define EXTRACT_DELAY(str) \ 54 (short) (strp = strchr(str, '*'), strp ? atoi(strp+1) : 0) 55 56 /* current (4.4BSD) capabilities marked obsolete */ 57 if (VALID_STRING(carriage_return) 58 && (capval = EXTRACT_DELAY(carriage_return))) 59 carriage_return_delay = capval; 60 if (VALID_STRING(newline) && (capval = EXTRACT_DELAY(newline))) 61 new_line_delay = capval; 62 63 /* current (4.4BSD) capabilities not obsolete */ 64 if (!VALID_STRING(termcap_init2) && VALID_STRING(init_3string)) { 65 termcap_init2 = init_3string; 66 init_3string = ABSENT_STRING; 67 } 68 if (!VALID_STRING(termcap_reset) 69 && VALID_STRING(reset_2string) 70 && !VALID_STRING(reset_1string) 71 && !VALID_STRING(reset_3string)) { 72 termcap_reset = reset_2string; 73 reset_2string = ABSENT_STRING; 74 } 75 if (magic_cookie_glitch_ul == ABSENT_NUMERIC 76 && magic_cookie_glitch != ABSENT_NUMERIC 77 && VALID_STRING(enter_underline_mode)) 78 magic_cookie_glitch_ul = magic_cookie_glitch; 79 80 /* totally obsolete capabilities */ 81 linefeed_is_newline = (char) (VALID_STRING(newline) 82 && (strcmp("\n", newline) == 0)); 83 if (VALID_STRING(cursor_left) 84 && (capval = EXTRACT_DELAY(cursor_left))) 85 backspace_delay = capval; 86 if (VALID_STRING(tab) && (capval = EXTRACT_DELAY(tab))) 87 horizontal_tab_delay = capval; 88 #undef EXTRACT_DELAY 89 } 90