load.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <hooks/hooks.h>
  2. #include <map>
  3. #include <boost/foreach.hpp>
  4. #include "logger.h"
  5. #include "common.h"
  6. using namespace isc::hooks;
  7. using namespace isc::data;
  8. std::map<std::string, std::string> cm_map;
  9. std::map<std::string, std::string> option122_map;
  10. std::string host;
  11. std::string database;
  12. std::string user;
  13. std::string password;
  14. extern "C" {
  15. int load(LibraryHandle& handle)
  16. {
  17. // seteo valores por defecto
  18. host = "mysql";
  19. database = "fd3_dhcp";
  20. user = "root";
  21. password = "235r2342gtfsw";
  22. ConstElementPtr hostPtr = handle.getParameter("host");
  23. ConstElementPtr databasePtr = handle.getParameter("database");
  24. ConstElementPtr userPtr = handle.getParameter("user");
  25. ConstElementPtr passwordPtr = handle.getParameter("password");
  26. if (hostPtr && hostPtr->getType() == Element::string) {
  27. host = hostPtr->stringValue();
  28. }
  29. if (databasePtr && databasePtr->getType() == Element::string) {
  30. database = databasePtr->stringValue();
  31. }
  32. if (userPtr && userPtr->getType() == Element::string) {
  33. user = userPtr->stringValue();
  34. }
  35. if (passwordPtr && passwordPtr->getType() == Element::string) {
  36. password = passwordPtr->stringValue();
  37. }
  38. return 0;
  39. }
  40. } // end extern "C"