void *dlopen(const char* pathname, int mode) { message_start(); message_string("Warning: dummy dlopen called with argument `"); message_string(pathname); message_string("'.\n"); message_string(" The statically-linked runtime has failed to load this library."); message_end(); return 0; }
// --------------------------------------------------------------------------- // Constructeur // ------------ bStdAlert::bStdAlert(int kind, int def_btn, bool has_cancel, const char* error_string, const char* explanation_string, bool silent, UInt32 delay){ _res=false; if(silent){ fprintf(stderr,"ALERT : %s\n",error_string); fprintf(stderr,"%s\n",explanation_string); _res=true; return; } AlertStdCFStringAlertParamRec prm; (void)GetStandardAlertDefaultParams(&prm,kStdCFStringAlertVersionOne); prm.defaultButton=def_btn; if(def_btn==kAlertStdAlertOKButton){ prm.cancelButton=kAlertStdAlertCancelButton; } else if(def_btn==kAlertStdAlertCancelButton){ prm.cancelButton=kAlertStdAlertOKButton; } char msg[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgOk,msg,1); prm.defaultText=CFStringCreateWithCString(kCFAllocatorDefault,msg,kCFStringEncodingMacRoman); if(has_cancel){ message_string(kMsgCancel,msg,1); prm.cancelText=CFStringCreateWithCString(kCFAllocatorDefault,msg,kCFStringEncodingMacRoman); } CFStringRef err=CFStringCreateWithCString(kCFAllocatorDefault,error_string,kCFStringEncodingMacRoman); CFStringRef exp=CFStringCreateWithCString(kCFAllocatorDefault,explanation_string,kCFStringEncodingMacRoman); DialogRef alrt; (void)CreateStandardAlert(kind,err,exp,&prm,&alrt); SetDialogTimeout(alrt,def_btn,delay); (void)RunStandardAlert(alrt,NULL,&_hit); _res=(_hit==def_btn); CFRelease(err); CFRelease(exp); }
// --------------------------------------------------------------------------- // // ------------ void bvDefScaleRef::wd_init(WindowRef wd){ _idx=1; read(); ControlRef c; if(_set==1){ c=get_control(kvDefScaleRefViewSignature,kvDefScaleRefTypeNameLegendID); HideControl(c); c=get_control(kvDefScaleRefViewSignature,kvDefScaleRefTypeNameID); HideControl(c); } else{ c=get_control(kvDefScaleRefViewSignature,kvDefScaleRefTypeNameID); char name[256]; if(_tp){ _tp->name(name); } else{ message_string(kMsgVirtual,name,1); } SetTextControlValue(c,name); } c=get_control(kvDefScaleRefViewSignature,kvDefScaleRefPopupID); PopulatePopupControlWithScales(_gapp,c,_idx); }
// --------------------------------------------------------------------------- // // ----------- void bToolPrintArea::set_as_ppsz(WindowRef wd){ ControlRef c; ControlID cid={kPrintAreaSignature,0}; i2dvertex ivxa={_vxr.left,_vxr.bottom}; i2dvertex ivxb={_vxr.right,_vxr.top}; CGPoint pa,pb; char val[256]; float m; Convert(&pa,&ivxa); Convert(&pb,&ivxb); cid.id=kPrintAreaWID; GetControlByID(wd,&cid,&c); m=pb.x-pa.x; m*=(2.54/72.0); sprintf(val,"%.2f",m); SetTextControlValue(c,val); cid.id=kPrintAreaHID; GetControlByID(wd,&cid,&c); m=pb.y-pa.y; m*=(2.54/72.0); sprintf(val,"%.2f",m); SetTextControlValue(c,val); message_string(kMsgCentimetersAB,val,0); for(int i=kPrintAreaWUnitID;i<=kPrintAreaHUnitID;i++){ cid.id=i; GetControlByID(wd,&cid,&c); SetTextControlValue(c,val); } }
PFPSimDebugger::DebugMsg* DebuggerIPCServer::recv() { struct nn_pollfd pfd; pfd.fd = socket; pfd.events = NN_POLLIN; auto rc = nn_poll(&pfd, 1, 100); if (rc == 0) { return nullptr; } if (rc == -1) { // TODO(gordon) printf("Error!"); exit(1); } if (pfd.revents & NN_POLLIN) { char *buf; int bytes = nn_recv(socket, &buf, NN_MSG, 0); if (bytes != -1) { std::string message_string(buf, bytes); nn_freemsg(buf); PFPSimDebugger::DebugMsg *message = new PFPSimDebugger::DebugMsg(); message->ParseFromString(message_string); return message; } else { return nullptr; } } else { return nullptr; } }
void LLMessageTemplateParserTestObject::test<4>() // tests variable parsing method { LLTemplateTokenizer tokens(std::string("{ Test0 \n\t\n U32 \n\n }")); LLMessageVariable * var = LLTemplateParser::parseVariable(tokens); ensure("test0 var parsed", var != 0); ensure_equals("name of variable", std::string(var->getName()), std::string("Test0")); ensure_equals("type of variable is U32", var->getType(), MVT_U32); ensure_equals("size of variable", var->getSize(), 4); delete var; std::string message_string("\n\t{ \t Test1 Fixed \n 523 }\n\n"); tokens = LLTemplateTokenizer(message_string); var = LLTemplateParser::parseVariable(tokens); ensure("test1 var parsed", var != 0); ensure_equals("name of variable", std::string(var->getName()), std::string("Test1")); ensure_equals("type of variable is Fixed", var->getType(), MVT_FIXED); ensure_equals("size of variable", var->getSize(), 523); delete var; // *NOTE: the parsers call llerrs on invalid input, so we can't really // test that :-( }
// --------------------------------------------------------------------------- // // ------------ bool bXMapCloneDetector::detect(clonedetector_prm* prm){ bArray sel(*(_gapp->selMgr()->elements())); bArray* arr; char msg[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgProgress,msg,1); bProgressWait wt("",msg,true,true,sel.count()); _gapp->cntMgr()->flush(); bGenericGeoElement *oa,*ob; bGenericType* tp; ivx_rect vxr; int i,j; bool flg=false; for(i=1;i<=sel.count();i++){ if(!wt.set_progress(i)){ break; } sel.get(i,&oa); if(oa->contrasted()){ continue; } tp=_gapp->typesMgr()->get(oa->getType()); oa->getBounds(&vxr); tp->iterator()->objs_in_rect(&arr,&vxr); if(!arr){ continue; } for(j=1;j<=arr->count();j++){ arr->get(j,&ob); if(oa==ob){ continue; } if(ob->contrasted()){ continue; } if(obj_comp(oa,ob,prm)){ flg=true; if(ob->masked()){ ob->setmasked(false,true); } ob->setcontrast(true,true); } } delete arr; } if(flg){ b_message_string(kXMapCloneFoundMessageID,msg,getbundle(),0); } else{ b_message_string(kXMapNoCloneFoundMessageID,msg,getbundle(),0); } bAlertStop alrt(msg,""); return(true); }
void context_lua_t::on_received(message_t& message) { switch (message_raw_type(message)) { case LUA_CTX_INIT: lua_ctx_init(message); return; case CONTEXT_QUERY: response_context_query(message); break; case CONTEXT_REPLY: response_context_reply(message); break; case LUA_CTX_WAIT: response_context_wait(message); break; case LUA_CTX_WAKEUP: response_context_wakeup(message); break; case RESPONSE_TCP_LISTEN: response_tcp_listen(message); break; case RESPONSE_TCP_ACCEPT: response_tcp_accept(message); break; case RESPONSE_TCP_CONNECT: response_tcp_connect(message); break; case RESPONSE_TCP_READ: response_tcp_read(message); break; case RESPONSE_TCP_WRITE: response_tcp_write(message); break; case RESPONSE_HANDLE_CLOSE: response_handle_close(message); break; case RESPONSE_TCP_CLOSING: response_tcp_closing(message); break; case RESPONSE_TIMEOUT: response_timeout(message); break; case SYSTEM_CTX_DESTROY: singleton_ref(node_lua_t).context_destroy(this, message.m_source, message_string(message)); return; default: break; } if (!is_active()) { singleton_ref(node_lua_t).context_destroy(this, m_handle, "lua context exit normally"); } }
void context_lua_t::lua_pushmessage(lua_State *L, message_t& message) { message_array_t *array = NULL; switch (message_data_type(message)) { case NIL: lua_pushnil(L); return; case TBOOLEAN: lua_pushboolean(L, message_bool(message)); return; case USERDATA: lua_pushlightuserdata(L, message_userdata(message)); return; case NUMBER: lua_pushnumber(L, message_number(message)); return; case INTEGER: lua_pushinteger(L, message_integer(message)); return; case BUFFER: create_buffer(L, message_buffer(message)); return; case STRING: lua_pushstring(L, message_string(message)); return; case BSON: if (message_bson(message)->extract) { bson_decode(message_bson(message), L); } else { create_bson(message_bson(message), L); } return; case TERROR: lua_pushinteger(L, message_error(message)); return; case ARRAY: array = message_array(message); if (array != NULL && array->m_count > 0) { for (int32_t i = 0; i < array->m_count; ++i) { //extract them lua_pushmessage(L, array->m_array[i]); } } else { lua_pushnil(L); } return; default: lua_pushnil(L); return; } }
// --------------------------------------------------------------------------- // // ----------- bool bMacMapType::load(){ _bTrace_("bMacMapType::load",true); bool k,b; long i,n; char cftitle[__MESSAGE_STRING_LENGTH_MAX__],cfprompt[__MESSAGE_STRING_LENGTH_MAX__]; _tm_(_idx+" "+_name); message_string(kMsgOpen,cftitle,true); strcpy(cfprompt,_name); k=true; n=_bse.count_records(); bProgressWait wait(cftitle,cfprompt,true,true,n); for(i=1;i<=n;i++){ if(!wait.set_progress(i)){ _iter->flush(); break; } if(!load_object(i,&b)){ k=false; _te_("false at load_object "+i); break; } if(!b){ continue; } } if(k){ _iter->start(); _bounds.top=_bounds.left=_bounds.bottom=_bounds.right; _iter->iterate(&_bounds,get_rect); _iter->set_bounds(&_bounds); } (void)_styles->load(); return(k); }
static void ReportException(Environment* env, v8::Handle<v8::Value> er, v8::Handle<v8::Message> message) { v8::HandleScope scope(env->isolate()); AppendExceptionLine(env, er, message); v8::Local<v8::Value> trace_value; if (er->IsUndefined() || er->IsNull()) trace_value = Undefined(env->isolate()); else trace_value = er->ToObject()->Get(env->stack_string()); v8::String::Utf8Value trace(trace_value); // range errors have a trace member set to undefined if (trace.length() > 0 && !trace_value->IsUndefined()) { fprintf(stderr, "%s\n", *trace); } else { // this really only happens for RangeErrors, since they're the only // kind that won't have all this info in the trace, or when non-Error // objects are thrown manually. v8::Local<v8::Value> message; v8::Local<v8::Value> name; if (er->IsObject()) { v8::Local<v8::Object> err_obj = er.As<v8::Object>(); message = err_obj->Get(env->message_string()); name = err_obj->Get(FIXED_UTF8_STRING(env->isolate(), "name")); } if (message.IsEmpty() || message->IsUndefined() || name.IsEmpty() || name->IsUndefined()) { // Not an error object. Just print as-is. v8::String::Utf8Value message(er); fprintf(stderr, "%s\n", *message); } else { v8::String::Utf8Value name_string(name); v8::String::Utf8Value message_string(message); fprintf(stderr, "%s: %s\n", *name_string, *message_string); } } fflush(stderr); }
// --------------------------------------------------------------------------- // // ------------ void bXMapReverse::reverse(int dummy){ ivertices* vxs; bGenericGeoElement* o; bArray sel(*(_gapp->selMgr()->elements())); char mess[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgProgress,mess,1); bProgressWait wt("",mess,true,false,sel.count()); _gapp->layersMgr()->SetObjInvalidation(false); for(int i=1;i<=sel.count();i++){ if(!wt.set_progress(i)){ break; } sel.get(i,&o); o->getVertices(&vxs); ivs_reverse(vxs); o->setVertices(vxs); } _gapp->layersMgr()->SetObjInvalidation(true); }
void ZmqServer::serve() { while (1) { try { zmq::message_t message; if (!rep_socket) { throw std::runtime_error("ZMQ RPC server reply socket is null"); } while (rep_socket->recv(&message)) { std::string message_string(reinterpret_cast<const char *>(message.data()), message.size()); MDEBUG(std::string("Received RPC request: \"") + message_string + "\""); std::string response = handler.handle(message_string); zmq::message_t reply(response.size()); memcpy((void *) reply.data(), response.c_str(), response.size()); rep_socket->send(reply); MDEBUG(std::string("Sent RPC reply: \"") + response + "\""); } } catch (const boost::thread_interrupted& e) { MDEBUG("ZMQ Server thread interrupted."); } catch (const zmq::error_t& e) { MERROR(std::string("ZMQ error: ") + e.what()); } boost::this_thread::interruption_point(); } }
// --------------------------------------------------------------------------- // Destructeur // ----------- bMacMapType::~bMacMapType(){ _bTrace_("bMacMapType::~bMacMapType",true); _tm_("deleting "+_idx+" "+_name); if(_iter){ bMacMapGeoElement* geo; bArray arr(sizeof(bMacMapGeoElement*)); char cftitle[__MESSAGE_STRING_LENGTH_MAX__]; char cfprompt[__MESSAGE_STRING_LENGTH_MAX__]; message_string(kMsgClose,cftitle,true); strcpy(cfprompt,_name); _tm_("iterate"); _iter->iterate(&arr,add_to_array); _tm_("flush iterator"); _iter->flush(); _tm_((int)arr.count()+" objects to delete"); bProgressWait wait(cftitle,cfprompt,true,false,arr.count()); for(long i=1;i<=arr.count();i++){ //_tm_(i); wait.set_progress(i); if(arr.get(i,&geo)){ delete geo; } } arr.reset(); _tm_("deleting _iter"); extmgr->get_component(kComponentGeoIterator)->i_free(_iter); } if(_styles){ _tm_("deleting _styles"); _styles->unload(); delete _styles; } }
// --------------------------------------------------------------------------- // // ------------ void bXMapLineUp::make(){ bGenericGeoElement* o; ivx_rect vr,vrb,bnd; bArray arr(*_gapp->selMgr()->elements()); int i,j,ko,kv; int imax,jmax,n=0; insidePtr inside; ivertices *ref,*vxs; i2dvertex p,lp; bool end=false; int hd=round(Measure_d2i(_gapp,_hd)); int vd=round(Measure_d2i(_gapp,_vd)); if(_use_surf){ inside=ivx_in_ivs; _gapp->cntMgr()->elements()->get(1,&o); o->getBounds(&bnd); o->getVertices(&ref); imax=1+(bnd.bottom-bnd.top)/vd; jmax=1+(bnd.right-bnd.left)/hd; } else{ inside=dummy_ivx_in_ivs; arr.get(1,&o); o->getBounds(&bnd); vr=bnd; o->getVertices(&vxs); n+=vxs->nv; for(i=2;i<arr.count();i++){ arr.get(i,&o); o->getBounds(&vrb); ivr_union(&vrb,&vr,&bnd); vr=bnd; o->getVertices(&vxs); n+=vxs->nv; } ref=NULL; if(_kind==kXMapLineUpKindLine){ imax=ceil((double)n/_nb); jmax=_nb; } else{ imax=_nb; jmax=ceil((double)n/_nb); } } _gapp->layersMgr()->SetObjInvalidation(false); char msg[__MESSAGE_STRING_LENGTH_MAX__]; char ttl[__MESSAGE_STRING_LENGTH_MAX__]; get_localized_name(ttl,getbundle()); message_string(kMsgProgress,msg,1); bProgressWait wt(ttl,msg,true,true,arr.count()); bEventLog log(_gapp,this); ko=1; kv=0; arr.get(ko,&o); o->getVertices(&vxs); lp.h=bnd.left; lp.v=bnd.top; for(i=0;i<imax;i++){ for(j=0;j<jmax;j++){ p.h=bnd.left+j*hd; p.v=bnd.top+i*vd; if(!inside(&p,ref,1)){ continue; } lp=p; vxs->vx.vx2[kv]=p; kv++; if(kv==vxs->nv){ kv=0; ko++; o->setVertices(vxs); if(!wt.set_progress(ko)){ end=true; break; } if(!arr.get(ko,&o)){ end=true; break; } o->getVertices(&vxs); } } if(end){ break; } } if(!end){ if(kv<vxs->nv){ for(i=kv;i<vxs->nv;i++){ vxs->vx.vx2[kv]=lp; } o->setVertices(vxs); ko++; } for(i=ko;i<=arr.count();i++){ if(!wt.set_progress(i)){ break; } arr.get(i,&o); o->getVertices(&vxs); for(j=0;j<vxs->nv;j++){ vxs->vx.vx2[j]=lp; } o->setVertices(vxs); } } _gapp->layersMgr()->SetObjInvalidation(true); log.close(); }
int32_t context_lua_t::context_query_yield_finalize(lua_State *root_coro, lua_State *main_coro, void *userdata, uint32_t destination) { if (root_coro != NULL) { context_lua_t* lctx = context_lua_t::lua_get_context(root_coro); message_t& message = lctx->get_yielding_message(); message.m_session = context_lua_t::lua_ref_yield_coroutine(root_coro); bool ret; if (message_is_string(message)) { ret = singleton_ref(node_lua_t).context_send_string_safe(destination, lctx->get_handle(), message.m_session, CONTEXT_QUERY, message_string(message)); } else if (message_is_bson(message)) { } else { ret = singleton_ref(node_lua_t).context_send(destination, message); } if (ret) { int64_t timeout = lctx->get_yielding_timeout(); if (timeout > 0) { context_lua_t::lua_ref_timer(main_coro, message.m_session, timeout, 0, false); } return UV_OK; } else { lua_free_ref_session(main_coro, message.m_session); return NL_ENOCONTEXT; } } return UV_OK; }
// --------------------------------------------------------------------------- // // ------------ bool bMacMapLayerAccessContext::add(int tidx, int sidx){ _bTrace_("bMacMapLayerAccessContext::add",true); bGenericType* tp=typesmgr->get(tidx); bStyle* style; if(tp){ style=new bStyle(); } else{ style=new bVirtualStyle(); } if(!style){ return(false); } if(!_elts->add(&style)){ delete style; return(false); } bArray arr(sizeof(xmlelt)); if(tp){ add_cdesc(arr,0,"layer",""); } else{ add_cdesc(arr,0,"virtuallayer",""); } char name[256]; if(tp){ tp->name(name); } else{ message_string(kMsgVirtual,name,1); } style->settype(name); if(tp){ add_cdesc(arr,1,"type",name); } if(tp){ tp->styles()->get_name(sidx,name); } else{ map_doc->styles()->get_name(sidx,name); } style->setname(name); add_cdesc(arr,1,"style",name); style->setvisible(true); add_idesc(arr,1,"visible",1); style->setselectable(true); add_idesc(arr,1,"selectable",(tp!=0)); bGenericXMLBaseElement *root=clssmgr->ParseXMLDescriptors(&arr); free_descs(arr); if(!root){ delete style; _elts->rmv(_elts->count()); return(false); } style->setlayer(root); _array->addelement(root); parse(_elts->count()); // map_wd->inval(); _MMAPP_->mapIntf()->inval(); return(true); }