xref: /illumos-gate/usr/src/cmd/mandoc/dbm.h (revision 0b0eb2f5d8243c8a1c87a28d13c3caebd85bd584)
1 /*	$Id: dbm.h,v 1.1 2016/07/19 21:31:55 schwarze Exp $ */
2 /*
3  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * Public interface for the map-based version
18  * of the mandoc database, for read-only access.
19  * To be used by dbm*.c, dba_read.c, and man(1) and apropos(1).
20  */
21 
22 enum dbm_mtype {
23 	DBM_EXACT = 0,
24 	DBM_SUB,
25 	DBM_REGEX
26 };
27 
28 struct dbm_match {
29 	regex_t		*re;
30 	const char	*str;
31 	enum dbm_mtype	 type;
32 };
33 
34 struct dbm_res {
35 	int32_t		 page;
36 	int32_t		 bits;
37 };
38 
39 struct dbm_page {
40 	const char	*name;
41 	const char	*sect;
42 	const char	*arch;
43 	const char	*desc;
44 	const char	*file;
45 	int32_t		 addr;
46 };
47 
48 struct dbm_macro {
49 	const char	*value;
50 	const int32_t	*pp;
51 };
52 
53 int		 dbm_open(const char *);
54 void		 dbm_close(void);
55 
56 int32_t		 dbm_page_count(void);
57 struct dbm_page	*dbm_page_get(int32_t);
58 void		 dbm_page_byname(const struct dbm_match *);
59 void		 dbm_page_bysect(const struct dbm_match *);
60 void		 dbm_page_byarch(const struct dbm_match *);
61 void		 dbm_page_bydesc(const struct dbm_match *);
62 void		 dbm_page_bymacro(int32_t, const struct dbm_match *);
63 struct dbm_res	 dbm_page_next(void);
64 
65 int32_t		 dbm_macro_count(int32_t);
66 struct dbm_macro *dbm_macro_get(int32_t, int32_t);
67 void		 dbm_macro_bypage(int32_t, int32_t);
68 char		*dbm_macro_next(void);
69