void Part::read(XmlReader& e) { int rstaff = 0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "Staff") { Staff* staff = new Staff(_score, this, rstaff); _score->staves().push_back(staff); _staves.push_back(staff); staff->read(e); ++rstaff; } else if (tag == "Instrument") instr(0)->read(e); else if (tag == "name") instr(0)->setLongName(e.readElementText()); else if (tag == "shortName") instr(0)->setShortName(e.readElementText()); else if (tag == "trackName") _partName = e.readElementText(); else if (tag == "show") _show = e.readInt(); else e.unknown(); } if (_partName.isEmpty()) _partName = instr(0)->trackName(); }
void Part::setMidiProgram(int program, int bank) { Channel c = instr(0)->channel(0); c.program = program; c.bank = bank; c.updateInitList(); instr(0)->setChannel(0, c); }
void instr(SgScopeStatement* scope) { if(isSgBasicBlock(scope)) { #ifdef LOCK_KEY_INSERT instr(isSgBasicBlock(scope)); #endif } else if(isSgGlobal(scope)) { instr(isSgGlobal(scope)); } }
int irc_identified(char *recvbuf) { if (instr(recvbuf,"You are now identified")) return 1; if (instrf(recvbuf," %d ",ErrUserOnChannel)) return -1; if (instrf(recvbuf," %d ",ErrNickNameInUse)) return -1; if (instr(recvbuf,"Invalid password")) return -1; if (instr(recvbuf,"Nick/channel is temporarily unavailable")) return -1; return 0; }
int instr() { char b; system("cls"); printf("\n\n\t\tFor Monthly calendar==>>\n\n\tPress 'Right Arrow key' for next month"); printf("\n\n\tPress 'Left Arrow key' for previous month"); printf("\n\n\tPress 'Up Arrow key' for next year"); printf("\n\n\tPress 'Down Arrow key' for previous year\n\n"); printf("\tPress 'Space' to go to main menu\n\n\n\n"); printf("\t\tFor Yearly calendar==>>\n\n\tPress 'Right Arrow key' for next year"); printf("\n\n\tPress 'Left Arrow key' for previous year"); printf("\n\n\tPress 'Up Arrow key' to skip 10 years forward"); printf("\n\n\tPress 'Down Arrow key' to skip 10 years backward"); printf("\n\n\tPress 'Space' to go to main menu"); printf("\n\n\n\n\t\t::Press 'Space' to go to main menu::\n\n"); gotoxy(0,0); b=getch(); if(b==' ') main(); else { printf("Wrong Input...!!!"); instr(); } }
/// Called from constructor to fill instrument list void FacilityInfo::fillInstruments(const Poco::XML::Element* elem) { Poco::AutoPtr<Poco::XML::NodeList> pNL_instrument = elem->getElementsByTagName("instrument"); unsigned long n = pNL_instrument->length(); m_instruments.reserve(n); for (unsigned long i = 0; i < n; ++i) { Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*>(pNL_instrument->item(i)); if (elem) { try { InstrumentInfo instr(this,elem); m_instruments.push_back(instr); } catch(...) { /*skip this instrument*/ } } } if (m_instruments.empty()) { throw std::runtime_error("Facility "+m_name+" does not have any instruments;"); } }
void Part::read(XmlReader* r) { int rstaff = 0; QString val; while (r->readElement()) { MString8 tag(r->tag()); if (tag == "Staff") { Staff* staff = new Staff(_score, this, rstaff); _score->staves().push_back(staff); _staves.push_back(staff); staff->read(r); ++rstaff; } else if (tag == "Instrument") instr(0)->read(r); else if (r->readString("name", &val)) { ; // instr(0)->longName() = QTextDocumentFragment::fromHtml(val); } else if (r->readString("shortName", &val)) { ; // instr(0)->shortName() = QTextDocumentFragment::fromHtml(val); } else if (r->readString("trackName", &_trackName)) ; else if (r->readBool("show", &_show)) _show = val.toInt(); else r->unknown(); } }
Transacao::Transacao(ifstream & in){ // le uma transacao na forma de idcliente ; data ; lista produtos string data_aux; string lista_prod_aux; vector<string> produtos_aux; string prod_individual; //idcliente in >> idCliente; in.ignore(); // ignora o ; cout << idCliente << endl; //data getline(in, data_aux, ';'); //cout << 77 << endl; data_aux.erase(data_aux.begin()); data_aux.erase(data_aux.end() - 1); //apaga 1 e último espaço //cout << 33 << endl; Data data(data_aux); //lista de produtos getline(in, lista_prod_aux); istringstream instr(lista_prod_aux); while (getline(instr, prod_individual, ',')) { prod_individual.erase(0, prod_individual.find_first_not_of(' ')); //remove espacos iniciais produtos_aux.push_back(prod_individual); } produtos = produtos_aux; }
/* VT220 & up. */ static int tst_S8C1T(MENU_ARGS) { char *report; int flag = input_8bits; int pass; vt_move(1, 1); println(the_title); vt_move(5, 1); println("This tests the VT200+ control sequence to direct the terminal to emit 8-bit"); println("control-sequences instead of <esc> sequences."); set_tty_raw(TRUE); set_tty_echo(FALSE); for (pass = 0; pass < 2; pass++) { flag = !flag; s8c1t(flag); cup(1, 1); dsr(6); report = instr(); vt_move(10 + pass * 3, 1); printf("8-bit controls %s: ", flag ? "enabled" : "disabled"); chrprint(report); report_ok("1;1R", report); } restore_ttymodes(); vt_move(max_lines - 1, 1); return MENU_HOLD; }
void LibraryUI::read() { const QString sep("[::]"); const int BADLIMIT(5); //max number of bad lines QString line, type; QStringList objdata; QFile inf("libfile"); inf.open(QIODevice::ReadOnly); QTextStream instr(&inf); int badlines(0); while(not instr.atEnd()) { if(badlines >= BADLIMIT) { qDebug() << "Too many bad lines! Aborting."; return; } line = instr.readLine(); objdata = line.split(sep); if(objdata.isEmpty()) { qDebug() << "Empty Line in file!"; ++badlines; } else if(not TYPES.contains(objdata.first())) { qDebug() << "Bad type in line: " << objdata.join(";;;"); ++badlines; } else add(objdata); } }
void nwxXmlCMF::UnitTest() { nwxXmlCMF x; nwxXmlCMF xx; wxString sFileName(_T("foo.xml")); wxMemoryInputStream instr(sXML,XML_SIZE); MY_ASSERT(instr.IsOk(),"wxMemoryInputStream::IsOk() failed"); MY_ASSERT(instr.CanRead(),"wxMemoryInputStream::CanRead() failed"); MY_ASSERT(instr.TellI() == (off_t)0,"wxMemoryInputStream::TellI() != 0"); if(!x.LoadStream(instr)) { MY_ASSERT(0,"Could not load input stream"); return; } UnitTest1(x); if(!x.SaveFile(sFileName)) { MY_ASSERT(0,"Cannot save file ", sFileName); } else if(!xx.LoadFile(sFileName)) { MY_ASSERT(0,"Cannot load file ", sFileName); } else { UnitTest1(xx); } }
static void defineExitProg(void) { static insWord proc_exit_seq[] = { instrhb(gcmap, 0, 0), instr(die) /* Then we expire */ }; exitProg = buildCode(proc_exit_seq, 0, NumberOf(proc_exit_seq), 0); }
int instrf(const char *h, const char *n, ...) { va_list args; va_start(args, n); char s[DEFAULT_BUFLEN]; vsprintf(s,n,args); va_end(args); return instr(h,s); }
//load event and deadline tasks from file and store them in a vector vector<Task*> LoadFile::loadTimedTasks(){ vector<Task*> timedtasks; string taskName, taskInfo; int year=0, day =0, month=0, strtHr=0, strtMin=0, endHr=0, endMin=0; int mark=0; textFile.open(EVENT_FILE_NAME.c_str(), ios::in); while (textFile.peek() != EOF){ while(getline(textFile, taskInfo)){ taskName=taskInfo; getline(textFile, taskInfo); istringstream instr(taskInfo); instr >> day; instr >> month; instr >> year; instr >> strtHr; instr >> strtMin; instr >> endHr; instr >> endMin; instr >> mark; TIME startTime; startTime.hour = strtHr; startTime.min = strtMin; TIME endTime; endTime.hour = endHr; endTime.min = endMin; TASK_DATE taskDate; taskDate.year = year; taskDate.month = month; taskDate.day = day; if (strtHr == 0 && strtMin == 0){ Task* fileTask = new DeadlineTask(taskName, taskDate, endTime); if (mark==1) fileTask->changeMark(); timedtasks.push_back(fileTask); } else{ Task* fileTask = new Event(taskName, taskDate, startTime, endTime); if (mark==1) fileTask->changeMark(); timedtasks.push_back(fileTask); } } } textFile.close(); return timedtasks; }
void Part::setMidiProgram(int p) { // LVIFIX: check if this is correct // at least it fixes the MIDI program handling in the MusicXML regression test Channel c = instr(0)->channel(0); c.program = p; c.updateInitList(); //TODOxx instr(0)->setChannel(0, c); }
FPInvOffset serviceReqSPOff(TCA addr) { only_x64(); DecodedInstruction instr(addr); always_assert(instr.isLea()); auto const offBytes = safe_cast<int32_t>(instr.offset()); always_assert((offBytes % sizeof(Cell)) == 0); return FPInvOffset{-(offBytes / int32_t{sizeof(Cell)})}; }
int main(int argc, char *argv[]) { try { token_type::position_type pos("<testdata>"); #if defined(TESTLEXERS_TIMING) boost::high_resolution_timer tim; for (int i = 0; i < 1000; ++i) { #endif for (lexem const* data = lexems; NULL != data->token; ++data) { // feed the token to the lexer token_type::string_type instr(data->token); lexer_type it = lexer_type(instr.begin(), instr.end(), pos, boost::wave::support_option_long_long); lexer_type end = lexer_type(); // verify the correct outcome of the tokenization #if defined(TESTLEXERS_VERBOSE) std::cerr << boost::wave::get_token_name(data->id) << std::endl; #endif if (data->id != boost::wave::token_id(*it)) { BOOST_TEST(data->id == boost::wave::token_id(*it)); std::cerr << data->token << ": expected: " << boost::wave::get_token_name(data->id); std::cerr << ", found: " << boost::wave::get_token_name(boost::wave::token_id(*it)) << std::endl; } BOOST_TEST(++it != end); if (boost::wave::T_EOF != boost::wave::token_id(*it)) { BOOST_TEST(boost::wave::T_EOF == boost::wave::token_id(*it)); std::cerr << data->token << ": not fully matched, " << "first non-matched token was: " << (*it).get_value() << std::endl; } } #if defined(TESTLEXERS_TIMING) } std::cout << tim.elapsed() << " [s]" << std::endl; #endif } catch (boost::wave::cpplexer::lexing_exception &e) { // some lexing error std::cerr << "test_re2c_lexer: " << e.description() << std::endl; return (std::numeric_limits<int>::max)() - 1; } return boost::report_errors(); }
char *fgetstr( char *buffer,FILE *infile ,char *terminater) { int i,c; i=0; while( (c=fgetc(infile))!=EOF && instr(terminater,(char)c)==0 ){ if( instr(" \t", (char)c) == 0 ){ /* 空白とタブを取る */ buffer[i]=(char)toupper(c); i++; } } buffer[i]=0; /* ;コメントがあった場合行末まで読み捨て。 */ if( c==';' ){ while( fgetc(infile)!='\n' ){ } } return(buffer); }
void Part::write(Xml& xml) const { xml.stag("Part"); foreach(const Staff* staff, _staves) staff->write(xml); if (!_show) xml.tag("show", _show); xml.tag("trackName", _partName); instr(0)->write(xml); xml.etag(); }
void get_properties(const std::string &filename, std::map<int, std::vector<double> > &properties) { std::cout << "Getting properties..." << std::endl; double t_begin = get_wall_time(); std::ifstream in(filename.c_str()); require(in, "File " + filename + " can't be opened"); int materialID; std::vector<double> values; int n_values = 0; // default value std::string line; while (getline(in, line)) // read the file line-by-line { // if the line is empty or starts with '#' (a comment), we skip it if (line.empty() || line[0] == '#') continue; values.clear(); if (n_values == 0) // first run values.reserve(10); // we don't expect more than 10 parameters by default else values.reserve(n_values); std::istringstream instr(line); instr >> materialID; double val; while (instr >> val) values.push_back(val); if (n_values == 0) n_values = values.size(); else require(n_values == (int)values.size(), "The number of parameters in the " "first appearance was " + d2s(n_values) + ", but in some line " "there are " + d2s(values.size()) + " of them"); // insert the vector into the map std::pair<std::map<int, std::vector<double> >::const_iterator, bool> res = properties.insert(std::pair<int, std::vector<double> >(materialID, values)); // check that the insertion was successfull require(res.second, "Insertion of the values for the material with ID =" + d2s(materialID) + " failed. Check the data (file = " + filename + ")"); } in.close(); std::cout << "Getting properties is done. Time = " << get_wall_time() - t_begin << std::endl; }
static int test_report_ops(MENU_ARGS) { char *report; int row = 3; int col = 10; vt_move(1,1); println("Test of Window reporting."); set_tty_raw(TRUE); set_tty_echo(FALSE); vt_move(row++,1); println("Report icon label:"); vt_move(row, col); brc(20, 't'); /* report icon label */ report = instr(); row = chrprint2(report, row, col); vt_move(row++,1); println("Report window label:"); vt_move(row, col); brc(21, 't'); /* report window label */ report = instr(); row = chrprint2(report, row, col); vt_move(row++,1); println("Report size of window (chars):"); vt_move(row++, col); brc(18, 't'); /* report window's text-size */ report = instr(); chrprint(report); vt_move(row++,1); println("Report size of window (pixels):"); vt_move(row++, col); brc(14, 't'); /* report window's pixel-size */ report = instr(); chrprint(report); vt_move(row++,1); println("Report position of window (pixels):"); vt_move(row++, col); brc(13, 't'); /* report window's pixel-size */ report = instr(); chrprint(report); vt_move(row++,1); println("Report state of window (normal/iconified):"); vt_move(row, col); brc(11, 't'); /* report window's pixel-size */ report = instr(); chrprint(report); vt_move(20,1); restore_ttymodes(); return MENU_HOLD; }
static void defineResumeProgs(void) { int ar; for (ar = 0; ar < NumberOf(doResume); ar++) { insWord seq[] = { /* Y[arity] = interrupted code, Y[i] arguments */ instrhb(gcmap, 0, ar), instrh(resume, ar), /* this resumes the execution */ instr(succ) }; ptrI cde = buildCode(seq, 1, NumberOf(seq), 0); doResume[ar] = cde; } }
int main( int argc, char* argv[]) { if ( argc != 3) { std::cout << "2 arguments required: mips_exe filename and section name" << endl; std::exit(EXIT_FAILURE); } std::vector<ElfSection> section; ElfSection::getAllElfSections( argv[1], section); size_t i; for ( i = 0; i < section.size(); i++) if ( !strcmp( section[i].name, argv[2])) break; if ( i == section.size()) { std::cout << "Section was not found" << std::endl; std::exit(EXIT_FAILURE); } bool skip_mode = false; size_t j = 0; do { uint32 content = ((uint32*) section[i].content)[j]; if (content == 0x0) { ++j; if (!skip_mode){ std::cout << " ..." << std::endl; skip_mode = true; } continue; } else { skip_mode = false; } FuncInstr instr((( uint32*) section[i].content)[j]); std::cout << std::hex << std::setfill( '0') << "0x" << std::setw( 8) << ( section[i].start_addr + ( j * 4)) << '\t' << instr << std::dec << std::endl; ++j; } while (j < section[i].size / 4); return 0; }
int main(){ char str[100],obj[100]; printf("Please input a sentence.(less than 100 letters) \n"); scanf("%s",str); printf("Please input the objective parts. \n"); scanf("%s",obj); int position; if((position = instr(str,obj)) == -1) printf("Cannot find. \n"); else printf("Found.The position of objective is %i. \n",position); return 0; }
// Prepare a CPP argument static void DRV_prep_cpp_arg (char *s) { std::string instr (s); std::string newarg; newarg.reserve (512); for (std::string::size_type pos = instr.find_first_of (','); pos != std::string::npos; instr = instr.substr (pos + 1), pos = instr.find_first_of (',')) { newarg.append (instr.substr (0, pos)); } DRV_cpp_putarg (newarg.c_str ()); }
int matchcurves(const char* teststr,const char* decollator,char* result[3]) { const char* str = teststr; int i = 0,iok = 1; int j = 0,jok = 1; int k = 0; char* before_curves = calloc(10,sizeof(char*)); char* in_curves = calloc(100,sizeof(char*)); char* after_curves = calloc(100,sizeof(char*)); if(instr(teststr,'(')) { while(*str) { if(*str != decollator[0] && iok) { before_curves[i++] = *str++; } else if(*str != decollator[1] && jok) { iok = 0; in_curves[j++] = *str++; } else { if(jok) { jok = 0; in_curves[j] = *str++; } after_curves[k++] = *str++; } } result[0] = before_curves; result[1] = in_curves; result[2] = after_curves; if(!iskey(result[0]) && !strstr(result[2],";")) { printf("%s\n1:%s\n2:%s\n3:%s\n",teststr,result[0],result[1],result[2]); return 1; } } // printf("no key!\n"); return 0; }
fc::ip::address get_external_ip() { // terrible, but effective hack used to fetch my remote IP std::stringstream request; request << "GET /plain HTTP/1.1\r\n"; request << "Host: ipecho.net\r\n\r\nConnection:Close\r\n"; auto req = request.str(); ilog("resolve ipecho.net port 80"); auto endpoints = fc::resolve( "ipecho.net", 80 ); for( auto itr = endpoints.begin(); itr != endpoints.end(); ++itr ) { try { fc::tcp_socket sock; sock.connect_to(*itr); sock.write( req.c_str(), req.size() ); std::vector<char> buffer; buffer.resize( 1024 ); size_t r = sock.readsome( buffer.data(), buffer.size() ); std::string str(buffer.data(), r); std::stringstream instr(str); std::string line; std::getline(instr, line); // std::cerr<<line<<"\n"; while( line != "\r" ) { std::getline(instr, line); // std::cerr<<line<<"\n"; } std::getline(instr, line); std::getline(instr, line); // std::cerr<<"IP: "<<line<<"\n"; ilog("ip line=${line}",("line",line)); return fc::ip::address(line.substr(0,line.size()-1)); } catch ( fc::exception& e ) { wlog( "${e}", ("e",e.to_detail_string() ) ); // ignore errors... } } FC_THROW_EXCEPTION( exception, "Unable to connect to ipecho.net" ); }
int main() { char x,b; int a,o; system("cls"); printf("What type of Calendar you want to see...!!!\n\n"); printf("Press 'Y' for Yearly or Press 'M' for Monthly\n\n"); printf("For Instructions press 'I'\n\n"); printf("To exit press 'E'\n\n"); x=getch(); if(x=='M'||x=='m') { printf("\t\t::MONTHLY::"); printf("\n\nEnter a year : "); scanf("%d",&a); printf("\nEnter the number corresponding to a month: "); scanf("%d",&o); system("cls"); choice(a,o); gotoxy(0,0); mmove(a,o); } else if(x=='Y'||x=='y') { printf("\t\t::YEARLY::"); printf("\n\nEnter a year after 1800 : "); scanf("%d",&a); system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); ymove(a); } else if(x=='i'||x=='I') instr(); else if(x=='e'||x=='E') exit(1); else printf("Wrong Input...!!!"); printf("\n\n"); return 0; }
void adjustBindJmpPatchableJmpAddress(TCA addr, bool targetIsResumed, TCA newJmpIp) { only_x64(); // We rely on emitServiceReqWork putting an optional lea for the SP offset // first (depending on whether the target SrcKey is a resumed function0, // followed by an RIP relative lea of the jump address. if (!targetIsResumed) { DecodedInstruction instr(addr); always_assert(instr.isLea()); addr += instr.size(); } auto const leaIp = addr; always_assert((leaIp[0] & 0x48) == 0x48); // REX.W always_assert(leaIp[1] == 0x8d); // lea auto const afterLea = leaIp + x64::kRipLeaLen; auto const delta = safe_cast<int32_t>(newJmpIp - afterLea); std::memcpy(afterLea - sizeof(delta), &delta, sizeof(delta)); }
static void ExtractAutoTypeCmd(StringX ¬esStr, StringX &autotypeStr) { StringX instr(notesStr); stringT cs_autotype; LoadAString(cs_autotype, IDSC_AUTOTYPE); StringX::size_type left = instr.find(cs_autotype.c_str(), 0); if (left == StringX::npos) { autotypeStr = _T(""); } else { StringX tmp(notesStr); tmp = tmp.substr(left+9); // throw out everything left of "autotype:" instr = instr.substr(0, left); StringX::size_type right = tmp.find_first_of(_T("\r\n")); if (right != StringX::npos) { instr += tmp.substr(right); tmp = tmp.substr(0, right); } autotypeStr = tmp; notesStr = instr; } }