Next Previous Contents

4. The CONFDB object

The CONFDB (configuration database) is a simple text database. Each line in the file has a key made of two parts. The file may have section (like .ini files). The CONFDB file make it easy to retrieve, add, modify the content of the database.

#Specification: misc / CONFDB / intro ([confdb.cc,87])

The CONFDB object was designed to support the /etc/conf.linuxconf file. This save configuration information in an ascii file with a simple one line one record format. The line start with a key and the value(s) (words or whatever) follow up to the end of the line. The key is separated from the value(s) by blank characters.

4.1 Alphabetical function listing

Classe CONFDB, vue publique

4.2 Defining a database

CONFDB::CONFDB()

        PUBLIC CONFDB::CONFDB(
                CONFIG_FILE&_fcfg)
        

CONFDB::CONFDB()

        PUBLIC CONFDB::CONFDB(
                CONFIG_FILE&_fcfg,
                bool use_equal_sign,
                const char comcar)
        

CONFDB::CONFDB()

Constructor used when the database is not simply read from a file

        PUBLIC CONFDB::CONFDB(
                void)
        

4.3 Getting values

CONFDB::getitem()

        PUBLIC CONFOBJ *CONFDB::getitem(
                int no)
        

CONFDB::getval()

Find a record. Return NULL if not found.

        PUBLIC VIRTUAL const char *CONFDB::getval(
                const char *prefix,
                const char *key,
                const char *defval)
        

CONFDB::getval()

Find a record. Return NULL if not found.

        PUBLIC const char *CONFDB::getval(
                const char *prefix,
                const char *key)
        

CONFDB::getvalnum()

Locate one numeric configuration parameter. Return defval if not found.

        PUBLIC int CONFDB::getvalnum(
                const char *prefix,
                const char *key,
                int defval)
        

CONFDB::getvalf()

Locate one numeric configuration parameter. Return defval if not found.

        PUBLIC double CONFDB::getvalf(
                const char *prefix,
                const char *key,
                double defval)
        

CONFDB::getall()

Locate all configuration parameter with the same key. Return the number found.

        PUBLIC VIRTUAL int CONFDB::getall(
                const char *prefix,
                const char *key,
                SSTRINGS&lst,
                bool copy)      // Take a copy of the values
        

4.4 Updating the database

CONFDB::add()

Add one record to the configuration file

        PUBLIC VIRTUAL void CONFDB::add(
                const char *prefix,
                const char *key,
                const char *val)
        

CONFDB::add()

Add one record to the configuration file

        PUBLIC void CONFDB::add(
                const char *prefix,
                const char *key,
                const SSTRING&val)
        

CONFDB::add()

Add one record to the configuration file

        PUBLIC void CONFDB::add(
                const char *prefix,
                const char *key,
                int val)
        

CONFDB::add()

Add one record to the configuration file

        PUBLIC void CONFDB::add(
                const char *prefix,
                const char *key,
                bool val)
        

CONFDB::addline()

Add a non-parsed line to the database

        PUBLIC void CONFDB::addline(
                const char *buf)
        

CONFDB::removeall()

Remove all entry with a given key.

        PUBLIC VIRTUAL void CONFDB::removeall(
                const char *prefix,
                const char *key)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                const char *val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                char val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                int val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                bool val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                long val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                double val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                const SSTRING&val)
        

CONFDB::replace()

Replace one record in the configuration file

        PUBLIC void CONFDB::replace(
                const char *prefix,
                const char *key,
                const SSTRINGS&vals)
        

CONFDB::save()

Update the configuration file Return -1 if any error.

        PUBLIC VIRTUAL int CONFDB::save(
                PRIVILEGE *priv)
        

CONFDB::save()

        PUBLIC int CONFDB::save(
                void)
        

CONFDB::savesys()

Save all entries owned by a subsystem

        PRIVATE void CONFDB::savesys(
                char *sys,
                SSTREAM&ss)
        

CONFDB::setcursys()

Record the new current subsystem used to add entries in the CONFDB This current subsys stay current until it is changed or the file is saved. If the subsystem is unknown, it is added. subsystem are case sensitive.

        PUBLIC VIRTUAL void CONFDB::setcursys(
                const char *_subsys,
                bool _subsys_scope)     // Only update record member of the sys-system
        

CONFDB::setcursys()

Record the new current subsystem used to add entries in the CONFDB This current subsys stay current until it is changed or the file is saved. If the subsystem is unknown, it is added. subsystem are case sensitive.

        PUBLIC VIRTUAL void CONFDB::setcursys(
                const char *_subsys)
        

4.5 archiving

CONFDB::archive()

Archive one sub-system of a CONFDB file

        PUBLIC VIRTUAL int CONFDB::archive(
                SSTREAM&ss,
                const char *_sys)
        

CONFDB::extract()

Extract one sub-system of a CONFDB file

        PUBLIC VIRTUAL int CONFDB::extract(
                SSTREAM&ss,
                const char *_sys)
        

CONFDB::savesys()

Save all entries owned by a subsystem

        PRIVATE void CONFDB::savesys(
                char *sys,
                SSTREAM&ss)
        

4.6 Misc.

CONFDB::patchsys()

Initially, there were no concept of subsystem in CONFDB files. They were introduce to ease archiving and remote administration on a sub-system per sub-system basis. This function try to distribute the various information in conf.linuxconf for those who are using linuxconf prior to 1.9r26.18 So this function is called only from misc/linuxconf.c as an autorepair. Note that sub-system are not important for the proper working of linuxconf. Mostly the ordering of the lines in that file has never been important. The organisation in sub-system is just for archiving.

        PUBLIC void CONFDB::patchsys(
                void)

CONFDB::delsys()

Erase all member of a subsystem

        PUBLIC void CONFDB::delsys(
                const char *_sys)
        

Next Previous Contents