int parseAndComputeMsParamArrayToEnv( msParamArray_t *var, Env *env, ruleExecInfo_t *rei, int reiSaveFlag, rError_t *errmsg, Region *r ) { int i; for ( i = 0; i < var->len; i++ ) { Res *res = newRes( r ); int ret = convertMsParamToRes( var->msParam[i], res, r ); if ( ret != 0 ) { return ret; } char *varName = var->msParam[i]->label; if ( TYPE( res ) == T_UNSPECED ) { if ( varName != NULL ) { updateInEnv( env, varName, res ); } continue; } if ( TYPE( res ) != T_STRING ) { return -1; } char *expr = res->text; res = parseAndComputeExpression( expr, env, rei, reiSaveFlag, errmsg, r ); if ( getNodeType( res ) == N_ERROR ) { return RES_ERR_CODE( res ); } if ( varName != NULL ) { updateInEnv( env, varName, res ); } } return 0; }
Res *setVariableValue(char *varName, Res *val, ruleExecInfo_t *rei, Env *env, rError_t *errmsg, Region *r) { int i; char *varMap; char errbuf[ERR_MSG_LEN]; if (varName[0] == '$') { if(TYPE(val)!=T_STRING) { snprintf(errbuf, ERR_MSG_LEN, "error: assign a nonstring value to session variable %s.", varName); addRErrorMsg(errmsg, RE_UNSUPPORTED_OP_OR_TYPE, errbuf); return newErrorRes(r, RE_UNSUPPORTED_OP_OR_TYPE); } i = getVarMap("", varName, &varMap, 0); if (i < 0) { snprintf(errbuf, ERR_MSG_LEN, "error: unsupported session variable \"%s\".",varName); addRErrorMsg(errmsg, RE_UNSUPPORTED_SESSION_VAR, errbuf); return newErrorRes(r, RE_UNSUPPORTED_SESSION_VAR); } setVarValue(varMap, rei, strdup(val->text)); return newIntRes(r, 0); } else if(varName[0] == '*') { if(lookupFromEnv(env, varName)==NULL) { /* new variable */ if(insertIntoHashTable(env->current, varName, val) == 0) { snprintf(errbuf, ERR_MSG_LEN, "error: unable to write to local variable \"%s\".",varName); addRErrorMsg(errmsg, RE_UNABLE_TO_WRITE_LOCAL_VAR, errbuf); return newErrorRes(r, RE_UNABLE_TO_WRITE_LOCAL_VAR); } } else { updateInEnv(env, varName, val); } return newIntRes(r, 0); } return newIntRes(r, 0); }
int updateMsParamArrayToEnvAndFreeNonIRODSType(msParamArray_t *var, Env *env, rError_t *errmsg, Region *r) { int i; for(i=0;i<var->len;i++) { Res *res = newRes(r); int ret = convertMsParamToResAndFreeNonIRODSType(var->msParam[i], res, errmsg, r); if(ret != 0) { return ret; } char *varName = var->msParam[i]->label; if(varName!=NULL) { updateInEnv(env, varName, res); } } return 0; }