#ifndef _UDSF_CONFIG_H_
#define _UDSF_CONFIG_H_

#include <libconfig.h++>
#include <string>

#define UDSF_CONFIG_STRING_UDSF_CONFIG "UDSF"
#define UDSF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
#define UDSF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define UDSF_CONFIG_STRING_INTERFACES "INTERFACES"
#define UDSF_CONFIG_STRING_INTERFACE_SBI "SBI"
#define UDSF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define UDSF_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define UDSF_CONFIG_STRING_PORT "PORT"

#define UDSF_CONFIG_STRING_MYSQL "MYSQL"
#define UDSF_CONFIG_STRING_MYSQL_SERVER "MYSQL_SERVER"
#define UDSF_CONFIG_STRING_MYSQL_USER "MYSQL_USER"
#define UDSF_CONFIG_STRING_MYSQL_PASS "MYSQL_PASS"
#define UDSF_CONFIG_STRING_MYSQL_DB "MYSQL_DB"
#define UDSF_CONFIG_STRING_MYSQL_PORT "MYSQL_PORT"

using namespace libconfig;
namespace config {

typedef struct {
  std::string mysql_server = "192.168.83.129";
  std::string mysql_user = "root";
  std::string mysql_pass = "pass";
  std::string mysql_db = "liuyu";
  unsigned int mysql_port = 3306;
} mysql_conf_t;

typedef struct interface_cfg_s {
  std::string if_name;
  std::string addr4;
  unsigned int port;
} interface_cfg_t;

class udsf_config {
public:
  udsf_config();
  ~udsf_config();

   int load(const std::string &config_file);
   int getip(std::string &ip, std::string &ifname);
   int load_interface(const Setting &if_cfg, interface_cfg_t &cfg);
   void display();

   unsigned int instance;
   std::string pid_dir;
   interface_cfg_t sbi;
   mysql_conf_t mysql;
};
} // namespace config

#endif
