1MANSEARCH(3)             BSD Library Functions Manual             MANSEARCH(3)
2

NAME

4     mansearch — search manual page databases
5

SYNOPSIS

7     #include <stdint.h>
8     #include <manconf.h>
9     #include <mansearch.h>
10
11     int
12     mansearch(const struct mansearch *search, const struct manpaths *paths,
13         int argc, char *argv[], struct manpage **res, size_t *sz);
14

DESCRIPTION

16     The mansearch() function returns information about manuals matching a
17     search query from a mandoc.db(5) database.
18
19     The query arguments are as follows:
20
21     const struct mansearch *search
22             Search options, defined in <mansearch.h>.
23
24     const struct manpaths *paths
25             Directories to be searched, defined in <manconf.h>.
26
27     int argc, char *argv[]
28             Search criteria, usually taken from the command line.
29
30     The output arguments are as follows:
31
32     struct manpage **res
33             Returns a pointer to an array of result structures defined in
34             <mansearch.h>.  The user is expected to call free(3) on the file,
35             names, and output fields of all structures, as well as the res
36             array itself.
37
38     size_t *sz
39             Returns the number of result structures contained in res.
40

IMPLEMENTATION NOTES

42     For each manual page tree, the search is done in two steps.  In the first
43     step, a list of pages matching the search criteria is built.  In the sec‐
44     ond step, the requested information about these pages is retrieved from
45     the database and assembled into the res array.
46
47     All function mentioned here are defined in the file mansearch.c.
48
49   Finding matches
50     Command line parsing is done by the function exprcomp() building a singly
51     linked list of expr structures, using the helper functions expr_and() and
52     exprterm().
53
54   Assembling the results
55     The names, sections, and architectures of the manuals found are assembled
56     into the names field of the result structure by the function
57     buildnames().
58

FILES

60     mandoc.db  The manual page database.
61

SEE ALSO

63     apropos(1), mandoc.db(5), makewhatis(8)
64

HISTORY

66     The mansearch() subsystem first appeared in OpenBSD 5.6.
67

AUTHORS

69     A module to search manual page databases was first written by Kristaps
70     Dzonsons <kristaps@bsd.lv> in 2011, at first using the Berkeley DB; he
71     rewrote it for SQLite3 in 2012, and Ingo Schwarze <schwarze@openbsd.org>
72     removed the dependency on SQLite3 in 2016.
73
74BSD                              June 20, 2019                             BSD
Impressum