//
//    Save
//    ====
//
//    Save the information for this object to the AuditDataFile
//
bool CLocaleScanner::SaveData	(CAuditDataFile* pAuditDataFile)
{
	CLogFile log;
	log.Write("CLocaleScanner::SaveData Start" ,true);

	CString strValue;

	// Add the Category for memory
	CAuditDataFileCategory category(HARDWARE_CLASS);

	// Each audited item gets added an a CAuditDataFileItem to the category
	CAuditDataFileItem l1(V_LOCALE_CODEPAGE ,m_iCodePage);
	CAuditDataFileItem l2(V_LOCALE_CALENDARTYPE ,m_strCalendarType);
	CAuditDataFileItem l3(V_LOCALE_COUNTRY ,m_strCountry);
	CAuditDataFileItem l4(V_LOCALE_COUNTRYCODE ,m_iCountryCode);
	CAuditDataFileItem l5(V_LOCALE_CURRENCY ,m_strCurrency);
	CAuditDataFileItem l6(V_LOCALE_DATEFORMAT ,m_strDateFormat);
	CAuditDataFileItem l7(V_LOCALE_LANGUAGE ,m_strLanguage);
	CAuditDataFileItem l8(V_LOCALE_LOCALLANGUAGE ,m_strLocaleLocalLanguage);
	CAuditDataFileItem l9(V_LOCALE_OEM_CODEPAGE ,m_iOEMCodePage);
	CAuditDataFileItem l10(V_LOCALE_TIMEFORMAT ,m_strTimeFormat);
	CAuditDataFileItem l11(V_LOCALE_TIMEFORMATSPECIFIER ,m_strTimeFormatSpecifier);
	CAuditDataFileItem l12(V_LOCALE_TIMEZONE ,m_strLocaleTimeZone);

	// Add the items to the category
	category.AddItem(l1);
	category.AddItem(l2);
	category.AddItem(l3);
	category.AddItem(l4);
	category.AddItem(l5);
	category.AddItem(l6);
	category.AddItem(l7);
	category.AddItem(l8);
	category.AddItem(l9);
	category.AddItem(l10);
	category.AddItem(l11);
	category.AddItem(l12);

	// ...and add the category to the AuditDataFile
	pAuditDataFile->AddAuditDataFileItem(category);

	// we always need to get the default browser details so do here
	CAuditDataFileCategory browserCategory("Internet|Browsers|Default Browser", FALSE, TRUE);
	CAuditDataFileItem b1("Path", GetRegValue("HKEY_CLASSES_ROOT\\http\\shell\\open\\command", ""));
	browserCategory.AddItem(b1);

	pAuditDataFile->AddInternetItem(browserCategory);


	log.Write("CLocaleScanner::SaveData End" ,true);
	return true;
}
Beispiel #2
0
void test_flash_led()
{
	ngac ac("ac1", 0, 5, 1);
	ngresistor r("r1", 370);
	ngled led("led1", 5e-3);
	ngground gnd;

	ngline l0(ac.p1, gnd.p1);
	ngline l1(ac.p2, r.p1);
	ngline l2(r.p2, led.p1);
	ngline l3(led.p2, ac.p1);

	schema sch;
	sch.AddDevices(&ac, &r, &led, &gnd, 0);
	sch.AddLines(&l0, &l1, &l2, &l3, 0);

	circuit cir(&sch);
	cir.Tran("2", "10m");

	do 
	{
		Sleep(200);

	} while (cir.IsRunning());
	
	getchar();
}
Beispiel #3
0
void test_restart()
{
	ngac ac("ac1", 0, 5, 1);
	ngresistor r("r1", 370);
	ngled led("led1", 5e-3);
	ngground gnd;

	ngline l0(ac.p1, gnd.p1);
	ngline l1(ac.p2, r.p1);
	ngline l2(r.p2, led.p1);
	ngline l3(led.p2, ac.p1);

	schema sch;
	sch.AddDevices(&ac, &r, &led, &gnd, 0);
	sch.AddLines(&l0, &l1, &l2, &l3, 0);

	circuit cir(&sch);
	cir.Tran("1000");

	do 
	{
		Sleep(200);
		char ch = getchar();
		switch (ch)
		{
		case 'r':
			cir.Restart();
			Sleep(200);
			break;
		default:
			break;
		}
	} while (cir.IsRunning());
}
Beispiel #4
0
void SpiralScene::setupLights()
{
	Color white(1, 1, 1);

	LightPointer l1(new Light(Vector3d(-3, 12, -15), 0));
	l1->setAmbient(white * .2);
	l1->setDiffuse(white);
	l1->setSpecular(white);
	addLight(l1);

	LightPointer l2(new Light(Vector3d(-10, 10, -15), 0));
	Color l2Color(.3, .8, .3);
	l2->setDiffuse(l2Color * .8);
	l2->setSpecular(l2Color);
	addLight(l2);

	LightPointer l3(new Light(Vector3d(10, 10, -50), 0));
	Color l3Color(.3, .3, .8);
	l3->setDiffuse(l3Color * .9);
	l3->setSpecular(l3Color);
	addLight(l3);

	LightPointer l4(new Light(Vector3d(0, 0, -100), 0));
	Color l4Color(.8, .3, .3);
	l4->setDiffuse(l4Color * .9);
	l4->setSpecular(l4Color);
	addLight(l4);
}
TEST_F(FixedArraysTest, Assignment) {
  FixedVector<double, 2> u2({1, 2});
  FixedVector<double, 2> v2 = {1, 2};
  FixedVector<double, 2> w2;
  w2 = {1, 2};
  EXPECT_EQ(u2, v2);
  EXPECT_EQ(u2, w2);

  FixedMatrix<double, 2, 3> l23({1, 2, 3,
                                 4, 5, 6});
  FixedMatrix<double, 2, 3> m23 = {1, 2, 3,
                                   4, 5, 6};
  FixedMatrix<double, 2, 3> n23 = {0, 0, 0,
                                   0, 0, 0};
  n23 = {1, 2, 3,
         4, 5, 6};
  EXPECT_EQ(l23, m23);
  EXPECT_EQ(l23, n23);

  FixedStrictlyLowerTriangularMatrix<double, 3> l3({
                                                    1,
                                                    2, 3});
  FixedStrictlyLowerTriangularMatrix<double, 3> m3 = {
                                                      1,
                                                      2, 3};
  FixedStrictlyLowerTriangularMatrix<double, 3> n3 = {
                                                      0,
                                                      0, 0};
  n3 = {
        1,
        2, 3};
  EXPECT_EQ(l3, m3);
  EXPECT_EQ(l3, n3);
}
Beispiel #6
0
void test_int_list () {
  CoolList<int> l1(1, 1);
  CoolList<int> l2(2, 1, 2);
  CoolList<int> l3(3, 1, 2 , 3);

  typedef CoolPair<int, CoolList<int> > Hack; //##
  CoolAssociation<int,CoolList<int> > a;
  cout << a << endl;
  a.put(1, l1);
  cout << a << endl;
  a.put(2, l2);
  cout << a << endl;
  a.put(3, l3);
  cout << a << endl;
  a.put(4, l3);

  cout << a << endl;

  CoolList<int> l;
  a.get(0, l);
  l.describe(cout); cout << endl;
  a.get(1, l);
  l.describe(cout); cout << endl;
  a.get(2, l);
  l.describe(cout); cout << endl;
  a.get(3, l);
  l.describe(cout); cout << endl;
  a.get(4, l);
  l.describe(cout); cout << endl;
  
}
Beispiel #7
0
int main()
{
    vec v1(1, 1), v2(0, 2);
    cout << "vec1(1,1) cross vec2(0,2): " << cross(v1, v2) << endl << endl;
    node p0(0, 0), p1(0, 1), p2(1, 2), p3(2, 1), p4(2, 0), p5(1, 0), p6(1, 1);
    node s[7];
    s[0] = p4, s[1] = p3, s[2] = p2, s[3] = p1, s[4] = p0, s[5] = p5, s[6] = p6;
    segment l0(p0, p3), l1(p5, p6), l2(p6, p4), l3(p1, p2);
    test_segment(l0, l1);
    test_segment(l1, l2);
    test_segment(l0, l3);

    segment ll[4];
    ll[0] = l0, ll[1] = l1, ll[2] = l2, ll[3] = l3;
    for(int i = 0; i < 4; ++ i) {
        ll[i].s_lt.n_idx = i;
        ll[i].s_rt.n_idx = i;
        ll[i].s_lt.n_lt = 1;
        ll[i].s_rt.n_lt = 0;
    }
    cout << "sweeping:" << endl;
    for(int i = 0; i < 4; ++ i)
        ll[i].s_print();
    if(sweeping(ll, 4))
        cout << "yes" << endl;
    else
        cout << "no" << endl;

    return(0);
}
            void ControllerWidget::TimerEvent() {
                Lock l(m_HzMutex);
                
                if (m_counter == (20/m_Hz) ) {
                    Lock l2(m_vehicleControlMutex);

                    m_vehicleControl.setBrakeLights(m_brakeLEDs->isChecked());
                    m_vehicleControl.setFlashingLightsLeft(m_leftTurningLEDs->isChecked());
                    m_vehicleControl.setFlashingLightsRight(m_rightTurningLEDs->isChecked());

                    {
                        Lock l3(m_sendVehicleControlDataMutex);

                        if (m_sendVehicleControlData) {
                            Container c(m_vehicleControl);
                            m_conference.send(c);
                            m_counter = 0;
                        }
                    }
                }

                if (m_counter > (20/m_Hz)) {
                    m_counter = 0;
                }

                m_counter++;
            }
Beispiel #9
0
int main (){
	

	RealVectorValue v1(1,0,0);
	RealVectorValue v2(0,1,0);
	
	RealVectorValue l1(1,2,3);
	RealVectorValue l2(4,5,6);
	RealVectorValue l3(7,8,9);
	
	//RealTensorValue m1(l1,l2,l3);
	
//	std::cout<<v1.cross(v2)<<std::endl;
	//std::cout<<m1.transpose()<<std::endl;
	//std::cout<<m1*v1<<std::endl;
	//std::cout<<"\n dyadic\n"<<dyad_prod(l1,l2)<<std::endl;
	
	
	
	
	//levi_civita test
	
	std::cout<<le_ci[0][1][2]<<" "<<le_ci[2][0][1]<<" "<<le_ci[1][2][0]<<std::endl;
	std::cout<<le_ci[0][2][1]<<" "<<le_ci[2][1][0]<<" "<<le_ci[1][0][2]<<std::endl;
	std::cout<<le_ci[0][1][0]<<" "<<le_ci[0][1][1]<<std::endl;
	
	
	std::cout<<"done\n";
	return 0;
}
Beispiel #10
0
PageDialog::PageDialog() : QDialog( 0, 0, 1 ),
    gb(i18n(" Page "),this), ed(&gb), ok(&gb), cancel(&gb)
{
    setCaption( i18n("Go to page") );
    gb.setFrameStyle( QFrame::Box | QFrame::Sunken );
    gb.setLineWidth( 1 );
    QBoxLayout l1( this, QBoxLayout::LeftToRight, 15 );
    l1.addWidget( &gb );
    QBoxLayout l2( &gb, QBoxLayout::Down, 15, 10 );
    l2.addSpacing(fontMetrics().height());
    l2.addWidget( &ed );
    ed.setFocus();
    connect( &ed, SIGNAL(returnPressed()), SLOT(go()) );
    QBoxLayout l3( QBoxLayout::LeftToRight, 15 );
    l2.addLayout( &l3 );
    l3.addWidget( &ok );
    l3.addWidget( &cancel );
    ok.setText( i18n("Go to") );
    connect( &ok, SIGNAL(clicked()), SLOT(go()) );
    cancel.setText( i18n("Cancel") );
    resize( 300, 150 );
    l1.activate();
    l2.activate();
    setFixedSize(size());
    connect( &cancel, SIGNAL(clicked()), SLOT(reject()) );
}
Beispiel #11
0
int main(void)
{
	static const struct st3 a = {1, 2, 3, 4, 5, 6};

	l1(100);
	l2(100, 200);
	l3(100, 200, 300);
	l4(100, 200, 300, 400);
	l5(100, 200, 300, 400, 500);
	l6(100, 200, 300, 400, 500, 600);
	l7(100, 200, 300, 400, 500, 600, 700);
	l8(100, 200, 300, 400, 500, 600, 700, 800);

	d1();
	d2(43);
	d3(100, 200);
	d4(a);
	d5('a', 43, a);
	d6('a', 1);

	c1(44);
	c2(100, 'a', 3.4);
	c3(200, 2.777, 'q');
	c4(200, 1);
	c5(1.1, 2.2);
	c6(1.23, 45.6);
	c7('z', 0x200);

	a1('a');
	a2(10);
	a3(20);
	a4(102030405060LL);

	b1('a', 20);
	b2(30, 'b');
	b3(10, 20, 30, 40, 50, 60);

	s1(sx);
	s1p(&sx);
	s2(sy);
	s3(sz);
	s4(sq);
	s5(sa);
	s6(sb);

	r1();
	r3();
	r4();

	q1(200, sx);
	q2(300, 't', sx);
	q3(400, 410, sy);
	q4(500, 510, sq);
	q5(600, 610, 'z', 'q', sq);

	real1("fresh air");
	real2();

	return 0;
}
Beispiel #12
0
int main()
{
  unsigned int i;
  std::vector<Livro> livros;

  Livro l1("C Completo e Total", 1997);
  Livro l2("Turbo C - Guia do Usuário", 1990);
  Livro l3("A Arte do Java", 2003);
  livros.push_back(l1);
  livros.push_back(l2);
  livros.push_back(l3);

  std::cout << "Livros ordenados por ano" << std::endl;
  std::sort(livros.begin(), livros.end(), Livro::ordenarPorAno());
  for (i=0; i < livros.size(); i++)
    std::cout << livros.at(i).getTitulo() << " - " << livros.at(i).getAnoLancamento() << std::endl;

  std::cout << std::endl;

  std::cout << "Livros ordenados por título" << std::endl;
  std::sort(livros.begin(), livros.end(), Livro::ordenarPorTitulo());
  for (i=0; i < livros.size(); i++)
    std::cout << livros.at(i).getTitulo() << " - " << livros.at(i).getAnoLancamento() << std::endl;

  return 0;
}
Beispiel #13
0
bool Run::mustStop() const
{
    QMutexLocker l1(stoppingMutex_);
    QMutexLocker l2(stepDoneMutex_);
    QMutexLocker l3(breakHitMutex_);


    if (vm->error().length()>0) {        
        return true;
    }

    if (stoppingFlag_) {
        return true;
    }

    if (breakHitFlag_) {
        return true;
    }

    if (_runMode==Shared::RunInterface::RM_StepOut) {
        return algDoneFlag_;
    }
    else if (_runMode!=Shared::RunInterface::RM_ToEnd) {
        return stepDoneFlag_;
    }
    else {
        return false;
    }
}
Beispiel #14
0
TEST(TestMultipleSharedSection, General)
{
    CSharedSection sec;

    CEvent event;
    std::atomic<long> mutex(0L);

    locker<CSharedLock> l1(sec,&mutex, &event);

    {
        CSharedLock lock(sec);
        thread waitThread1(l1);

        EXPECT_TRUE(waitForThread(mutex,1,10000));
        SleepMillis(10);

        EXPECT_TRUE(l1.haslock);

        event.Set();

        EXPECT_TRUE(waitThread1.timed_join(MILLIS(10000)));
    }

    locker<CSharedLock> l2(sec,&mutex,&event);
    locker<CSharedLock> l3(sec,&mutex,&event);
    locker<CSharedLock> l4(sec,&mutex,&event);
    locker<CSharedLock> l5(sec,&mutex,&event);
    {
        CExclusiveLock lock(sec);
        thread waitThread1(l2);
        thread waitThread2(l3);
        thread waitThread3(l4);
        thread waitThread4(l5);

        EXPECT_TRUE(waitForThread(mutex,4,10000));
        SleepMillis(10);

        EXPECT_TRUE(!l2.haslock);
        EXPECT_TRUE(!l3.haslock);
        EXPECT_TRUE(!l4.haslock);
        EXPECT_TRUE(!l5.haslock);

        lock.Leave();

        EXPECT_TRUE(waitForWaiters(event,4,10000));

        EXPECT_TRUE(l2.haslock);
        EXPECT_TRUE(l3.haslock);
        EXPECT_TRUE(l4.haslock);
        EXPECT_TRUE(l5.haslock);

        event.Set();

        EXPECT_TRUE(waitThread1.timed_join(MILLIS(10000)));
        EXPECT_TRUE(waitThread2.timed_join(MILLIS(10000)));
        EXPECT_TRUE(waitThread3.timed_join(MILLIS(10000)));
        EXPECT_TRUE(waitThread4.timed_join(MILLIS(10000)));
    }
}
Beispiel #15
0
void test_switch_by_csw()
{
	ngdc dc("dc1", 5);
	ngspst spst("spst", ngspst::on);
	ngresistor r("1", 5);
	ngled led("led");
	ngground gnd;

	ngline l1(dc.pos, spst.p1);
	ngline l2(spst.p2, r.p1);
	ngline l3(r.p2, led.pos);
	ngline l4(led.neg, dc.neg);
	ngline l0(dc.neg, gnd.ground);

	schema sch;
	sch.AddDevices(&dc, &spst, &r, &gnd, &led, 0);
	sch.AddLines(&l1, &l2, &l3, &l0, &l4, 0);

	circuit cir(&sch);

#if 0//not work
	// tran with spst disconnected
	cir.Tran("10", "1m");
	do 
	{
		Sleep(100);
	} while (cir.IsRunning());
	//cir.Stop();

	// tran with spst connected, however it's still disconnected
	string sw = spst.switchover();
	cir.Do(sw);
	cir.Tran("10", "1m");
	do 
	{
		Sleep(100);
	} while (cir.IsRunning());
#endif


	// run with event input to switch spst
	cir.Tran("1t", "1m", 0);
	do 
	{
		Sleep(200);
		char ch = getchar();
		switch (ch)
		{
		case 'a':
			cir.SwitchOver(&spst);
			Sleep(200);
			break;
		case 'q':
			cir.Halt();
		default:
			break;
		};
	} while (cir.IsRunning());
}
void test(int i) {
  Literal<int> l1;     // expected-warning {{unused variable 'l1'}}
  Literal<int> l2(42); // expected-warning {{unused variable 'l2'}}
  Literal<int> l3(i);  // no-warning
  Literal<T> l4(0);    // no-warning
  NoLiteral nl1;       // no-warning
  NoLiteral nl2(42);   // no-warning
}
Beispiel #17
0
 void finish_l3 ()
   {
     if (trace_used)
       l3()->registerTracer(t);
     else if (t)
       delete t;
     t = NULL;
   }
Beispiel #18
0
void l3__Wrapper() {
  int  tape_index__ANONYMOUS_s89=0;
  glblInit_tape_index__ANONYMOUS_s110(tape_index__ANONYMOUS_s89);
  bool _tt1[143] = {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, 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, 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};
  bool*  tape__ANONYMOUS_s88= new bool [143]; CopyArr<bool >(tape__ANONYMOUS_s88,_tt1, 143, 143);
  glblInit_tape__ANONYMOUS_s108(tape__ANONYMOUS_s88);
  l3(tape__ANONYMOUS_s88, tape_index__ANONYMOUS_s89);
  delete[] tape__ANONYMOUS_s88;
}
Beispiel #19
0
/* List */
void challenge() {
    int numbers[] = { 1, 2, 3, 4, 5 };
    list<int> l1(numbers, numbers + 5);
    print<list<int> >(l1);

    list<int> l2;
    for (int i = 0; i < 10; ++i) {
        l2.push_back(i);
    }
    print<list<int> >(l2);

    for (int i = 0; i < 10; ++i) {
        l2.push_front(i);
    }
    print<list<int> >(l2);

    for (int i = 0; i < 10; ++i) {
        l2.pop_front();
    }
    print<list<int> >(l2);
    for (int i = 0; i < 10; ++i) {
        l2.pop_back();
    }
    print<list<int> >(l2);

    list<int> l3 (numbers, numbers + 5);
    // O(1)
    l3.erase(l3.begin());
    print<list<int> >(l3);
    // O(n), n = distance(begin, end)
    l3.erase(l3.begin(), l3.end());
    print<list<int> >(l3);
    // List operations
    list<int> l4 (numbers, numbers + 5);
    list<int> l5 (numbers, numbers + 5);
    // O(size() + size() - 1)
    l4.merge(l5);
    print<list<int> >(l4);
    print<list<int> >(l5); // Empty

    list<int> l6 (numbers, numbers + 5);
    print<list<int> >(l6);
    // O(n)
    l6.reverse();
    print<list<int> >(l6);
    // O(nlog(n))
    l6.sort();
    print<list<int> >(l6);

    print<list<int> >(l4);
    // O(n)
    l4.unique();
    print<list<int> >(l4);
}
 ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function       
     l1 = reverse(l1);
     l2 = reverse(l2);
     
     ListNode l3 (-1);
     
     int carry = 0;
     
     while(l1!=NULL && l2!=NULL){
         
         int sum = (l1->val) + (l2->val) + carry;
         
         sum = sum%10;
         
         l3.insert(sum);
         
         carry = carry + sum/10;
         
     }
     
     
     while(l1!=NULL){
         
         int sum = l1->val + carry;
         
         sum = sum % 10;
         
         l3.insert(sum);
         
         carry = carry + sum/10;
     }
     
     
      while(l2!=NULL){
         
         int sum = l2->val + carry;
         
         sum = sum % 10;
         
         l3.insert(sum);
         
         carry = carry + sum/10;
     }
     
     ListNode * rl;
     
     l4 = reverse(rl);
     
     return l4;
     
 }
Beispiel #21
0
void process_msg_prio_(int fd, char* msg, ssize_t len, struct game* g)
{
    GList * conn_to_terminate = NULL;
    if (!g)
        g = find_game_by_fd(fd);
    if (g) {
        int i;
        for (i = 0; i < g->players_number; i++) {
            // Pings are for the server only. Don't broadcast them to save bandwidth.
            if (len == 3 && msg[1] == 'p') {
                // nada

                // Emitter wants to receive synchro message as well
            } else if (g->players_conn[i] == fd && len > 2 && msg[1] == '!') {
                char synchro4self[] = "?!\n";
                ssize_t retval;
                synchro4self[0] = fd;
                l1(OUTPUT_TYPE_DEBUG, "[%d] sending self synchro", g->players_conn[i]);
                retval = send(g->players_conn[i], synchro4self, sizeof(synchro4self) - 1, MSG_NOSIGNAL|MSG_DONTWAIT);
                if (retval != sizeof(synchro4self) - 1) {
                    if (retval != -1) {
                        l4(OUTPUT_TYPE_INFO, "[%d] short send of %zd instead of %zd bytes from %d - destination is not reading data "
                           "(illegal FB client) or our upload bandwidth is saturated - sorry, cannot continue serving "
                           "this client in this situation, closing connection",
                           g->players_conn[i], retval, sizeof(synchro4self) - 1, fd);
                    }
                    conn_to_terminate = g_list_append(conn_to_terminate, GINT_TO_POINTER(g->players_conn[i]));
                }

            } else if (g->players_conn[i] != fd) {
                ssize_t retval;
                l3(OUTPUT_TYPE_DEBUG, "[%d] sending %zd bytes to %d", fd, len, g->players_conn[i]);
                retval = send(g->players_conn[i], msg, len, MSG_NOSIGNAL|MSG_DONTWAIT);
                if (retval != len) {
                    if (retval != -1) {
                        l4(OUTPUT_TYPE_INFO, "[%d] short send of %zd instead of %zd bytes from %d - destination is not reading data "
                           "(illegal FB client) or our upload bandwidth is saturated - sorry, cannot continue serving "
                           "this client in this situation, closing connection",
                           g->players_conn[i], retval, len, fd);
                    }
                    conn_to_terminate = g_list_append(conn_to_terminate, GINT_TO_POINTER(g->players_conn[i]));
                }
            }
        }
        if (conn_to_terminate) {
            g_list_foreach(conn_to_terminate, conn_to_terminate_helper, NULL);
            g_list_free(conn_to_terminate);
        }
    } else {
        l1(OUTPUT_TYPE_ERROR, "Internal error: could not find game by fd: %d", fd);
        exit(EXIT_FAILURE);
    }
}
Beispiel #22
0
int main()
{
  try
    {
      symbol k("k"),q("q"),p("p"),p1("p1"),p2("p2"),p3("p3"),ms("ms"),l("l"),s("s"),m1s("m1s"),m2s("m2s"),m3s("m3s");
      symbol l1("l1"),l2("l2"),l3("l3"),l4("l4"),t("t"),p4("p4"),p5("p5"),p6("p6"),tp("tp"),v1("v1"),v2("v2"),l5("l5");
      symbol k1("k1"),k2("k2"),k3("k3"),k4("k4"),k5("k5"),ms1("ms1"),ms2("ms2"),ms3("ms3"),ms4("ms4");
      symbol s12("s12"),s23("s23"),s34("s34"),s45("s45"),s51("s51"),s13("s13"),s15("s15"),s56("s56"),s16("s16"),s123("s123"),s234("s234"),s345("s345");
      lst inv_l;
      inv_l.append(p1*p1 == 0);
      inv_l.append( p2*p2 == 0);inv_l.append( p3*p3  ==  0);inv_l.append( p4*p4  ==  0);inv_l.append( p5*p5  ==  0);inv_l.append( p6*p6  ==  0);
      inv_l.append(p1* p2  ==  s12/2);inv_l.append( p2* p3  ==  s23/2);inv_l.append( p3* p4  ==  s34/2);inv_l.append( p4* p5  ==  s45/2);
      inv_l.append(p5* p6  ==  s56/2);inv_l.append( p1* p6  ==  s16/2);inv_l.append( p1* p3  ==  (-s12 + s123 - s23)/2);
      inv_l.append(p2* p4  ==  (-s23 + s234 - s34)/2);
      inv_l.append( p3* p5  ==  (-s34 + s345 - s45)/2);
      inv_l.append(p1* p4  ==  (-s123 + s23 - s234 + s56)/2);
      inv_l.append(p1* p5  ==  (-s16 + s234 - s56)/2);
      inv_l.append( p2* p5  ==  (s16 - s234 + s34 - s345)/2);
      inv_l.append( p2* p6  ==  (-s12 - s16 + s345)/2);
      inv_l.append( p3* p6  ==  (s12 - s123 - s345 + s45)/2);
      inv_l.append( p4* p6  ==  (s123 - s45 - s56)/2);
      
      
      RoMB_loop_by_loop hexag(lst(k1),
                              lst(-pow(p1 + k1,2),-pow(p1 + p2 + k1,2),
                                  -pow(p1 + p2 + p3 + k1,2),
                                  -pow(p1 + p2 + p3 + p4 + k1,2),
                                  -pow(p1+p2+p3+p4+p5+k1,2),-pow(k1,2)),
                              inv_l,
                              lst(1,1,1,1,1,1),true);
      hexag.integrate_map(lst(s12 == -1, s23 == -2, s34 == -3, s45 == -4, s56 == -5, s16 == -6, s123 == -7, s234 == -8, s345 == -9));
/*

 FRESULT for parameters: {s12==-1,s23==-2,s34==-3,s45==-4,s56==-5,s16==-6,s123==-7,s234==-8,s345==-9}
 
  FRESULT anl :           = -0.1955084880526298663-1/240*log(8)*log(6)+947/60480*log(2)^2-1/480*log(6)*log(4)+1/1080*log(3)*log(7)+131/7560*log(9)*log(2)+19/1260*log(9)^2-1/560*log(8)*log(4)+523/60480*log(3)^2-1/1080*log(7)*log(5)+41/4320*log(3)*log(5)-1/48*log(8)*log(5)-1/1080*log(7)*log(4)+22/945*log(6)*log(7)+19/3780*log(3)*log(4)+493/30240*Pi^2+43/1008*eps^(-2)+49/8640*log(5)^2-641/30240*log(2)*log(6)+1/1080*log(9)*log(5)-22/945*log(2)*log(7)+271/60480*log(4)^2-3/112*log(8)*log(3)-19/3780*log(9)*log(4)+1/1080*log(4)*log(5)-61/2520*log(9)*log(7)+61/5040*log(7)^2+1/168*log(3)*log(2)+1/168*log(8)*log(9)+13/3360*log(2)*log(4)-1/30240*(-1132.7960047725738361+576*log(8)-163*log(3)+264*log(9)+533*log(2)-479*log(6)-444*log(7)+271*log(4)-287*log(5))*eps^(-1)+47/1680*log(8)^2-17/1680*log(8)*log(2)+767/60480*log(6)^2-22/945*log(9)*log(6)-13/1890*log(3)*log(9)
   FRESULT num:           = 1.9907333428263254975E-4+(0.032177795803854872908)*eps^(-1)+(0.04265873015873015873)*eps^(-2)
    eps^-2 term: 43/1008 +/- 0
     eps^-1 term: 0.03746018534300839405-2/105*log(8)+163/30240*log(3)-11/1260*log(9)-533/30240*log(2)+479/30240*log(6)+37/2520*log(7)-271/30240*log(4)+41/4320*log(5) +/- 9.022403780167233619E-6
      eps^0 term: -0.1955084880526298663-1/240*log(8)*log(6)+947/60480*log(2)^2-1/480*log(6)*log(4)+1/1080*log(3)*log(7)+131/7560*log(9)*log(2)+19/1260*log(9)^2-1/560*log(8)*log(4)+523/60480*log(3)^2-1/1080*log(7)*log(5)+41/4320*log(3)*log(5)-1/48*log(8)*log(5)-1/1080*log(7)*log(4)+22/945*log(6)*log(7)+19/3780*log(3)*log(4)+493/30240*Pi^2+49/8640*log(5)^2-641/30240*log(2)*log(6)+1/1080*log(9)*log(5)-22/945*log(2)*log(7)+271/60480*log(4)^2-3/112*log(8)*log(3)-19/3780*log(9)*log(4)+1/1080*log(4)*log(5)-61/2520*log(9)*log(7)+61/5040*log(7)^2+1/168*log(3)*log(2)+1/168*log(8)*log(9)+13/3360*log(2)*log(4)+47/1680*log(8)^2-17/1680*log(8)*log(2)+767/60480*log(6)^2-22/945*log(9)*log(6)-13/1890*log(3)*log(9) +/- 1.04620404922048185285E-4
      */

    }
  catch(std::exception &p)
    {
      std::cerr<<"******************************************************************"<<endl;
      std::cerr<<"   >>>ERROR:  "<<p.what()<<endl;
      std::cerr<<"******************************************************************"<<endl;
      return 1;
    }
  return 0;
}
MatrixXd Utils::calculateHomographyMatrixFromFiveOrtoghonalLines(QList<Line*> firstOrtoghonalLines, QList<Line*> secondOrthogonalLines,
                     QList<Line*> thirdOrthogonalLines, QList<Line*> fourthOrthogonalLines,
                     QList<Line*> fifthOrthogonalLines)
{
    // A * x = b.
    MatrixXd A(5, 6);
    MatrixXd b(5, 1);
    MatrixXd x(5, 1);

    Vector3d l1 = getLineInHomogeneousCoordinates(firstOrtoghonalLines.at(0));
    Vector3d m1 = getLineInHomogeneousCoordinates(firstOrtoghonalLines.at(1));
    Vector3d l2 = getLineInHomogeneousCoordinates(secondOrthogonalLines.at(0));
    Vector3d m2 = getLineInHomogeneousCoordinates(secondOrthogonalLines.at(1));
    Vector3d l3 = getLineInHomogeneousCoordinates(thirdOrthogonalLines.at(0));
    Vector3d m3 = getLineInHomogeneousCoordinates(thirdOrthogonalLines.at(1));
    Vector3d l4 = getLineInHomogeneousCoordinates(fourthOrthogonalLines.at(0));
    Vector3d m4 = getLineInHomogeneousCoordinates(fourthOrthogonalLines.at(1));
    Vector3d l5 = getLineInHomogeneousCoordinates(fifthOrthogonalLines.at(0));
    Vector3d m5 = getLineInHomogeneousCoordinates(fifthOrthogonalLines.at(1));

    b << -l1(1)*m1(1), -l2(1)*m2(1), -l3(1)*m3(1), -l4(1)*m4(1), -l5(1)*m5(1);
    A << l1(0)*m1(0), (l1(0)*m1(1)+l1(1)*m1(0))/2, l1(1)*m1(1), (l1(0)*m1(2)+l1(2)*m1(0))/2, (l1(1)*m1(2)+l1(2)*m1(1))/2, l1(2)*m1(2),
         l2(0)*m2(0), (l2(0)*m2(1)+l2(1)*m2(0))/2, l2(1)*m2(1), (l2(0)*m2(2)+l2(2)*m2(0))/2, (l2(1)*m2(2)+l2(2)*m2(1))/2, l2(2)*m2(2),
         l3(0)*m3(0), (l3(0)*m3(1)+l3(1)*m3(0))/2, l3(1)*m3(1), (l3(0)*m3(2)+l3(2)*m3(0))/2, (l3(1)*m3(2)+l3(2)*m3(1))/2, l3(2)*m3(2),
         l4(0)*m4(0), (l4(0)*m4(1)+l4(1)*m4(0))/2, l4(1)*m4(1), (l4(0)*m4(2)+l4(2)*m4(0))/2, (l4(1)*m4(2)+l4(2)*m4(1))/2, l4(2)*m4(2),
         l5(0)*m5(0), (l5(0)*m5(1)+l5(1)*m5(0))/2, l5(1)*m5(1), (l5(0)*m5(2)+l5(2)*m5(0))/2, (l5(1)*m5(2)+l5(2)*m5(1))/2, l5(2)*m5(2);

   x = A.colPivHouseholderQr().solve(b);

   x/=x(2);

   Matrix3d C;
   C << x(0), x(1)/2, x(3)/2,
        x(1)/2, x(2), x(4)/2,
        x(3)/2, x(4)/2, 1;

   Matrix2d kkt;
   kkt << C(0,0), C(0,1),
          C(1,0), C(1,1);

   MatrixXd vKKt(1,2);
   vKKt << C(2,0), C(2,1);

   MatrixXd V(1,2);
   V = vKKt * kkt.inverse();

   LLT<MatrixXd> llt(kkt);
   MatrixXd U = llt.matrixU();

   MatrixXd J (3,3);
   J << U(0,0), U(0,1),0, U(1,0), U(1,1),0, V(0), V(1), 1;

   return J;
}
Beispiel #24
0
void test_try_lock_five()
{
    int const num_mutexes=5;
    
    for(int i=-1;i<num_mutexes;++i)
    {
        dummy_mutex mutexes[num_mutexes];

        if(i>=0)
        {
            mutexes[i].lock();
        }
        boost::unique_lock<dummy_mutex> l1(mutexes[0],boost::defer_lock),
            l2(mutexes[1],boost::defer_lock),
            l3(mutexes[2],boost::defer_lock),
            l4(mutexes[3],boost::defer_lock),
            l5(mutexes[4],boost::defer_lock);

        int const res=boost::try_lock(l1,l2,l3,l4,l5);
    
        BOOST_CHECK(res==i);
        for(int j=0;j<num_mutexes;++j)
        {
            if((i==j) || (i==-1))
            {
                BOOST_CHECK(mutexes[j].is_locked);
            }
            else
            {
                BOOST_CHECK(!mutexes[j].is_locked);
            }
        }
        if(i==-1)
        {
            BOOST_CHECK(l1.owns_lock());
            BOOST_CHECK(l2.owns_lock());
            BOOST_CHECK(l3.owns_lock());
            BOOST_CHECK(l4.owns_lock());
            BOOST_CHECK(l5.owns_lock());
        }
        else
        {
            BOOST_CHECK(!l1.owns_lock());
            BOOST_CHECK(!l2.owns_lock());
            BOOST_CHECK(!l3.owns_lock());
            BOOST_CHECK(!l4.owns_lock());
            BOOST_CHECK(!l5.owns_lock());
        }
    }
}
Beispiel #25
0
void JViewSet::addRect(double x, double y, double width, double height) {
  JFPoint p1(x, y);
  JFPoint p2(x+width, y);
  JFPoint p3(x+width, y+height);
  JFPoint p4(x, y+height);
  JLineObj l1(p1, p2);
  JLineObj l2(p2, p3);
  JLineObj l3(p3, p4);
  JLineObj l4(p4, p1);
  add(l1);
  add(l2);
  add(l3);
  add(l4);
}
void lock_five_mutexes_slowly(boost::mutex* m1,boost::mutex* m2,boost::mutex* m3,boost::mutex* m4,boost::mutex* m5,
                              wait_data* locked,wait_data* quit)
{
    boost::lock_guard<boost::mutex> l1(*m1);
    boost::this_thread::sleep(boost::posix_time::milliseconds(500));
    boost::lock_guard<boost::mutex> l2(*m2);
    boost::this_thread::sleep(boost::posix_time::milliseconds(500));
    boost::lock_guard<boost::mutex> l3(*m3);
    boost::this_thread::sleep(boost::posix_time::milliseconds(500));
    boost::lock_guard<boost::mutex> l4(*m4);
    boost::this_thread::sleep(boost::posix_time::milliseconds(500));
    boost::lock_guard<boost::mutex> l5(*m5);
    locked->signal();
    quit->wait();
}
Beispiel #27
0
QList<RVector> RTriangle::getPointsWithDistanceToEnd(double distance, RS::From from) const {
    Q_UNUSED(from)

    QList<RVector> c;

    RLine l1(corner[0], corner[1]);
    RLine l2(corner[1], corner[2]);
    RLine l3(corner[2], corner[0]);

    c.append(l1.getPointsWithDistanceToEnd(distance));
    c.append(l2.getPointsWithDistanceToEnd(distance));
    c.append(l3.getPointsWithDistanceToEnd(distance));

    return c;
}
Beispiel #28
0
// return true if the atoms are r = s, s = t, and r = t (up to commutativity)
// 29/04/2002 Manchester
// 28/08/2002 Torrevieja, changed
bool Atom::transitivity (Atom a1, Atom a2, Atom a3) 
{
  TRACER("Atom::transitivity");

  if ( ! (a1.isEquality() && 
          a2.isEquality() && 
          a3.isEquality()) ) {
    return false;
  }
  // a1, a2, a3 are equalities
  Term l1 (a1.args().head());
  Term r1 (a1.args().second());
  if ( l1.equal(r1) ) {
    return false;
  }
  Term l2 (a2.args().head());
  Term r2 (a2.args().second());
  if ( l2.equal(r2) ) {
    return false;
  }
  Term l3 (a3.args().head());
  Term r3 (a3.args().second());
  if ( l3.equal(r3) ) {
    return false;
  }

  if ( l1.equal(l2) ) { // l1 = l2 = s
    return (r1.equal(l3) && r2.equal(r3)) ||
           (r2.equal(l3) && r1.equal(r3));
  }
  // l1 != l2
  if ( l1.equal(r2) ) { // l1 = r2 = s
    return (r1.equal(l3) && l2.equal(r3)) ||
           (l2.equal(l3) && r1.equal(r3));
  }
  // 
  if ( r1.equal(l2) ) { // r1 = l2 = s
    return (l1.equal(l3) && r2.equal(r3)) ||
           (r2.equal(l3) && l1.equal(r3));
  }
  // l1 not in {l2,r2}, r1 != l2
  if ( r1.equal(r2) ) { // r1 = r2 = s
    return (l1.equal(l3) && l2.equal(r3)) ||
           (l2.equal(l3) && l1.equal(r3));
  }

  return false;
} // Atom::transitivity
Beispiel #29
0
int main(int argc, char **argv)
{
	FILE *fh;
	int slen, rlen, retval = 0;
	char *next, *sbuf, *rbuf;

	if (argc != 2) {
		fprintf(stderr, "Syntax: %s scriptfile\n", argv[0]);
		exit(1);
	}

	fh = fopen(argv[1], "r");
	if (!fh) {
		perror("fopen");
		exit(1);
	}

	if (init() < 0)
		exit(1);

	if (l3(RFID_PROTOCOL_TCL) < 0)
		exit(1);

	printf("Protocol T=CL\n");
	/* we've established T=CL at this point */

	while (next = nextline(fh)) {
		if (!(strlen(next) >= 2 && strncmp(next, "//", 2) == 0)) {
			if (make_command(next, &sbuf, &slen)) {
				rlen = 1024;
				rbuf = calloc(rlen, 1);
				
				retval = send_command(sbuf, slen, rbuf, rlen);

				free(sbuf);
				free(rbuf);
			}
		}
		free(next);

		if (retval < 0)
			break;
	}

	rfid_reader_close(rh);
	
	exit(0);
}
bool
GenericSchedulerThread::quitThread(bool allowRestarts)
{
    if ( !isRunning() ) {
        return false;
    }

    // Disallow temporarily any thread to request a new render so that we do not end up starting the thread again
    // just after the abort
    {
        QMutexLocker k(&_imp->mustQuitMutex);
        // We already called quitThread
        if (_imp->mustQuit || !_imp->lastQuitThreadAllowedRestart) {
            return true;
        }
        _imp->mustQuit = true;
        _imp->startingThreadAllowed = false;
        _imp->lastQuitThreadAllowedRestart = allowRestarts;
    }

    if (getThreadState() == eThreadStateActive) {
        abortThreadedTask();
    }


    // Clear any task enqueued and push a fake request
    {
        QMutexLocker k(&_imp->enqueuedTasksMutex);
        _imp->enqueuedTasks.clear();
        boost::shared_ptr<GenericThreadStartArgs> stubArgs( new GenericThreadStartArgs(true) );
        _imp->enqueuedTasks.push_back(stubArgs);
    }


    // Wake-up the thread with a fake request
    {
        QMutexLocker l3(&_imp->startRequestsMutex);
        ++_imp->startRequests;
        _imp->startRequestsCond.wakeOne();
    }
#ifdef TRACE_GENERIC_SCHEDULER_THREAD
    qDebug() << QThread::currentThread() << ": Termination request on " << getThreadName().c_str();
#endif

    onQuitRequested(allowRestarts);
    return true;
}