Add config options

Obtain the DBus service name prefix and sensors namespace
root path from the configure script.

Change-Id: I5c48882b62b09a466b3b7b30b3935d65ccc58326
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/configure.ac b/configure.ac
index aee00f0..845b186 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,13 @@
     AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
 )
 
+AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.])
+AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.])
+AS_IF([test "x$BUSNAME_PREFIX" == "x"], [BUSNAME_PREFIX="xyz.openbmc_project.Hwmon"])
+AS_IF([test "x$SENSOR_ROOT" == "x"], [SENSOR_ROOT="/xyz/openbmc_project/Sensors"])
+AC_DEFINE_UNQUOTED([BUSNAME_PREFIX], ["$BUSNAME_PREFIX"], [The DBus busname prefix.])
+AC_DEFINE_UNQUOTED([SENSOR_ROOT], ["$SENSOR_ROOT"], [The DBus sensors namespace root.])
+
 # Create configured output
 AC_CONFIG_FILES([Makefile test/Makefile])
 AC_OUTPUT
diff --git a/mainloop.cpp b/mainloop.cpp
index 012b993..8d34b18 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -22,8 +22,14 @@
 #include "sysfs.hpp"
 #include "mainloop.hpp"
 
-MainLoop::MainLoop(const std::string& path)
-    : _shutdown(false), _path(path)
+MainLoop::MainLoop(
+    const std::string& path,
+    const char* prefix,
+    const char* root)
+    : _shutdown(false),
+      _path(path),
+      _prefix(prefix),
+      _root(root)
 {
 
 }
diff --git a/mainloop.hpp b/mainloop.hpp
index 4bc08c4..2d2cea2 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -18,8 +18,19 @@
         /** @brief Constructor
          *
          *  @param[in] path - hwmon sysfs instance to manage
+         *  @param[in] prefix - DBus busname prefix.
+         *  @param[in] root - DBus sensors namespace root.
+         *
+         *  Any DBus objects are created relative to the DBus
+         *  sensors namespace root.
+         *
+         *  At startup, the application will own a busname with
+         *  the format <prefix>.hwmon<n>.
          */
-        explicit MainLoop(const std::string& path);
+        MainLoop(
+            const std::string& path,
+            const char* prefix,
+            const char* root);
 
         /** @brief Start polling loop and process dbus traffic. */
         void run();
@@ -36,4 +47,8 @@
         volatile bool _shutdown;
         /** @brief Path to hwmon sysfs instance. */
         std::string _path;
+        /** @brief DBus busname prefix. */
+        const char* _prefix;
+        /** @brief DBus sensors namespace root. */
+        const char* _root;
 };
diff --git a/readd.cpp b/readd.cpp
index 0c611b6..d8ad098 100644
--- a/readd.cpp
+++ b/readd.cpp
@@ -17,6 +17,7 @@
 #include <memory>
 #include "argument.hpp"
 #include "mainloop.hpp"
+#include "config.h"
 
 static void exit_with_error(const char* err, char** argv)
 {
@@ -41,7 +42,10 @@
     // Finished getting options out, so cleanup the parser.
     options.reset();
 
-    MainLoop loop(path);
+    MainLoop loop(
+        path,
+        BUSNAME_PREFIX,
+        SENSOR_ROOT);
     loop.run();
 
     return 0;
diff --git a/test/test.cpp b/test/test.cpp
index cf2fb37..df9ed22 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -43,7 +43,9 @@
     std::ofstream f{entry};
     f << "1234";
 
-    auto loop = MainLoop(dir);
+    auto loop = MainLoop(
+                    dir,
+                    "xyz.openbmc_project.Testing", "/testing");
     auto t = std::thread(server_thread, &loop);
 
     runTests(loop);