[BACK]Return to term_private.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libterminfo

Annotation of src/lib/libterminfo/term_private.h, Revision 1.2

1.2     ! snj         1: /* $NetBSD: term_private.h,v 1.1 2010/02/03 15:16:32 roy Exp $ */
1.1       roy         2:
                      3: /*
                      4:  * Copyright (c) 2009 The NetBSD Foundation, Inc.
                      5:  *
                      6:  * This code is derived from software contributed to The NetBSD Foundation
                      7:  * by Roy Marples.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     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.
                     17:  *
                     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.
                     28:  */
                     29:
                     30: #ifndef _TERM_PRIVATE_H_
                     31: #define        _TERM_PRIVATE_H_
                     32:
                     33: /* This header should only be used by libterminfo, tic and infocmp. */
                     34:
                     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.
1.2     ! snj        43:  * The largest capability block we can handle is 65535 bytes.
1.1       roy        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:
                     48:  * description,
                     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.
                     55:  */
                     56:
                     57: #include <sys/types.h>
                     58:
                     59: #define _TERMINFO
                     60:
                     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
                     63:  * directly. */
                     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)
                     73:
                     74: typedef struct termextra {
                     75:        const char *id;
                     76:        char type;
                     77:        char flag;
                     78:        short num;
                     79:        const char *str;
                     80: } TERMUSERDEF;
                     81:
                     82: typedef struct terminal {
                     83:        int fildes;
                     84:        /* We need to expose these so that the macros work */
                     85:        char *name;
                     86:        char *desc;
                     87:        char *flags;
                     88:        short *nums;
                     89:        const char **strs;
                     90:        /* Storage area for terminfo data */
                     91:        char *_area;
                     92:        size_t _nuserdefs;
                     93:        TERMUSERDEF *_userdefs;
                     94:        /* So we don't rely on the global ospeed */
                     95:        short _ospeed;
                     96:        /* Output buffer for tparm */
                     97:        char *_buf;
                     98:        size_t _buflen;
                     99:        size_t _bufpos;
                    100:        /* A-Z static variables for tparm  */
                    101:        long _snums[26];
                    102: } TERMINAL;
                    103:
                    104: extern const char *    _ti_database;
                    105:
                    106: ssize_t                _ti_flagindex(const char *);
                    107: ssize_t                _ti_numindex(const char *);
                    108: ssize_t                _ti_strindex(const char *);
                    109: const char *   _ti_flagid(ssize_t);
                    110: const char *   _ti_numid(ssize_t);
                    111: const char *   _ti_strid(ssize_t);
                    112: int            _ti_getterm(TERMINAL *, const char *, int);
                    113: void           _ti_setospeed(TERMINAL *);
                    114: void           _ti_freeterm(TERMINAL *);
                    115:
                    116: #endif

CVSweb <webmaster@jp.NetBSD.org>