dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / mdb / common / kmdb / kmdb_terminfo_skel.c
blob3a3ca0935ca3e40c0de934e1d0bb17f11dc648d0
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
22 /* BEGIN PROLOGUE */
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
32 * kmdb_terminfo_skel.c is the skeleton used to generate
33 * kmdb_terminfo.c, which contains the kmdb-specific version
34 * of terminfo.
37 #include <strings.h>
38 #include <unistd.h>
39 #include <curses.h>
41 #include <mdb/mdb_io.h>
42 #include <mdb/mdb_debug.h>
43 #include <mdb/mdb.h>
45 typedef enum {
46 TIO_ATTR_REQSTR,
47 TIO_ATTR_STR,
48 TIO_ATTR_BOOL,
49 TIO_ATTR_INT
50 } termio_attr_type_t;
52 typedef struct {
53 const char *ta_name;
54 termio_attr_type_t ta_type;
55 const void *ta_data;
56 } termio_attr_t;
58 typedef struct {
59 const char *td_name;
60 const termio_attr_t *td_data;
61 } termio_desc_t;
63 /* END PROLOGUE */
66 * tigen will insert the following definitions here:
68 * <term>_attrs (one per terminal type passed to tigen)
69 * termio_db
72 /* BEGIN EPILOGUE */
74 static const termio_desc_t *tdp;
76 /*ARGSUSED*/
77 int
78 setupterm(char *name, int fd, int *err)
80 for (tdp = termio_db; tdp->td_name != NULL; tdp++) {
81 if (strcmp(tdp->td_name, name) == 0)
82 return (OK);
85 *err = 0;
86 return (ERR);
89 int
90 restartterm(char *name, int fd, int *err)
92 const termio_desc_t *otdp = tdp;
93 int status;
95 if ((status = setupterm(name, fd, err)) != OK)
96 tdp = otdp; /* restore old terminal settings */
98 return (status);
101 char *
102 tigetstr(const char *name)
104 const termio_attr_t *tap;
106 for (tap = tdp->td_data; tap->ta_name != NULL; tap++) {
107 if (strcmp(tap->ta_name, name) == 0) {
108 if (tap->ta_type == TIO_ATTR_REQSTR ||
109 tap->ta_type == TIO_ATTR_STR)
110 return ((char *)tap->ta_data);
111 else
112 return ((char *)-1);
116 return (NULL);
120 tigetflag(const char *name)
122 const termio_attr_t *tap;
124 for (tap = tdp->td_data; tap->ta_name != NULL; tap++) {
125 if (strcmp(tap->ta_name, name) == 0) {
126 if (tap->ta_type == TIO_ATTR_BOOL)
127 return ((uintptr_t)tap->ta_data);
128 else
129 return (-1);
133 return (0);
137 tigetnum(const char *name)
139 const termio_attr_t *tap;
141 for (tap = tdp->td_data; tap->ta_name != NULL; tap++) {
142 if (strcmp(tap->ta_name, name) == 0) {
143 if (tap->ta_type == TIO_ATTR_INT)
144 return ((uintptr_t)tap->ta_data);
145 else
146 return (-2);
150 return (-1);
153 /* END EPILOGUE */