conf - function declaration style

Use consistent style - function return type and declaration on
same line.
pull/1523/head
Jason Ish 10 years ago committed by Victor Julien
parent 0a4fd39f9c
commit d9fe95bc8a

@ -61,8 +61,7 @@ static ConfNode *root_backup = NULL;
* \retval The existing configuration node if it exists, or a newly * \retval The existing configuration node if it exists, or a newly
* created node for the provided name. On error, NULL will be returned. * created node for the provided name. On error, NULL will be returned.
*/ */
static ConfNode * static ConfNode *ConfGetNodeOrCreate(const char *name, int final)
ConfGetNodeOrCreate(const char *name, int final)
{ {
ConfNode *parent = root; ConfNode *parent = root;
ConfNode *node = NULL; ConfNode *node = NULL;
@ -111,8 +110,7 @@ end:
/** /**
* \brief Initialize the configuration system. * \brief Initialize the configuration system.
*/ */
void void ConfInit(void)
ConfInit(void)
{ {
if (root != NULL) { if (root != NULL) {
SCLogDebug("already initialized"); SCLogDebug("already initialized");
@ -133,8 +131,7 @@ ConfInit(void)
* *
* \retval An allocated configuration node on success, NULL on failure. * \retval An allocated configuration node on success, NULL on failure.
*/ */
ConfNode * ConfNode *ConfNodeNew(void)
ConfNodeNew(void)
{ {
ConfNode *new; ConfNode *new;
@ -152,8 +149,7 @@ ConfNodeNew(void)
* *
* \param node The configuration node to SCFree. * \param node The configuration node to SCFree.
*/ */
void void ConfNodeFree(ConfNode *node)
ConfNodeFree(ConfNode *node)
{ {
ConfNode *tmp; ConfNode *tmp;
@ -177,8 +173,7 @@ ConfNodeFree(ConfNode *node)
* \retval A pointer to ConfNode is found or NULL if the configuration * \retval A pointer to ConfNode is found or NULL if the configuration
* node does not exist. * node does not exist.
*/ */
ConfNode * ConfNode *ConfGetNode(const char *name)
ConfGetNode(const char *name)
{ {
ConfNode *node = root; ConfNode *node = root;
char node_name[NODE_NAME_MAX]; char node_name[NODE_NAME_MAX];
@ -205,8 +200,7 @@ ConfGetNode(const char *name)
/** /**
* \brief Get the root configuration node. * \brief Get the root configuration node.
*/ */
ConfNode * ConfNode *ConfGetRootNode(void)
ConfGetRootNode(void)
{ {
return root; return root;
} }
@ -223,8 +217,7 @@ ConfGetRootNode(void)
* *
* \retval 1 if the value was set otherwise 0. * \retval 1 if the value was set otherwise 0.
*/ */
int int ConfSet(const char *name, char *val)
ConfSet(const char *name, char *val)
{ {
ConfNode *node = ConfGetNodeOrCreate(name, 0); ConfNode *node = ConfGetNodeOrCreate(name, 0);
if (node == NULL || node->final) { if (node == NULL || node->final) {
@ -253,8 +246,7 @@ ConfSet(const char *name, char *val)
* *
* \retval 1 if the value was set otherwise 0. * \retval 1 if the value was set otherwise 0.
*/ */
int int ConfSetFinal(const char *name, char *val)
ConfSetFinal(const char *name, char *val)
{ {
ConfNode *node = ConfGetNodeOrCreate(name, 1); ConfNode *node = ConfGetNodeOrCreate(name, 1);
if (node == NULL) { if (node == NULL) {
@ -286,8 +278,7 @@ ConfSetFinal(const char *name, char *val)
* \retval 1 will be returned if the name is found, otherwise 0 will * \retval 1 will be returned if the name is found, otherwise 0 will
* be returned. * be returned.
*/ */
int int ConfGet(const char *name, char **vptr)
ConfGet(const char *name, char **vptr)
{ {
ConfNode *node = ConfGetNode(name); ConfNode *node = ConfGetNode(name);
if (node == NULL) { if (node == NULL) {
@ -315,7 +306,8 @@ int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr)
} }
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, char **vptr) int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt,
const char *name, char **vptr)
{ {
int ret = ConfGetChildValue(base, name, vptr); int ret = ConfGetChildValue(base, name, vptr);
/* Get 'default' value */ /* Get 'default' value */
@ -335,8 +327,7 @@ int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, con
* \retval 1 will be returned if the name is found and was properly * \retval 1 will be returned if the name is found and was properly
* converted to an interger, otherwise 0 will be returned. * converted to an interger, otherwise 0 will be returned.
*/ */
int int ConfGetInt(const char *name, intmax_t *val)
ConfGetInt(const char *name, intmax_t *val)
{ {
char *strval; char *strval;
intmax_t tmpint; intmax_t tmpint;
@ -376,7 +367,8 @@ int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
} }
int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val) int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt,
const char *name, intmax_t *val)
{ {
int ret = ConfGetChildValueInt(base, name, val); int ret = ConfGetChildValueInt(base, name, val);
/* Get 'default' value */ /* Get 'default' value */
@ -397,8 +389,7 @@ int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt,
* \retval 1 will be returned if the name is found and was properly * \retval 1 will be returned if the name is found and was properly
* converted to a boolean, otherwise 0 will be returned. * converted to a boolean, otherwise 0 will be returned.
*/ */
int int ConfGetBool(const char *name, int *val)
ConfGetBool(const char *name, int *val)
{ {
char *strval; char *strval;
@ -424,7 +415,8 @@ int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
return 1; return 1;
} }
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val) int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt,
const char *name, int *val)
{ {
int ret = ConfGetChildValueBool(base, name, val); int ret = ConfGetChildValueBool(base, name, val);
/* Get 'default' value */ /* Get 'default' value */
@ -446,8 +438,7 @@ int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt,
* *
* \retval 1 If the value is true, 0 if not. * \retval 1 If the value is true, 0 if not.
*/ */
int int ConfValIsTrue(const char *val)
ConfValIsTrue(const char *val)
{ {
char *trues[] = {"1", "yes", "true", "on"}; char *trues[] = {"1", "yes", "true", "on"};
size_t u; size_t u;
@ -472,8 +463,7 @@ ConfValIsTrue(const char *val)
* *
* \retval 1 If the value is false, 0 if not. * \retval 1 If the value is false, 0 if not.
*/ */
int int ConfValIsFalse(const char *val)
ConfValIsFalse(const char *val)
{ {
char *falses[] = {"0", "no", "false", "off"}; char *falses[] = {"0", "no", "false", "off"};
size_t u; size_t u;
@ -497,8 +487,7 @@ ConfValIsFalse(const char *val)
* \retval 1 will be returned if the name is found and was properly * \retval 1 will be returned if the name is found and was properly
* converted to a double, otherwise 0 will be returned. * converted to a double, otherwise 0 will be returned.
*/ */
int int ConfGetDouble(const char *name, double *val)
ConfGetDouble(const char *name, double *val)
{ {
char *strval; char *strval;
double tmpdo; double tmpdo;
@ -528,8 +517,7 @@ ConfGetDouble(const char *name, double *val)
* \retval 1 will be returned if the name is found and was properly * \retval 1 will be returned if the name is found and was properly
* converted to a double, otherwise 0 will be returned. * converted to a double, otherwise 0 will be returned.
*/ */
int int ConfGetFloat(const char *name, float *val)
ConfGetFloat(const char *name, float *val)
{ {
char *strval; char *strval;
double tmpfl; double tmpfl;
@ -552,8 +540,7 @@ ConfGetFloat(const char *name, float *val)
/** /**
* \brief Remove (and SCFree) the provided configuration node. * \brief Remove (and SCFree) the provided configuration node.
*/ */
void void ConfNodeRemove(ConfNode *node)
ConfNodeRemove(ConfNode *node)
{ {
if (node->parent != NULL) if (node->parent != NULL)
TAILQ_REMOVE(&node->parent->head, node, next); TAILQ_REMOVE(&node->parent->head, node, next);
@ -568,8 +555,7 @@ ConfNodeRemove(ConfNode *node)
* \retval Returns 1 if the parameter was removed, otherwise 0 is returned * \retval Returns 1 if the parameter was removed, otherwise 0 is returned
* most likely indicating the parameter was not set. * most likely indicating the parameter was not set.
*/ */
int int ConfRemove(const char *name)
ConfRemove(const char *name)
{ {
ConfNode *node; ConfNode *node;
@ -585,8 +571,7 @@ ConfRemove(const char *name)
/** /**
* \brief Creates a backup of the conf_hash hash_table used by the conf API. * \brief Creates a backup of the conf_hash hash_table used by the conf API.
*/ */
void void ConfCreateContextBackup(void)
ConfCreateContextBackup(void)
{ {
root_backup = root; root_backup = root;
root = NULL; root = NULL;
@ -598,8 +583,7 @@ ConfCreateContextBackup(void)
* \brief Restores the backup of the hash_table present in backup_conf_hash * \brief Restores the backup of the hash_table present in backup_conf_hash
* back to conf_hash. * back to conf_hash.
*/ */
void void ConfRestoreContextBackup(void)
ConfRestoreContextBackup(void)
{ {
root = root_backup; root = root_backup;
root_backup = NULL; root_backup = NULL;
@ -610,8 +594,7 @@ ConfRestoreContextBackup(void)
/** /**
* \brief De-initializes the configuration system. * \brief De-initializes the configuration system.
*/ */
void void ConfDeInit(void)
ConfDeInit(void)
{ {
if (root != NULL) { if (root != NULL) {
ConfNodeFree(root); ConfNodeFree(root);
@ -621,8 +604,7 @@ ConfDeInit(void)
SCLogDebug("configuration module de-initialized"); SCLogDebug("configuration module de-initialized");
} }
static char * static char *ConfPrintNameArray(char **name_arr, int level)
ConfPrintNameArray(char **name_arr, int level)
{ {
static char name[128*128]; static char name[128*128];
int i; int i;
@ -640,8 +622,7 @@ ConfPrintNameArray(char **name_arr, int level)
/** /**
* \brief Dump a configuration node and all its children. * \brief Dump a configuration node and all its children.
*/ */
void void ConfNodeDump(const ConfNode *node, const char *prefix)
ConfNodeDump(const ConfNode *node, const char *prefix)
{ {
ConfNode *child; ConfNode *child;
@ -671,8 +652,7 @@ ConfNodeDump(const ConfNode *node, const char *prefix)
/** /**
* \brief Dump configuration to stdout. * \brief Dump configuration to stdout.
*/ */
void void ConfDump(void)
ConfDump(void)
{ {
ConfNodeDump(root, NULL); ConfNodeDump(root, NULL);
} }
@ -688,8 +668,7 @@ ConfDump(void)
* *
* \retval A pointer the child ConfNode if found otherwise NULL. * \retval A pointer the child ConfNode if found otherwise NULL.
*/ */
ConfNode * ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *name)
ConfNodeLookupChild(const ConfNode *node, const char *name)
{ {
ConfNode *child; ConfNode *child;
@ -713,8 +692,7 @@ ConfNodeLookupChild(const ConfNode *node, const char *name)
* *
* \retval A pointer the child ConfNodes value if found otherwise NULL. * \retval A pointer the child ConfNodes value if found otherwise NULL.
*/ */
const char * const char *ConfNodeLookupChildValue(const ConfNode *node, const char *name)
ConfNodeLookupChildValue(const ConfNode *node, const char *name)
{ {
ConfNode *child; ConfNode *child;
@ -731,7 +709,8 @@ ConfNodeLookupChildValue(const ConfNode *node, const char *name)
* \return the ConfNode matching or NULL * \return the ConfNode matching or NULL
*/ */
ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value) ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key,
const char *value)
{ {
ConfNode *child; ConfNode *child;
@ -758,8 +737,7 @@ ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const ch
* \retval 1 if the child node has a true value, otherwise 0 is * \retval 1 if the child node has a true value, otherwise 0 is
* returned, even if the child node does not exist. * returned, even if the child node does not exist.
*/ */
int int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
{ {
const char *val; const char *val;
@ -814,8 +792,7 @@ char *ConfLoadCompleteIncludePath(const char *file)
* *
* \param node The configuration node to prune. * \param node The configuration node to prune.
*/ */
void void ConfNodePrune(ConfNode *node)
ConfNodePrune(ConfNode *node)
{ {
ConfNode *item, *it; ConfNode *item, *it;
@ -847,8 +824,7 @@ ConfNodePrune(ConfNode *node)
* *
* \return 1 if node is a seuence, otherwise 0. * \return 1 if node is a seuence, otherwise 0.
*/ */
int int ConfNodeIsSequence(const ConfNode *node)
ConfNodeIsSequence(const ConfNode *node)
{ {
return node->is_seq == 0 ? 0 : 1; return node->is_seq == 0 ? 0 : 1;
} }
@ -858,8 +834,7 @@ ConfNodeIsSequence(const ConfNode *node)
/** /**
* Lookup a non-existant value. * Lookup a non-existant value.
*/ */
static int static int ConfTestGetNonExistant(void)
ConfTestGetNonExistant(void)
{ {
char name[] = "non-existant-value"; char name[] = "non-existant-value";
char *value; char *value;
@ -870,8 +845,7 @@ ConfTestGetNonExistant(void)
/** /**
* Set then lookup a value. * Set then lookup a value.
*/ */
static int static int ConfTestSetAndGet(void)
ConfTestSetAndGet(void)
{ {
char name[] = "some-name"; char name[] = "some-name";
char value[] = "some-value"; char value[] = "some-value";
@ -894,8 +868,7 @@ ConfTestSetAndGet(void)
* Test that overriding a value is allowed provided allow_override is * Test that overriding a value is allowed provided allow_override is
* true and that the config parameter gets the new value. * true and that the config parameter gets the new value.
*/ */
static int static int ConfTestOverrideValue1(void)
ConfTestOverrideValue1(void)
{ {
char name[] = "some-name"; char name[] = "some-name";
char value0[] = "some-value"; char value0[] = "some-value";
@ -921,8 +894,7 @@ ConfTestOverrideValue1(void)
/** /**
* Test that a final value will not be overrided by a ConfSet. * Test that a final value will not be overrided by a ConfSet.
*/ */
static int static int ConfTestOverrideValue2(void)
ConfTestOverrideValue2(void)
{ {
char name[] = "some-name"; char name[] = "some-name";
char value0[] = "some-value"; char value0[] = "some-value";
@ -948,8 +920,7 @@ ConfTestOverrideValue2(void)
/** /**
* Test retrieving an integer value from the configuration db. * Test retrieving an integer value from the configuration db.
*/ */
static int static int ConfTestGetInt(void)
ConfTestGetInt(void)
{ {
char name[] = "some-int.x"; char name[] = "some-int.x";
intmax_t val; intmax_t val;
@ -987,8 +958,7 @@ ConfTestGetInt(void)
/** /**
* Test retrieving a boolean value from the configuration db. * Test retrieving a boolean value from the configuration db.
*/ */
static int static int ConfTestGetBool(void)
ConfTestGetBool(void)
{ {
char name[] = "some-bool"; char name[] = "some-bool";
char *trues[] = { char *trues[] = {
@ -1028,8 +998,7 @@ ConfTestGetBool(void)
return 1; return 1;
} }
static int static int ConfNodeLookupChildTest(void)
ConfNodeLookupChildTest(void)
{ {
char *test_vals[] = { "one", "two", "three" }; char *test_vals[] = { "one", "two", "three" };
size_t u; size_t u;
@ -1077,8 +1046,7 @@ ConfNodeLookupChildTest(void)
return 1; return 1;
} }
static int static int ConfNodeLookupChildValueTest(void)
ConfNodeLookupChildValueTest(void)
{ {
char *test_vals[] = { "one", "two", "three" }; char *test_vals[] = { "one", "two", "three" };
size_t u; size_t u;
@ -1212,8 +1180,7 @@ static int ConfGetChildValueBoolWithDefaultTest(void)
/** /**
* Test the removal of a configuration node. * Test the removal of a configuration node.
*/ */
static int static int ConfNodeRemoveTest(void)
ConfNodeRemoveTest(void)
{ {
ConfCreateContextBackup(); ConfCreateContextBackup();
ConfInit(); ConfInit();
@ -1236,8 +1203,7 @@ ConfNodeRemoveTest(void)
return 1; return 1;
} }
static int static int ConfSetTest(void)
ConfSetTest(void)
{ {
ConfCreateContextBackup(); ConfCreateContextBackup();
ConfInit(); ConfInit();
@ -1270,8 +1236,7 @@ ConfSetTest(void)
return 1; return 1;
} }
static int static int ConfGetNodeOrCreateTest(void)
ConfGetNodeOrCreateTest(void)
{ {
ConfNode *node; ConfNode *node;
int ret = 0; int ret = 0;
@ -1363,8 +1328,7 @@ end:
return ret; return ret;
} }
static int static int ConfNodePruneTest(void)
ConfNodePruneTest(void)
{ {
int ret = 0; int ret = 0;
ConfNode *node; ConfNode *node;
@ -1411,8 +1375,7 @@ end:
return ret; return ret;
} }
int int ConfNodeIsSequenceTest(void)
ConfNodeIsSequenceTest(void)
{ {
int retval = 0; int retval = 0;
ConfNode *node = ConfNodeNew(); ConfNode *node = ConfNodeNew();
@ -1436,8 +1399,7 @@ end:
return retval; return retval;
} }
void void ConfRegisterTests(void)
ConfRegisterTests(void)
{ {
UtRegisterTest("ConfTestGetNonExistant", ConfTestGetNonExistant, 1); UtRegisterTest("ConfTestGetNonExistant", ConfTestGetNonExistant, 1);
UtRegisterTest("ConfSetTest", ConfSetTest, 1); UtRegisterTest("ConfSetTest", ConfSetTest, 1);

Loading…
Cancel
Save