END_TEST #define test_i(type, var, format) \ do { \ omlc_set_ ## type(to, var); \ fail_unless(omlc_get_ ## type(to) == var, \ "Error setting " #type ", expected %" format ", got %" format, \ var, omlc_get_ ## type(to)); \ from = to; \ fail_unless(omlc_get_ ## type(from) == var, \ "Error copying" #type ", expected %" format ", got %" format, \ var, omlc_get_ ## type(to)); \ } while(0) START_TEST (test_intrinsic) { OmlValueU to, from; int32_t i32 = -123234; uint32_t u32 = 128937; int64_t i64 = -123234892374; uint64_t u64 = 128939087987; double d = M_PI; omlc_zero(to); omlc_zero(from); test_i(int32, i32, "i"); test_i(uint32, u32, "u"); test_i(int64, i64, PRId64); test_i(uint64, u64, PRIu64); test_i(double, d, "f"); test_i(bool, 0, "d"); test_i(bool, 1, "d"); }
PortableServer::Servant ServantLocator::preinvoke ( const PortableServer::ObjectId & /* oid */, PortableServer::POA_ptr /* adapter */, const char * operation, PortableServer::ServantLocator::Cookie & /* the_cookie */) { if (ACE_OS::strcmp (operation, "shutdown") != 0) { if (receive_request_service_contexts_called == 0) { error_status_ = true; ACE_ERROR ((LM_ERROR, "PortableInterceptor::ServerRequestInterceptor:: " "receive_request_service_contexts() not called\n" "prior to " "PortableServer::ServantLocator::preinvoke().\n")); throw CORBA::INTERNAL (); } if (this->servant_.in () == 0) { test_i * servant; ACE_NEW_THROW_EX (servant, test_i (this->orb_.in ()), CORBA::NO_MEMORY ()); this->servant_ = servant; } } return this->servant_.in (); }
PortableServer::Servant create_test_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) { PortableServer::Servant servant; ACE_NEW_RETURN (servant, test_i (orb, poa), 0); return servant; }
int EventNotify::notify_i(int id, int usecs) { if (!test_i(id)) { return -1; } lock(); serialTest[id].used = false; serialTest[id].notified = true; ::pthread_cond_broadcast(&cond); unlock(); return 0; }
static void TestI(void) { static int nums[] = { 0, 1, -1, 10, -10, 32767, -32768, }; static char *signs[] = { "", "0", "-", "+", " ", "0-", "0+", "0 ", "-0", "-+", "- ", "+0", "+-", "+ ", " 0", " -", " +", "0-+", "0- ", "0+-", "0+ ", "0 -", "0 +", "-0+", "-0 ", "-+0", "-+ ", "- 0", "- +", "+0-", "+0 ", "+-0", "+- ", "+ 0", "+ -", " 0-", " 0+", " -0", " -+", " +0", " +-", "0-+ ", "0- +", "0+- ", "0+ -", "0 -+", "0 +-", "-0+ ", "-0 +", "-+0 ", "-+ 0", "- 0+", "- +0", "+0- ", "+0 -", "+-0 ", "+- 0", "+ 0-", "+ -0", " 0-+", " 0+-", " -0+", " -+0", " +0-", " +-0", }; static char *precs[] = { "", "3", "5", "43", "7.3", "7.5", "7.11", "7.43", }; static char *formats[] = { "d", "o", "x", "u", "hd", "ho", "hx", "hu" }; int f, s, n, p; char fmt[20]; for (f = 0; f < countof(formats); f++) { for (s = 0; s < countof(signs); s++) { for (p = 0; p < countof(precs); p++) { fmt[0] = '%'; fmt[1] = 0; if (signs[s]) strcat(fmt, signs[s]); if (precs[p]) strcat(fmt, precs[p]); if (formats[f]) strcat(fmt, formats[f]); for (n = 0; n < countof(nums); n++) { test_i(fmt, nums[n]); } } } } }
PortableServer::Servant supply_servant (const PortableServer::ObjectId &oid, PortableServer::POA_ptr poa, CORBA::ORB_ptr orb) { PortableServer::Servant servant = 0; // Convert ObjectId to string. CORBA::String_var s = PortableServer::ObjectId_to_string (oid); if (ACE_OS::strstr (s.in (), "test") != 0) ACE_NEW_RETURN (servant, test_i (orb, poa), 0); return servant; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { #if TAO_HAS_INTERCEPTORS == 1 Server_ORBInitializer *temp_initializer = 0; ACE_NEW_RETURN (temp_initializer, Server_ORBInitializer, -1); // No exceptions yet! PortableInterceptor::ORBInitializer_var orb_initializer = temp_initializer; PortableInterceptor::register_orb_initializer (orb_initializer.in ()); #endif /* TAO_HAS_INTERCEPTORS == 1 */ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "Server ORB"); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (::parse_args (argc, argv) != 0) return -1; test_i *test_impl; ACE_NEW_RETURN (test_impl, test_i (number, orb.in ()), 1); PortableServer::ServantBase_var owner_transfer (test_impl); PortableServer::ObjectId_var id = root_poa->activate_object (test_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); RedirectionTest::test_var test = RedirectionTest::test::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test.in ()); FILE *output_file= ACE_OS::fopen (ior_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file <%s> for writing " "IOR: %C\n", ior_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); if (server_number == 2) ACE_OS::exit (1); poa_manager->activate (); // Run the ORB event loop. orb->run (); root_poa->destroy (1, 1); orb->destroy (); ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "Server ORB"); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (::parse_args (argc, argv) != 0) return -1; test_i *test_impl = 0; ACE_NEW_RETURN (test_impl, test_i (1, orb.in ()), 1); PortableServer::ServantBase_var owner_transfer (test_impl); PortableServer::ObjectId_var id = root_poa->activate_object (test_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); RedirectionTest::test_var test = RedirectionTest::test::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test.in ()); FILE *output_file= ACE_OS::fopen (ior_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file <%s> for writing " "IOR: %s", ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); root_poa->destroy (1, 1 ); orb->destroy (); ACE_DEBUG ((LM_DEBUG, "Server event loop finished.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; test_i *test_impl; ACE_NEW_RETURN (test_impl, test_i (), 1); PortableServer::ServantBase_var owner_transfer(test_impl); PortableServer::ObjectId_var id = root_poa->activate_object (test_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); test_var test = test::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test.in ()); // If the ior_output_file exists, output the ior to it FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); delete test_impl; root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
ServantActivator * create_servant_manager (CORBA::ORB_ptr orb, PortableServer::POA_ptr child_poa) { CORBA::Object_var forward_to; if (forward_to_ior) { forward_to = orb->string_to_object (forward_to_ior); } ServantActivator *activator = 0; ACE_NEW_RETURN (activator, ServantActivator (orb, forward_to.in ()), 0); // Set ServantActivator to be the servant activator. child_poa->set_servant_manager (activator); // For the code above, we're using the CORBA 3.0 servant manager // semantics supported by TAO. For CORBA 2.x ORBs you'd need to // use the following code in place of the previous line: // // PortableServer::ServantManager_var servant_activator = // activator->_this (); // // child_poa->set_servant_manager (servant_activator.in (), //); test_i *servant = 0; ACE_NEW_RETURN (servant, test_i (orb, child_poa, *activator, 127), 0); PortableServer::ServantBase_var servant_var (servant); test_var test = servant->_this (); CORBA::String_var ior = orb->object_to_string (test.in ()); FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) { ACE_ERROR ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", ior_output_file)); } else { ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } return activator; }
void TRKCACHE::seek(FDD *d, unsigned cyl, unsigned side, SEEK_MODE fs) { if ((d == drive) && (sf == fs) && (cyl == TRKCACHE::cyl) && (side == TRKCACHE::side)) return; drive = d; sf = fs; s = 0; TRKCACHE::cyl = cyl; TRKCACHE::side = side; if (cyl >= d->cyls || !d->rawdata) { trkd = 0; return; } assert(cyl < MAX_CYLS); trkd = d->trkd[cyl][side]; trki = d->trki[cyl][side]; trklen = d->trklen[cyl][side]; if (!trklen) { trkd = 0; return; } ts_byte = Z80FQ / (trklen * FDD_RPS); if (fs == JUST_SEEK) return; // else find sectors for (unsigned i = 0; i < trklen - 8; i++) { if (trkd[i] != 0xA1 || trkd[i+1] != 0xFE || !test_i(i)) // Поиск idam continue; if (s == MAX_SEC) errexit("too many sectors"); SECHDR *h = &hdr[s++]; // Заполнение заголовка h->id = trkd + i + 2; // Указатель на заголовок сектора h->c = h->id[0]; h->s = h->id[1]; h->n = h->id[2]; h->l = h->id[3]; h->crc = *(unsigned short*)(trkd+i+6); h->c1 = (wd93_crc(trkd+i+1, 5) == h->crc); h->data = 0; h->datlen = 0; // if (h->l > 5) continue; [vv] unsigned end = min(trklen - 8, i + 8 + 43); // 43-DD, 30-SD // Формирование указателя на зону данных сектора for (unsigned j = i + 8; j < end; j++) { if (trkd[j] != 0xA1 || !test_i(j) || test_i(j+1)) continue; if (trkd[j+1] == 0xF8 || trkd[j+1] == 0xFB) // Найден data am { h->datlen = 128 << (h->l & 3); // [vv] FD1793 use only 2 lsb of sector size code h->data = trkd + j + 2; h->c2 = (wd93_crc(h->data-1, h->datlen+1) == *(unsigned short*)(h->data+h->datlen)); } break; } } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("SERVER: Unable to initialize the POA.\n")), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (::parse_args (argc, argv) != 0) return -1; // Servant test_i *servant = 0; ACE_NEW_RETURN (servant, test_i (0, orb.in ()), -1); PortableServer::ServantBase_var safe (servant); PortableServer::ObjectId_var oid = root_poa->activate_object (servant); CORBA::Object_var obj = root_poa->servant_to_reference (servant); CORBA::String_var ior = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SERVER: test_i servant: <%C>\n"), ior.in ())); poa_manager->activate (); // IOR FILE *output_file= ACE_OS::fopen (ior_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("SERVER: Cannot open output file <%s> ") ACE_TEXT ("for writting IOR: %C"), ior_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); // Run the ORB event loop. orb->run (); root_poa->destroy (1, 1); orb->destroy (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SERVER: Event loop finished.\n"))); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } return 0; }
int Task::svc (void) { try { CORBA::Object_var object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); CORBA::PolicyList policies; int result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, debug); if (result != 0) return result; result = get_priority_lanes ("server", lanes_file, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, debug); if (result != 0) return result; CORBA::Policy_var priority_model_policy = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0); // Implicit_activation policy. CORBA::Policy_var implicit_activation_policy = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); policies.length (policies.length () + 1); policies[policies.length () - 1] = priority_model_policy; policies.length (policies.length () + 1); policies[policies.length () - 1] = implicit_activation_policy; PortableServer::POA_var poa = root_poa->create_POA ("child", poa_manager.in (), policies); test_i *servant = 0; ACE_NEW_THROW_EX (servant, test_i (this->orb_.in (), poa.in ()), CORBA::NO_MEMORY ()); PortableServer::ServantBase_var safe_servant (servant); PortableServer::ObjectId_var id = poa->activate_object (servant); CORBA::Object_var object_act = poa->id_to_reference (id.in ()); test_var test = test::_narrow (object_act.in ()); write_iors_to_file (test.in (), this->orb_.in (), ior); poa_manager->activate (); this->orb_->run (); this->orb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int Server_i::init (int argc, ACE_TCHAR** argv) { try { this->orb_ = CORBA::ORB_init (argc, argv); int retval = this->parse_args (argc, argv); if (retval != 0) return retval; CORBA::Object_var obj = this->orb_->resolve_initial_references ("RootPOA"); this->root_poa_ = PortableServer::POA::_narrow (obj.in ()); ACE_ASSERT(! CORBA::is_nil(this->root_poa_.in())); PortableServer::POAManager_var poa_manager = this->root_poa_->the_POAManager (); obj = this->orb_->resolve_initial_references ("IORTable"); IORTable::Table_var ior_table = IORTable::Table::_narrow (obj.in ()); ACE_ASSERT(! CORBA::is_nil(ior_table.in())); // If -orbuseimr 1 is specified then all persistent poas will be // registered with the imr. CORBA::PolicyList policies (2); policies.length (2); policies[0] = this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID); policies[1] = this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT); test_i* test_svt; ACE_NEW_RETURN (test_svt, test_i(orb_.in()), -1); PortableServer::ServantBase_var scoped_svt(test_svt); PortableServer::ObjectId_var server_id = PortableServer::string_to_ObjectId ("Test"); // Create count_ POAs, activate an object in each, and register the object with // the IORTable. for (int i = 0; i < this->count_; ++i) { ACE_CString name = this->server_name_ + "_" + toStr(i); PortableServer::POA_var poa = this->root_poa_->create_POA (name.c_str(), poa_manager.in (), policies); poa->activate_object_with_id (server_id.in (), test_svt); TAO_Root_POA* tmp_poa = dynamic_cast<TAO_Root_POA*>(poa.in()); obj = tmp_poa->id_to_reference_i (server_id.in (), false); CORBA::String_var ior = this->orb_->object_to_string (obj.in ()); ior_table->bind (name.c_str(), ior.in ()); } policies[0]->destroy(); policies[1]->destroy(); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Server_i::init"); throw; } return 0; }