bool read_buf(char * buf,const char * key,char * value){ if (strncmp(buf,key, strlen(key)) == 0) { strcpy(value, buf + after_equal(buf)); trim(value); if (DEBUG) printf("%s\n",value); return 1; } return 0; }
int read_buf(char *buf, const char *key, char *value) { if (strncmp(buf, key, strlen(key)) == 0) { strcpy(value, buf + after_equal(buf)); trim(value); write_log("%s = %s\n", key, value); return 1; } return 0; }
int main() { g1 = 3; g2 = 4; n = 5; gen_g1(g1map, g1); gen_g2(g2map, g2); gen_big(smap, n); /*map<string, G1>::iterator it; for(it = g1map.begin(); it != g1map.end(); ++it) { cout<< it->first << endl; }*/ while(true) { string str; cin >> str; if(str == "bye") break; string mid_str = after_equal(str); string val = before_equal(str); string d = split_word(mid_str); queue<string> mid; queue<string> rpn; string word; istringstream istr(d); while(!istr.eof()) { istr >> word; mid.push(word); } rpn_convert(mid, rpn); double time = 0; if(val.substr(0,2) == "gt") { time = calcu_gt(rpn, g1map, g2map, smap, gtmap, val); } else if(val.substr(0,2) == "g1") { time = calcu_g1(rpn, g1map, smap, val); } else if(val.substr(0,2) == "g2") { time = calcu_g2(rpn, g2map, smap, val); } cout<< str + " " << time << endl; } /* string str = "g1_3 = g1_0 * g1_1"; string mid_str = after_equal(str); string val = before_equal(str); string d = split_word(mid_str); queue<string> mid; queue<string> rpn; string word; istringstream istr(d); while(!istr.eof()) { istr >> word; mid.push(word); } rpn_convert(mid, rpn); double time = 0; if(val.substr(0,2) == "gt") { time = calcu_gt(rpn, g1map, g2map, smap, gtmap, val); } else if(val.substr(0,2) == "g1") { time = calcu_g1(rpn, g1map, smap, val); } else if(val.substr(0,2) == "g2") { time = calcu_g2(rpn, g2map, smap, val); } cout<< str + " " << time << endl; */ return 0; }