SharedLibrary_VMS.cpp
Go to the documentation of this file.
00001 //
00002 // SharedLibrary_VMS.cpp
00003 //
00004 // $Id: //poco/1.3/Foundation/src/SharedLibrary_VMS.cpp#1 $
00005 //
00006 // Library: Foundation
00007 // Package: SharedLibrary
00008 // Module:  SharedLibrary
00009 //
00010 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00011 // and Contributors.
00012 //
00013 // Permission is hereby granted, free of charge, to any person or organization
00014 // obtaining a copy of the software and accompanying documentation covered by
00015 // this license (the "Software") to use, reproduce, display, distribute,
00016 // execute, and transmit the Software, and to prepare derivative works of the
00017 // Software, and to permit third-parties to whom the Software is furnished to
00018 // do so, all subject to the following:
00019 // 
00020 // The copyright notices in the Software and this entire statement, including
00021 // the above license grant, this restriction and the following disclaimer,
00022 // must be included in all copies of the Software, in whole or in part, and
00023 // all derivative works of the Software, unless such copies or derivative
00024 // works are solely in the form of machine-executable object code generated by
00025 // a source language processor.
00026 // 
00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00033 // DEALINGS IN THE SOFTWARE.
00034 //
00035 
00036 
00037 #include "Poco/SharedLibrary_VMS.h"
00038 #include "Poco/Path.h"
00039 #include <lib$routines.h>
00040 #include <libdef.h>
00041 #include <descrip.h>
00042 #include <chfdef.h>
00043 #include <libfisdef.h>
00044 
00045 
00046 namespace Poco {
00047 
00048 
00049 FastMutex SharedLibraryImpl::_mutex;
00050 
00051 
00052 SharedLibraryImpl::SharedLibraryImpl()
00053 {
00054 }
00055 
00056 
00057 SharedLibraryImpl::~SharedLibraryImpl()
00058 {
00059 }
00060 
00061 
00062 void SharedLibraryImpl::loadImpl(const std::string& path)
00063 {
00064         FastMutex::ScopedLock lock(_mutex);
00065 
00066         if (!_path.empty()) throw LibraryAlreadyLoadedException(path);
00067         _path = path;
00068 }
00069 
00070 
00071 void SharedLibraryImpl::unloadImpl()
00072 {
00073         _path.clear();
00074 }
00075 
00076 
00077 bool SharedLibraryImpl::isLoadedImpl() const
00078 {
00079         return !_path.empty();
00080 }
00081 
00082 
00083 void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
00084 {
00085         FastMutex::ScopedLock lock(_mutex);
00086 
00087         if (_path.empty()) return NULL;
00088 
00089         Path p(_path);
00090         std::string filename = p.getBaseName();
00091         std::string ext = p.getExtension();
00092         std::string imageSpec = p.makeParent().toString();
00093         if (!imageSpec.empty() && !ext.empty())
00094         {
00095                 imageSpec.append(".");
00096                 imageSpec.append(ext);
00097         }
00098         int value = 0;
00099         long flags = LIB$M_FIS_MIXEDCASE;
00100         POCO_DESCRIPTOR_STRING(filenameDsc, filename);
00101         POCO_DESCRIPTOR_STRING(symbolDsc, name);
00102         POCO_DESCRIPTOR_STRING(imageSpecDsc, imageSpec);
00103 
00104         try
00105         {
00106                 // lib$find_image_symbol only accepts 32-bit pointers
00107                 #pragma pointer_size save
00108                 #pragma pointer_size 32
00109                 lib$find_image_symbol(&filenameDsc, &symbolDsc, &value, imageSpec.empty() ? 0 : &imageSpecDsc, flags);
00110                 #pragma pointer_size restore
00111         }
00112         catch (struct chf$signal_array& sigarr)
00113         {
00114                 unsigned sig = sigarr.chf$is_sig_name;
00115                 unsigned act = LIB$_ACTIMAGE;
00116                 if (lib$match_cond(&sig, &act)) 
00117                         throw LibraryLoadException(_path);
00118         }
00119         return (void*) value;
00120 }
00121 
00122 
00123 const std::string& SharedLibraryImpl::getPathImpl() const
00124 {
00125         return _path;
00126 }
00127 
00128 
00129 std::string SharedLibraryImpl::suffixImpl()
00130 {
00131 #if defined(_DEBUG)
00132         return "d.exe";
00133 #else
00134         return ".exe";
00135 #endif
00136 }
00137 
00138 
00139 } // namespace Poco


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19