2015-12-13 21:45:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-01-31 02:21:12 +00:00
|
|
|
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2021-07-18 14:06:48 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-13 21:45:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2016-02-23 06:46:22 +00:00
|
|
|
#include <sstream>
|
2016-01-11 04:47:08 +00:00
|
|
|
#include <wx/dynload.h>
|
2016-02-23 06:46:22 +00:00
|
|
|
#include <wx/log.h>
|
2016-01-12 07:03:17 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/translation.h>
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
#include "pluginldr.h"
|
|
|
|
|
|
|
|
|
|
|
|
KICAD_PLUGIN_LDR::KICAD_PLUGIN_LDR()
|
|
|
|
{
|
|
|
|
ok = false;
|
2021-07-18 14:06:48 +00:00
|
|
|
m_getPluginClass = nullptr;
|
|
|
|
m_getClassVersion = nullptr;
|
|
|
|
m_checkClassVersion = nullptr;
|
|
|
|
m_getPluginName = nullptr;
|
|
|
|
m_getVersion = nullptr;
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KICAD_PLUGIN_LDR::~KICAD_PLUGIN_LDR()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginClass )
|
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( ok )
|
|
|
|
Close();
|
|
|
|
|
|
|
|
if( aFullFileName.empty() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_fileName.clear();
|
|
|
|
|
2016-01-11 04:47:08 +00:00
|
|
|
m_PluginLoader.Load( aFullFileName, wxDL_LAZY );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2016-01-11 04:47:08 +00:00
|
|
|
if( !m_PluginLoader.IsLoaded() )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * could not open file: '" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2015-12-13 21:45:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
LINK_ITEM( m_getPluginClass, GET_PLUGIN_CLASS, "GetKicadPluginClass" );
|
|
|
|
LINK_ITEM( m_getClassVersion, GET_CLASS_VERSION, "GetClassVersion" );
|
|
|
|
LINK_ITEM( m_checkClassVersion, CHECK_CLASS_VERSION , "CheckClassVersion" );
|
|
|
|
LINK_ITEM( m_getPluginName, GET_PLUGIN_NAME, "GetKicadPluginName" );
|
2015-12-15 07:53:03 +00:00
|
|
|
LINK_ITEM( m_getVersion, GET_VERSION, "GetPluginVersion" );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool fail = false;
|
|
|
|
|
|
|
|
if( !m_getPluginClass )
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginClass')";
|
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
fail = true;
|
|
|
|
}
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( !m_getClassVersion )
|
|
|
|
{
|
|
|
|
if( !fail )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
2021-07-18 14:06:48 +00:00
|
|
|
wxString errmsg = "incompatible plugin (missing function 'GetClassVersion')";
|
2016-02-23 06:46:22 +00:00
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2015-12-13 21:45:22 +00:00
|
|
|
fail = true;
|
|
|
|
}
|
2021-07-18 14:06:48 +00:00
|
|
|
else
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
wxString errmsg = "missing function 'GetClassVersion'";
|
|
|
|
ostr << errmsg.ToUTF8();
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
2021-07-18 14:06:48 +00:00
|
|
|
}
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( !m_checkClassVersion )
|
|
|
|
{
|
|
|
|
if( !fail )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
wxString errmsg = "incompatible plugin (missing function 'CheckClassVersion')";
|
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
fail = true;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
2021-07-18 14:06:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
wxString errmsg = "missing function 'CheckClassVersion'";
|
|
|
|
ostr << errmsg.ToUTF8();
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( !m_getPluginName )
|
|
|
|
{
|
|
|
|
if( !fail )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginName')";
|
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
fail = true;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
2021-07-18 14:06:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
wxString errmsg = "missing function 'GetKicadPluginName'";
|
|
|
|
ostr << errmsg.ToUTF8();
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( !m_getVersion )
|
|
|
|
{
|
|
|
|
if( !fail )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
wxString errmsg = "incompatible plugin (missing function 'GetVersion')";
|
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
wxString errmsg = "missing function 'GetVersion'";
|
|
|
|
ostr << errmsg.ToUTF8() << "\n";
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
2021-07-18 14:06:48 +00:00
|
|
|
}
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
if( !m_getPluginClass || !m_getClassVersion || !m_checkClassVersion
|
|
|
|
|| !m_getPluginName || !m_getVersion )
|
|
|
|
{
|
|
|
|
m_error = "incompatible plugin interface (missing functions)";
|
|
|
|
close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// note: since 'ok' is not yet set at this point we must use the function
|
|
|
|
// pointers directly rather than invoking the functions exposed by this class
|
|
|
|
|
|
|
|
// check that the Plugin Class matches
|
|
|
|
char const* pclassName = m_getPluginClass();
|
|
|
|
|
|
|
|
if( !pclassName || strcmp( aPluginClass, pclassName ) )
|
|
|
|
{
|
|
|
|
m_error = "Loader type (";
|
|
|
|
m_error.append( aPluginClass );
|
|
|
|
m_error.append( ") does not match Plugin type (" );
|
|
|
|
|
|
|
|
if( pclassName )
|
|
|
|
m_error.append( pclassName );
|
|
|
|
else
|
2021-07-18 14:06:48 +00:00
|
|
|
m_error.append( "nullptr" );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
m_error.append( ")" );
|
|
|
|
|
|
|
|
close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// perform a universally enforced version check (major number must match)
|
|
|
|
unsigned char lMajor;
|
|
|
|
unsigned char lMinor;
|
|
|
|
unsigned char lPatch;
|
2015-12-14 03:51:28 +00:00
|
|
|
unsigned char lRevno;
|
2015-12-13 21:45:22 +00:00
|
|
|
unsigned char pMajor;
|
|
|
|
unsigned char pMinor;
|
|
|
|
unsigned char pPatch;
|
2015-12-14 03:51:28 +00:00
|
|
|
unsigned char pRevno;
|
2015-12-13 21:45:22 +00:00
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
m_getClassVersion( &pMajor, &pMinor, &pPatch, &pRevno );
|
|
|
|
GetLoaderVersion( &lMajor, &lMinor, &lPatch, &lRevno );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
// major version changes by definition are incompatible and
|
|
|
|
// that is enforced here.
|
|
|
|
if( pMajor != lMajor )
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << "Loader Major version (" << lMajor;
|
|
|
|
ostr << ") does not match Plugin Major version (" << pMajor << ")";
|
|
|
|
|
|
|
|
m_error = ostr.str();
|
|
|
|
close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
if( !m_checkClassVersion( lMajor, lMinor, lPatch, lRevno ) )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
2015-12-14 03:51:28 +00:00
|
|
|
ostr << "Plugin Version (" << pMajor << "." << pMinor << "." << pPatch << "." << pRevno;
|
2015-12-13 21:45:22 +00:00
|
|
|
ostr << ") does not support Loader Version (" << pMajor << "." << pMinor;
|
2015-12-14 03:51:28 +00:00
|
|
|
ostr << "." << pPatch << "." << pRevno << ")";
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
m_error = ostr.str();
|
|
|
|
close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fileName = aFullFileName;
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] opened plugin " << m_fileName.ToUTF8();
|
|
|
|
char const* cp = m_getPluginName();
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr != cp )
|
2016-02-23 06:46:22 +00:00
|
|
|
ostr << " * [INFO] plugin name: '" << cp << "'\n";
|
|
|
|
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
ok = true;
|
2016-01-31 02:21:12 +00:00
|
|
|
|
|
|
|
// set the plugin info string
|
|
|
|
m_pluginInfo = GetKicadPluginName();
|
|
|
|
std::ostringstream ostr;
|
|
|
|
unsigned char r0, r1, r2, r3;
|
|
|
|
GetVersion( &r0, &r1, &r2, &r3 );
|
|
|
|
ostr << ":" << (unsigned int)r0 << "." << (unsigned int)r1;
|
|
|
|
ostr << "." << (unsigned int)r2 << "." << (unsigned int)r3;
|
|
|
|
m_pluginInfo.append( ostr.str() );
|
|
|
|
|
2015-12-13 21:45:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KICAD_PLUGIN_LDR::close( void )
|
|
|
|
{
|
|
|
|
ok = false;
|
2021-07-18 14:06:48 +00:00
|
|
|
m_getPluginClass = nullptr;
|
|
|
|
m_getClassVersion = nullptr;
|
|
|
|
m_checkClassVersion = nullptr;
|
|
|
|
m_getPluginName = nullptr;
|
|
|
|
m_getVersion = nullptr;
|
2016-01-11 04:47:08 +00:00
|
|
|
m_PluginLoader.Unload();
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KICAD_PLUGIN_LDR::reopen( void )
|
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( m_fileName.empty() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
wxString fname = m_fileName;
|
|
|
|
|
|
|
|
return Open( fname );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string KICAD_PLUGIN_LDR::GetLastError( void ) const
|
|
|
|
{
|
|
|
|
return m_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void )
|
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( !ok && !reopen() )
|
|
|
|
{
|
|
|
|
if( m_error.empty() )
|
|
|
|
m_error = "[INFO] no open plugin / plugin could not be opened";
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == m_getPluginClass )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error = "[BUG] GetPluginClass is not linked";
|
2016-01-12 07:03:17 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * " << m_error;
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2016-01-12 07:03:17 +00:00
|
|
|
#endif
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_getPluginClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Minor,
|
2021-07-18 14:06:48 +00:00
|
|
|
unsigned char* Patch, unsigned char* Revision )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( Major )
|
|
|
|
*Major = 0;
|
|
|
|
|
|
|
|
if( Minor )
|
|
|
|
*Minor = 0;
|
|
|
|
|
|
|
|
if( Patch )
|
|
|
|
*Patch = 0;
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
if( Revision )
|
|
|
|
*Revision = 0;
|
|
|
|
|
2015-12-13 21:45:22 +00:00
|
|
|
unsigned char major;
|
|
|
|
unsigned char minor;
|
|
|
|
unsigned char patch;
|
2015-12-14 03:51:28 +00:00
|
|
|
unsigned char revno;
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
if( !ok && !reopen() )
|
|
|
|
{
|
|
|
|
if( m_error.empty() )
|
|
|
|
m_error = "[INFO] no open plugin / plugin could not be opened";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == m_checkClassVersion )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error = "[BUG] CheckClassVersion is not linked";
|
2016-01-12 07:03:17 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * " << m_error;
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2016-01-12 07:03:17 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-13 21:45:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
m_getClassVersion( &major, &minor, &patch, &revno );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
if( Major )
|
|
|
|
*Major = major;
|
|
|
|
|
|
|
|
if( Minor )
|
|
|
|
*Minor = minor;
|
|
|
|
|
|
|
|
if( Patch )
|
|
|
|
*Patch = patch;
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
if( Revision )
|
|
|
|
*Revision = revno;
|
|
|
|
|
2015-12-13 21:45:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Minor,
|
2021-07-18 14:06:48 +00:00
|
|
|
unsigned char Patch, unsigned char Revision )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( !ok && !reopen() )
|
|
|
|
{
|
|
|
|
if( m_error.empty() )
|
|
|
|
m_error = "[INFO] no open plugin / plugin could not be opened";
|
|
|
|
|
2016-01-12 07:03:17 +00:00
|
|
|
return false;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == m_checkClassVersion )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error = "[BUG] CheckClassVersion is not linked";
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * " << m_error;
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
|
|
|
return false;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
return m_checkClassVersion( Major, Minor, Patch, Revision );
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* KICAD_PLUGIN_LDR::GetKicadPluginName( void )
|
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( !ok && !reopen() )
|
|
|
|
{
|
|
|
|
if( m_error.empty() )
|
|
|
|
m_error = "[INFO] no open plugin / plugin could not be opened";
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == m_getPluginName )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error = "[BUG] GetKicadPluginName is not linked";
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * " << m_error;
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2015-12-13 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_getPluginName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor,
|
2021-07-18 14:06:48 +00:00
|
|
|
unsigned char* Patch, unsigned char* Revision )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
|
|
|
|
if( !ok && !reopen() )
|
|
|
|
{
|
|
|
|
if( m_error.empty() )
|
|
|
|
m_error = "[INFO] no open plugin / plugin could not be opened";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == m_getVersion )
|
2015-12-13 21:45:22 +00:00
|
|
|
{
|
|
|
|
m_error = "[BUG] GetKicadPluginName is not linked";
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
#ifdef DEBUG
|
2016-02-23 06:46:22 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * " << m_error;
|
|
|
|
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
2021-07-18 14:06:48 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-13 21:45:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-14 03:51:28 +00:00
|
|
|
m_getVersion( Major, Minor, Patch, Revision );
|
2015-12-13 21:45:22 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-31 02:21:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void KICAD_PLUGIN_LDR::GetPluginInfo( std::string& aPluginInfo )
|
|
|
|
{
|
|
|
|
aPluginInfo = m_pluginInfo;
|
|
|
|
}
|