From: Russell Bryant <russell(a)russellbryant.net>
Change mh_os_dnssrv_lookup() to be an internal function and create a
wrapper around it. This makes it match the convention set by other core
code.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/include/matahari/dnssrv.h | 2 +-
src/lib/CMakeLists.txt | 2 +-
src/lib/dnssrv.c | 28 ++++++++++++++++++++++++++++
src/lib/dnssrv_private.h | 34 ++++++++++++++++++++++++++++++++++
src/lib/mh_agent.cpp | 2 +-
src/tests/mh_hsa_linux.h | 2 +-
6 files changed, 66 insertions(+), 4 deletions(-)
create mode 100644 src/lib/dnssrv.c
create mode 100644 src/lib/dnssrv_private.h
diff --git a/src/include/matahari/dnssrv.h b/src/include/matahari/dnssrv.h
index 58328e9..7d7a0c4 100644
--- a/src/include/matahari/dnssrv.h
+++ b/src/include/matahari/dnssrv.h
@@ -34,7 +34,7 @@
*
* \return buffer to hold domain retrieved
*/
-extern char *mh_os_dnssrv_lookup(const char *query);
+extern char *mh_dnssrv_lookup(const char *query);
#endif /* __MH_DNSSRV_H__ */
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 9dd1fbd..e130995 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -6,7 +6,7 @@ include_directories(${pcre_INCLUDE_DIRS})
# See
http://sourceware.org/autobook/autobook/autobook_91.html for
# how to set the library version appropriately
-add_library (mcommon SHARED utilities.c mainloop.c dnssrv_${VARIANT}.c)
+add_library (mcommon SHARED utilities.c mainloop.c dnssrv.c dnssrv_${VARIANT}.c)
set_target_properties(mcommon PROPERTIES SOVERSION 1.0.0)
target_link_libraries(mcommon ${SIGAR} ${glib_LIBRARIES})
diff --git a/src/lib/dnssrv.c b/src/lib/dnssrv.c
new file mode 100644
index 0000000..f3e095f
--- /dev/null
+++ b/src/lib/dnssrv.c
@@ -0,0 +1,28 @@
+/* dnssrv.c - Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef WIN32
+#include "config.h"
+#endif
+
+#include "dnssrv_private.h"
+
+char *
+mh_dnssrv_lookup(const char *query)
+{
+ return mh_os_dnssrv_lookup(query);
+}
diff --git a/src/lib/dnssrv_private.h b/src/lib/dnssrv_private.h
new file mode 100644
index 0000000..3f63ab7
--- /dev/null
+++ b/src/lib/dnssrv_private.h
@@ -0,0 +1,34 @@
+/* dnssrv_private.h - Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/**
+ * \file
+ * \brief Platform specific function prototypes.
+ *
+ * The functions in this header must be implemented by the platform
+ * specific host data code.
+ * - dnssrv_linux.c
+ * - dnssrv_windows.c
+ */
+
+#ifndef __MH_DNSSRV_PRIVATE_H__
+#define __MH_DNSSRV_PRIVATE_H__
+
+extern char *
+mh_os_dnssrv_lookup(const char *query);
+
+#endif /* __MH_DNSSRV_PRIVATE_H__ */
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index 871d1e4..cdea1c9 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -208,7 +208,7 @@ mh_connect(qpid::types::Variant::Map mh_options,
qpid::types::Variant::Map amqp_
/* Is _ssl valid here as a protocol? _udp? */
std::stringstream fqdn;
fqdn << "_matahari._tcp." << mh_domainname();
- target = mh_os_dnssrv_lookup(fqdn.str().c_str());
+ target = mh_dnssrv_lookup(fqdn.str().c_str());
if(target) {
mh_info("SRV record resolved to: %s", target);
diff --git a/src/tests/mh_hsa_linux.h b/src/tests/mh_hsa_linux.h
index 9305076..ee5f421 100644
--- a/src/tests/mh_hsa_linux.h
+++ b/src/tests/mh_hsa_linux.h
@@ -48,7 +48,7 @@ class MhHsaSuite : public CxxTest::TestSuite
char *target;
const char *host = "_matahari._tcp.matahariproject.org";
- target = mh_os_dnssrv_lookup(host);
+ target = mh_dnssrv_lookup(host);
TS_ASSERT(target != NULL);
TS_ASSERT((mh_test_is_match("^www\\.matahariproject\\.org$",
target)) >= 0);
--
1.7.6