xref: /openbsd-src/lib/libcurses/term_entry.h (revision c21ba70dd518c922f8dfa93d6c24c449ab5763d9)
1 /*	$OpenBSD: term_entry.h,v 1.6 1999/02/24 06:31:07 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30 
31 /****************************************************************************
32  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
33  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
34  ****************************************************************************/
35 
36 
37 /*
38  *	term_entry.h -- interface to entry-manipulation code
39  */
40 
41 #ifndef _TERM_ENTRY_H
42 #define _TERM_ENTRY_H
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define MAX_USES	32
49 
50 typedef struct entry {
51 	TERMTYPE	tterm;
52 	int		nuses;
53 	struct
54         {
55 	    void	*parent;	/* (char *) or (ENTRY *) */
56 	    long	line;
57         }
58 	uses[MAX_USES];
59 	long		cstart, cend;
60 	long		startline;
61 	struct entry	*next;
62 	struct entry	*last;
63 }
64 ENTRY;
65 
66 extern ENTRY	*_nc_head, *_nc_tail;
67 #define for_entry_list(qp)	for (qp = _nc_head; qp; qp = qp->next)
68 
69 #define MAX_LINE	132
70 
71 #define NULLHOOK        (bool(*)(ENTRY *))0
72 
73 /*
74  * Note that WANTED and PRESENT are not simple inverses!  If a capability
75  * has been explicitly cancelled, it's not considered WANTED.
76  */
77 #define WANTED(s)	((s) == ABSENT_STRING)
78 #define PRESENT(s)	(((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
79 
80 #define ANDMISSING(p,q) \
81 		{if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
82 
83 #define PAIRED(p,q) \
84 		{ \
85 		if (PRESENT(q) && !PRESENT(p)) \
86 			_nc_warning(#q " but no " #p); \
87 		if (PRESENT(p) && !PRESENT(q)) \
88 			_nc_warning(#p " but no " #q); \
89 		}
90 
91 /* alloc_entry.c: elementary allocation code */
92 extern void _nc_init_entry(TERMTYPE *const);
93 extern char *_nc_save_str(const char *const);
94 extern void _nc_merge_entry(TERMTYPE *const, TERMTYPE *const);
95 extern void _nc_wrap_entry(ENTRY *const);
96 
97 /* parse_entry.c: entry-parsing code */
98 extern int _nc_parse_entry(ENTRY *, int, bool);
99 extern int _nc_capcmp(const char *, const char *);
100 
101 /* write_entry.c: writing an entry to the file system */
102 extern void _nc_set_writedir(char *);
103 extern void _nc_write_entry(TERMTYPE *const);
104 
105 /* comp_parse.c: entry list handling */
106 extern void _nc_read_entry_source(FILE*, char*, int, bool, bool (*)(ENTRY*));
107 extern bool _nc_entry_match(char *, char *);
108 extern int _nc_resolve_uses(void);
109 extern void _nc_free_entries(ENTRY *);
110 extern void (*_nc_check_termtype)(TERMTYPE *);
111 
112 
113 #ifdef __OpenBSD__
114 /* read_bsd_terminfo.c: terminfo.db reading */
115 extern int _nc_read_bsd_terminfo_entry(const char * const, char * const, TERMTYPE *const);
116 extern int _nc_read_bsd_terminfo_file(const char * const, TERMTYPE *const);
117 #endif /* __OpenBSD__ */
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif /* _TERM_ENTRY_H */
124