PLplot  5.10.0
ltdl_win32.c
Go to the documentation of this file.
00001 //      Contains all prototypes for driver functions.
00002 //
00003 //  Copyright (C) 2008  Werner Smekal
00004 //
00005 //  This file is part of PLplot.
00006 //
00007 //  PLplot is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Library General Public License as published
00009 //  by the Free Software Foundation; either version 2 of the License, or
00010 //  (at your option) any later version.
00011 //
00012 //  PLplot is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Library General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Library General Public License
00018 //  along with PLplot; if not, write to the Free Software
00019 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020 //
00021 //
00022 
00027 
00028 #include <windows.h>
00029 #include <stdlib.h>
00030 #include "ltdl_win32.h"
00031 
00032 // (static) pointer to the last handle, which contains a pointer
00033 // to a possible previous handle
00034 lt_dlhandle lastHandle = NULL;
00035 
00036 // buffer for error messages
00037 char errortext[512];
00038 
00039 
00042 void lt_dlinit( void )
00043 {
00044     lastHandle = NULL;
00045 }
00046 
00047 
00050 void lt_dlexit( void )
00051 {
00052     lt_dlhandle prev;
00053 
00054     while ( lastHandle != NULL )
00055     {
00056         if ( lastHandle->hinstLib )
00057             FreeLibrary( lastHandle->hinstLib );
00058         prev = lastHandle->previousHandle;
00059         free( lastHandle );
00060         lastHandle = prev;
00061     }
00062 }
00063 
00064 
00073 lt_dlhandle lt_dlopenext( char* dllname )
00074 {
00075     lt_dlhandle dlhandle = malloc( sizeof ( struct __dlhandle ) );
00076     memset( dlhandle, '\0', sizeof ( struct __dlhandle ) );
00077 
00078     dlhandle->hinstLib = LoadLibrary( dllname );
00079     if ( !dlhandle->hinstLib )
00080     {
00081         free( dlhandle );
00082         return NULL;
00083     }
00084 
00085     dlhandle->previousHandle = lastHandle;
00086     lastHandle = dlhandle;
00087 
00088     return dlhandle;
00089 }
00090 
00091 
00096 const char* lt_dlerror()
00097 {
00098     strncpy( errortext, "No error information", 512 );
00099 
00100     return errortext;
00101 }
00102 
00103 
00111 void* lt_dlsym( lt_dlhandle dlhandle, const char* symbol )
00112 {
00113     if ( dlhandle->hinstLib )
00114     {
00115 #ifdef __BORLANDC__
00116         unsigned int bufferLength = strlen( symbol ) + 2;
00117         char         * buffer     = (char *) malloc( bufferLength );
00118         void         * retPointer;
00119 
00120         buffer[0] = '_';
00121         strncpy( &buffer[1], symbol, bufferLength - 2 );
00122         buffer[bufferLength - 1] = '\0';
00123         retPointer = GetProcAddress( dlhandle->hinstLib, buffer );
00124         free( buffer );
00125         return retPointer;
00126 #else
00127         return GetProcAddress( dlhandle->hinstLib, symbol );
00128 #endif
00129     }
00130     else
00131         return NULL;
00132 }
00133 
00140 int lt_dlmakeresident( lt_dlhandle handle )
00141 {
00142     return 0;
00143 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines