]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add start of zap_dso abstraction
authorMichael Jerris <mike@jerris.com>
Wed, 27 Aug 2008 17:51:05 +0000 (17:51 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 27 Aug 2008 17:51:05 +0000 (17:51 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@514 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/msvc/openzap.vcproj
libs/openzap/src/include/zap_dso.h [new file with mode: 0644]
libs/openzap/src/zap_dso.c [new file with mode: 0644]

index 10c7e5a912f12f9d8af8090b53b218cd7f62ce54..c3af23614fd2188be72ebc0ccc7386f36da7964d 100644 (file)
@@ -42,7 +42,7 @@
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
                                AdditionalIncludeDirectories="../src/include;../src/isdn/include"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                AdditionalIncludeDirectories="../src/include;../src/isdn/include"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"\r
                                RuntimeLibrary="2"\r
                                DisableLanguageExtensions="false"\r
                                RuntimeTypeInfo="false"\r
                                        RelativePath="..\src\zap_config.c"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\src\zap_dso.c"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\src\zap_io.c"\r
                                        >\r
                                        RelativePath="..\src\include\zap_config.h"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\src\include\zap_dso.h"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\src\include\zap_threadmutex.h"\r
                                        >\r
diff --git a/libs/openzap/src/include/zap_dso.h b/libs/openzap/src/include/zap_dso.h
new file mode 100644 (file)
index 0000000..e4337e6
--- /dev/null
@@ -0,0 +1,44 @@
+/* \r
+ * Cross Platform dso/dll load abstraction\r
+ * Copyright(C) 2008 Michael Jerris\r
+ *\r
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
+ * copies of the Software, and permit persons to whom the Software is\r
+ * furnished to do so.\r
+ *\r
+ * This work is provided under this license on an "as is" basis, without warranty of any kind,\r
+ * either expressed or implied, including, without limitation, warranties that the covered code\r
+ * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire\r
+ * risk as to the quality and performance of the covered code is with you. Should any covered\r
+ * code prove defective in any respect, you (not the initial developer or any other contributor)\r
+ * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty\r
+ * constitutes an essential part of this license. No use of any covered code is authorized hereunder\r
+ * except under this disclaimer. \r
+ *\r
+ */\r
+\r
+\r
+#ifndef _ZAP_DSO_H\r
+#define _ZAP_DSO_H\r
+
+typedef void (*zap_func_ptr_t) (void);
+typedef void * zap_dso_lib_t;
+
+void zap_dso_destroy(zap_dso_lib_t *lib);
+zap_dso_lib_t zap_dso_open(const char *path, const char **err);
+zap_func_ptr_t zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, const char **err);
+
+
+#endif\r
+\r
+/* For Emacs:\r
+ * Local Variables:\r
+ * mode:c\r
+ * indent-tabs-mode:t\r
+ * tab-width:4\r
+ * c-basic-offset:4\r
+ * End:\r
+ * For VIM:\r
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4\r
+ */\r
+\r
diff --git a/libs/openzap/src/zap_dso.c b/libs/openzap/src/zap_dso.c
new file mode 100644 (file)
index 0000000..cbcc591
--- /dev/null
@@ -0,0 +1,66 @@
+/* \r
+ * Cross Platform dso/dll load abstraction\r
+ * Copyright(C) 2008 Michael Jerris\r
+ *\r
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
+ * copies of the Software, and permit persons to whom the Software is\r
+ * furnished to do so.\r
+ *\r
+ * This work is provided under this license on an "as is" basis, without warranty of any kind,\r
+ * either expressed or implied, including, without limitation, warranties that the covered code\r
+ * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire\r
+ * risk as to the quality and performance of the covered code is with you. Should any covered\r
+ * code prove defective in any respect, you (not the initial developer or any other contributor)\r
+ * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty\r
+ * constitutes an essential part of this license. No use of any covered code is authorized hereunder\r
+ * except under this disclaimer. \r
+ *\r
+ */\r
+
+
+/*
+** {========================================================================
+** This is an implementation of loadlib based on the dlfcn interface.
+** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,
+** NetBSD, AIX 4.2, HPUX 11, and  probably most other Unix flavors, at least
+** as an emulation layer on top of native functions.
+** =========================================================================
+*/
+
+#include <dlfcn.h>
+
+void zap_dso_destroy(zap_dso_lib_t *lib) {
+       if (lib) {
+               dlclose(lib);
+               lib = NULL;
+       }
+}
+
+zap_dso_lib_t zap_dso_open(const char *path, const char **err) {
+       void *lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
+       if (lib == NULL) {
+               *err = strdup(dlerror());
+       }
+       return lib;
+}
+
+zap_func_ptr_t zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, const char **err) {
+       zap_dso_lib_t func = (zap_dso_lib_t)dlsym(lib, sym);
+       if (!func) {
+               *err = strdup(dlerror());
+       }
+       return func;
+}
+
+/* }====================================================== */
+\r
+/* For Emacs:\r
+ * Local Variables:\r
+ * mode:c\r
+ * indent-tabs-mode:t\r
+ * tab-width:4\r
+ * c-basic-offset:4\r
+ * End:\r
+ * For VIM:\r
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4\r
+ */\r