1 /* $NetBSD: term_private.h,v 1.8 2010/09/22 06:10:51 roy Exp $ */
4 * Copyright (c) 2009, 2010 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.
45 * The header is version (char), name.
46 * version 0 is an alias, and the name refers to the real terminfo.
47 * version 1 capabilities are defined as so:
49 * cap length, num flags, index, char,
50 * cap length, num numbers, index, number,
51 * cap length, num strings, index, string,
52 * cap lelngth, num undefined caps, name, type (char), flag, number, string
53 * The database itself is created using ndbm(3) and the numbers are
54 * always stored as little endian.
57 #include <sys/types.h>
61 /* We use the same ncurses tic macros so that our data is identical
62 * when a caller uses the long name macros to access te terminfo data
64 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
65 #define ABSENT_NUMERIC (-1)
66 #define ABSENT_STRING (char *)0
67 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
68 #define CANCELLED_NUMERIC (-2)
69 #define CANCELLED_STRING (char *)(-1)
70 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
71 #define VALID_NUMERIC(s) ((s) >= 0)
72 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
84 /* We need to expose these so that the macros work */
90 /* Storage area for terminfo data */
94 TERMUSERDEF
*_userdefs
;
95 /* So we don't rely on the global ospeed */
97 /* Output buffer for tparm */
101 /* A-Z static variables for tparm */
103 /* aliases of the terminal, | separated */
107 extern const char * _ti_database
;
109 ssize_t
_ti_flagindex(const char *);
110 ssize_t
_ti_numindex(const char *);
111 ssize_t
_ti_strindex(const char *);
112 const char * _ti_flagid(ssize_t
);
113 const char * _ti_numid(ssize_t
);
114 const char * _ti_strid(ssize_t
);
115 int _ti_getterm(TERMINAL
*, const char *, int);
116 void _ti_setospeed(TERMINAL
*);
117 void _ti_freeterm(TERMINAL
*);
119 /* libterminfo can compile terminfo strings too */
120 #define TIC_WARNING (1 << 0)
121 #define TIC_DESCRIPTION (1 << 1)
122 #define TIC_ALIAS (1 << 2)
123 #define TIC_COMMENT (1 << 3)
124 #define TIC_EXTRA (1 << 4)
126 #define UINT16_T_MAX 0xffff
145 char *_ti_grow_tbuf(TBUF
*, size_t);
146 char *_ti_get_token(char **, char);
147 char *_ti_find_cap(TBUF
*, char, short);
148 char *_ti_find_extra(TBUF
*, const char *);
149 size_t _ti_store_extra(TIC
*, int, char *, char, char, short,
150 char *, size_t, int);
151 TIC
*_ti_compile(char *, int);
152 ssize_t
_ti_flatten(uint8_t **, const TIC
*);
153 void _ti_freetic(TIC
*);