forked from Mirrors/freeswitch
add start of zap_dso abstraction
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@514 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
d36e174cda
commit
b5a23ffa69
@ -42,7 +42,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../src/include;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
@ -110,7 +110,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../src/include;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
DisableLanguageExtensions="false"
|
||||
RuntimeTypeInfo="false"
|
||||
@ -471,6 +471,10 @@
|
||||
RelativePath="..\src\zap_config.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\zap_dso.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\zap_io.c"
|
||||
>
|
||||
@ -533,6 +537,10 @@
|
||||
RelativePath="..\src\include\zap_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\zap_dso.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\include\zap_threadmutex.h"
|
||||
>
|
||||
|
44
libs/freetdm/src/include/zap_dso.h
Normal file
44
libs/freetdm/src/include/zap_dso.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ZAP_DSO_H
|
||||
#define _ZAP_DSO_H
|
||||
|
||||
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
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
66
libs/freetdm/src/zap_dso.c
Normal file
66
libs/freetdm/src/zap_dso.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** {========================================================================
|
||||
** 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;
|
||||
}
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
/* 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
|
||||
*/
|
Loading…
Reference in New Issue
Block a user