]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
line endings
authorMichael Jerris <mike@jerris.com>
Fri, 7 Nov 2008 23:47:01 +0000 (23:47 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 7 Nov 2008 23:47:01 +0000 (23:47 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10300 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_dso.c

index 70e3c5ba6f8f735792a38955289b8f209ee12ea6..2dc2910dbc70b466058c6ea3bee6e46f4e9b71b4 100644 (file)
-/* 
- * Cross Platform dso/dll load abstraction
- * Copyright(C) 2008 Michael Jerris
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so.
- *
- * This work is provided under this license on an "as is" basis, without warranty of any kind,
- * either expressed or implied, including, without limitation, warranties that the covered code
- * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire
- * risk as to the quality and performance of the covered code is with you. Should any covered
- * code prove defective in any respect, you (not the initial developer or any other contributor)
- * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty
- * constitutes an essential part of this license. No use of any covered code is authorized hereunder
- * except under this disclaimer. 
- *
- */
-
-#include <switch.h>
-#include "switch_dso.h"
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef WIN32
-
-void switch_dso_destroy(switch_dso_lib_t *lib) {
-       if (lib && *lib) {
-               FreeLibrary(*lib);
-               *lib = NULL;
-       }
-}
-
-switch_dso_lib_t switch_dso_open(const char *path, int global, char **err) {
+/* \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
+#include <switch.h>\r
+#include "switch_dso.h"\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#ifdef WIN32\r
+\r
+void switch_dso_destroy(switch_dso_lib_t *lib) {\r
+       if (lib && *lib) {\r
+               FreeLibrary(*lib);\r
+               *lib = NULL;\r
+       }\r
+}\r
+\r
+switch_dso_lib_t switch_dso_open(const char *path, int global, char **err) {\r
     HINSTANCE lib;\r
-       
-       lib = LoadLibraryEx(path, NULL, 0);
-
-       if (!lib) {
-               LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
-       }
-
-       if (!lib) {
-               DWORD error = GetLastError();
-               *err = switch_mprintf("dll open error [%ul]\n", error);
-       }
-
-       return lib;
-}
-
-switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {
-       FARPROC func = GetProcAddress(lib, sym);
-       if (!func) {
-               DWORD error = GetLastError();
-               *err = switch_mprintf("dll sym error [%ul]\n", error);
-       }
-       return (switch_dso_func_t)func;
-}
-
-void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {
-       FARPROC addr = GetProcAddress(lib, sym);
-       if (!addr) {
-               DWORD error = GetLastError();
-               *err = switch_mprintf("dll sym error [%ul]\n", error);
-       }
-       return (void *)(intptr_t)addr;
-}
-
-
-#else
-/*
-** {========================================================================
-** 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 switch_dso_destroy(switch_dso_lib_t *lib) {
-       if (lib && *lib) {
-               dlclose(*lib);
-               *lib = NULL;
-       }
-}
-
-switch_dso_lib_t switch_dso_open(const char *path, int global, char **err) {
-       void *lib;
-       
-       if (global) {
-               lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
-       } else {
-               lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
-       }
-
-       if (lib == NULL) {
-               *err = strdup(dlerror());
-       }
-       return lib;
-}
-
-switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {
-       void *func = dlsym(lib, sym);
-       if (!func) {
-               *err = strdup(dlerror());
-       }
-       return (switch_dso_func_t)(intptr_t)func;
-}
-
-void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {
-       void *addr = dlsym(lib, sym);
-       if (!addr) {
-               *err = strdup(dlerror());
-       }
-       return addr;
-}
-
-#endif
-/* }====================================================== */
-
-/* For Emacs:
- * Local Variables:
- * mode:c
- * indent-tabs-mode:t
- * tab-width:4
- * c-basic-offset:4
- * End:
- * For VIM:
- * vim:set softtabstop=4 shiftwidth=4 tabstop=4
- */
+       \r
+       lib = LoadLibraryEx(path, NULL, 0);\r
+\r
+       if (!lib) {\r
+               LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);\r
+       }\r
+\r
+       if (!lib) {\r
+               DWORD error = GetLastError();\r
+               *err = switch_mprintf("dll open error [%ul]\n", error);\r
+       }\r
+\r
+       return lib;\r
+}\r
+\r
+switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {\r
+       FARPROC func = GetProcAddress(lib, sym);\r
+       if (!func) {\r
+               DWORD error = GetLastError();\r
+               *err = switch_mprintf("dll sym error [%ul]\n", error);\r
+       }\r
+       return (switch_dso_func_t)func;\r
+}\r
+\r
+void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {\r
+       FARPROC addr = GetProcAddress(lib, sym);\r
+       if (!addr) {\r
+               DWORD error = GetLastError();\r
+               *err = switch_mprintf("dll sym error [%ul]\n", error);\r
+       }\r
+       return (void *)(intptr_t)addr;\r
+}\r
+\r
+\r
+#else\r
+/*\r
+** {========================================================================\r
+** This is an implementation of loadlib based on the dlfcn interface.\r
+** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD,\r
+** NetBSD, AIX 4.2, HPUX 11, and  probably most other Unix flavors, at least\r
+** as an emulation layer on top of native functions.\r
+** =========================================================================\r
+*/\r
+\r
+\r
+#include <dlfcn.h>\r
+\r
+void switch_dso_destroy(switch_dso_lib_t *lib) {\r
+       if (lib && *lib) {\r
+               dlclose(*lib);\r
+               *lib = NULL;\r
+       }\r
+}\r
+\r
+switch_dso_lib_t switch_dso_open(const char *path, int global, char **err) {\r
+       void *lib;\r
+       \r
+       if (global) {\r
+               lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);\r
+       } else {\r
+               lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);\r
+       }\r
+\r
+       if (lib == NULL) {\r
+               *err = strdup(dlerror());\r
+       }\r
+       return lib;\r
+}\r
+\r
+switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {\r
+       void *func = dlsym(lib, sym);\r
+       if (!func) {\r
+               *err = strdup(dlerror());\r
+       }\r
+       return (switch_dso_func_t)(intptr_t)func;\r
+}\r
+\r
+void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {\r
+       void *addr = dlsym(lib, sym);\r
+       if (!addr) {\r
+               *err = strdup(dlerror());\r
+       }\r
+       return addr;\r
+}\r
+\r
+#endif\r
+/* }====================================================== */\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