1MANDOC.DB(5)                BSD File Formats Manual               MANDOC.DB(5)
2

NAME

4     mandoc.db — manual page database
5

DESCRIPTION

7     The mandoc.db file format is used to store information about installed
8     manual pages to facilitate semantic searching for manuals.  Each manual
9     page tree contains its own mandoc.db file; see FILES for examples.
10
11     Such database files are generated by makewhatis(8) and used by man(1),
12     apropos(1) and whatis(1).
13
14     The file format uses three datatypes:
15
16       -  32-bit signed integer numbers in big endian (network) byte ordering
17       -  NUL-terminated strings
18       -  lists of NUL-terminated strings, terminated by a second NUL charac‐
19          ter
20
21     Numbers are aligned to four-byte boundaries; where they follow strings or
22     lists of strings, padding with additional NUL characters occurs.  Some,
23     but not all, numbers point to positions in the file.  These pointers are
24     measured in bytes, and the first byte of the file is considered to be
25     byte 0.
26
27     Each file consists of:
28
29       -  One magic number, 0x3a7d0cdb.
30       -  One version number, currently 1.
31       -  One pointer to the macros table.
32       -  One pointer to the final magic number.
33       -  The pages table (variable length).
34       -  The macros table (variable length).
35       -  The magic number once again, 0x3a7d0cdb.
36
37     The pages table contains one entry for each physical manual page file, no
38     matter how many hard and soft links it may have in the file system.  The
39     pages table consists of:
40
41       -  The number of pages in the database.
42       -  For each page:
43            -  One pointer to the list of names.
44            -  One pointer to the list of sections.
45            -  One pointer to the list of architectures or 0 if the page is
46               machine-independent.
47            -  One pointer to the one-line description string.
48            -  One pointer to the list of filenames.
49       -  For each page, the list of names.  Each name is preceded by a single
50          byte indicating the sources of the name.  The meaning of the bits
51          is:
52            -  0x10: The name appears in a filename.
53            -  0x08: The name appears in a header line, i.e. in a .Dt or .TH
54               macro.
55            -  0x04: The name is the first one in the title line, i.e. it
56               appears in the first .Nm macro in the NAME section.
57            -  0x02: The name appears in any .Nm macro in the NAME section.
58            -  0x01: The name appears in an .Nm block in the SYNOPSIS section.
59       -  For each page, the list of sections.  Each section is given as a
60          string, not as a number.
61       -  For each architecture-dependent page, the list of architectures.
62       -  For each page, the one-line description string taken from the .Nd
63          macro.
64       -  For each page, the list of filenames relative to the root of the
65          respective manpath.  This list includes hard links, soft links, and
66          links simulated with .so roff(7) requests.  The first filename is
67          preceded by a single byte having the following significance:
68            -  FORM_SRC = 0x01: The file format is mdoc(7) or man(7).
69            -  FORM_CAT = 0x02: The manual page is preformatted.
70       -  Zero to three NUL bytes for padding.
71
72     The macros table consists of:
73
74       -  The number of different macro keys, currently 36.  The ordering of
75          macros is defined in <mansearch.h> and the significance of the macro
76          keys is documented in apropos(1).
77       -  For each macro key, one pointer to the respective macro table.
78       -  For each macro key, the macro table (variable length).
79
80     Each macro table consists of:
81
82       -  The number of entries in the table.
83       -  For each entry:
84            -  One pointer to the value of the macro key.  Each value is a
85               string of text taken from some macro invocation.
86            -  One pointer to the list of pages.
87       -  For each entry, the value of the macro key.
88       -  Zero to three NUL bytes for padding.
89       -  For each entry, one or more pointers to pages in the pages table,
90          pointing to the pointer to the list of names, followed by the number
91          0.
92

FILES

94     /usr/share/man/mandoc.db  The manual page database for the base system.
95     /usr/X11R6/man/mandoc.db  The same for the X(7) Window System.
96     /usr/local/man/mandoc.db  The same for packages(7).
97
98     A program to dump mandoc.db files in a human-readable format suitable for
99     diff(1) is provided in the directory
100     /usr/src/regress/usr.bin/mandoc/db/dbm_dump/.
101

SEE ALSO

103     apropos(1), man(1), whatis(1), makewhatis(8)
104

HISTORY

106     A manual page database /usr/lib/whatis first appeared in 2BSD.  The
107     present format first appeared in OpenBSD 6.1.
108

AUTHORS

110     The original version of makewhatis(8) was written by Bill Joy in 1979.
111     The present database format was designed by Ingo Schwarze
112     <schwarze@openbsd.org> in 2016.
113
114BSD                              June 20, 2019                             BSD
Impressum