xref: /netbsd-src/usr.sbin/makemandb/init_db.3 (revision dd255ccea4286b0c44fa8fd48a9a19a768afe8e1)
1.\" $NetBSD: init_db.3,v 1.2 2012/10/06 15:33:59 wiz Exp $
2.\"
3.\" Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
4.\" All rights reserved.
5.\"
6.\" This code was developed as part of Google's Summer of Code 2011 program.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in
16.\"    the documentation and/or other materials provided with the
17.\"    distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
23.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd October 5, 2011
33.Dt INIT_DB 3
34.Os
35.Sh NAME
36.Nm init_db
37.Nd open apropos database connection
38.Sh SYNOPSIS
39.In apropos-utils.h
40.Ft sqlite3 *
41.Fn init_db "int db_flag" "char *manconf"
42.Sh DESCRIPTION
43The
44.Fn init_db
45function will try to initialize a connection to
46.Pa man.db
47which is an
48Sqlite database and return a pointer to a sqlite3 structure.
49The connection should subsequentially be closed by calling
50.Fn close_db
51which will also release any resources being used by it.
52.Pp
53The argument
54.Fa db_flag
55can be one of the following:
56.Bl -hang -width -compact
57.It Dv MANDB_READONLY
58This will open the database in read-only mode.
59Use this when you only want to query the database.
60.It Dv MANDB_WRITE
61This will open the database in read/write mode.
62.It Dv MANDB_CREATE
63This will open the database in read/write mode, and will also create
64the database schema if it does not exist already.
65.El
66.Pp
67The second argument
68.Fa manconf
69specifies the location of the man.conf configuration file.
70By default it is stored at
71.Pa /etc/man.conf .
72The location of the man.db database is configured in the configuration file
73using the
74.Cd _mandb
75tag.
76.Sh RETURN VALUES
77On successful execution the
78.Fn init_db
79function will return a pointer to a sqlite3 structure which represents
80a connection to the database.
81.Pp
82In case the man.db file does not exist and
83.Dv DB_CREATE
84is not used as a value of
85.Fa db_flag ,
86.Dv NULL
87will be returned.
88.Sh FILES
89.Bl -hang -width /etc/man.conf -compact
90.It Pa /etc/man.conf
91The location of the Sqlite FTS database can be configured using the
92.Cd _mandb
93tag.
94.El
95.Sh SEE ALSO
96.Xr apropos-utils 3 ,
97.Xr close_db 3 ,
98.Xr run_query 3 ,
99.Xr run_query_html 3 ,
100.Xr run_query_pager 3
101.Sh AUTHORS
102.An Abhinav Upadhyay
103