int getSessionVarValue( char *action, char *varName, ruleExecInfo_t *rei, char **varValue ) { char *varMap; int i, vinx; Res *res; Region *r = make_region( 0, NULL ); vinx = getVarMap( action, varName, &varMap, 0 ); while ( vinx >= 0 ) { i = getVarValue( varMap, rei, &res, r ); if ( i >= 0 ) { free( varMap ); *varValue = convertResToString( res ); region_free( r ); return( i ); } else if ( i == NULL_VALUE_ERR ) { free( varMap ); vinx = getVarMap( action, varName, &varMap, vinx + 1 ); } else { free( varMap ); region_free( r ); return( i ); } } region_free( r ); if ( vinx < 0 ) { return( vinx ); } return( i ); }
int getSessionVarValue (char *action, char *varName, ruleExecInfo_t *rei, char **varValue) { char *varMap; int i, vinx; vinx = getVarMap (action,varName, &varMap, 0); while (vinx >= 0) { i = getVarValue (varMap, rei, varValue); if (i >= 0) { free(varMap); return(i); } else if (i == NULL_VALUE_ERR) { free(varMap); vinx = getVarMap (action,varName, &varMap, vinx+1); } else { free(varMap); return(i); } } if (vinx < 0) { return(vinx); } return(i); }
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 getSessionVarValue( char *action, char *varName, ruleExecInfo_t *rei, char **varValue ) { Region *r = make_region( 0, NULL ); char *varMap; int vinx = getVarMap( action, varName, &varMap, 0 ); while ( vinx >= 0 ) { Res *res; int i = getVarValue( varMap, rei, &res, r ); free( varMap ); if ( i != NULL_VALUE_ERR ) { if ( i >= 0 ) { *varValue = convertResToString( res ); } region_free( r ); return i; } vinx = getVarMap( action, varName, &varMap, vinx + 1 ); } free( varMap ); region_free( r ); return vinx; }