<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>cplgetsymbol.cpp Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.3-20001105 on Thu Mar 28 09:47:28 2002 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>cplgetsymbol.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font> 00002 <font class="comment"> * $Id: cplgetsymbol_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $</font> 00003 <font class="comment"> *</font> 00004 <font class="comment"> * Project: Common Portability Library</font> 00005 <font class="comment"> * Purpose: Fetch a function pointer from a shared library / DLL.</font> 00006 <font class="comment"> * Author: Frank Warmerdam, warmerda@home.com</font> 00007 <font class="comment"> *</font> 00008 <font class="comment"> ******************************************************************************</font> 00009 <font class="comment"> * Copyright (c) 1999, Frank Warmerdam</font> 00010 <font class="comment"> *</font> 00011 <font class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</font> 00012 <font class="comment"> * copy of this software and associated documentation files (the "Software"),</font> 00013 <font class="comment"> * to deal in the Software without restriction, including without limitation</font> 00014 <font class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</font> 00015 <font class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</font> 00016 <font class="comment"> * Software is furnished to do so, subject to the following conditions:</font> 00017 <font class="comment"> *</font> 00018 <font class="comment"> * The above copyright notice and this permission notice shall be included</font> 00019 <font class="comment"> * in all copies or substantial portions of the Software.</font> 00020 <font class="comment"> *</font> 00021 <font class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</font> 00022 <font class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</font> 00023 <font class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</font> 00024 <font class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</font> 00025 <font class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</font> 00026 <font class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</font> 00027 <font class="comment"> * DEALINGS IN THE SOFTWARE.</font> 00028 <font class="comment"> ******************************************************************************</font> 00029 <font class="comment"> *</font> 00030 <font class="comment"> * $Log: cplgetsymbol_cpp-source.html,v $ 00030 <font class="comment"> * Revision 1.10 2002/04/16 13:11:48 warmerda 00030 <font class="comment"> * updated 00030 <font class="comment"> *</font> 00031 <font class="comment"> * Revision 1.11 2001/07/18 04:00:49 warmerda</font> 00032 <font class="comment"> * added CPL_CVSID</font> 00033 <font class="comment"> *</font> 00034 <font class="comment"> * Revision 1.10 2001/01/19 21:16:41 warmerda</font> 00035 <font class="comment"> * expanded tabs</font> 00036 <font class="comment"> *</font> 00037 <font class="comment"> * Revision 1.9 2000/09/25 19:59:03 warmerda</font> 00038 <font class="comment"> * look for WIN32 not _WIN32</font> 00039 <font class="comment"> *</font> 00040 <font class="comment"> * Revision 1.8 1999/05/20 02:54:38 warmerda</font> 00041 <font class="comment"> * Added API documentation</font> 00042 <font class="comment"> *</font> 00043 <font class="comment"> * Revision 1.7 1999/04/23 13:56:36 warmerda</font> 00044 <font class="comment"> * added stub implementation. Don't check for __unix__</font> 00045 <font class="comment"> *</font> 00046 <font class="comment"> * Revision 1.6 1999/04/21 20:06:05 warmerda</font> 00047 <font class="comment"> * Removed incorrect comment.</font> 00048 <font class="comment"> *</font> 00049 <font class="comment"> * Revision 1.5 1999/03/02 21:20:00 warmerda</font> 00050 <font class="comment"> * test for dlfcn.h, not -ldl</font> 00051 <font class="comment"> *</font> 00052 <font class="comment"> * Revision 1.4 1999/03/02 21:08:11 warmerda</font> 00053 <font class="comment"> * autoconf switch</font> 00054 <font class="comment"> *</font> 00055 <font class="comment"> * Revision 1.3 1999/01/28 18:35:44 warmerda</font> 00056 <font class="comment"> * minor windows cleanup.</font> 00057 <font class="comment"> *</font> 00058 <font class="comment"> * Revision 1.2 1999/01/27 20:16:03 warmerda</font> 00059 <font class="comment"> * Added windows implementation.</font> 00060 <font class="comment"> *</font> 00061 <font class="comment"> * Revision 1.1 1999/01/11 15:34:57 warmerda</font> 00062 <font class="comment"> * New</font> 00063 <font class="comment"> *</font> 00064 <font class="comment"> */</font> 00065 00066 <font class="preprocessor">#include "<a class="code" href="cpl_conv_h.html">cpl_conv.h</a>"</font> 00067 00068 CPL_CVSID(<font class="stringliteral">"$Id: cplgetsymbol_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $"</font>); 00069 00070 <font class="comment">/* ==================================================================== */</font> 00071 <font class="comment">/* Unix Implementation */</font> 00072 <font class="comment">/* ==================================================================== */</font> 00073 <font class="preprocessor">#if defined(HAVE_DLFCN_H)</font> 00074 <font class="preprocessor"></font> 00075 <font class="preprocessor">#define GOT_GETSYMBOL</font> 00076 <font class="preprocessor"></font> 00077 <font class="preprocessor">#include <dlfcn.h></font> 00078 00079 <font class="comment">/************************************************************************/</font> 00080 <font class="comment">/* CPLGetSymbol() */</font> 00081 <font class="comment">/************************************************************************/</font> 00082 00116 <font class="keywordtype">void</font> *<a class="code" href="cpl_conv_h.html#a8">CPLGetSymbol</a>( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszLibrary, <font class="keyword">const</font> <font class="keywordtype">char</font> * pszSymbolName )<font class="keyword"></font> 00117 <font class="keyword"></font> 00118 <font class="keyword"></font>{ 00119 <font class="keywordtype">void</font> *pLibrary; 00120 <font class="keywordtype">void</font> *pSymbol; 00121 00122 pLibrary = dlopen(pszLibrary, RTLD_LAZY); 00123 <font class="keywordflow">if</font>( pLibrary == NULL ) 00124 { 00125 <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_AppDefined, 00126 <font class="stringliteral">"%s"</font>, dlerror() ); 00127 <font class="keywordflow">return</font> NULL; 00128 } 00129 00130 pSymbol = dlsym( pLibrary, pszSymbolName ); 00131 00132 <font class="keywordflow">if</font>( pSymbol == NULL ) 00133 { 00134 <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_AppDefined, 00135 <font class="stringliteral">"%s"</font>, dlerror() ); 00136 <font class="keywordflow">return</font> NULL; 00137 } 00138 00139 <font class="keywordflow">return</font>( pSymbol ); 00140 } 00141 00142 <font class="preprocessor">#endif </font><font class="comment">/* def __unix__ && defined(HAVE_DLFCN_H) */</font> 00143 00144 <font class="comment">/* ==================================================================== */</font> 00145 <font class="comment">/* Windows Implementation */</font> 00146 <font class="comment">/* ==================================================================== */</font> 00147 <font class="preprocessor">#ifdef WIN32</font> 00148 <font class="preprocessor"></font> 00149 <font class="preprocessor">#define GOT_GETSYMBOL</font> 00150 <font class="preprocessor"></font> 00151 <font class="preprocessor">#include <windows.h></font> 00152 00153 <font class="comment">/************************************************************************/</font> 00154 <font class="comment">/* CPLGetSymbol() */</font> 00155 <font class="comment">/************************************************************************/</font> 00156 00157 <font class="keywordtype">void</font> *<a class="code" href="cpl_conv_h.html#a8">CPLGetSymbol</a>( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszLibrary, <font class="keyword">const</font> <font class="keywordtype">char</font> * pszSymbolName )<font class="keyword"></font> 00158 <font class="keyword"></font> 00159 <font class="keyword"></font>{ 00160 <font class="keywordtype">void</font> *pLibrary; 00161 <font class="keywordtype">void</font> *pSymbol; 00162 00163 pLibrary = LoadLibrary(pszLibrary); 00164 <font class="keywordflow">if</font>( pLibrary == NULL ) 00165 { 00166 <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_AppDefined, 00167 <font class="stringliteral">"Can't load requested DLL: %s"</font>, pszLibrary ); 00168 <font class="keywordflow">return</font> NULL; 00169 } 00170 00171 pSymbol = GetProcAddress( (HINSTANCE) pLibrary, pszSymbolName ); 00172 00173 <font class="keywordflow">if</font>( pSymbol == NULL ) 00174 { 00175 <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_AppDefined, 00176 <font class="stringliteral">"Can't find requested entry point: %s\n"</font>, pszSymbolName ); 00177 <font class="keywordflow">return</font> NULL; 00178 } 00179 00180 <font class="keywordflow">return</font>( pSymbol ); 00181 } 00182 00183 <font class="preprocessor">#endif </font><font class="comment">/* def _WIN32 */</font> 00184 00185 <font class="comment">/* ==================================================================== */</font> 00186 <font class="comment">/* Dummy implementation. */</font> 00187 <font class="comment">/* ==================================================================== */</font> 00188 00189 <font class="preprocessor">#ifndef GOT_GETSYMBOL</font> 00190 <font class="preprocessor"></font> 00191 <font class="comment">/************************************************************************/</font> 00192 <font class="comment">/* CPLGetSymbol() */</font> 00193 <font class="comment">/* */</font> 00194 <font class="comment">/* Dummy implementation. */</font> 00195 <font class="comment">/************************************************************************/</font> 00196 00197 <font class="keywordtype">void</font> *<a class="code" href="cpl_conv_h.html#a8">CPLGetSymbol</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *, <font class="keyword">const</font> <font class="keywordtype">char</font> *)<font class="keyword"></font> 00198 <font class="keyword"></font> 00199 <font class="keyword"></font>{ 00200 <font class="keywordflow">return</font> NULL; 00201 } 00202 <font class="preprocessor">#endif</font> </font></div></pre><hr><address><small>Generated at Thu Mar 28 09:47:28 2002 for GDAL by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img src="doxygen.gif" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.3-20001105 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2000</small></address> </body> </html>