1 /*        Id: dba.h,v 1.2 2016/08/17 20:46:56 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 of the allocation-based version
18  * of the mandoc database, for read-write access.
19  * To be used by dba.c, dba_read.c, and makewhatis(8).
20  */
21 
22 #define   DBP_NAME  0
23 #define   DBP_SECT  1
24 #define   DBP_ARCH  2
25 #define   DBP_DESC  3
26 #define   DBP_FILE  4
27 #define   DBP_MAX             5
28 
29 struct dba_array;
30 
31 struct dba {
32           struct dba_array    *pages;
33           struct dba_array    *macros;
34 };
35 
36 
37 struct dba          *dba_new(int32_t);
38 void                 dba_free(struct dba *);
39 struct dba          *dba_read(const char *);
40 int                  dba_write(const char *, struct dba *);
41 
42 struct dba_array *dba_page_new(struct dba_array *, const char *,
43                               const char *, const char *, enum form);
44 void                 dba_page_add(struct dba_array *, int32_t, const char *);
45 void                 dba_page_alias(struct dba_array *, const char *, uint64_t);
46 
47 void                 dba_macro_new(struct dba *, int32_t,
48                               const char *, const int32_t *);
49 void                 dba_macro_add(struct dba_array *, int32_t,
50                               const char *, struct dba_array *);
51