MANSEARCH(3)
π MANSEARCH(3) π
okay so bestie, this is a page from the Library Functions Manual and it's all about mansearch β the lil' function that goes digging through your manual page databases. she's a library function, she's lowkey iconic, and by the end of this you're gonna be obsessed. periodt. π
β¨ NAME β¨
mansearch β search manual page databases π
πΈ SYNOPSIS πΈ
#include <stdint.h>
#include <manconf.h>
#include <mansearch.h>
int
mansearch(const struct mansearch *search, const struct manpaths *paths,
int argc, char *argv[], struct manpage **res, size_t *sz);
π¦ DESCRIPTION π¦
The mansearch() function returns information about manuals matching a search query from a mandoc.db(5) database. literally that's her whole job and she ate. π
The query arguments are as follows:
const struct mansearch *searchβ the search options, and they're defined in<mansearch.h>. β¨const struct manpaths *pathsβ the directories to be searched, defined in<manconf.h>. she needs to know where to look, bestie. πΊοΈint argc, char *argv[]β the search criteria, usually taken from the command line. yep, the usual suspects. π
The output arguments are as follows:
struct manpage **resβ returns a pointer to an array of result structures defined in<mansearch.h>. and listen, this one comes with homework: the user is expected to callfree(3)on the file, names, and output fields of all structures, as well as theresarray itself. do not skip the cleanup, bestie, that's not the vibe. π§Ήsize_t *szβ returns the number of result structures contained inres. the count, the receipts, the number. π’
π IMPLEMENTATION NOTES π
For each manual page tree, the search is done in two steps. ok so:
- 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
resarray. π§©
All function mentioned here are defined in the file mansearch.c. (yes that's the original's grammar, we're keeping the facts exactly as they are, no cap.) π
π Finding matches π
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(). it's giving linked list realness, it's giving helpers doing the heavy lifting. π
π Assembling the results π
The names, sections, and architectures of the manuals found are assembled into the names field of the result structure by the function buildnames(). she's building the names, she's the main character of this subsection, and honestly? deserved. π
π FILES π
mandoc.dbβ The manual page database. the one and only, the blueprint, the source of truth. πΎ
β SEE ALSO β
go read those too, iykyk. π«Ά
π HISTORY π
The mansearch() subsystem first appeared in OpenBSD 5.6. a classic, an OG, a founding mother. π°οΈ
π AUTHORS π
A module to search manual page databases was first written by Kristaps Dzonsons <kristaps@bsd.lv> in 2011, at first using the Berkeley DB; he rewrote it for SQLite3 in 2012, and Ingo Schwarze <schwarze@openbsd.org> removed the dependency on SQLite3 in 2016. the glow-up arc is real, we love a rewrite journey. πβ¨
fr fr, that's the whole page. no details skipped, no options invented, everything exactly where the original put it. π
Debian β March 30, 2017 β MANSEARCH(3) π mwah, bestie, go call free(3) on your results and slay the rest of your day. π
π¦πΈ
π¦ where this page comes from
- alpine 3.22: mandoc-doc 1.14.6-r13 Β· ISC
- alpine 3.23: mandoc-doc 1.14.6-r14 Β· ISC
- alpine 3.24: mandoc-doc 1.14.6-r15 Β· ISC
- debian trixie: libmandoc-dev 1.14.6-4 Β· ISC
- epel 10: libmandoc-devel 1.14.6-11.el10_1 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- epel 9: libmandoc-devel 1.14.6-2.el9 Β· ISC
- fedora 43: libmandoc-devel 1.14.6-12.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 43: libmandoc-devel 1.14.6-12.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 44: libmandoc-devel 1.14.6-13.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- fedora 44: libmandoc-devel 1.14.6-13.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause
- ubuntu questing: libmandoc-dev 1.14.6-4
- ubuntu resolute: libmandoc-dev 1.14.6-4build1 Β· ISC
- ubuntu stonking: libmandoc-dev 1.14.6-4build1 Β· ISC
- Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms