xref: /openbsd-src/usr.bin/mandoc/dba.h (revision 289fdc1a87fd959053d8bda85d6806aa24b682c7)
1*289fdc1aSschwarze /*	$OpenBSD: dba.h,v 1.2 2016/08/17 20:46:06 schwarze Exp $ */
2ff2dbb0fSschwarze /*
3ff2dbb0fSschwarze  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4ff2dbb0fSschwarze  *
5ff2dbb0fSschwarze  * Permission to use, copy, modify, and distribute this software for any
6ff2dbb0fSschwarze  * purpose with or without fee is hereby granted, provided that the above
7ff2dbb0fSschwarze  * copyright notice and this permission notice appear in all copies.
8ff2dbb0fSschwarze  *
9ff2dbb0fSschwarze  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10ff2dbb0fSschwarze  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11ff2dbb0fSschwarze  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12ff2dbb0fSschwarze  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13ff2dbb0fSschwarze  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14ff2dbb0fSschwarze  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15ff2dbb0fSschwarze  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16ff2dbb0fSschwarze  *
17ff2dbb0fSschwarze  * Public interface of the allocation-based version
18ff2dbb0fSschwarze  * of the mandoc database, for read-write access.
19ff2dbb0fSschwarze  * To be used by dba.c, dba_read.c, and makewhatis(8).
20ff2dbb0fSschwarze  */
21ff2dbb0fSschwarze 
22ff2dbb0fSschwarze #define	DBP_NAME	0
23ff2dbb0fSschwarze #define	DBP_SECT	1
24ff2dbb0fSschwarze #define	DBP_ARCH	2
25ff2dbb0fSschwarze #define	DBP_DESC	3
26ff2dbb0fSschwarze #define	DBP_FILE	4
27ff2dbb0fSschwarze #define	DBP_MAX		5
28ff2dbb0fSschwarze 
29ff2dbb0fSschwarze struct dba_array;
30ff2dbb0fSschwarze 
31ff2dbb0fSschwarze struct dba {
32ff2dbb0fSschwarze 	struct dba_array	*pages;
33ff2dbb0fSschwarze 	struct dba_array	*macros;
34ff2dbb0fSschwarze };
35ff2dbb0fSschwarze 
36ff2dbb0fSschwarze 
37ff2dbb0fSschwarze struct dba	*dba_new(int32_t);
38ff2dbb0fSschwarze void		 dba_free(struct dba *);
39ff2dbb0fSschwarze struct dba	*dba_read(const char *);
40ff2dbb0fSschwarze int		 dba_write(const char *, struct dba *);
41ff2dbb0fSschwarze 
42ff2dbb0fSschwarze struct dba_array *dba_page_new(struct dba_array *, const char *,
43*289fdc1aSschwarze 			const char *, const char *, enum form);
44ff2dbb0fSschwarze void		 dba_page_add(struct dba_array *, int32_t, const char *);
45ff2dbb0fSschwarze void		 dba_page_alias(struct dba_array *, const char *, uint64_t);
46ff2dbb0fSschwarze 
47ff2dbb0fSschwarze void		 dba_macro_new(struct dba *, int32_t,
48ff2dbb0fSschwarze 			const char *, const int32_t *);
49ff2dbb0fSschwarze void		 dba_macro_add(struct dba_array *, int32_t,
50ff2dbb0fSschwarze 			const char *, struct dba_array *);
51