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