示例#1
0
文件: rules.cpp 项目: irods/irods
int parseAndComputeRuleAdapter( char *rule, msParamArray_t *msParamArray, ruleExecInfo_t *rei, int reiSaveFlag, Region *r ) {
    /* set clearDelayed to 0 so that nested calls to this function do not call clearDelay() */
    int recclearDelayed = ruleEngineConfig.clearDelayed;
    ruleEngineConfig.clearDelayed = 0;

    rError_t errmsgBuf;
    errmsgBuf.errMsg = NULL;
    errmsgBuf.len = 0;

    Env *env = defaultEnv( r );

    rei->status = 0;

    int rescode = 0;
    if ( msParamArray != NULL ) {
        if ( strncmp( rule, "@external\n", 10 ) == 0 ) {
            rescode = parseAndComputeMsParamArrayToEnv( msParamArray, globalEnv( env ), rei, reiSaveFlag, &errmsgBuf, r );
            RE_ERROR( rescode < 0 );
            rule = rule + 10;
        }
        else {
            rescode = convertMsParamArrayToEnv( msParamArray, globalEnv( env ), r );
            RE_ERROR( rescode < 0 );
        }
    }

    deleteFromHashTable(globalEnv(env)->current, "ruleExecOut");

    rei->msParamArray = msParamArray;

    rescode = parseAndComputeRule( rule, env, rei, reiSaveFlag, &errmsgBuf, r );
    RE_ERROR( rescode < 0 );

    if ( NULL == rei->msParamArray ) {
        rei->msParamArray = newMsParamArray();
    }
    rescode = convertEnvToMsParamArray( rei->msParamArray, env, &errmsgBuf, r );
    RE_ERROR( rescode < 0 );

    freeRErrorContent( &errmsgBuf );
    /* deleteEnv(env, 3); */

    return rescode;
error:
    logErrMsg( &errmsgBuf, &rei->rsComm->rError );
    rei->status = rescode;
    freeRErrorContent( &errmsgBuf );
    /* deleteEnv(env, 3); */
    if ( recclearDelayed ) {
        clearDelayed();
    }
    ruleEngineConfig.clearDelayed = recclearDelayed;

    return rescode;


}
示例#2
0
文件: rules.cpp 项目: bpow/irods
int parseAndComputeRuleNewEnv( char *rule, ruleExecInfo_t *rei, int reiSaveFlag, msParamArray_t *msParamArray, rError_t *errmsg, Region *r ) {
    Env *env = defaultEnv( r );
    addCmdExecOutToEnv( globalEnv( env ), r );

    int rescode = 0;
    msParamArray_t *orig = NULL;

    if ( msParamArray != NULL ) {
        rescode = convertMsParamArrayToEnv( msParamArray, env->previous, r );
        RE_ERROR( rescode < 0 );
    }

    orig = rei->msParamArray;
    rei->msParamArray = NULL;

    rescode = parseAndComputeRule( rule, env, rei, reiSaveFlag, errmsg, r );
    RE_ERROR( rescode < 0 );

    if ( orig == NULL ) {
        rei->msParamArray = newMsParamArray();
    }
    else {
        rei->msParamArray = orig;
    }
    rescode = convertEnvToMsParamArray( rei->msParamArray, env, errmsg, r );
    RE_ERROR( rescode < 0 );
    /* deleteEnv(env, 3); */
    return rescode;

error:

    /* deleteEnv(env, 3); */
    return rescode;
}
示例#3
0
文件: rules.cpp 项目: bpow/irods
/*
 * Set retOutParam to 1 if you need to retrieve the output parameters from inMsParamArray and 0 if not
 */
Res *parseAndComputeExpressionAdapter( char *inAction, msParamArray_t *inMsParamArray, int retOutParams, ruleExecInfo_t *rei, int reiSaveFlag, Region *r ) { // JMC - backport 4540
    /* set clearDelayed to 0 so that nested calls to this function do not call clearDelay() */
    int recclearDelayed = ruleEngineConfig.clearDelayed;
    ruleEngineConfig.clearDelayed = 0;
    int freeRei = 0;
    if ( rei == NULL ) {
        rei = ( ruleExecInfo_t * ) malloc( sizeof( ruleExecInfo_t ) );
        memset( rei, 0, sizeof( ruleExecInfo_t ) );
        freeRei = 1;
    }
    rei->status = 0;
    Env *env = defaultEnv( r );
    /* retrieve generated data here as it may be overridden by convertMsParamArrayToEnv */
    execCmdOut_t *execOut = addCmdExecOutToEnv( globalEnv( env ), r );
    Res *res;
    rError_t errmsgBuf;
    errmsgBuf.errMsg = NULL;
    errmsgBuf.len = 0;

    msParamArray_t *orig = rei->msParamArray;
    rei->msParamArray = NULL;

    if ( inMsParamArray != NULL ) {
        convertMsParamArrayToEnv( inMsParamArray, env, r );
    }

    res = parseAndComputeExpression( inAction, env, rei, reiSaveFlag, &errmsgBuf, r );
    if ( retOutParams ) { // JMC - backport 4540
        if ( inMsParamArray != NULL ) {
            clearMsParamArray( inMsParamArray, 0 );
            convertEnvToMsParamArray( inMsParamArray, env, &errmsgBuf, r );
        }
    }
    rei->msParamArray = orig;

    freeCmdExecOut( execOut );
    /* deleteEnv(env, 3); */
    if ( getNodeType( res ) == N_ERROR && !freeRei ) {
        logErrMsg( &errmsgBuf, &rei->rsComm->rError );
        rei->status = RES_ERR_CODE( res );
    }
    freeRErrorContent( &errmsgBuf );
    if ( freeRei ) {
        free( rei );
    }
    if ( recclearDelayed ) {
        clearDelayed();
    }
    ruleEngineConfig.clearDelayed = recclearDelayed;
    return res;

}
示例#4
0
文件: rules.cpp 项目: bpow/irods
int parseAndComputeRuleAdapter( char *rule, msParamArray_t *msParamArray, ruleExecInfo_t *rei, int reiSaveFlag, Region *r ) {
    /* set clearDelayed to 0 so that nested calls to this function do not call clearDelay() */
    int recclearDelayed = ruleEngineConfig.clearDelayed;
    ruleEngineConfig.clearDelayed = 0;

    rError_t errmsgBuf;
    errmsgBuf.errMsg = NULL;
    errmsgBuf.len = 0;

    Env *env = defaultEnv( r );

    rei->status = 0;

    msParamArray_t *orig = NULL;

    Res *execOutRes;

    int rescode = 0;
    if ( msParamArray != NULL ) {
        if ( strncmp( rule, "@external\n", 10 ) == 0 ) {
            rescode = parseAndComputeMsParamArrayToEnv( msParamArray, globalEnv( env ), rei, reiSaveFlag, &errmsgBuf, r );
            RE_ERROR( rescode < 0 );
            rule = rule + 10;
        }
        else {
            rescode = convertMsParamArrayToEnv( msParamArray, globalEnv( env ), r );
            RE_ERROR( rescode < 0 );
        }
    }

    if ( ( execOutRes = ( Res * )lookupFromEnv( env, "ruleExecOut" ) ) == NULL || TYPE( execOutRes ) == T_UNSPECED ) {
        /* add cmdExecOut only if ruleExecOut is an output parameter */
        deleteFromHashTable( globalEnv( env )->current, "ruleExecOut" );
        addCmdExecOutToEnv( globalEnv( env ), r );
    }

    orig = rei->msParamArray;
    rei->msParamArray = NULL;

    rescode = parseAndComputeRule( rule, env, rei, reiSaveFlag, &errmsgBuf, r );

    if ( orig == NULL ) {
        rei->msParamArray = newMsParamArray();
    }
    else {
        rei->msParamArray = orig;
    }
    convertEnvToMsParamArray( rei->msParamArray, env, &errmsgBuf, r );

    RE_ERROR( rescode < 0 );
    freeRErrorContent( &errmsgBuf );
    /* deleteEnv(env, 3); */

    return rescode;
error:
    logErrMsg( &errmsgBuf, &rei->rsComm->rError );
    rei->status = rescode;
    freeRErrorContent( &errmsgBuf );
    /* deleteEnv(env, 3); */
    if ( recclearDelayed ) {
        clearDelayed();
    }
    ruleEngineConfig.clearDelayed = recclearDelayed;

    return rescode;


}