1 /* $NetBSD: term_private.h,v 1.11 2013/01/24 10:41:28 roy Exp $ */
4 * Copyright (c) 2009, 2010, 2013 The NetBSD Foundation, Inc.
6 * This code is derived from software contributed to The NetBSD Foundation
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _TERM_PRIVATE_H_
31 #define _TERM_PRIVATE_H_
33 /* This header should only be used by libterminfo, tic and infocmp. */
35 /* The terminfo database structure is private to us,
36 * so it's documented here.
37 * terminfo defines the largest number as 32767 and the largest
38 * compiled entry as 4093 bytes long.
39 * Thus, we store all numbers as uint16_t, including string length.
40 * All strings are prefixed by length, including the null terminator.
41 * The largest string length we can handle is 65535 bytes,
42 * including the null terminator.
43 * The largest capability block we can handle is 65535 bytes.
44 * This means that we exceed the current terminfo defined limits.
46 * Version 1 capabilities are defined as:
47 * header byte (always 1)
50 * cap length, num flags, index, char,
51 * cap length, num numbers, index, number,
52 * cap length, num strings, index, string,
53 * cap length, num undefined caps, name, type (char), flag, number, string
55 * Version 2 entries are aliases and defined as:
56 * header byte (always 2)
57 * 32bit id of the corresponding terminal in the file
60 * The database itself is created using cdbw(3) and the numbers are
61 * always stored as little endian.
64 #include <sys/types.h>
68 /* We use the same ncurses tic macros so that our data is identical
69 * when a caller uses the long name macros to access te terminfo data
71 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
72 #define ABSENT_NUMERIC (-1)
73 #define ABSENT_STRING (char *)0
74 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
75 #define CANCELLED_NUMERIC (-2)
76 #define CANCELLED_STRING (char *)(-1)
77 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
78 #define VALID_NUMERIC(s) ((s) >= 0)
79 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
91 /* We need to expose these so that the macros work */
97 /* Storage area for terminfo data */
101 TERMUSERDEF
*_userdefs
;
102 /* So we don't rely on the global ospeed */
104 /* Output buffer for tparm */
108 /* A-Z static variables for tparm */
110 /* aliases of the terminal, | separated */
114 extern const char * _ti_database
;
116 ssize_t
_ti_flagindex(const char *);
117 ssize_t
_ti_numindex(const char *);
118 ssize_t
_ti_strindex(const char *);
119 const char * _ti_flagid(ssize_t
);
120 const char * _ti_numid(ssize_t
);
121 const char * _ti_strid(ssize_t
);
122 int _ti_getterm(TERMINAL
*, const char *, int);
123 void _ti_setospeed(TERMINAL
*);
125 /* libterminfo can compile terminfo strings too */
126 #define TIC_WARNING (1 << 0)
127 #define TIC_DESCRIPTION (1 << 1)
128 #define TIC_ALIAS (1 << 2)
129 #define TIC_COMMENT (1 << 3)
130 #define TIC_EXTRA (1 << 4)
132 #define UINT16_T_MAX 0xffff
151 char *_ti_grow_tbuf(TBUF
*, size_t);
152 char *_ti_get_token(char **, char);
153 char *_ti_find_cap(TBUF
*, char, short);
154 char *_ti_find_extra(TBUF
*, const char *);
155 size_t _ti_store_extra(TIC
*, int, char *, char, char, short,
156 char *, size_t, int);
157 TIC
*_ti_compile(char *, int);
158 ssize_t
_ti_flatten(uint8_t **, const TIC
*);
159 void _ti_freetic(TIC
*);
161 #define TPARM_MAX 9 /* not likely to change */
162 int _ti_parm_analyse(const char *, int *, int);