/* Default error handler */ static int defaultHandler(int error, opt_Option *opt, char *arg, void *client) { switch (error) { case opt_NoScanner: message("no scanner (%s)\n", opt->name); break; case opt_Missing: message("no value(s) (%s)\n", opt->name); break; case opt_Format: message2("bad value ", arg, opt->name); break; case opt_Range: message2("value out of range ", arg, opt->name); break; case opt_Required: message("required option missing (%s)\n", opt->name); break; case opt_Exclusive: message("mutually exclusive option conflict (%s)\n", opt->name); break; case opt_Unknown: message("unknown option (%s)\n", arg); break; } return 1; }
static void lex_print_state(void) { int i; message("Lex-state\n"); message2("Pos: %i", lex_pos); message2("\tStpos: %i\nStack:", stackpos); for (i=0;i<=stackpos; i++) message2("%i,", stack[i]); message("\nEnd-Lex-state\n"); }
void edit_signal_to_proces(int signl, Char *shname) { EDITINFO *edata; int i=0; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW,&i)) && Ustrcmp(edata->pathname,shname)) i++; if (!edata) { message2(MP_ERROR, shname, translate(" is not running.")); return; } if (!edata->pid) { message2(MP_ERROR, translate("Unable to send signals to "),shname); return; } kill(edata->pid, signl); }
int RPC::connect(const char *host, int port) { // Disconnect if necessary to reconnect disconnect(); // New TCP/IP socket sock = (int)socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) return DISK_ERROR; // Resolve host struct hostent *hostent = gethostbyname(host); if (hostent == NULL) return DISK_ERROR; // Set port struct sockaddr_in peer; memset(&peer, 0, sizeof(peer)); peer.sin_family = AF_INET; memcpy(&peer.sin_addr, hostent->h_addr, hostent->h_length); peer.sin_port = htons((short)port); // Connect if (::connect(sock, (const struct sockaddr*)&peer, sizeof(peer)) < 0) return DISK_ERROR; message2("Connected to %s:%d\n", host, port); return DISK_OK; }
void CDsaWrapTest::testSignVerifyTruncHash() { const quint32 kKeyLength = 1024; const QByteArray kSeed("doiehcogbbbcdeui904704ho900478hdh930dh3dh98"); CDsaWrap dsa; QVERIFY( dsa.GenerateKey(kKeyLength, kSeed) ); CSha256To160 hash; QByteArray message1("123456"), message2("abcdef"); QByteArray digest1, digest2; QVERIFY( dsa.Sign(message1, &hash, digest1) ); QVERIFY( dsa.Sign(message2, &hash, digest2) ); bool bVerifyRes = false; QVERIFY( dsa.Verify(message1, &hash, digest1, bVerifyRes) ); QVERIFY( bVerifyRes ); QVERIFY( dsa.Verify(message1, &hash, digest2, bVerifyRes) ); QVERIFY( !bVerifyRes ); QVERIFY( dsa.Verify(message2, &hash, digest1, bVerifyRes) ); QVERIFY( !bVerifyRes ); QVERIFY( dsa.Verify(message2, &hash, digest2, bVerifyRes) ); QVERIFY( bVerifyRes ); }
/* header to be able to add this function to a menu */ void open_helpfile(void *data, int nr __attribute__((unused))) { Char *c = (Char*) data; int i=0,hpos=0; Char *f; Char *name; Char *fullname; EDITINFO *edata; if (!c || !(f = (Char*) malloc(sizeof(Char)*(Ustrlen(c)+1)))) return; for (i=0; (f[i]=c[i]) ; i++) if (c[i]=='#') if (!i) hpos=-1; else if (hpos) hpos=0; else hpos=i; if (hpos>0) { name = c+hpos+1; f[hpos]='\0'; } else name = c+i; f = standard_dir(f); fullname = search_through_dirs(help_dirs, nr_help_dirs, f); if (!fullname && f[0]=='/') fullname=f; else free(f); if (!fullname) { message(MP_ERROR, translate("Help document not found.")); return; } i=0; while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,fullname)) i++; if (!edata) { as_icon=1; edit_open(); as_icon=0; if (state_window) { edata = state_window; handle_view_filename((void *) state_window, concat(fullname,NULL)); word_wrap_window(edata->info); } } if (!edata) { message2(MP_CLICKREMARK, translate("Unable to open an edit window for document "), name); return; } if (name[0]) { int j=Ustrlen(name)+1; Char *cname = (Char*) malloc(j*sizeof(Char)); if (cname) { for (i=j-1;i>=0; i--) cname[i]=name[i]; editwindow_topto(edata->info, cname); free(cname); } } if (edata->iconized) { XMapWindow(display, edata->win_id); } XRaiseWindow(display, edata->win_id); }
void WBSDDoserWindow::on_leftB2SlowTest_clicked() { ParameterMsg message1(Message::MCB,Message::DV,2); ParameterMsg message2(Message::MCB,Message::DV,16); message1.setBit(10,1); message2.setBit(5,1); itsBaseWindow->addMessageToQue(message1); itsBaseWindow->addMessageToQue(message2); }
void WBSDDoserWindow::on_rightB2Test_released() { ParameterMsg message1(Message::MCB,Message::DV,2); ParameterMsg message2(Message::MCB,Message::DV,16); message1.setBit(10,0); message2.setBit(12,0); itsBaseWindow->addMessageToQue(message2); itsBaseWindow->addMessageToQue(message1); }
void WBSDOutletWindow::on_rbibAirValve_pressed() { ParameterMsg message1(Message::MCB,Message::DV,2,Message::SET_PARAMETER); ParameterMsg message2(Message::MCB,Message::DV,15,Message::SET_PARAMETER); message1.setBit(10,1); message2.setBit(11,1); itsBaseWindow->addMessageToQue(message1); itsBaseWindow->addMessageToQue(message2); }
void WBSDOutletWindow::on_coldWaterValve_released() { ParameterMsg message1(Message::MCB,Message::DV,2,Message::SET_PARAMETER); ParameterMsg message2(Message::MCB,Message::DV,15,Message::SET_PARAMETER); message1.setBit(10,0); message2.setBit(7,0); itsBaseWindow->addMessageToQue(message2); itsBaseWindow->addMessageToQue(message1); }
void WBSDOutletWindow::on_normalOpenValve_released() { ParameterMsg message1(Message::MCB,Message::DV,2,Message::SET_PARAMETER); ParameterMsg message2(Message::MCB,Message::DV,15,Message::SET_PARAMETER); message1.setBit(10,0); message2.setBit(4,0); qDebug() << "No 2 r"; itsBaseWindow->addMessageToQue(message2); qDebug() << "No 1 r"; itsBaseWindow->addMessageToQue(message1); }
static void handle_view_filename(void *data, Char *name) { EDITINFO *einf = (EDITINFO *) data; if (name) { FILE *f; int i; if (!(f = fopen((char*)UstrtoFilename(name),"rb"))) { message2(MP_CLICKREMARK, translate("Unable to open file "), name); free(name); failure=MP_True; return; } i=test_file(f); set_wait_cursor(einf->win_id); switch (i) { case BINDOC: message(MP_MESSAGE, translate("Viewing ascii file.")); read_file(f,BINARYFILE); unset_file(); load_editwindow(einf->info); break; case OLDDOC: i = edit_fnr; edit_fnr = 0; view_notation_filenames(f); old_load_editwindow(einf->info,f); edit_fnr = i; break; case NEWDOC: i = edit_fnr; edit_fnr = 0; read_file(f,DOCUMENTFILE); unset_file(); load_editwindow(einf->info); edit_fnr = i; break; default: break; } fclose(f); cleanup_filestack(); cleanup_stencilstack(); cleanup_nodestack(); einf->saved = MP_True; einf->auto_saved = MP_True; einf->view_mode = MP_True; set_name(einf, name); set_output_name(einf); remove_wait_cursor(); return; } free(name); }
void CGUIControlGroupList::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { if (m_scroller.Update(currentTime)) MarkDirtyRegion(); // first we update visibility of all our items, to ensure our size and // alignment computations are correct. for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; GUIPROFILER_VISIBILITY_BEGIN(control); control->UpdateVisibility(); GUIPROFILER_VISIBILITY_END(control); } ValidateOffset(); if (m_pageControl && m_lastScrollerValue != m_scroller.GetValue()) { CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (int)Size(), (int)m_totalSize); SendWindowMessage(message); CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (int)m_scroller.GetValue()); SendWindowMessage(message2); m_lastScrollerValue = m_scroller.GetValue(); } // we run through the controls, rendering as we go int index = 0; float pos = GetAlignOffset(); for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_scroller.GetValue()); else g_graphicsContext.SetOrigin(m_posX + pos - m_scroller.GetValue(), m_posY); control->DoProcess(currentTime, dirtyregions); if (control->IsVisible()) { if (IsControlOnScreen(pos, control)) { if (control->HasFocus()) m_focusedPosition = index; index++; } pos += Size(control) + m_itemGap; } g_graphicsContext.RestoreOrigin(); } CGUIControl::Process(currentTime, dirtyregions); }
void CGUIControlGroupList::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { if (m_scrollSpeed != 0) { MarkDirtyRegion(); m_offset += m_scrollSpeed * (currentTime - m_scrollLastTime); if ((m_scrollSpeed < 0 && m_offset < m_scrollOffset) || (m_scrollSpeed > 0 && m_offset > m_scrollOffset)) { m_offset = m_scrollOffset; m_scrollSpeed = 0; } } m_scrollLastTime = currentTime; // first we update visibility of all our items, to ensure our size and // alignment computations are correct. for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; GUIPROFILER_VISIBILITY_BEGIN(control); control->UpdateVisibility(); GUIPROFILER_VISIBILITY_END(control); } ValidateOffset(); if (m_pageControl) { CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (int)m_height, (int)m_totalSize); SendWindowMessage(message); CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (int)m_offset); SendWindowMessage(message2); } // we run through the controls, rendering as we go float pos = GetAlignOffset(); for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_offset); else g_graphicsContext.SetOrigin(m_posX + pos - m_offset, m_posY); control->DoProcess(currentTime, dirtyregions); if (control->IsVisible()) pos += Size(control) + m_itemGap; g_graphicsContext.RestoreOrigin(); } CGUIControl::Process(currentTime, dirtyregions); }
TEST (message, keepalive_deserialize) { rai::keepalive message1; message1.peers[0] = rai::endpoint (boost::asio::ip::address_v6::loopback (), 10000); std::vector<uint8_t> bytes; { rai::vectorstream stream (bytes); message1.serialize (stream); } rai::bufferstream stream (bytes.data (), bytes.size ()); auto error (false); rai::message_header header (error, stream); ASSERT_FALSE (error); ASSERT_EQ (rai::message_type::keepalive, header.type); rai::keepalive message2 (error, stream, header); ASSERT_FALSE (error); ASSERT_EQ (message1.peers, message2.peers); }
/* create temporary file with PVS header */ PVSProof *pvs_temporary_file(int nr, FILE **f) { char buffer[1024]; char *head; int clnr; PVSProof *pvsproof; sprintf(buffer, "%s/%s%i.pvs", UstrtoFilename(pvs_context_dir), UstrtoFilename(pvs_hint_file), nr); *f=fopen(buffer, "wb"); if (!*f) { message2(MP_ERROR, translate("Unable to create temporary PVS file "), LocaletoUstr((unsigned char*)buffer)); return NULL; } pvsproof = malloc(sizeof(PVSProof)); if (!pvsproof) { return NULL; } pvsproof->file = strdup(buffer); { char *theoryname; theoryname = strrchr(buffer, '.'); *theoryname=0; theoryname = strrchr(buffer,'/'); theoryname++; pvsproof->theory = strdup(theoryname); } head = (char*)UstrtoLocale(translate("PVS_HEADER")); fprintf(*f, "%s%s\n", pvsproof->theory, head); clnr=0; while (*head) { if (*head=='\n') clnr++; head++; } clnr++; pvsproof->linenr = clnr; pvsproof->lemma=0; pvsproof->step=0; pvsproof->next=0; return pvsproof; }
static void edit_handle_fileselc_output(void *data, Char *name) { EDITINFO *einf = (EDITINFO *) data; FILE *f; if (aig(f=fopen((char*)UstrtoFilename(name), "w"))) { tex_set_file(f); tex_mode(texmode); tex_placeholders(ON); latex_editwindow(einf->info); tex_unset(); fclose(f); free(einf->outputname); einf->outputname = name; sprintf(envbuf,"OUTPUTFILE=%s", UstrtoFilename(einf->outputname)); if (putenv(envbuf)!=0) printf("No outputfile set!!!\n"); message(MP_MESSAGE, translate("Document converted.")); } else { message2(MP_CLICKREMARK, translate("No output made. Unable to open file "), name); failure=MP_True; } }
TEST(UnitTestTeeStreambuf, UnitTest) { stk::tee_streambuf out_tee_streambuf; std::ostream my_out(&out_tee_streambuf); std::ostringstream dest1; std::ostringstream dest2; out_tee_streambuf.add(&dest1); out_tee_streambuf.add(&dest2); std::string message1("This is a test"); std::string message2("This is a test"); std::string message3 = message1 + message2; my_out << message1; ASSERT_EQ((dest1.str() == message1), true); ASSERT_EQ((dest2.str() == message1), true); out_tee_streambuf.remove(&dest2); my_out << message2; ASSERT_EQ((dest1.str() == message3), true); ASSERT_EQ((dest2.str() == message1), true); out_tee_streambuf.remove(&dest1); my_out << message2; ASSERT_EQ((dest1.str() == message3), true); ASSERT_EQ((dest2.str() == message1), true); }
int pvs_parse_prove(unsigned char *buffer, unsigned int *len) { char *pos, *startat; if (!toproof || !curstep) { /* end of proof, expect a 'really want to quit?' prompt */ if (strstr(buffer,"want to quit?")) { edit_string_to_proces(translate("y\n"), translate("PVS-shell")); } return 0; } startat=(char*)buffer; while (startat && *startat) { switch (prove_pos) { case InRubbish: pos = strstr(startat, "Q.E.D."); if (pos) { Char *pvsres; Char txt[10240]; pvsres = translate("PVS Results"); string_to_window(pvsres, LocaletoUstr((unsigned char*)toproof->lemma)); string_to_window(pvsres, translate(" is correct according to PVS.\n")); curstep = curstep->next; txt[0]=0; while (curstep) { if (curstep->steptype == KeywordStep) { string_to_window(pvsres, translate("Warning: keyword \"")); string_to_window(pvsres, curstep->keyword->str); string_to_window(pvsres, translate("\" is not needed\n")); Ustrcat(txt, translate("Warning: keyword \"")); Ustrcat(txt, curstep->keyword->str); Ustrcat(txt, translate("\" is not needed.\n")); } curstep=curstep->next; } if (txt[0]) { int i=Ustrlen(txt); make_node(MP_Text, txt, i, 0,0); txt[0]=PhNum2Char(MP_Text,1); make_node(MP_Op, txt, 1, warning_template,0); } else { make_node(MP_Op, txt, 0, good_template,0); } finish_current_proof(0); startat=0; break; } pos = strstr(startat, "this yields "); if (pos && strstr(pos, "subgoals")) { Char *pvsres; Char *split_error; Char txt[1024]; pvsres = translate("PVS Results"); split_error = translate(": PVS split the proof into subgoals. Unable to proceed."); string_to_window(pvsres, LocaletoUstr((unsigned char*)toproof->lemma)); string_to_window(pvsres, split_error); string_to_window(pvsres, LocaletoUstr("\n")); message2(MP_ERROR, LocaletoUstr(toproof->lemma), split_error); Ustrcpy(txt, split_error); make_node(MP_Text, txt, Ustrlen(txt),0,0); txt[0]=PhNum2Char(MP_Text,1); make_node(MP_Op, txt, 1, wrong_template, 0); finish_current_proof(1); startat=0; break; } pos = strstr(startat, "want to quit?"); if (pos) { edit_string_to_proces(translate("y\n"), translate("PVS-shell")); startat=0; /* no matter what happened, the proof is finished */ break; } pos = strstr(startat, toproof->lemma); if (pos) { pos=pos+strlen(toproof->lemma); if (*pos!='.') { /* perhaps could use strchr(pos,'\n') here. */ while (*pos && *pos!=':') pos++; if (*pos==':') pos++; while (*pos==' ' || *pos=='\t') pos++; while (*pos=='\n') pos++; step_clear_result(curstep); prove_pos = InExpr; startat = pos; break; } } pos = strstr(startat, "Rule? "); if (pos) { if (!pos[6]) { /* !pos[6] indicates that there is no more input yet. */ if (curstep->next) { ProofStep *h=curstep; /* send next step */ curstep=curstep->next; if (curstep->pvsinput) { edit_string_to_proces(LocaletoUstr(curstep->pvsinput), translate("PVS-shell")); } if (curstep->keyword) { edit_string_to_proces(LocaletoUstr(curstep->keyword->step), translate("PVS-shell")); } if (curstep->use_result) { PVSProof *prf; pvs_use_result(h->result, curstep->use_result-1); curstep=0; prf=toproof; toproof=toproof->next; destruct_selection(prf->selection); /* free prf */ } } else { Char *pvsres; Char *insuf_error; pvsres= translate("PVS Results"); insuf_error= translate(": Insufficient information to prove the selected hint."); message2(MP_ERROR, LocaletoUstr(toproof->lemma), insuf_error); string_to_window(pvsres, LocaletoUstr(toproof->lemma)); string_to_window(pvsres, insuf_error); string_to_window(pvsres, LocaletoUstr("\n")); string_to_window(pvsres, translate("The proof attempt ends with the following PVS expression:\n")); /* add parse - diff - analyse routine here */ if (1) { Char txt[2]; pvs_parse_result(curstep->result); txt[0]=PhNum2Char(MP_Text,1); make_node(MP_Op, txt, 1, wrong_template,0); /* structure_to_window(pvsres); */ } else { string_to_window(pvsres, LocaletoUstr(curstep->result)); } string_to_window(pvsres, LocaletoUstr("\n")); finish_current_proof(1); } } startat=pos+6; break; } pos = strstr(startat, ";;; GC:"); if (pos) { message(MP_MESSAGE, translate("PVS collects garbage. One moment please.")); startat = pos+7; break; } pos = strstr(startat, ";;; Finished GC"); if (pos) { message(MP_MESSAGE, translate("PVS finished collecting garbage. Sorry for the inconvenience.")); startat = pos+15; break; } /* nothing usefull found. Just skip everything. */ startat=0; break; case InExpr: /* search for the PVS prompt */ if (after_newline && startat[0]=='\n') { int stepreslen; stepreslen = strlen(curstep->result); curstep->result[stepreslen-1]=0; startat++; after_newline=0; prove_pos=InRubbish; } else { pos = strstr(startat, "\n\n"); if (pos) { *pos=0; step_add_to_result(curstep,startat); after_newline=0; startat=pos+2; prove_pos=InRubbish; } else { step_add_to_result(curstep,startat); if (startat[strlen(startat)-1]=='\n') { after_newline=1; } startat = 0; } } break; default: fprintf(stderr, "Bad case in pvs_parse_prove.\n"); startat=0; break; } } *len=0; return 0; }
void queues_getting_started_sample() { try { // Initialize storage account azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); // Create a queue azure::storage::cloud_queue_client queue_client = storage_account.create_cloud_queue_client(); azure::storage::cloud_queue queue = queue_client.get_queue_reference(U("my-sample-queue")); // Return value is true if the queue did not exist and was successfully created. queue.create_if_not_exists(); // Insert some queue messages azure::storage::cloud_queue_message message1(U("some message")); queue.add_message(message1); azure::storage::cloud_queue_message message2(U("different message")); queue.add_message(message2); azure::storage::cloud_queue_message message3(U("another message")); queue.add_message(message3); // Peek the next queue message azure::storage::cloud_queue_message peeked_message = queue.peek_message(); ucout << U("Peek: ") << peeked_message.content_as_string() << std::endl; // Dequeue the next queue message azure::storage::cloud_queue_message dequeued_message = queue.get_message(); ucout << U("Get: ") << dequeued_message.content_as_string() << std::endl; // Update a queue message (content and visibility timeout) dequeued_message.set_content(U("changed message")); queue.update_message(dequeued_message, std::chrono::seconds(30), true); ucout << U("Update: ") << dequeued_message.content_as_string() << std::endl; // Delete the queue message queue.delete_message(dequeued_message); // Dequeue some queue messages (maximum 32 at a time) and set their visibility timeout to 5 minutes azure::storage::queue_request_options options; azure::storage::operation_context context; std::vector<azure::storage::cloud_queue_message> messages = queue.get_messages(32, std::chrono::seconds(300), options, context); for (std::vector<azure::storage::cloud_queue_message>::const_iterator it = messages.cbegin(); it != messages.cend(); ++it) { ucout << U("Get: ") << it->content_as_string() << std::endl; } // Delete the queue messages for (std::vector<azure::storage::cloud_queue_message>::iterator it = messages.begin(); it != messages.end(); ++it) { queue.delete_message(*it); } // Get the approximate queue size queue.download_attributes(); ucout << U("Approximate message count: ") << queue.approximate_message_count() << std::endl; // Delete the queue // Return value is true if the queue did exist and was succesfully deleted. queue.delete_queue_if_exists(); } catch (const azure::storage::storage_exception& e) { ucout << U("Error: ") << e.what() << std::endl; azure::storage::request_result result = e.result(); azure::storage::storage_extended_error extended_error = result.extended_error(); if (!extended_error.message().empty()) { ucout << extended_error.message() << std::endl; } } catch (const std::exception& e) { ucout << U("Error: ") << e.what() << std::endl; } }
void attack_lit_deff (void) { message2 (&font_fixed6, "MARTIAN ATTACK", "IS LIT"); }
bool Trigger::Initialise(std::string configfile, DataModel &data){ if(configfile!="") m_variables.Initialise(configfile); //m_variables.Print(); m_data= &data; m_variables.Get("verbose",m_verbose); m_variables.Get("VME_service_name",VME_service_name); m_variables.Get("numVME",numVME); m_variables.Get("VME_port",VME_port); m_data->triggered=false; std::vector<Store*> RemoteServices; zmq::socket_t Ireceive (*(m_data->context), ZMQ_DEALER); Ireceive.connect("inproc://ServiceDiscovery"); for(int i=0;i<11;i++){ zmq::message_t send(256); snprintf ((char *) send.data(), 256 , "%s" ,"All NULL") ; Ireceive.send(send); zmq::message_t receive; Ireceive.recv(&receive); std::istringstream iss(static_cast<char*>(receive.data())); int size; iss>>size; for(int i=0;i<RemoteServices.size();i++){ delete RemoteServices.at(i); RemoteServices.at(i)=0; } RemoteServices.clear(); for(int i=0;i<size;i++){ Store *service = new Store; zmq::message_t servicem; Ireceive.recv(&servicem); std::istringstream ss(static_cast<char*>(servicem.data())); service->JsonPaser(ss.str()); std::string servicetype; service->Get("msg_value",servicetype); //printf("%s \n",servicetype.c_str()); if(servicetype==VME_service_name) RemoteServices.push_back(service); else delete service ; } if (RemoteServices.size()==numVME)break; else usleep(1500000); } if (RemoteServices.size()!=numVME){ Log("ERROR!! Cant find all of the VME boards",0,m_verbose); return false; } for(int i=0;i<RemoteServices.size();i++){ std::string ip; //int logport=24010; //*(it->second)>> output; ip=*((*(RemoteServices.at(i)))["ip"]); zmq::socket_t *RemoteSend = new zmq::socket_t(*(m_data->context), ZMQ_DEALER); int a=12000; RemoteSend->setsockopt(ZMQ_SNDTIMEO, a); RemoteSend->setsockopt(ZMQ_RCVTIMEO, a); std::stringstream tmp; tmp<<"tcp://"<<ip<<":"<<VME_port; // printf("%s \n",tmp.str().c_str()); RemoteSend->connect(tmp.str().c_str()); VMESockets.push_back(RemoteSend); } for(int i=0;i<RemoteServices.size();i++){ delete RemoteServices.at(i); RemoteServices.at(i)=0; } RemoteServices.clear(); /* backup zmq::socket_t *RemoteSend = new zmq::socket_t(*(m_data->context), ZMQ_DEALER); int a=12000; RemoteSend->setsockopt(ZMQ_SNDTIMEO, a); RemoteSend->setsockopt(ZMQ_RCVTIMEO, a); std::stringstream tmp; tmp<<"tcp://"<<"192.168.1.21"<<":"<<VME_port; // printf("%s \n",tmp.str().c_str()); RemoteSend->connect(tmp.str().c_str()); VMESockets.push_back(RemoteSend); */ ///////// Sending trigger settings //////////// // std::cout<<"VMESockets.size() "<<VMESockets.size()<<std::endl; for (int i=0;i<VMESockets.size();i++){ //std::cout<<"debug 1 "<<i<<std::endl; std::string query="Initialise"; zmq::message_t message(query.length()+1); snprintf ((char *) message.data(), query.length()+1 , "%s" ,query.c_str() ) ; // std::cout<<"debug 2"<<std::endl; if( VMESockets.at(i)->send(message)){ //std::cout<<"debug 3"<<std::endl; std::string setup; //m_variables.Print(); m_variables>>setup; //std::cout<<"setup "<<setup<<std::endl; zmq::message_t message2(setup.length()+1); snprintf ((char *) message2.data(), setup.length()+1 , "%s" ,setup.c_str() ) ; //std::cout<<"debug 4 "<<setup<<std::endl; VMESockets.at(i)->send(message2); // std::cout<<"debug 5"<<std::endl; zmq::message_t re; if(VMESockets.at(i)->recv(&re)){ std::istringstream iss2(static_cast<char*>(re.data())); // std::cout<<"debug 6 "<<iss2.str()<<std::endl; } else{ Log("Error receiving trigger query from VME",0,m_verbose); return false; } //std::cout<<"debug 7"<<std::endl; } else{
void fatal1(const char *a) { message2(fatal, a); exit(1); }
int RPC::dispatch(Disk& disk) { char buf[NDISK_BLOCK_SIZE]; char packet[NDISK_BLOCK_SIZE + 8]; size_t len = NDISK_BLOCK_SIZE + 8; char *msg = packet; if (disk.block_size() != NDISK_BLOCK_SIZE) return DISK_ERROR; // Read the packet (with 8-byte header) do { ssize_t nread = recv(sock, msg, len, 0); if (nread <= 0) return DISK_ERROR; len -= nread; msg += nread; } while (len > 0); // Get the command from the packet's first four bytes char command[5]; memcpy(command, packet, 4); command[4] = '\0'; // Get the block number parameter from the packet int block_num = ston(packet + 4); if (!strcmp(command, "NUMB")) { // Write num blocks into packet data ntos(packet + 8, disk.num_blocks()); } else if (!strcmp(command, "FRMT")) { disk.format(block_num); } else if (!strcmp(command, "READ")) { disk.read(block_num, buf); memcpy(packet + 8, buf, NDISK_BLOCK_SIZE); } else if (!strcmp(command, "WRTE")) { memcpy(buf, packet + 8, NDISK_BLOCK_SIZE); disk.write(block_num, buf); } else { message1("Unknown RPC command %s\n", command); } message2("RPC command %s(%d)\n", command, block_num); len = NDISK_BLOCK_SIZE + 8; msg = packet; // Write the packet (with 8-byte header) do { ssize_t nwritten = send(sock, msg, len, 0); if (nwritten < 0) return DISK_ERROR; len -= nwritten; msg += nwritten; } while (len > 0); return DISK_OK; }
void CGUIControlGroupList::Render() { if (m_scrollSpeed != 0) { m_offset += m_scrollSpeed * (m_renderTime - m_scrollTime); if (m_scrollSpeed < 0 && m_offset < m_scrollOffset || m_scrollSpeed > 0 && m_offset > m_scrollOffset) { m_offset = m_scrollOffset; m_scrollSpeed = 0; } } m_scrollTime = m_renderTime; ValidateOffset(); if (m_pageControl) { CGUIMessage message(GUI_MSG_LABEL_RESET, GetParentID(), m_pageControl, (DWORD)m_height, (DWORD)m_totalSize); SendWindowMessage(message); CGUIMessage message2(GUI_MSG_ITEM_SELECT, GetParentID(), m_pageControl, (DWORD)m_offset); SendWindowMessage(message2); } // we run through the controls, rendering as we go bool render(g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height)); float pos = 0; float focusedPos = 0; CGUIControl *focusedControl = NULL; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { // note we render all controls, even if they're offscreen, as then they'll be updated // with respect to animations CGUIControl *control = *it; control->UpdateVisibility(); if (m_renderFocusedLast && control->HasFocus()) { focusedControl = control; focusedPos = pos; } else { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + pos - m_offset); else g_graphicsContext.SetOrigin(m_posX + pos - m_offset, m_posY); control->DoRender(m_renderTime); } if (control->IsVisible()) pos += Size(control) + m_itemGap; g_graphicsContext.RestoreOrigin(); } if (focusedControl) { if (m_orientation == VERTICAL) g_graphicsContext.SetOrigin(m_posX, m_posY + focusedPos - m_offset); else g_graphicsContext.SetOrigin(m_posX + focusedPos - m_offset, m_posY); focusedControl->DoRender(m_renderTime); } if (render) g_graphicsContext.RestoreClipRegion(); CGUIControl::Render(); }
void edit_string_to_proces(Char *txt, Char *shname) { EDITINFO *edata; char *c,*h; Char *d; char *arg[4]; Bool only_text=MP_False; int len=0,i=0; char lpref='\0'; /* ** txt uses the following format sequences: ** %t %1 target selection ** %s %2 source selection ** %a %3 argument selection ** %P? ? is added at the beginning of each line (in a selection) ** %T only text place holders are passed through ** %E all place holders are passed through ** %? ? character ** To add: some way to select the output mode. */ while (aig(edata = (EDITINFO*) next_data_with_type(MAINEDITWINDOW, &i)) && Ustrcmp(edata->pathname,shname)) i++; if (!edata) { message2(MP_ERROR, shname,translate(" is not running.")); return; } if (!edata->shell) { message2(MP_ERROR, shname,translate(" can not receive input.")); return; } if (edata->fini) { message2(MP_ERROR, shname,translate(" is finished.")); return; } if (!edata->strt) message2(MP_MESSAGE, shname, translate(" is still busy.")); /* scan txt for arguments, to determine len */ d=txt; for (i=0; i<4; arg[i++]=NULL); while (*d) { switch (*d) { case '%': d++; i=0; switch (*d) { case 't': case '1': i=1; break; case 's': case '2': i=2; break; case 'a': case '3': i=3; break; case 'P': d++; lpref=*d; if (!*d) d--; break; case 'T': only_text=MP_True; break; case 'E': only_text=MP_False; break; case '\0': c--; break; default: len++; break; } if (i) { if (!arg[i]) { tex_set_string(&arg[i]); tex_placeholders(ON); tex_mode(ASCII); latex_text_only(only_text); latex_selection(i); latex_text_only(MP_False); tex_unset(); } if (arg[i]) { len+=strlen(arg[i]); if (lpref>32) { h=arg[i]; while (*h) { if (*h=='\n') len++; h++; } } } else { arg[0]=malloc(sizeof(char)); arg[0][0]=0; } } break; default: len++; break; } d++; } if (arg[0]) { message(MP_ERROR, translate("Selections not set properly.")); for (i=0;i<4;i++) if (arg[i]) free(arg[i]); return; } /* make string */ c=h=(char*)malloc(sizeof(char)*(len+2)); while (*txt) { switch (*txt) { case '%': txt++; i=0; switch (*txt) { case 't': case '1': i=1; break; case 's': case '2': i=2; break; case 'a': case '3': i=3; break; case 'P': txt++; lpref=*txt; if (!*txt) txt--; break; case 'T': break; case '\0': txt--; break; default: *h++=*txt; break; } if (i && arg[i]) { if (lpref>32) { char *t=arg[i]; while (aig(*h=*t)) { if (*h=='\n') { h++; *h=lpref; } h++; t++; } } else { strcpy(h, arg[i]); while (*h) h++; } } break; default: *h++=*txt; break; } txt++; } *h='\0'; /* send string c */ edit_send_to_proces((void*)edata, (unsigned char*) c, len); free(c); for (i=0; i<4; i++) if (arg[i]) free(arg[i]); }
void luck_award_deff (void) { const char *award = luck_awards[0]; message2 (&font_fixed6, "STROKE OF LUCK", award); }
static void handle_filename(void *data, Char *name) { EDITINFO *einf = (EDITINFO *) data; if (name) { FILE *f; int i; int check_found = check_name(einf, name); if (!(f = fopen((char*)UstrtoFilename(name),"rb"))) { message2(MP_CLICKREMARK, translate("Unable to open file "), name); free(name); failure=MP_True; return; } i = test_file(f); set_wait_cursor(einf->win_id); switch (i) { case BINDOC: message(MP_MESSAGE, translate("Loading ascii file.")); read_file(f,BINARYFILE); unset_file(); load_editwindow(einf->info); break; case OLDDOC: i = edit_fnr; edit_fnr = 0; load_notation_filenames(f); old_load_editwindow(einf->info,f); edit_fnr = i; if (!state_open) clear_file_ref(); break; case NEWDOC: i = edit_fnr; edit_fnr = 0; read_file(f,DOCUMENTFILE); unset_file(); load_editwindow(einf->info); edit_fnr = i; break; default: break; } fclose(f); cleanup_nodestack(); cleanup_filestack(); cleanup_stencilstack(); einf->saved = MP_True; einf->auto_saved = MP_True; einf->view_mode = check_found; set_name(einf, name); set_output_name(einf); name = NULL; remove_wait_cursor(); if (check_found) message(MP_CLICKREMARK, translate("The document is already loaded.\n" "This copy has been loaded in view mode\n" "in order to ensure that only one\n" "backup is made.")); return; } free(name); }
void luck_lit_deff (void) { message2 (&font_fixed6, "STROKE OF LUCK", "IS LIT"); }