configparser: rename BOOL, document types
Rename CONFIG_KEY_BOOL to CONFIG_KEY_BOOLEAN, just like CONFIG_KEY_INTEGER is not CONFIG_KEY_INT, for consistency. Document the types expected for the void* and name the enum in the header, so it is clear what config_key::type means. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ handle_key(const struct config_key *key, const char *value)
|
|||||||
*(char **)key->data = s;
|
*(char **)key->data = s;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case CONFIG_KEY_BOOL:
|
case CONFIG_KEY_BOOLEAN:
|
||||||
if (strcmp(value, "false\n") == 0)
|
if (strcmp(value, "false\n") == 0)
|
||||||
*(int *)key->data = 0;
|
*(int *)key->data = 0;
|
||||||
else if (strcmp(value, "true\n") == 0)
|
else if (strcmp(value, "true\n") == 0)
|
||||||
|
|||||||
@@ -23,15 +23,15 @@
|
|||||||
#ifndef CONFIGPARSER_H
|
#ifndef CONFIGPARSER_H
|
||||||
#define CONFIGPARSER_H
|
#define CONFIGPARSER_H
|
||||||
|
|
||||||
enum {
|
enum config_key_type {
|
||||||
CONFIG_KEY_INTEGER,
|
CONFIG_KEY_INTEGER, /* typeof data = int */
|
||||||
CONFIG_KEY_STRING,
|
CONFIG_KEY_STRING, /* typeof data = char* */
|
||||||
CONFIG_KEY_BOOL
|
CONFIG_KEY_BOOLEAN /* typeof data = int */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct config_key {
|
struct config_key {
|
||||||
const char *name;
|
const char *name;
|
||||||
int type;
|
enum config_key_type type;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user