void MQFunctions::inq(MQHCONN conn, MQHOBJ obj, const std::vector<int>& intSelectors, const std::map<int, int>& charSelectors, std::map<int, int>& intResult, std::map<int, std::string>& charResult) { std::vector<MQLONG> selectors; for(std::vector<int>::const_iterator it = intSelectors.begin(); it != intSelectors.end(); it++) { selectors.push_back(*it); } std::vector<MQLONG> intAttrs(intSelectors.size()); MQLONG charAttrLength = 0; for(std::map<int, int>::const_iterator it = charSelectors.begin(); it != charSelectors.end(); it++) { selectors.push_back(it->first); charAttrLength += it->second; } std::vector<MQCHAR> charAttrs(charAttrLength); inq(conn, obj, (MQLONG) selectors.size(), selectors.size() == 0 ? NULL : &selectors[0], (MQLONG) intAttrs.size(), intAttrs.size() == 0 ? NULL : &intAttrs[0], (MQLONG) charAttrs.size(), charAttrs.size() == 0 ? NULL : &charAttrs[0]); for(int i = 0; i < intAttrs.size(); i++) { intResult[intSelectors[i]] = intAttrs[i]; } std::string result(charAttrs.begin(), charAttrs.end()); for(std::map<int, int>::const_iterator it = charSelectors.begin(); it != charSelectors.end(); it++) { std::string value = result.substr(0, it->second); result.erase(0, it->second); charResult[it->first] = Poco::trimRightInPlace(value); } }
//this function sends characters to the keyboard buffer //from a string of characters void sendtokeyb(const char *s,queue_t *q) { int i; stopints(); for (i=0;s[i];i++) { inq(q,s[i]); }; startints(); };
void MQFunctions::inq(MQHCONN conn, MQHOBJ obj, MQLONG selectorCount, MQLONG* selectors, MQLONG intAttrCount, MQLONG* intAttrs, MQLONG charAttrLength, PMQCHAR charAttrs) { MQLONG cc = MQCC_OK; MQLONG rc = MQRC_NONE; inq(conn, obj, selectorCount, selectors, intAttrCount, intAttrs, charAttrLength, charAttrs, &cc, &rc); if ( cc != MQCC_OK ) { throw MQException("", "MQINQ", cc, rc); } }
void bfsIterative(int node){ visited[node] = 1; inq(node); // visited[node] = 1; // printf("%c ", dic[node]); while(start < end){ //printf("%d %d\n", start , end); int next_node = dq(); printf("%c ", dic[next_node]); int i; for(i = A; i <= G; i++) { if(!visited[i] && g[next_node][i]) { visited[i] = 1; inq(i); } } // int j; // for(j = 0; j <= MAX_N; j++) printf("%c ", dic[Q[j]]); // printf("\n"); } }
void kbd_irq(void) { unsigned scan_code; char temp[255]; unsigned int c; DWORD flags; dex32_stopints(&flags); /* read I/O port 60h to reset interrupt at 8042 keyboard controller chip */ scan_code = inportb(0x60); c=set1_scancode_to_ascii(scan_code); if (c!=-1) { if (!kb_dohotkey(c,kbd_status)) { if (c == SOFT_RESET) ps_shutdown(); else if (c==KEY_F2+400) console_new(); else if (c==KEY_F1+400) dex32_set_tm_state(!dex32_get_tm_state()); else if (c==KEY_F4+400) kill_foreground(); //force terminate else if (c=='c'-'a') signal_foreground(); //ask the app to terminate itself else { if (inq(&_q,c)==-1) beep(); } }; }; dex32_restoreints(flags); };
void TestLimiterNode() { int out_int; tbb::flow::graph g; tbb::flow::limiter_node<int> ln(g,1); REMARK("Testing limiter_node: preds and succs"); ASSERT(ln.decrement.my_predecessor_count == 0, "error in pred count"); ASSERT(ln.decrement.my_initial_predecessor_count == 0, "error in initial pred count"); ASSERT(ln.decrement.my_current_count == 0, "error in current count"); ASSERT(ln.init_decrement_predecessors == 0, "error in decrement predecessors"); ASSERT(ln.my_threshold == 1, "error in my_threshold"); tbb::flow::queue_node<int> inq(g); tbb::flow::queue_node<int> outq(g); tbb::flow::broadcast_node<tbb::flow::continue_msg> bn(g); tbb::flow::make_edge(inq,ln); tbb::flow::make_edge(ln,outq); tbb::flow::make_edge(bn,ln.decrement); g.wait_for_all(); ASSERT(!(ln.my_successors.empty()),"successors empty after make_edge"); ASSERT(ln.my_predecessors.empty(), "input edge reversed"); inq.try_put(1); g.wait_for_all(); ASSERT(outq.try_get(out_int) && out_int == 1, "limiter_node didn't pass first value"); ASSERT(ln.my_predecessors.empty(), "input edge reversed"); inq.try_put(2); g.wait_for_all(); ASSERT(!outq.try_get(out_int), "limiter_node incorrectly passed second input"); ASSERT(!ln.my_predecessors.empty(), "input edge to limiter_node not reversed"); bn.try_put(tbb::flow::continue_msg()); g.wait_for_all(); ASSERT(outq.try_get(out_int) && out_int == 2, "limiter_node didn't pass second value"); g.wait_for_all(); ASSERT(!ln.my_predecessors.empty(), "input edge was reversed(after try_get())"); g.reset(); ASSERT(ln.my_predecessors.empty(), "input edge not reset"); inq.try_put(3); g.wait_for_all(); ASSERT(outq.try_get(out_int) && out_int == 3, "limiter_node didn't pass third value"); REMARK(" rf_clear_edges"); // currently the limiter_node will not pass another message g.reset(tbb::flow::rf_clear_edges); ASSERT(ln.decrement.my_predecessor_count == 0, "error in pred count"); ASSERT(ln.decrement.my_initial_predecessor_count == 0, "error in initial pred count"); ASSERT(ln.decrement.my_current_count == 0, "error in current count"); ASSERT(ln.init_decrement_predecessors == 0, "error in decrement predecessors"); ASSERT(ln.my_threshold == 1, "error in my_threshold"); ASSERT(ln.my_predecessors.empty(), "preds not reset(rf_clear_edges)"); ASSERT(ln.my_successors.empty(), "preds not reset(rf_clear_edges)"); ASSERT(inq.my_successors.empty(), "Arc not removed on reset(rf_clear_edges)"); ASSERT(inq.my_successors.empty(), "Arc not removed on reset(rf_clear_edges)"); ASSERT(bn.my_successors.empty(), "control edge not removed on reset(rf_clear_edges)"); tbb::flow::make_edge(inq,ln); tbb::flow::make_edge(ln,outq); inq.try_put(4); inq.try_put(5); g.wait_for_all(); ASSERT(outq.try_get(out_int),"missing output after reset(rf_clear_edges)"); ASSERT(out_int == 4, "input incorrect (4)"); bn.try_put(tbb::flow::continue_msg()); g.wait_for_all(); ASSERT(!outq.try_get(out_int),"second output incorrectly passed (rf_clear_edges)"); REMARK(" done\n"); }