1 .\" $Id: mansearch.3,v 1.5 2017/03/30 22:22:05 schwarze Exp $
3 .\" Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
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.
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.
17 .Dd $Mdocdate: March 30 2017 $
22 .Nd search manual page databases
29 .Fa "const struct mansearch *search"
30 .Fa "const struct manpaths *paths"
33 .Fa "struct manpage **res"
39 function returns information about manuals matching a search query from a
43 The query arguments are as follows:
45 .It Fa "const struct mansearch *search"
46 Search options, defined in
48 .It Fa "const struct manpaths *paths"
49 Directories to be searched, defined in
51 .It Fa "int argc" , "char *argv[]"
52 Search criteria, usually taken from the command line.
55 The output arguments are as follows:
57 .It Fa "struct manpage **res"
58 Returns a pointer to an array of result structures defined in
60 The user is expected to call
67 fields of all structures, as well as the
71 Returns the number of result structures contained in
74 .Sh IMPLEMENTATION NOTES
75 For each manual page tree, the search is done in two steps.
76 In the first step, a list of pages matching the search criteria is built.
77 In the second step, the requested information about these pages is
78 retrieved from the database and assembled into the
82 All function mentioned here are defined in the file
85 Command line parsing is done by the function
87 building a singly linked list of
89 structures, using the helper functions
93 .Ss Assembling the results
94 The names, sections, and architectures of the manuals found
95 are assembled into the
97 field of the result structure by the function
100 .Bl -tag -width mandoc.db -compact
102 The manual page database.
111 subsystem first appeared in
115 A module to search manual page databases was first written by
116 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
117 in 2011, at first using the Berkeley DB;
118 he rewrote it for SQLite3 in 2012, and
119 .An Ingo Schwarze Aq Mt schwarze@openbsd.org
120 removed the dependency on SQLite3 in 2016.