[PATCH 05/30] Moved platform.c to linux/platform.c


Michael Schonberg <mschonberg@...>
 

The funcitons for accessing shared libraries in platform.c are os
dependent. This is in prepration for windows support.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 1 +
common/c_cpp/src/c/linux/platform.c | 85 +++++++++++++++++++++++++++++++++++
common/c_cpp/src/c/platform.c | 85 -----------------------------------
3 files changed, 86 insertions(+), 85 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/platform.c
delete mode 100644 common/c_cpp/src/c/platform.c

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index 31e78fc..dfd450b 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -48,6 +48,7 @@ AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
src/c/machine_port.c:src/c/linux/machine.c
+ src/c/platform.c:src/c/linux/platform.c
src/c/environment.c:src/c/linux/environment.c]) ;;
esac

diff --git a/common/c_cpp/src/c/linux/platform.c b/common/c_cpp/src/c/linux/platform.c
new file mode 100644
index 0000000..8bf7f4e
--- /dev/null
+++ b/common/c_cpp/src/c/linux/platform.c
@@ -0,0 +1,85 @@
+/* $Id: platform.c,v 1.8.16.2 2011/08/10 14:53:24 nicholasmarriott Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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 library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "platform.h"
+#include "wombat/wincompat.h"
+
+/**
+ * Functions relating to DLLs/shared objects
+ */
+char errorBuf[25];
+LIB_HANDLE openSharedLib (const char* libName, const char* path)
+{
+ size_t nameLength;
+ char* fileName;
+ LIB_HANDLE handle;
+
+ if (path)
+ {
+ nameLength = strlen(path) + strlen(libName) + strlen(LIB_EXTENSION) +
+ strlen(PATHSEP) + strlen("lib") + 1;
+ }
+ else
+ {
+ nameLength = strlen(libName) + strlen(LIB_EXTENSION) + strlen("lib") + 1;
+ }
+ fileName = (char*) calloc (nameLength, sizeof (char));
+ if(fileName == NULL)
+ {
+ return 0;
+ }
+
+ if (path)
+ {
+ snprintf (fileName, nameLength, "%s%slib%s%s", path, PATHSEP, libName, LIB_EXTENSION);
+ }
+ else
+ {
+ snprintf (fileName, nameLength, "lib%s%s", libName, LIB_EXTENSION);
+ }
+
+ handle = dlopen (fileName, RTLD_NOW | RTLD_GLOBAL);
+
+ free(fileName);
+ return handle;
+}
+
+
+int closeSharedLib (LIB_HANDLE handle)
+{
+ return dlclose (handle);
+}
+
+void* loadLibFunc (LIB_HANDLE handle, const char* funcName)
+{
+ return dlsym (handle, funcName);
+}
+
+char* getLibError (void)
+{
+ return dlerror();
+}
diff --git a/common/c_cpp/src/c/platform.c b/common/c_cpp/src/c/platform.c
deleted file mode 100644
index 8bf7f4e..0000000
--- a/common/c_cpp/src/c/platform.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $Id: platform.c,v 1.8.16.2 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
- * OpenMAMA: The open middleware agnostic messaging API
- * Copyright (C) 2011 NYSE Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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 library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include "port.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-
-#include "platform.h"
-#include "wombat/wincompat.h"
-
-/**
- * Functions relating to DLLs/shared objects
- */
-char errorBuf[25];
-LIB_HANDLE openSharedLib (const char* libName, const char* path)
-{
- size_t nameLength;
- char* fileName;
- LIB_HANDLE handle;
-
- if (path)
- {
- nameLength = strlen(path) + strlen(libName) + strlen(LIB_EXTENSION) +
- strlen(PATHSEP) + strlen("lib") + 1;
- }
- else
- {
- nameLength = strlen(libName) + strlen(LIB_EXTENSION) + strlen("lib") + 1;
- }
- fileName = (char*) calloc (nameLength, sizeof (char));
- if(fileName == NULL)
- {
- return 0;
- }
-
- if (path)
- {
- snprintf (fileName, nameLength, "%s%slib%s%s", path, PATHSEP, libName, LIB_EXTENSION);
- }
- else
- {
- snprintf (fileName, nameLength, "lib%s%s", libName, LIB_EXTENSION);
- }
-
- handle = dlopen (fileName, RTLD_NOW | RTLD_GLOBAL);
-
- free(fileName);
- return handle;
-}
-
-
-int closeSharedLib (LIB_HANDLE handle)
-{
- return dlclose (handle);
-}
-
-void* loadLibFunc (LIB_HANDLE handle, const char* funcName)
-{
- return dlsym (handle, funcName);
-}
-
-char* getLibError (void)
-{
- return dlerror();
-}
--
1.7.7.6