mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@66 8ec27952-4edc-4aab-86aa-e87bb2611832
79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
/** Configuration file parser.
|
|
*
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
|
* @file cfg.h
|
|
*/
|
|
|
|
#ifndef _CFG_H_
|
|
#define _CFG_H_
|
|
|
|
#include <libconfig.h>
|
|
|
|
struct node;
|
|
struct path;
|
|
|
|
/** Global configuration */
|
|
struct settings {
|
|
/** Name of this node */
|
|
const char *name;
|
|
/** Task priority (lower is better) */
|
|
int priority;
|
|
/** Core affinity of this task */
|
|
int affinity;
|
|
/** Protocol version of UDP packages */
|
|
int protocol;
|
|
/** User for the server process */
|
|
int uid;
|
|
/** Group for the server process */
|
|
int gid;
|
|
|
|
/** A libconfig object pointing to the root of the config file */
|
|
config_setting_t *cfg;
|
|
};
|
|
|
|
/** Parse configuration file and store settings in supplied struct settings.
|
|
*
|
|
* @param cfg A libconfig object
|
|
* @param set The global configuration structure (also contains the config filename)
|
|
* @param nodes A pointer to a linked list of nodes which should be parsed
|
|
* @param paths A pointer to a linked list of paths which should be parsed
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int config_parse(const char *filename, config_t *cfg,
|
|
struct settings *set, struct node **nodes, struct path **paths);
|
|
|
|
/** Parse the global section of a configuration file.
|
|
*
|
|
* @param cfg A libconfig object pointing to the root of the file
|
|
* @param set The global configuration file
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int config_parse_global(config_setting_t *cfg, struct settings *set);
|
|
|
|
/** Parse a single path and add it to the global configuration.
|
|
*
|
|
* @param cfg A libconfig object pointing to the path
|
|
* @param path A pointer to the new path
|
|
* @param nodes A linked list of all existing nodes
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int config_parse_path(config_setting_t *cfg, struct path *path, struct node *nodes);
|
|
|
|
/** Parse a single node and add it to the global configuration.
|
|
*
|
|
* @param cfg A libconfig object pointing to the node
|
|
* @param node A pointer to the new node
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int config_parse_node(config_setting_t *cfg, struct node *node);
|
|
|
|
#endif /* _CFG_H_ */
|