From 332e09e24eb26f6af1364aacafe5abae5ba8503e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 5 Jun 2014 09:34:52 +0000 Subject: [PATCH] more changes for new configuration file parser git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@24 8ec27952-4edc-4aab-86aa-e87bb2611832 --- include/cfg.h | 48 +++++++++++++++++++++++++++++++++++++++++------- include/config.h | 18 ++++++------------ 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/include/cfg.h b/include/cfg.h index 8ea44fcd1..6cba8d129 100644 --- a/include/cfg.h +++ b/include/cfg.h @@ -1,21 +1,55 @@ /** * Configuration parser * - * @author Steffen Vogel + * @author Steffen Vogel * @copyright 2014, Institute for Automation of Complex Power Systems, EONERC */ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ +#ifndef _CFG_H_ +#define _CFG_H_ #include #include "path.h" #include "node.h" -int config_parse(config_t *c, const char *filename, struct path *paths, struct node *nodes); +struct config { + /// Name of this node + const char *name; + /// Configuration filename + const char *filename; + /// Verbosity level + int debug; + /// Task priority (lower is better) + int nice; + /// Core affinity of this task + int affinity; + /// Protocol version of UDP packages + int protocol; + /// Number of parsed paths + int path_count, node_count; -int config_parse_path(config_setting_t *c, struct path *p); -int config_parse_node(config_setting_t *c, struct node *n); + /// libconfig object + config_t obj; -#endif /* _CONFIG_H_ */ + /// Array of nodes + struct node *nodes; + /// Array of paths + struct path *paths; +}; + +/** + * @brief Parse configuration file and store settings in suplied struct + * + * @param c A libconfig object + * @param g The global configuration structure (also contains the config filename) + */ +int config_parse(config_t *c, struct config *g); + +int config_parse_global(config_setting_t *c, struct config *g); + +int config_parse_path(config_setting_t *c, struct config *g); + +int config_parse_node(config_setting_t *c, struct config *g); + +#endif /* _CFG_H_ */ diff --git a/include/config.h b/include/config.h index fb49e25e8..a65f69246 100644 --- a/include/config.h +++ b/include/config.h @@ -10,23 +10,17 @@ /// The version number of the s2ss server #define VERSION __GIT_TAG__ "-" __GIT_REV__ -/// The Procotol version determines the format of a struct msg -#define PROTOCOL 0 -/// The name of this node -#define NAME "acs" - -#define PRIORITY sched_get_priority_max(SCHED_FIFO) -#define CORES ((1 << 6) | (1 << 7)) /// Maximum number of double values in a struct msg -#define MAX_VALUES 4 +#define MAX_VALUES 6 + /// Maximum number of registrable hook functions per path #define MAX_HOOKS 5 -/// Maximum number of paths -#define MAX_PATHS 2 -/// Maximum number of nodes -#define MAX_NODES 2 + /// Size of the stack which gets prefaulted during initialization #define MAX_SAFE_STACK (16*1024) /* 16 KiB */ +/// Socket priority +#define SOCKET_PRIO 7 + #endif /* _CONFIG_H_ */