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