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(
00020 "",
00021 "" ),
00022 num_args_( 0 ),
00023 call_action_( 0 ) {
00024 }
00025
00026 ms_table_entry::ms_table_entry(
00027 int _n ) :
00028 plugin_base(
00029 "msvc",
00030 "ctx" ),
00031 num_args_( _n ),
00032 call_action_( 0 ) {
00033 }
00034
00035 ms_table_entry::ms_table_entry(
00036 const std::string& _name,
00037 int _num_args,
00038 ms_func_ptr _fcn_ptr ) :
00039 plugin_base(
00040 "msvc",
00041 "ctx" ),
00042 num_args_( _num_args ),
00043 call_action_( _fcn_ptr ) {
00044 }
00045
00046 ms_table_entry::ms_table_entry(
00047 const ms_table_entry& _rhs ) :
00048 plugin_base( _rhs ),
00049 num_args_( _rhs.num_args_ ),
00050 call_action_( _rhs.call_action_ ) {
00051 }
00052
00053 ms_table_entry& ms_table_entry::operator=(
00054 const ms_table_entry& _rhs ) {
00055 plugin_base::operator=( _rhs );
00056 num_args_ = _rhs.num_args_;
00057 call_action_ = _rhs.call_action_;
00058 return *this;
00059 }
00060
00061 ms_table_entry::~ms_table_entry() {
00062 }
00063
00064 error ms_table_entry::delay_load(
00065 void* _h ) {
00066
00067
00068 if( !_h ) {
00069 return ERROR( SYS_INVALID_INPUT_PARAM, "null handle parameter" );
00070 }
00071
00072
00073
00074 if( 0 == ops_for_delay_load_.size() ) {
00075 return ERROR( SYS_INVALID_INPUT_PARAM, "no ops to load" );
00076 }
00077
00078
00079
00080 std::string action = ops_for_delay_load_[0].first;
00081 call_action_ = reinterpret_cast< ms_func_ptr >( dlsym( _h, action.c_str() ) );
00082
00083
00084
00085
00086 if( !call_action_ ) {
00087 std::stringstream msg;
00088 msg << "failed to load msvc function [";
00089 msg << action;
00090 msg << "]";
00091 return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
00092 }
00093
00094 return SUCCESS();
00095
00096 }
00097
00098
00099
00100
00101 error load_microservice_plugin( ms_table& _table, const std::string _ms ) {
00102
00103 ms_table_entry* entry = 0;
00104 error load_err = load_plugin< ms_table_entry >( entry, _ms, EIRODS_MS_HOME, "msvc", "ctx" );
00105 if( load_err.ok() && entry ) {
00106 _table[ _ms ] = entry;
00107 return SUCCESS();
00108 } else {
00109 error ret = PASSMSG( "Failed to create ms plugin entry.", load_err );
00110
00111 return ret;
00112 }
00113 }
00114
00115 };