4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
46 #include <sys/types.h>
47 #include "curses_inc.h"
49 /* Delete keys matching pat or key from the key map. */
52 delkey(char *sends
, int keyval
)
54 _KEY_MAP
*kp
, **kpp
= cur_term
->_keys
, **fpp
, **dpp
;
55 int mask
= 0, cmp
, numkeys
= cur_term
->_ksz
;
56 int counter
= 0, i
, num_deleted_keys
= 0;
57 short *lkorder
= &(cur_term
->_lastkey_ordered
),
58 *first_macro
= &(cur_term
->_first_macro
),
59 *lmorder
= &(cur_term
->_lastmacro_ordered
);
61 /* for ease of determination of key to delete */
68 while (++counter
< numkeys
) {
71 if (sends
&& (strcmp(sends
, kp
->_sends
) == 0))
73 if (kp
->_keyval
== keyval
)
76 /* found one to delete */
80 * If it was an externally created key, then the address
81 * of the sequence will be right after the structure.
82 * See the malloc in newkey.
84 if (kp
->_sends
== ((char *)kp
+ sizeof (_KEY_MAP
)))
87 /* shift left other keys */
88 i
= (numkeys
- counter
) - 1;
89 for (fpp
= kpp
, dpp
= kpp
+ 1; i
> 0; i
--, fpp
++, dpp
++)
91 if (counter
<= *lmorder
) {
92 if (counter
< *first_macro
) {
93 if (counter
<= *lkorder
)
103 /* Check if we've crossed boundary and/or hit 0 */
105 if ((cur_term
->_ksz
-= num_deleted_keys
) == 0)
106 (void) delkeymap(cur_term
);
108 cur_term
->_keys
= (_KEY_MAP
**) realloc((char *)
109 cur_term
->_keys
, (unsigned)cur_term
->_ksz
);
111 return (num_deleted_keys
);