- Add a configuration dumper.

- Fix a bug where you could override a configuration value that did not
  set allow_override to true.
remotes/origin/master-1.0.x
Jason Ish 16 years ago committed by Victor Julien
parent aad8aaf3cb
commit 3f51fc2ce7

@ -136,7 +136,7 @@ ConfSet(char *name, char *val, int allow_override)
lookup_key.name = name;
conf_node = HashTableLookup(conf_hash, &lookup_key, sizeof(lookup_key));
if (conf_node != NULL) {
if (!allow_override) {
if (!conf_node->allow_override) {
return 0;
}
HashTableRemove(conf_hash, conf_node, sizeof(*conf_node));
@ -210,6 +210,28 @@ ConfRemove(char *name)
return 0;
}
/**
* \brief Dump configuration to stdout.
*/
void
ConfDump(void)
{
HashTableBucket *b;
ConfNode *cn;
int i;
for (i = 0; i < conf_hash->array_size; i++) {
if (conf_hash->array[i] != NULL) {
b = (HashTableBucket *)conf_hash->array[i];
while (b != NULL) {
cn = (ConfNode *)b->data;
printf("%s=%s\n", cn->name, cn->val);
b = b->next;
}
}
}
}
#ifdef UNITTESTS
/**

@ -15,6 +15,7 @@
void ConfInit(void);
int ConfGet(char *name, char **vptr);
int ConfSet(char *name, char *val, int allow_override);
void ConfDump(void);
void ConfRegisterTests();
#endif /* ! __CONF_H__ */

Loading…
Cancel
Save