示例#1
0
int
applyRuleForPostProcForRead( rsComm_t *rsComm, bytesBuf_t *dataObjReadOutBBuf, char *objPath ) {
    if ( ReadWriteRuleState != ON_STATE ) {
        return 0;
    }

    ruleExecInfo_t rei2;
    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    msParamArray_t msParamArray;
    memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );

    if ( rsComm != NULL ) {
        rei2.rsComm = rsComm;
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }
    rei2.doi = ( dataObjInfo_t* )mallocAndZero( sizeof( dataObjInfo_t ) );
    snprintf( rei2.doi->objPath, sizeof( rei2.doi->objPath ), "%s", objPath );

    memset( &msParamArray, 0, sizeof( msParamArray ) );
    int * myInOutStruct = ( int* )malloc( sizeof( int ) );
    *myInOutStruct = dataObjReadOutBBuf->len;
    addMsParamToArray( &msParamArray, "*ReadBuf", BUF_LEN_MS_T, myInOutStruct,
                       dataObjReadOutBBuf, 0 );
    int status = applyRule( "acPostProcForDataObjRead(*ReadBuf)", &msParamArray, &rei2,
                    NO_SAVE_REI );
    free( rei2.doi );
    if ( status < 0 ) {
        if ( rei2.status < 0 ) {
            status = rei2.status;
        }
        rodsLog( LOG_ERROR,
                 "rsDataObjRead: acPostProcForDataObjRead error=%d", status );
        clearMsParamArray( &msParamArray, 0 );
        return status;
    }
    clearMsParamArray( &msParamArray, 0 );

    return 0;

}
// =-=-=-=-=-=-=-
// private - execute rule for pre operation
    error operation_rule_execution_manager::exec_op(
        rsComm_t*          _comm,
        keyValPair_t&      _kvp,
        const std::string& _name,
        std::string&       _res ) {
        // =-=-=-=-=-=-=-
        // determine if rule exists
        RuleIndexListNode* re_node = 0;
        if ( findNextRule2( const_cast<char*>( _name.c_str() ), 0, &re_node ) < 0 ) {
            return ERROR( SYS_RULE_NOT_FOUND, "no rule found" );
        }

        // =-=-=-=-=-=-=-
        // debug message for creating dynPEP rules
        rodsLog(
            LOG_DEBUG,
            "operation_rule_execution_manager exec_op [%s]",
            _name.c_str() );

        // =-=-=-=-=-=-=-
        // add additional global re params
        error err = add_global_re_params_to_kvp_for_dynpep( _kvp );
        if ( !err.ok() ) {
            return PASS( err );
        }

        // =-=-=-=-=-=-=-
        // manufacture an rei for the applyRule
        ruleExecInfo_t rei;
        memset( ( char* )&rei, 0, sizeof( ruleExecInfo_t ) );
        rei.rsComm        = _comm;
        rei.condInputData = &_kvp; // give rule scope to our key value pairs
        rstrcpy( rei.pluginInstanceName, instance_.c_str(), MAX_NAME_LEN );

        // =-=-=-=-=-=-=-
        // add the output parameter
        msParamArray_t params;
        memset( &params, 0, sizeof( msParamArray_t ) );
        char out_param[ MAX_NAME_LEN ] = {"EMPTY_PARAM"};
        if ( _res.empty() ) {
            addMsParamToArray( &params, "*OUT", STR_MS_T, out_param, NULL, 0 );
        }
        else {
            addMsParamToArray( &params, "*OUT", STR_MS_T, const_cast<char*>( _res.c_str() ), NULL, 0 );
        }

        // =-=-=-=-=-=-=-
        // rule exists, param array is build.  call the rule.
        std::string arg_name = _name + "(*OUT)";
        int ret = applyRuleUpdateParams(
                      const_cast<char*>( arg_name.c_str() ),
                      &params,
                      &rei,
                      NO_SAVE_REI );
        if ( 0 != ret ) {
            return ERROR( ret, "failed in call to applyRuleUpdateParams" );
        }

        // =-=-=-=-=-=-=-
        // extract the value from the outgoing param to pass out to the operation
        msParam_t* out_ms_param = getMsParamByLabel( &params, "*OUT" );
        if ( out_ms_param ) {
            _res = reinterpret_cast< char* >( out_ms_param->inOutStruct );

        }
        else {
            return ERROR( SYS_INVALID_INPUT_PARAM, "null out parameter" );

        }

        return SUCCESS();

    } // exec_op
示例#3
0
int
carryOverMsParam(msParamArray_t *sourceMsParamArray,msParamArray_t *targetMsParamArray)
{

  int i;
    msParam_t *mP, *mPt;
    char *a, *b;
    if (sourceMsParamArray == NULL)
      return(0);
    /****
    for (i = 0; i < sourceMsParamArray->len ; i++) {
      mPt = sourceMsParamArray->msParam[i];
      if ((mP = getMsParamByLabel (targetMsParamArray, mPt->label)) != NULL) 
	rmMsParamByLabel (targetMsParamArray, mPt->label, 1);
      addMsParam(targetMsParamArray, mPt->label, mPt->type, NULL,NULL);
      j = targetMsParamArray->len - 1;
      free(targetMsParamArray->msParam[j]->label);
      free(targetMsParamArray->msParam[j]->type);
      replMsParam(mPt,targetMsParamArray->msParam[j]);
    }
    ****/
    /****
    for (i = 0; i < sourceMsParamArray->len ; i++) {
      mPt = sourceMsParamArray->msParam[i];
      if ((mP = getMsParamByLabel (targetMsParamArray, mPt->label)) != NULL) 
	rmMsParamByLabel (targetMsParamArray, mPt->label, 1);
      addMsParamToArray(targetMsParamArray, 
			mPt->label, mPt->type, mPt->inOutStruct, mPt->inpOutBuf, 1);
    }
    ****/
    for (i = 0; i < sourceMsParamArray->len ; i++) {
      mPt = sourceMsParamArray->msParam[i];
      if ((mP = getMsParamByLabel (targetMsParamArray, mPt->label)) != NULL) {
	a = mP->label;
        b = mP->type;
	mP->label = NULL;
	mP->type = NULL;
	/** free(mP->inOutStruct);**/
	free(mP->inpOutBuf);
	replMsParam(mPt,mP);
	free(mP->label);
	mP->label = a;
	free(mP->type);
	mP->type = b;
      }
      else 
	addMsParamToArray(targetMsParamArray, 
			mPt->label, mPt->type, mPt->inOutStruct, mPt->inpOutBuf, 1);
    }
    /****
    for (i = 0; i < sourceMsParamArray->len ; i++) {
      mPt = sourceMsParamArray->msParam[i];
      if ((mP = getMsParamByLabel (targetMsParamArray, mPt->label)) != NULL) {
	if (mP->inOutStruct == mP->inOutStruct) {
	  if (mP->type != mPt->type) {
	    free(mP->type );
	    mP->type = mPt->type;
	  }
	  if (mP->label != mPt->label) {
	    free(mP->label);
	    mP->label= mPt->label;
	  }
	}
	else {
	  if (mP->type == mPt->type)
	    a = mP->type;
	  else {
	    free(mP->type );
	    a = NULL;
	  }
	  if (mP->label == mPt->label)
	    b = mP->label;
	  else {
	    free(mP->label );
	    b = NULL;
	  }
	  b = mP->label;
	  free(mP->inOutStruct);
	  free(mPt->inpOutBuf);
	  replMsParam(mPt,mP);
	  if (a != NULL) {
	    free(mP->type);
	    mP->type =  a;
	  }
	  if (b != NULL) {
	    free(mP->label);
	    mP->label =  b;
	  }
	}
      }
      else {
	addMsParamToArray(targetMsParamArray, 
			  mPt->label, mPt->type, mPt->inOutStruct, mPt->inpOutBuf, 1);
      }
    }
    ***/

  return(0);
}