void FlowContext::SetOpts(OptArgs &opts, Json::Value& json_params) { string fo = RetrieveParameterString(opts, json_params, '-', "flow-order", ""); if(fo.length() > 0) { if ( flowOrder ) free ( flowOrder ); flowOrder = strdup ( fo.c_str() ); numFlowsPerCycle = strlen ( flowOrder ); flowOrderOverride = true; } int tmp_flowlimit = RetrieveParameterInt(opts, json_params, '-', "flowlimit", -1); if(tmp_flowlimit >= 0) { SetFlowLimit( tmp_flowlimit ); } vector<int> vec; RetrieveParameterVectorInt(opts, json_params, '-', "start-flow-plus-interval", "0,0", vec); if(vec.size() == 2) { if( vec[1] > 0) { SetFlowRange(vec[0], vec[1]); } } else { fprintf ( stderr, "Option Error: start-flow-plus-interval format wrong, not size = 2\n" ); exit ( EXIT_FAILURE ); } }
void KeyContext::SetOpts(OptArgs &opts, Json::Value& json_params) { string libkey = RetrieveParameterString(opts, json_params, '-', "librarykey", ""); int len = libkey.length(); if( len > 0) { if ( libKey ) free ( libKey ); libKey = ( char * ) malloc ( len +1 ); strcpy ( libKey, libkey.c_str() ); ToUpper ( libKey ); } string tfkey = RetrieveParameterString(opts, json_params, '-', "tfkey", ""); len = tfkey.length(); if( len > 0) { if ( tfKey ) free ( tfKey ); tfKey = ( char * ) malloc ( len +1 ); strcpy ( tfKey, tfkey.c_str() ); ToUpper ( tfKey ); } }
void FlowContext::SetOpts(OptArgs &opts, Json::Value& json_params) { string fo = RetrieveParameterString(opts, json_params, '-', "flow-order", ""); if(fo.length() > 0) { if ( flowOrder ) free ( flowOrder ); // upgrade floworder to all-caps(!) // otherwise problems as the code does direct char compares for (unsigned int i=0; i<fo.size(); i++){ fo.at(i) = toupper(fo.at(i)); } flowOrder = strdup ( fo.c_str() ); numFlowsPerCycle = strlen ( flowOrder ); flowOrderOverride = true; } int tmp_flowlimit = RetrieveParameterInt(opts, json_params, '-', "flowlimit", -1); if(tmp_flowlimit >= 0) { SetFlowLimit( tmp_flowlimit ); } vector<int> vec; RetrieveParameterVectorInt(opts, json_params, '-', "start-flow-plus-interval", "0,0", vec); if(vec.size() == 2) { if( vec[1] > 0) { SetFlowRange(vec[0], vec[1]); } } else { fprintf ( stderr, "Option Error: start-flow-plus-interval format wrong, not size = 2\n" ); exit ( EXIT_FAILURE ); } }