You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PdnsSlave.cpp 899B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by robin on 8/8/15.
  3. //
  4. #include <fstream>
  5. #include "DataAccess/PdnsSlaveConfig.h"
  6. #include "PdnsSlave.h"
  7. PdnsSlave::PdnsSlave(const std::string &filePath)
  8. : _filePath(filePath)
  9. {
  10. }
  11. bool PdnsSlave::readConfig()
  12. {
  13. PdnsSlaveConfig conf(_filePath);
  14. if (!conf.readConfig())
  15. return false;
  16. _dhcpdFilePath = conf.getDhcpdFilePath();
  17. _dhcpdTemplatePath = conf.getDhcpdTemplatePath();
  18. _hostsPath = conf.getHostsPath();
  19. _masterConfig = conf.getMasterConfig();
  20. _slaveConfig = conf.getSlaveConfig();
  21. return true;
  22. }
  23. bool PdnsSlave::readDhcpdTemplate()
  24. {
  25. std::ifstream dhcpTemplate(_dhcpdTemplatePath);
  26. if (!dhcpTemplate)
  27. return false;
  28. while (!dhcpTemplate.eof())
  29. {
  30. std::string line;
  31. getline(dhcpTemplate, line);
  32. _dhcpdTemplateContent += line + "\n";
  33. }
  34. dhcpTemplate.close();
  35. return true;
  36. }