myxce/src/worker/include/xcecd_conf.h

47 lines
1.2 KiB
C

#ifndef XCECD_CONF_H
#define XCECD_CONF_H
#include <cyaml/cyaml.h>
#include <stdbool.h>
#include <stdint.h>
#define DEFAULT_CONFIG_PATH "/opt/xce/conf/worker.yaml"
#define MAX_HOSTNAME_LEN 256
#define MAX_PATH_LEN 512
#define MAX_LOG_LEVEL_LEN 16
typedef enum {
CONFIG_SUCCESS = 0,
CONFIG_ERROR_FILE_NOT_FOUND,
CONFIG_ERROR_PARSE_FAILED,
CONFIG_ERROR_INVALID_DATA,
CONFIG_ERROR_MEMORY,
CONFIG_ERROR_UNKNOWN
} config_error_t;
typedef struct {
char* hostname;
} management_host_t;
typedef struct {
management_host_t* management_list;
uint32_t management_list_count;
uint16_t controller_port;
char* log_level;
char* log_dir;
} worker_config_t;
typedef struct {
config_error_t error_code;
char error_message[512];
worker_config_t* config;
} config_result_t;
config_result_t* config_load(const char* config_path);
config_result_t* config_load_default(void);
void config_free(config_result_t* result);
const char* config_error_string(config_error_t error);
void config_print(const worker_config_t* config);
int level_to_int(const char* level);
#endif // XCECD_CONF_H