librnr  1.14.5
RoadNarrows Robotics Common Library 1
config.h File Reference

Configuration parser declarations. More...

#include <stdio.h>
#include "rnr/rnrconfig.h"

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_TConfigDbNew (const char *sMainName)
 Create and initialize a new empty configuration database. More...
 
void ConfigDbDelete (Config_T *pConfig)
 Delete the configuration database. More...
 
Config_TConfigDbRead (const char *sFileName)
 Create a new configuration database from a configuration file. More...
 
Config_TConfigDbReadFp (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_TConfigSectionNew (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_TConfigSectionGet (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_TConfigDbIterNew (Config_T *pConfig)
 Create a new configuration database iterator. More...
 
ConfigIter_TConfigSectionIterNew (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...
 

Detailed Description

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).

Syntax:
The configuration file consists of a series of sections, headed by a "[section]" header and followed by "key: value" or "key=value" entries.

Comments start with the character '#'. The configuration parser wlll ignore the '#' and all trailing characters to the end of the current line.
See also
example_config under "Related Pages" for an example usage of configuration.
Package
RoadNarrows Robotics Common Library 1
Library
librnr
File
rnr/config.h
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
License
MIT
EULA
See the README and EULA files for any copyright and licensing information.


Original Source Comment Block
Original Author
Jon Travis (jtrav.nosp@m.is@p.nosp@m.00p.o.nosp@m.rg)
Original Copyright
(C) 1992-2002
Original Header
* 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.

Typedef Documentation

typedef struct config_t Config_T

configuration database type

Forward declaration of types, hiding implementation.

Definition at line 89 of file config.h.

Function Documentation

void ConfigDbDelete ( Config_T pConfig)

Delete the configuration database.

All sections, section key=value entries, plus the database itself are deleted.

Parameters
pConfigConfiguration 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().

296 {
297  LOGDIAG4CALL(_TSTR(pConfig));
298 
299  if( pConfig == NULL )
300  {
301  return;
302  }
303 
304  // delete all sections and section entries
305  hash_table_destroy(pConfig->m_hashMain);
306 
307  // now delete the structure
308  delete(pConfig->m_sMainName);
309  delete(pConfig);
310 }
char * m_sMainName
configuration name
Definition: config.c:125
#define NULL
null pointer
Definition: rnrconfig.h:199
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
#define _TSTR(var)
string variable
Definition: log.h:578
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
void hash_table_destroy(hash_t *hash)
Delete the hash table, all of its entries, and all of the user data.
Definition: hash.c:750
const char* ConfigDbGetName ( Config_T pConfig)

Get the current name assigned to the configuration database.

Parameters
pConfigConfiguration database.
Returns
Returns current name.

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().

487 {
488  CHKPTR(pConfig, NULL);
489  return pConfig->m_sMainName;
490 }
char * m_sMainName
configuration name
Definition: config.c:125
#define CHKPTR(p,...)
Checks validity of pointer.
Definition: log.h:651
#define NULL
null pointer
Definition: rnrconfig.h:199
ConfigIter_T* ConfigDbIterNew ( Config_T pConfig)

Create a new configuration database iterator.

The iterator will iterator over section names.

Parameters
pConfigConfiguration database.
Returns
New iterator.

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().

944 {
945  ConfigIter_T *pIter;
946 
947  pIter = NEW(ConfigIter_T);
948  hash_scan_begin(&pIter->m_scanHash, pConfig->m_hashMain);
949 
950  return pIter;
951 }
#define NEW(T)
Allocate new type.
Definition: new.h:49
void hash_scan_begin(hscan_t *scan, hash_t *hash)
Reset the hash scanner (iterator).
Definition: hash.c:937
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
hscan_t m_scanHash
hash table scanner (iterator)
Definition: config.c:134
Config_T* ConfigDbNew ( const char *  sMainName)

Create and initialize a new empty configuration database.

Parameters
sMainNameName of configuration database. If Null, then a name will be auto-generated.
Returns
Returns new configuration database on success.
Returns NULL on failure.

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().

244 {
245  Config_T *pConfig;
246  char buf[32];
247 
248  LOGDIAG4CALL(_TSTR(sMainName));
249 
250  // new main configuration structure
251  pConfig = NEW(Config_T);
252 
253  // new empty main hash table of sections
254  pConfig->m_hashMain = hash_table_create(true,
257  NULL,
258  NULL,
260 
261  if( pConfig->m_hashMain == NULL )
262  {
263  LOGERROR("failed to create new configuration main hash table");
264  delete(pConfig);
265  return NULL;
266  }
267 
268  // create internal name
269  if( sMainName == NULL )
270  {
271  snprintf(buf, sizeof(buf), "__config.%d", ConfigMainCounter++);
272  buf[sizeof(buf)-1] = 0;
273  pConfig->m_sMainName = new_strdup(buf);
274  }
275 
276  // use given name
277  else
278  {
279  pConfig->m_sMainName = new_strdup(sMainName);
280  }
281 
282  LOGDIAG3(_TPTR(pConfig));
283 
284  return pConfig;
285 }
char * m_sMainName
configuration name
Definition: config.c:125
static int ConfigMainCounter
Definition: config.c:140
char * new_strdup(const char *s)
Duplicate a string.
Definition: new.c:176
#define LOGDIAG3(fmt,...)
Standard Diagnostic Level 3 logging.
Definition: log.h:393
#define NULL
null pointer
Definition: rnrconfig.h:199
#define HASH_MAX_SECTIONS
max. num. of database sections
Definition: config.c:102
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
#define HASH_MIN_SECTIONS
min. num. of database sections
Definition: config.c:101
static void ConfigMainHashDeleteCb(void *pKey, void *pData)
Delete section hash callback.
Definition: config.c:212
#define NEW(T)
Allocate new type.
Definition: new.h:49
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
#define _TSTR(var)
string variable
Definition: log.h:578
hash_t * hash_table_create(bool_t isdynamic, hashcount_t minsize, hashcount_t maxsize, hash_comp_t compfun, hash_fun_t hashfun, hnode_data_free_t freedatafun)
Create a dynamic hash table.
Definition: hash.c:691
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
void ConfigDbPrint ( Config_T pConfig,
FILE *  fp 
)

Print configuration database to the output file stream.

The output format is valid for input.

Parameters
pConfigConfiguration database.
fpOutput 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().

515 {
516  hscan_t scanHash;
517  hnode_t *pHashNode;
518  ConfigSection_T *pSect;
519 
520  fprintf(fp, "# Configuration %s\n", pConfig->m_sMainName);
521  hash_scan_begin(&scanHash, pConfig->m_hashMain);
522  while((pHashNode = hash_scan_next(&scanHash)) != NULL )
523  {
524  pSect = (ConfigSection_T *)hnode_get(pHashNode);
525  ConfigSectionPrint(pSect, fp);
526  fprintf(fp, "\n");
527  }
528 }
char * m_sMainName
configuration name
Definition: config.c:125
hnode_t * hash_scan_next(hscan_t *scan)
Retrieve the next node from the hash table.
Definition: hash.c:998
#define NULL
null pointer
Definition: rnrconfig.h:199
void hash_scan_begin(hscan_t *scan, hash_t *hash)
Reset the hash scanner (iterator).
Definition: hash.c:937
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
Hash scanner structure.
Definition: hash.h:302
#define hnode_get(N)
Get hash node user data.
Definition: hash.h:403
void ConfigSectionPrint(ConfigSection_T *pSect, FILE *fp)
Print one section to the output file stream.
Definition: config.c:654
Hash chain node structure.
Definition: hash.h:149
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.

Parameters
sFileNameFile path name of configuration file.
Returns
Returns populated configuration database on success.
Returns NULL on failure.

Definition at line 326 of file config.c.

References _TPTR, _TSTR, CHKPTR, ConfigDbReadFp(), LOGDIAG4, LOGDIAG4CALL, LOGSYSERROR, and NULL.

Referenced by CmdDbRead(), and test_config().

327 {
328  FILE *fp;
329  Config_T *pConfig;
330 
331  LOGDIAG4CALL(_TSTR(sFileName));
332 
333  CHKPTR(sFileName, NULL);
334 
335  if( (fp = fopen(sFileName, "r")) == NULL )
336  {
337  LOGSYSERROR("%s", sFileName);
338  return NULL;
339  }
340  else
341  {
342  pConfig = ConfigDbReadFp(fp, sFileName);
343  fclose(fp);
344  LOGDIAG4(_TPTR(pConfig));
345  return pConfig;
346  }
347 }
#define CHKPTR(p,...)
Checks validity of pointer.
Definition: log.h:651
#define NULL
null pointer
Definition: rnrconfig.h:199
Config_T * ConfigDbReadFp(FILE *fp, const char *sFileName)
Create a new configuration database from a opened configuration file.
Definition: config.c:364
#define LOGSYSERROR(fmt,...)
Standard System Error logging.
Definition: log.h:509
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
Definition: log.h:386
#define _TSTR(var)
string variable
Definition: log.h:578
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
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.

Parameters
fpInput file pointer.
sFileNameInput file name. NULL is okay.
Returns
Returns populated configuration database on success.
Returns NULL on failure.

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().

365 {
366  Config_T *pConfig;
367  ConfigSection_T *pCurSect;
368  char bufGet[HASH_INPUT_BUF_SIZE];
369  char bufKey[HASH_INPUT_BUF_SIZE];
370  char bufSep[HASH_INPUT_BUF_SIZE];
371  char bufVal[HASH_INPUT_BUF_SIZE];
372  char *s, *t;
373  int nLineNum;
374  int i;
375 
376  LOGDIAG4CALL(_TPTR(fp), _TSTR(sFileName));
377 
378  CHKPTR(fp, NULL);
379 
380  // New configuration
381  if( (pConfig = ConfigDbNew(sFileName)) == NULL )
382  {
383  return NULL;
384  }
385 
386  pCurSect = NULL;
387  nLineNum = 0;
388 
389  while( fgets(bufGet, (int)sizeof(bufGet), fp) != NULL )
390  {
391  nLineNum++;
392 
393  // eat white-space
394  for(i=0; isspace((int)bufGet[i]); ++i);
395 
396  // comment or white space
397  if( (bufGet[i] == 0) || (bufGet[i] == '#') || (bufGet[0] == '\n') )
398  {
399  continue; // empty or comment line
400  }
401 
402  //
403  // Begin a section
404  //
405  if( bufGet[i] == '[' )
406  {
407  if( (t = strrchr(bufGet+i, ']' )) == NULL )
408  {
409  LOGERROR("Config %s: Line %d: malformed section statement: %d",
410  pConfig->m_sMainName, nLineNum );
411  continue; // recoverable error
412  }
413  s = &bufGet[i+1];
414  *t = '\0';
415 
416  if( (pCurSect = ConfigSectionNew(pConfig, s)) == NULL )
417  {
418  LOGERROR("Config %s: [%s]: Line %d: failed adding section",
419  pConfig->m_sMainName, s, nLineNum);
420  ConfigDbDelete(pConfig);
421  return NULL; // non-recoverable error
422  }
423  continue;
424  }
425 
426  //
427  // Orphaned Key-Value Pair
428  //
429  if( pCurSect == NULL )
430  {
431  LOGERROR("Config %s: Line %d: not in a section",
432  pConfig->m_sMainName, nLineNum );
433  continue; // recoverable error
434  }
435 
436  //
437  // Key-Value Pair
438  //
439  bufKey[0] = bufSep[0] = bufVal[0] = 0;
440  if( sscanf(bufGet+i, "%[^:= \t]%[:= \t]%[^\n#]", bufKey, bufSep, bufVal)
441  != 3)
442  {
443  LOGERROR("Config %s: [%s]: Line %d: malformed input",
444  pConfig->m_sMainName, pCurSect->m_sSectionName, nLineNum );
445  continue; // recoverable error
446  }
447 
448  // strip any trailing white-space
449  i = (int)strlen(bufVal) - 1;
450  while( (i >= 0) && isspace((int)bufVal[i]) )
451  {
452  --i;
453  }
454  if( i < 0 )
455  {
456  LOGERROR("Config %s: [%s]: Line %d: malformed input",
457  pConfig->m_sMainName, pCurSect->m_sSectionName, nLineNum );
458  continue; // recoverable error
459  }
460  else
461  {
462  bufVal[i+1] = 0;
463  }
464 
465  if( ConfigSectionAddPair(pCurSect, bufKey, bufVal) == RC_ERROR )
466  {
467  LOGERROR("Config %s: [%s]: Line %d: failed to add key=value enttry",
468  pConfig->m_sMainName, pCurSect->m_sSectionName, nLineNum );
469  ConfigDbDelete(pConfig);
470  return NULL; // non-recoverable error
471  }
472  }
473 
474  LOGDIAG4(_TPTR(pConfig));
475 
476  return pConfig;
477 }
char * m_sMainName
configuration name
Definition: config.c:125
char * m_sSectionName
section name
Definition: config.c:116
static int ConfigSectionAddPair(ConfigSection_T *pSect, const char *sKey, const char *sVal)
Add or update a key-value pair in the given section.
Definition: config.c:151
#define CHKPTR(p,...)
Checks validity of pointer.
Definition: log.h:651
#define NULL
null pointer
Definition: rnrconfig.h:199
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
Config_T * ConfigDbNew(const char *sMainName)
Create and initialize a new empty configuration database.
Definition: config.c:243
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
Definition: log.h:386
ConfigSection_T * ConfigSectionNew(Config_T *pConfig, const char *sSectionName)
Add a new empty section to the configuration database.
Definition: config.c:547
#define HASH_INPUT_BUF_SIZE
Maximum input line size.
Definition: config.c:109
#define _TSTR(var)
string variable
Definition: log.h:578
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
void ConfigDbDelete(Config_T *pConfig)
Delete the configuration database.
Definition: config.c:295
void ConfigDbSetName ( Config_T pConfig,
const char *  sMainName 
)

Assign a new name for the configuration database.

Parameters
pConfigConfiguration database.
sMainNameNew database name.

Definition at line 498 of file config.c.

References CHKPTR, config_t::m_sMainName, and new_strdup().

499 {
500  CHKPTR(pConfig);
501  CHKPTR(sMainName);
502  delete(pConfig->m_sMainName);
503  pConfig->m_sMainName = new_strdup(sMainName);
504 }
char * m_sMainName
configuration name
Definition: config.c:125
char * new_strdup(const char *s)
Duplicate a string.
Definition: new.c:176
#define CHKPTR(p,...)
Checks validity of pointer.
Definition: log.h:651
int ConfigDelete ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey 
)

Delete entry from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

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().

907 {
908  ConfigSection_T *pSect;
909 
910  /* Can't add to an undefined section! */
911  if( (pSect = ConfigSectionGet(pConfig, sSectionName)) == NULL )
912  {
913  LOGDIAG4("%s: [%s]: section not defined",
914  pConfig->m_sMainName, sSectionName);
915  return RC_ERROR;
916  }
917  else if( !hash_delete(pSect->m_hashSection, (char *)sKey) )
918  {
919  LOGDIAG4("%s: [%s]: %s could not delete",
920  pConfig->m_sMainName, sSectionName, sKey);
921  return RC_ERROR;
922  }
923  else
924  {
925  return OK;
926  }
927 }
char * m_sMainName
configuration name
Definition: config.c:125
#define OK
Okay.
Definition: rnrconfig.h:301
#define NULL
null pointer
Definition: rnrconfig.h:199
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
bool_t hash_delete(hash_t *hash, void *key)
Unlink and delete a hash node with the given key from the hash table.
Definition: hash.c:1310
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
Definition: log.h:386
ConfigSection_T * ConfigSectionGet(Config_T *pConfig, const char *sSectionName)
Get a section from the configuration database.
Definition: config.c:635
hash_t * m_hashSection
section&#39;s key=value entries hash table
Definition: config.c:117
int ConfigGetDouble ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
double *  pVal 
)

Get and convert a double value from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
pValConverted value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 759 of file config.c.

References ConfigGetStr(), LOGERROR, config_t::m_sMainName, NULL, OK, and RC_ERROR.

Referenced by CmdGetd().

761 {
762  const char *sVal;
763  double fVal;
764  char *sEnd;
765 
766  if( (sVal = ConfigGetStr(pConfig, sSectionName, sKey)) == NULL )
767  {
768  return RC_ERROR;
769  }
770  else if( (sVal == NULL) || (*sVal == 0) )
771  {
772  LOGERROR("Config %s: [%s]: value is null",
773  pConfig->m_sMainName, sSectionName);
774  return RC_ERROR;
775  }
776  else
777  {
778  fVal = strtod(sVal, &sEnd);
779 
780  if( *sEnd != 0 )
781  {
782  LOGERROR("Config %s: [%s]: %s=%s: not a float",
783  pConfig->m_sMainName, sSectionName, sKey, sVal);
784  return RC_ERROR;
785  }
786  else
787  {
788  *pVal = fVal;
789  return OK;
790  }
791  }
792 }
char * m_sMainName
configuration name
Definition: config.c:125
#define OK
Okay.
Definition: rnrconfig.h:301
#define NULL
null pointer
Definition: rnrconfig.h:199
const char * ConfigGetStr(Config_T *pConfig, const char *sSectionName, const char *sKey)
Get a string value from the configuration database.
Definition: config.c:682
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
static int ConfigGetInt ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
int *  pVal 
)
inlinestatic

Get and convert an int value from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
pValConverted value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 152 of file config.h.

References ConfigGetLong().

Referenced by CmdGeti().

154 {
155  return ConfigGetLong(pConfig, sSectionName, sKey, (long *)pVal);
156 }
int ConfigGetLong(Config_T *pConfig, const char *sSectionName, const char *sKey, long *pVal)
Get and convert a long value from the configuration database.
Definition: config.c:714
int ConfigGetLong ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
long *  pVal 
)

Get and convert a long value from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
pValConverted value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

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().

716 {
717  const char *sVal;
718  long lVal;
719  char *sEnd;
720 
721  if( (sVal = ConfigGetStr(pConfig, sSectionName, sKey)) == NULL )
722  {
723  return RC_ERROR;
724  }
725  else if( (sVal == NULL) || (*sVal == 0) )
726  {
727  LOGERROR("Config %s: [%s]: value is null",
728  pConfig->m_sMainName, sSectionName);
729  return RC_ERROR;
730  }
731  else
732  {
733  lVal = strtol(sVal, &sEnd, 0);
734 
735  if( *sEnd != 0 )
736  {
737  LOGERROR("Config %s: [%s]: %s=%s: not an integer",
738  pConfig->m_sMainName, sSectionName, sKey, sVal);
739  return RC_ERROR;
740  }
741  else
742  {
743  *pVal = lVal;
744  return OK;
745  }
746  }
747 }
char * m_sMainName
configuration name
Definition: config.c:125
#define OK
Okay.
Definition: rnrconfig.h:301
#define NULL
null pointer
Definition: rnrconfig.h:199
const char * ConfigGetStr(Config_T *pConfig, const char *sSectionName, const char *sKey)
Get a string value from the configuration database.
Definition: config.c:682
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
const char* ConfigGetStr ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey 
)

Get a string value from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
Returns
Returns string value one success, NULL on failure.

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().

684 {
685  ConfigSection_T *pSect;
686  hnode_t *pHashNode;
687 
688  if( (pSect = ConfigSectionGet(pConfig, sSectionName)) == NULL )
689  {
690  return NULL;
691  }
692 
693  else if( (pHashNode = hash_lookup(pSect->m_hashSection, sKey)) == NULL )
694  {
695  return NULL;
696  }
697 
698  else
699  {
700  return hnode_get(pHashNode);
701  }
702 }
#define NULL
null pointer
Definition: rnrconfig.h:199
hnode_t * hash_lookup(hash_t *hash, const void *key)
Find a node in the hash table and return a pointer to it.
Definition: hash.c:1246
ConfigSection_T * ConfigSectionGet(Config_T *pConfig, const char *sSectionName)
Get a section from the configuration database.
Definition: config.c:635
#define hnode_get(N)
Get hash node user data.
Definition: hash.h:403
Hash chain node structure.
Definition: hash.h:149
hash_t * m_hashSection
section&#39;s key=value entries hash table
Definition: config.c:117
static const char* ConfigGetStrDft ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
const char *  sValDft 
)
inlinestatic

Get a value from the configuration database or default.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
sValDftDefault value.
Returns
Returns value found in database on success.
Returns default value if no value found in database or on error.

Definition at line 187 of file config.h.

References ConfigGetStr(), ConfigSetDouble(), ConfigSetLong(), ConfigSetStr(), ConfigSetULong(), and NULL.

191 {
192  const char *sVal;
193 
194  return (sVal = ConfigGetStr(pConfig, sSectionName, sKey)) != NULL?
195  sVal: sValDft;
196 }
#define NULL
null pointer
Definition: rnrconfig.h:199
const char * ConfigGetStr(Config_T *pConfig, const char *sSectionName, const char *sKey)
Get a string value from the configuration database.
Definition: config.c:682
static int ConfigGetULong ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
unsigned long *  pVal 
)
inlinestatic

Get and convert an unsigned long value from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
pValConverted value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 169 of file config.h.

References ConfigGetLong().

171 {
172  return ConfigGetLong(pConfig, sSectionName, sKey, (long *)pVal);
173 }
int ConfigGetLong(Config_T *pConfig, const char *sSectionName, const char *sKey, long *pVal)
Get and convert a long value from the configuration database.
Definition: config.c:714
void ConfigIterDelete ( ConfigIter_T pIter)

Delete a configuration iterator.

Parameters
pIterConfiguration iterator.

Definition at line 985 of file config.c.

Referenced by CmdFind(), and ConfigSetInt().

986 {
987  delete(pIter);
988 }
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.

Parameters
pIterConfiguration iterator.
Returns
Returns next value on success, NULL at end of iteration.

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().

1005 {
1006  hnode_t *pHashNode;
1007 
1008  if( pIter == NULL )
1009  {
1010  return NULL;
1011  }
1012  else if( (pHashNode = hash_scan_next(&pIter->m_scanHash)) == NULL )
1013  {
1014  return NULL;
1015  }
1016  else
1017  {
1018  return hnode_getkey(pHashNode);
1019  }
1020 }
#define hnode_getkey(N)
Get hash node hash key.
Definition: hash.h:409
hnode_t * hash_scan_next(hscan_t *scan)
Retrieve the next node from the hash table.
Definition: hash.c:998
#define NULL
null pointer
Definition: rnrconfig.h:199
Hash chain node structure.
Definition: hash.h:149
hscan_t m_scanHash
hash table scanner (iterator)
Definition: config.c:134
int ConfigSectionDelete ( Config_T pConfig,
ConfigSection_T pSect 
)

Delete a section from the configuration database.

Parameters
pConfigConfiguration database.
pSectConfiguration section to delete.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

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().

601 {
602  LOGDIAG4CALL(_TPTR(pConfig), _TPTR(pSect));
603 
604  if( pSect == NULL )
605  {
606  return OK;
607  }
608 
609  // make sure section exist
610  if( hash_lookup(pConfig->m_hashMain, pSect->m_sSectionName) == NULL )
611  {
612  LOGERROR("%s: [%s]: section not define",
613  pConfig->m_sMainName, pSect->m_sSectionName);
614  return RC_ERROR;
615  }
616 
617  // delete all section entries
618  else
619  {
620  hash_delete(pConfig->m_hashMain, pSect->m_sSectionName);
621  return OK;
622  }
623 }
char * m_sMainName
configuration name
Definition: config.c:125
char * m_sSectionName
section name
Definition: config.c:116
#define OK
Okay.
Definition: rnrconfig.h:301
#define NULL
null pointer
Definition: rnrconfig.h:199
hnode_t * hash_lookup(hash_t *hash, const void *key)
Find a node in the hash table and return a pointer to it.
Definition: hash.c:1246
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
bool_t hash_delete(hash_t *hash, void *key)
Unlink and delete a hash node with the given key from the hash table.
Definition: hash.c:1310
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
ConfigSection_T* ConfigSectionGet ( Config_T pConfig,
const char *  sSectionName 
)

Get a section from the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
Returns
Returns configuration section on success.
NULL on failure.

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().

636 {
637  hnode_t *pHashNode;
638 
639  if( (pHashNode = hash_lookup(pConfig->m_hashMain, sSectionName)) != NULL )
640  {
641  return (ConfigSection_T *)hnode_get(pHashNode);
642  }
643  return NULL;
644 }
#define NULL
null pointer
Definition: rnrconfig.h:199
hnode_t * hash_lookup(hash_t *hash, const void *key)
Find a node in the hash table and return a pointer to it.
Definition: hash.c:1246
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
#define hnode_get(N)
Get hash node user data.
Definition: hash.h:403
Hash chain node structure.
Definition: hash.h:149
ConfigIter_T* ConfigSectionIterNew ( Config_T pConfig,
const char *  sSectionName 
)

Create a new configuration section iterator.

The iterator will iterator over section keys.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
Returns
New iterator.

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().

964 {
965  ConfigSection_T *pSect;
966  ConfigIter_T *pIter;
967 
968  if( (pSect = ConfigSectionGet(pConfig, sSectionName)) == NULL )
969  {
970  return NULL;
971  }
972  else
973  {
974  pIter = NEW(ConfigIter_T);
975  hash_scan_begin(&pIter->m_scanHash, pSect->m_hashSection);
976  return pIter;
977  }
978 }
#define NULL
null pointer
Definition: rnrconfig.h:199
#define NEW(T)
Allocate new type.
Definition: new.h:49
void hash_scan_begin(hscan_t *scan, hash_t *hash)
Reset the hash scanner (iterator).
Definition: hash.c:937
ConfigSection_T * ConfigSectionGet(Config_T *pConfig, const char *sSectionName)
Get a section from the configuration database.
Definition: config.c:635
hash_t * m_hashSection
section&#39;s key=value entries hash table
Definition: config.c:117
hscan_t m_scanHash
hash table scanner (iterator)
Definition: config.c:134
ConfigSection_T* ConfigSectionNew ( Config_T pConfig,
const char *  sSectionName 
)

Add a new empty section to the configuration database.

The section cannot already exist.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
Returns
Returns configuration section on success.
NULL on failure.

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().

548 {
549  ConfigSection_T *pSect;
550 
551  LOGDIAG4CALL(_TPTR(pConfig), _TSTR(sSectionName));
552 
553  CHKPTR(pConfig, NULL);
554  CHKPTR(sSectionName, NULL);
555 
556  // make sure section does not already exist
557  if( hash_lookup(pConfig->m_hashMain, sSectionName) != NULL )
558  {
559  LOGERROR("%s: [%s]: section multiply defined",
560  pConfig->m_sMainName, sSectionName);
561  return NULL;
562  }
563 
564  // new section structure
565  pSect = NEW(ConfigSection_T);
566 
567  // new section hash table of key=value entries
568  pSect->m_hashSection = hash_table_create(true,
571  NULL,
572  NULL,
574 
575  if( pSect->m_hashSection == NULL )
576  {
577  LOGERROR("%s: [%s]: failed to create new section hash table",
578  pConfig->m_sMainName, sSectionName);
579  delete(pSect);
580  return NULL;
581  }
582 
583  // section name
584  pSect->m_sSectionName = new_strdup(sSectionName);
585 
586  // insert section into main hash table
587  hash_insert(pConfig->m_hashMain, (char *)pSect->m_sSectionName, pSect);
588 
589  return pSect;
590 }
char * m_sMainName
configuration name
Definition: config.c:125
char * m_sSectionName
section name
Definition: config.c:116
char * new_strdup(const char *s)
Duplicate a string.
Definition: new.c:176
#define CHKPTR(p,...)
Checks validity of pointer.
Definition: log.h:651
#define NULL
null pointer
Definition: rnrconfig.h:199
#define HASH_MAX_ENTRIES
max. num. of section entries
Definition: config.c:104
hnode_t * hash_lookup(hash_t *hash, const void *key)
Find a node in the hash table and return a pointer to it.
Definition: hash.c:1246
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
#define NEW(T)
Allocate new type.
Definition: new.h:49
hash_t * m_hashMain
main hash table of sections
Definition: config.c:126
#define _TSTR(var)
string variable
Definition: log.h:578
hash_t * hash_table_create(bool_t isdynamic, hashcount_t minsize, hashcount_t maxsize, hash_comp_t compfun, hash_fun_t hashfun, hnode_data_free_t freedatafun)
Create a dynamic hash table.
Definition: hash.c:691
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
hash_t * m_hashSection
section&#39;s key=value entries hash table
Definition: config.c:117
bool_t hash_insert(hash_t *hash, void *key, void *data)
Insert user data with the given key into the hash table.
Definition: hash.c:1283
#define HASH_MIN_ENTRIES
min. num. of section entries
Definition: config.c:103
static void ConfigSectionHashDeleteCb(void *pKey, void *pData)
Delete section entry hash callback.
Definition: config.c:197
void ConfigSectionPrint ( ConfigSection_T pSect,
FILE *  fp 
)

Print one section to the output file stream.

The output format is valid for input.

Parameters
pSectConfiguration section.
fpOutput 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().

655 {
656  hscan_t scanHash;
657  hnode_t *pHashNode;
658 
659  fprintf(fp, "[%s]\n", pSect->m_sSectionName);
660  hash_scan_begin(&scanHash, pSect->m_hashSection);
661  while( (pHashNode = hash_scan_next(&scanHash)) != NULL )
662  {
663  fprintf(fp, "%s=%s\n",
664  (char *)hnode_getkey(pHashNode), (char *)hnode_get(pHashNode));
665  }
666 }
char * m_sSectionName
section name
Definition: config.c:116
#define hnode_getkey(N)
Get hash node hash key.
Definition: hash.h:409
hnode_t * hash_scan_next(hscan_t *scan)
Retrieve the next node from the hash table.
Definition: hash.c:998
#define NULL
null pointer
Definition: rnrconfig.h:199
void hash_scan_begin(hscan_t *scan, hash_t *hash)
Reset the hash scanner (iterator).
Definition: hash.c:937
Hash scanner structure.
Definition: hash.h:302
#define hnode_get(N)
Get hash node user data.
Definition: hash.h:403
Hash chain node structure.
Definition: hash.h:149
hash_t * m_hashSection
section&#39;s key=value entries hash table
Definition: config.c:117
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.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
fValSection key double value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 883 of file config.c.

References ConfigSetStr().

Referenced by CmdSetd(), and ConfigGetStrDft().

885 {
886  char buf[64];
887 
888  sprintf(buf, "%.16f", fVal);
889  return ConfigSetStr(pConfig, sSectionName, sKey, buf);
890 }
int ConfigSetStr(Config_T *pConfig, const char *sSectionName, const char *sKey, const char *sVal)
Set or update a string value in the configuration database.
Definition: config.c:809
static int ConfigSetInt ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
int  iVal 
)
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.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
iValSection key int value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 226 of file config.h.

References C_DECLS_END, ConfigDbIterNew(), ConfigDelete(), ConfigIterDelete(), ConfigIterNext(), ConfigSectionIterNew(), and ConfigSetLong().

Referenced by CmdSeti().

228 {
229  return ConfigSetLong(pConfig, sSectionName, sKey, (long)iVal);
230 }
int ConfigSetLong(Config_T *pConfig, const char *sSectionName, const char *sKey, long lVal)
Set or update a long value in the configuration database.
Definition: config.c:841
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.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
lValSection key long value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 841 of file config.c.

References ConfigSetStr().

Referenced by ConfigGetStrDft(), and ConfigSetInt().

843 {
844  char buf[64];
845 
846  sprintf(buf, "%ld", lVal);
847  return ConfigSetStr(pConfig, sSectionName, sKey, buf);
848 }
int ConfigSetStr(Config_T *pConfig, const char *sSectionName, const char *sKey, const char *sVal)
Set or update a string value in the configuration database.
Definition: config.c:809
int ConfigSetStr ( Config_T pConfig,
const char *  sSectionName,
const char *  sKey,
const char *  sVal 
)

Set or update a string value in the configuration database.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
sValSection key value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

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().

811 {
812  ConfigSection_T *pSect;
813 
814  LOGDIAG4CALL(_TPTR(pConfig), _TSTR(sSectionName), _TSTR(sKey), _TSTR(sVal));
815 
816  /* Can't add to an undefined section! */
817  if( (pSect = ConfigSectionGet(pConfig, sSectionName)) == NULL )
818  {
819  LOGDIAG4("%s: [%s]: section not defined",
820  pConfig->m_sMainName, sSectionName);
821  return RC_ERROR;
822  }
823  else
824  {
825  return ConfigSectionAddPair(pSect, sKey, sVal);
826  }
827 }
char * m_sMainName
configuration name
Definition: config.c:125
static int ConfigSectionAddPair(ConfigSection_T *pSect, const char *sKey, const char *sVal)
Add or update a key-value pair in the given section.
Definition: config.c:151
#define NULL
null pointer
Definition: rnrconfig.h:199
#define RC_ERROR
common function error return code
Definition: rnrconfig.h:316
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
Definition: log.h:386
ConfigSection_T * ConfigSectionGet(Config_T *pConfig, const char *sSectionName)
Get a section from the configuration database.
Definition: config.c:635
#define _TSTR(var)
string variable
Definition: log.h:578
#define _TPTR(var)
pointer
Definition: log.h:587
#define LOGDIAG4CALL(...)
Standard Diagnostic Level 4 function call tracing.
Definition: log.h:442
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.

Parameters
pConfigConfiguration database.
sSectionNameConfiguration section name.
sKeySection key.
ulValSection key unsigned long value.
Returns
Returns OK(0) on success, RC_ERROR(-1) on failure.

Definition at line 862 of file config.c.

References ConfigSetStr().

Referenced by ConfigGetStrDft().

864 {
865  char buf[64];
866 
867  sprintf(buf, "%lu", ulVal);
868  return ConfigSetStr(pConfig, sSectionName, sKey, buf);
869 }
int ConfigSetStr(Config_T *pConfig, const char *sSectionName, const char *sKey, const char *sVal)
Set or update a string value in the configuration database.
Definition: config.c:809