00001
00002
00003
00004
00005 #include "eirods_ms_home.h"
00006 #include "eirods_ms_plugin.h"
00007 #include "eirods_load_plugin.h"
00008 #include "eirods_log.h"
00009
00010
00011
00012 #include <iostream>
00013 #include <sstream>
00014
00015 namespace eirods {
00016
00017
00018 ms_table_entry::ms_table_entry( ) :
00019 plugin_base( "msvc", "ctx" ),
00020 num_args_( 0 ),
00021 call_action_( 0 ) {
00022 }
00023
00024 ms_table_entry::ms_table_entry( int _n ) :
00025 plugin_base( "msvc", "ctx"),
00026 num_args_( _n ),
00027 call_action_( 0 ) {
00028 }
00029
00030 ms_table_entry::ms_table_entry( const std::string& _name,
00031 int _num_args,
00032 ms_func_ptr _fcn_ptr ) :
00033 plugin_base( "msvc", "ctx" ),
00034 num_args_( _num_args ),
00035 call_action_( _fcn_ptr ) {
00036 }
00037
00038 ms_table_entry::ms_table_entry( const ms_table_entry& _rhs ) :
00039 plugin_base( _rhs ),
00040 num_args_( _rhs.num_args_ ),
00041 call_action_( _rhs.call_action_ ) {
00042 }
00043
00044 ms_table_entry& ms_table_entry::operator=( const ms_table_entry& _rhs ) {
00045 plugin_base::operator=( _rhs );
00046 num_args_ = _rhs.num_args_;
00047 call_action_ = _rhs.call_action_;
00048 return *this;
00049 }
00050
00051 ms_table_entry::~ms_table_entry() {
00052 }
00053
00054 error ms_table_entry::delay_load( void* _h ) {
00055
00056
00057 if( !_h ) {
00058 return ERROR( SYS_INVALID_INPUT_PARAM, "null handle parameter" );
00059 }
00060
00061
00062
00063 if( 0 == ops_for_delay_load_.size() ) {
00064 return ERROR( SYS_INVALID_INPUT_PARAM, "no ops to load" );
00065 }
00066
00067
00068
00069 std::string action = ops_for_delay_load_[0].first;
00070 call_action_ = reinterpret_cast< ms_func_ptr >( dlsym( _h, action.c_str() ) );
00071
00072
00073
00074
00075 if( !call_action_ ) {
00076 std::stringstream msg;
00077 msg << "failed to load msvc function [";
00078 msg << action;
00079 msg << "]";
00080 return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
00081 }
00082
00083 return SUCCESS();
00084
00085 }
00086
00087
00088
00089
00090 error load_microservice_plugin( ms_table& _table, const std::string _ms ) {
00091
00092 ms_table_entry* entry = 0;
00093 error load_err = load_plugin< ms_table_entry >( entry, _ms, EIRODS_MS_HOME, "msvc", "ctx" );
00094 if( load_err.ok() && entry ) {
00095 _table[ _ms ] = entry;
00096 return SUCCESS();
00097 } else {
00098 error ret = PASSMSG( "Failed to create ms plugin entry.", load_err );
00099
00100 return ret;
00101 }
00102 }
00103
00104 };