mansearch — search manual page databases
Contents
Description
The mansearch() function returns information about manuals matching a search query from a mandoc.db(5)
database.
The query arguments are as follows:
conststructmansearch*search
Search options, defined in <mansearch.h>.
conststructmanpaths*paths
Directories to be searched, defined in <manconf.h>.
intargc, char*argv[]
Search criteria, usually taken from the command line.
The output arguments are as follows:
structmanpage**res
Returns a pointer to an array of result structures defined in <mansearch.h>. The user is
expected to call free(3) on the file, names, and output fields of all structures, as well as the
res array itself.
size_t*sz
Returns the number of result structures contained in res.
Files
mandoc.db The manual page database.
History
The mansearch() subsystem first appeared in OpenBSD 5.6.
Implementation Notes
For each manual page tree, the search is done in two steps. In the first step, a list of pages matching
the search criteria is built. In the second step, the requested information about these pages is
retrieved from the database and assembled into the res array.
All function mentioned here are defined in the file mansearch.c.
Findingmatches
Command line parsing is done by the function exprcomp() building a singly linked list of expr structures,
using the helper functions expr_and() and exprterm().
Assemblingtheresults
The names, sections, and architectures of the manuals found are assembled into the names field of the
result structure by the function buildnames().
Name
mansearch — search manual page databases
See Also
apropos(1), mandoc.db(5), makewhatis(8)
Synopsis
#include<stdint.h>#include<manconf.h>#include<mansearch.h>intmansearch(conststructmansearch*search, conststructmanpaths*paths, intargc, char*argv[],
structmanpage**res, size_t*sz);
