INIT_DB(3)

NAME
init_db - open apropos database connection

SYNOPSIS
#include <apropos-utils.h>
sqlite3 *
init_db(mandb_access_mode db_flag, const char *manconf);

DESCRIPTION
The init_db() function will try to initialize a connection to man.db which is an Sqlite database and return a pointer to a sqlite3 structure. The connection should subsequentially be closed by calling close_db() which will also release any resources being used by it.

The argument db_flag can be one of the following:
MANDB_READONLY
    This will open the database in read-only mode. Use this when you only want to query the database.
MANDB_WRITE
    This will open the database in read/write mode.
MANDB_CREATE
    This will open the database in read/write mode, and will also create the database schema if it does not exist already.

The second argument manconf specifies the location of the man.conf configuration file. By default it is stored at /etc/man.conf. The location of the man.db database is configured in the configuration file using the _mandb tag.

RETURN VALUES
On successful execution the init_db() function will return a pointer to a sqlite3 structure which represents a connection to the database.

In case the man.db file does not exist and DB_CREATE is not used as a value of db_flag, NULL will be returned.

FILES
/etc/man.conf
    The location of the Sqlite FTS database can be configured using the _mandb tag.

SEE ALSO
apropos-utils(3), close_db(3), run_query(3)

AUTHORS
Abhinav Upadhyay