![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Configuration parser declarations. More...
Go to the source code of this file.
Typedefs | |
| typedef struct config_t | Config_T |
| configuration database type More... | |
| typedef struct config_section_t | ConfigSection_T |
| configuration section tpe | |
| typedef struct config_iter_t | ConfigIter_T |
| configuration iterator type | |
Functions | |
| Config_T * | ConfigDbNew (const char *sMainName) |
| Create and initialize a new empty configuration database. More... | |
| void | ConfigDbDelete (Config_T *pConfig) |
| Delete the configuration database. More... | |
| Config_T * | ConfigDbRead (const char *sFileName) |
| Create a new configuration database from a configuration file. More... | |
| Config_T * | ConfigDbReadFp (FILE *fp, const char *sFileName) |
| Create a new configuration database from a opened configuration file. More... | |
| const char * | ConfigDbGetName (Config_T *pConfig) |
| Get the current name assigned to the configuration database. More... | |
| void | ConfigDbSetName (Config_T *pConfig, const char *sMainName) |
| Assign a new name for the configuration database. More... | |
| void | ConfigDbPrint (Config_T *pConfig, FILE *fp) |
| Print configuration database to the output file stream. More... | |
| ConfigSection_T * | ConfigSectionNew (Config_T *pConfig, const char *sSectionName) |
| Add a new empty section to the configuration database. More... | |
| int | ConfigSectionDelete (Config_T *pConfig, ConfigSection_T *sSectionName) |
| Delete a section from the configuration database. More... | |
| ConfigSection_T * | ConfigSectionGet (Config_T *pConfig, const char *sSectionName) |
| Get a section from the configuration database. More... | |
| void | ConfigSectionPrint (ConfigSection_T *pSect, FILE *fp) |
| Print one section to the output file stream. More... | |
| const char * | ConfigGetStr (Config_T *pConfig, const char *sSectionName, const char *sKey) |
| Get a string value from the configuration database. More... | |
| int | ConfigGetLong (Config_T *pConfig, const char *sSectionName, const char *sKey, long *pVal) |
| Get and convert a long value from the configuration database. More... | |
| int | ConfigGetDouble (Config_T *pConfig, const char *sSectionName, const char *sKey, double *pVal) |
| Get and convert a double value from the configuration database. More... | |
| static int | ConfigGetInt (Config_T *pConfig, const char *sSectionName, const char *sKey, int *pVal) |
| Get and convert an int value from the configuration database. More... | |
| static int | ConfigGetULong (Config_T *pConfig, const char *sSectionName, const char *sKey, unsigned long *pVal) |
| Get and convert an unsigned long value from the configuration database. More... | |
| static const char * | ConfigGetStrDft (Config_T *pConfig, const char *sSectionName, const char *sKey, const char *sValDft) |
| Get a value from the configuration database or default. More... | |
| int | ConfigSetStr (Config_T *pConfig, const char *sSectionName, const char *sKey, const char *sVal) |
| Set or update a string value in the configuration database. More... | |
| int | ConfigSetLong (Config_T *pConfig, const char *sSectionName, const char *sKey, long lVal) |
| Set or update a long value in the configuration database. More... | |
| int | ConfigSetULong (Config_T *pConfig, const char *sSectionName, const char *sKey, unsigned long ulVal) |
| Set or update an unsigned long value in the configuration database. More... | |
| int | ConfigSetDouble (Config_T *pConfig, const char *sSectionName, const char *sKey, double fVal) |
| Set or update a double value in the configuration database. More... | |
| static int | ConfigSetInt (Config_T *pConfig, const char *sSectionName, const char *sKey, int iVal) |
| Set or update an int value in the configuration database. More... | |
| int | ConfigDelete (Config_T *pConfig, const char *sSectionName, const char *sKey) |
| Delete entry from the configuration database. More... | |
| ConfigIter_T * | ConfigDbIterNew (Config_T *pConfig) |
| Create a new configuration database iterator. More... | |
| ConfigIter_T * | ConfigSectionIterNew (Config_T *pConfig, const char *sSectionName) |
| Create a new configuration section iterator. More... | |
| void | ConfigIterDelete (ConfigIter_T *pIter) |
| Delete a configuration iterator. More... | |
| const char * | ConfigIterNext (ConfigIter_T *pIter) |
| Get the next value in iteration. More... | |
Configuration parser declarations.
The librnr config module implements a basic configuration file parser and database that provides a structure similar to what you would find on Microsoft Windows INI files.
This file has been modified from the original source (see below).
—
* camserv - An internet streaming picture application * * Copyright (C) 1999-2002 Jon Travis (jtravis@p00p.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
Definition in file config.h.
| void ConfigDbDelete | ( | Config_T * | pConfig | ) |
Delete the configuration database.
All sections, section key=value entries, plus the database itself are deleted.
| pConfig | Configuration database. |
Definition at line 295 of file config.c.
References _TSTR, hash_table_destroy(), LOGDIAG4CALL, config_t::m_hashMain, config_t::m_sMainName, and NULL.
Referenced by CmdDbDelete(), and ConfigDbReadFp().
| const char* ConfigDbGetName | ( | Config_T * | pConfig | ) |
Get the current name assigned to the configuration database.
| pConfig | Configuration database. |
Definition at line 486 of file config.c.
References CHKPTR, config_t::m_sMainName, and NULL.
Referenced by CmdDelete(), CmdFind(), CmdGetd(), CmdGeti(), CmdGets(), CmdSectDelete(), CmdSectNew(), CmdSetd(), CmdSeti(), and CmdSets().
| ConfigIter_T* ConfigDbIterNew | ( | Config_T * | pConfig | ) |
Create a new configuration database iterator.
The iterator will iterator over section names.
| pConfig | Configuration database. |
Definition at line 943 of file config.c.
References hash_scan_begin(), config_t::m_hashMain, config_iter_t::m_scanHash, and NEW.
Referenced by CmdFind(), and ConfigSetInt().
| Config_T* ConfigDbNew | ( | const char * | sMainName | ) |
Create and initialize a new empty configuration database.
| sMainName | Name of configuration database. If Null, then a name will be auto-generated. |
Definition at line 243 of file config.c.
References _TPTR, _TSTR, ConfigMainCounter, ConfigMainHashDeleteCb(), HASH_MAX_SECTIONS, HASH_MIN_SECTIONS, hash_table_create(), LOGDIAG3, LOGDIAG4CALL, LOGERROR, config_t::m_hashMain, config_t::m_sMainName, NEW, new_strdup(), and NULL.
Referenced by CmdDbNew(), and ConfigDbReadFp().
| void ConfigDbPrint | ( | Config_T * | pConfig, |
| FILE * | fp | ||
| ) |
Print configuration database to the output file stream.
The output format is valid for input.
| pConfig | Configuration database. |
| fp | Output file pointer. |
Definition at line 514 of file config.c.
References ConfigSectionPrint(), hash_scan_begin(), hash_scan_next(), hnode_get, config_t::m_hashMain, config_t::m_sMainName, and NULL.
Referenced by CmdDbPrint(), and test_config().
| Config_T* ConfigDbRead | ( | const char * | sFileName | ) |
Create a new configuration database from a configuration file.
The file syntax must conform to the simplified 'INI' format supported by librnr config.
The file is closed upon exiting this function.
| sFileName | File path name of configuration file. |
Definition at line 326 of file config.c.
References _TPTR, _TSTR, CHKPTR, ConfigDbReadFp(), LOGDIAG4, LOGDIAG4CALL, LOGSYSERROR, and NULL.
Referenced by CmdDbRead(), and test_config().
| Config_T* ConfigDbReadFp | ( | FILE * | fp, |
| const char * | sFileName | ||
| ) |
Create a new configuration database from a opened configuration file.
The file syntax must conform to the simplified 'INI' format supported by librnr config.
The file is remains open upon exiting this function.
| fp | Input file pointer. |
| sFileName | Input file name. NULL is okay. |
Definition at line 364 of file config.c.
References _TPTR, _TSTR, CHKPTR, ConfigDbDelete(), ConfigDbNew(), ConfigSectionAddPair(), ConfigSectionNew(), HASH_INPUT_BUF_SIZE, LOGDIAG4, LOGDIAG4CALL, LOGERROR, config_t::m_sMainName, config_section_t::m_sSectionName, NULL, and RC_ERROR.
Referenced by ConfigDbRead().
| void ConfigDbSetName | ( | Config_T * | pConfig, |
| const char * | sMainName | ||
| ) |
Assign a new name for the configuration database.
| pConfig | Configuration database. |
| sMainName | New database name. |
Definition at line 498 of file config.c.
References CHKPTR, config_t::m_sMainName, and new_strdup().
| int ConfigDelete | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey | ||
| ) |
Delete entry from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
Definition at line 906 of file config.c.
References ConfigSectionGet(), hash_delete(), LOGDIAG4, config_section_t::m_hashSection, config_t::m_sMainName, NULL, OK, and RC_ERROR.
Referenced by CmdDelete(), and ConfigSetInt().
| int ConfigGetDouble | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| double * | pVal | ||
| ) |
Get and convert a double value from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| pVal | Converted value. |
Definition at line 759 of file config.c.
References ConfigGetStr(), LOGERROR, config_t::m_sMainName, NULL, OK, and RC_ERROR.
Referenced by CmdGetd().
|
inlinestatic |
Get and convert an int value from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| pVal | Converted value. |
Definition at line 152 of file config.h.
References ConfigGetLong().
Referenced by CmdGeti().
| int ConfigGetLong | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| long * | pVal | ||
| ) |
Get and convert a long value from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| pVal | Converted value. |
Definition at line 714 of file config.c.
References ConfigGetStr(), LOGERROR, config_t::m_sMainName, NULL, OK, and RC_ERROR.
Referenced by ConfigGetInt(), and ConfigGetULong().
| const char* ConfigGetStr | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey | ||
| ) |
Get a string value from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
Definition at line 682 of file config.c.
References ConfigSectionGet(), hash_lookup(), hnode_get, config_section_t::m_hashSection, and NULL.
Referenced by CmdFind(), CmdGets(), ConfigGetDouble(), ConfigGetLong(), and ConfigGetStrDft().
|
inlinestatic |
Get a value from the configuration database or default.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| sValDft | Default value. |
Definition at line 187 of file config.h.
References ConfigGetStr(), ConfigSetDouble(), ConfigSetLong(), ConfigSetStr(), ConfigSetULong(), and NULL.
|
inlinestatic |
Get and convert an unsigned long value from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| pVal | Converted value. |
Definition at line 169 of file config.h.
References ConfigGetLong().
| void ConfigIterDelete | ( | ConfigIter_T * | pIter | ) |
Delete a configuration iterator.
| pIter | Configuration iterator. |
Definition at line 985 of file config.c.
Referenced by CmdFind(), and ConfigSetInt().
| const char* ConfigIterNext | ( | ConfigIter_T * | pIter | ) |
Get the next value in iteration.
After an iterator is created, the first call will return the first vale. Subsequent calls return the next values.
If iterator was created to iterate over the section names, then the values returned are section names. If the iterator was created to iterate over section keys, then the values returned are keys.
| pIter | Configuration iterator. |
Definition at line 1004 of file config.c.
References hash_scan_next(), hnode_getkey, config_iter_t::m_scanHash, and NULL.
Referenced by CmdFind(), and ConfigSetInt().
| int ConfigSectionDelete | ( | Config_T * | pConfig, |
| ConfigSection_T * | pSect | ||
| ) |
Delete a section from the configuration database.
| pConfig | Configuration database. |
| pSect | Configuration section to delete. |
Definition at line 600 of file config.c.
References _TPTR, hash_delete(), hash_lookup(), LOGDIAG4CALL, LOGERROR, config_t::m_hashMain, config_t::m_sMainName, config_section_t::m_sSectionName, NULL, OK, and RC_ERROR.
Referenced by CmdSectDelete().
| ConfigSection_T* ConfigSectionGet | ( | Config_T * | pConfig, |
| const char * | sSectionName | ||
| ) |
Get a section from the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
Definition at line 635 of file config.c.
References hash_lookup(), hnode_get, config_t::m_hashMain, and NULL.
Referenced by CmdSectDelete(), ConfigDelete(), ConfigGetStr(), ConfigSectionIterNew(), and ConfigSetStr().
| ConfigIter_T* ConfigSectionIterNew | ( | Config_T * | pConfig, |
| const char * | sSectionName | ||
| ) |
Create a new configuration section iterator.
The iterator will iterator over section keys.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
Definition at line 963 of file config.c.
References ConfigSectionGet(), hash_scan_begin(), config_section_t::m_hashSection, config_iter_t::m_scanHash, NEW, and NULL.
Referenced by CmdFind(), and ConfigSetInt().
| ConfigSection_T* ConfigSectionNew | ( | Config_T * | pConfig, |
| const char * | sSectionName | ||
| ) |
Add a new empty section to the configuration database.
The section cannot already exist.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
Definition at line 547 of file config.c.
References _TPTR, _TSTR, CHKPTR, ConfigSectionHashDeleteCb(), hash_insert(), hash_lookup(), HASH_MAX_ENTRIES, HASH_MIN_ENTRIES, hash_table_create(), LOGDIAG4CALL, LOGERROR, config_t::m_hashMain, config_section_t::m_hashSection, config_t::m_sMainName, config_section_t::m_sSectionName, NEW, new_strdup(), and NULL.
Referenced by CmdSectNew(), and ConfigDbReadFp().
| void ConfigSectionPrint | ( | ConfigSection_T * | pSect, |
| FILE * | fp | ||
| ) |
Print one section to the output file stream.
The output format is valid for input.
| pSect | Configuration section. |
| fp | Output file pointer. |
Definition at line 654 of file config.c.
References hash_scan_begin(), hash_scan_next(), hnode_get, hnode_getkey, config_section_t::m_hashSection, config_section_t::m_sSectionName, and NULL.
Referenced by ConfigDbPrint().
| int ConfigSetDouble | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| double | fVal | ||
| ) |
Set or update a double value in the configuration database.
The double value is converted to a string prior to adding to the database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| fVal | Section key double value. |
Definition at line 883 of file config.c.
References ConfigSetStr().
Referenced by CmdSetd(), and ConfigGetStrDft().
|
inlinestatic |
Set or update an int value in the configuration database.
The long value is converted to a string prior to adding to the database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| iVal | Section key int value. |
Definition at line 226 of file config.h.
References C_DECLS_END, ConfigDbIterNew(), ConfigDelete(), ConfigIterDelete(), ConfigIterNext(), ConfigSectionIterNew(), and ConfigSetLong().
Referenced by CmdSeti().
| int ConfigSetLong | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| long | lVal | ||
| ) |
Set or update a long value in the configuration database.
The long value is converted to a string prior to adding to the database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| lVal | Section key long value. |
Definition at line 841 of file config.c.
References ConfigSetStr().
Referenced by ConfigGetStrDft(), and ConfigSetInt().
| int ConfigSetStr | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| const char * | sVal | ||
| ) |
Set or update a string value in the configuration database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| sVal | Section key value. |
Definition at line 809 of file config.c.
References _TPTR, _TSTR, ConfigSectionAddPair(), ConfigSectionGet(), LOGDIAG4, LOGDIAG4CALL, config_t::m_sMainName, NULL, and RC_ERROR.
Referenced by CmdSets(), ConfigGetStrDft(), ConfigSetDouble(), ConfigSetLong(), and ConfigSetULong().
| int ConfigSetULong | ( | Config_T * | pConfig, |
| const char * | sSectionName, | ||
| const char * | sKey, | ||
| unsigned long | ulVal | ||
| ) |
Set or update an unsigned long value in the configuration database.
The long value is converted to a string prior to adding to the database.
| pConfig | Configuration database. |
| sSectionName | Configuration section name. |
| sKey | Section key. |
| ulVal | Section key unsigned long value. |
Definition at line 862 of file config.c.
References ConfigSetStr().
Referenced by ConfigGetStrDft().