Esempio n. 1
0
main () {
    const ull a = 0x1400000000ULL;
    const ull b = 0x80000000ULL;
    const ull c = a/b;
    const ull d = 0x1400000000ULL / 0x80000000ULL;

    checkit ((int) c);
    checkit ((int) d);

    exit(0);
}
int checkit(int i,int j)
{
	if(i==10 || j==10 || i==-1 || j==-1 || a[i][j])
		return 0;
	a[i][j] = 1;
	if(c[i][j]=='F')
		return 1;
	else if(c[i][j] == '.')
		return 0;
	else
		return checkit(i-1,j)+checkit(i+1,j)+checkit(i,j-1)+checkit(i,j+1);
}
int main()
{
	int test_cases;
	scanf("%d",&test_cases);
	while(test_cases--)
	{
		int i,j,r,c,k,l;
		char ch;
		scanf("%d%d",&r,&c);
		for(i=0;i<r;i++)
		{
			scanf("%c",&ch);
			for(j=0;j<c;j++)
				scanf("%c",&a[i][j]);
		}
		for(i=0;i<r;i++)
		{
			for(j=0;j<c;j++)
			{
				checkit(r,c,i,j,0);
				if(done==1)
					break;
			}
			if(done==1)
				break;
		}
		printf("%s\n",done==1?"YES":"NO");
		done=0;
	}
	return 0;
}
Esempio n. 4
0
bool DirManager::AssignFile(wxFileName &fileName,
			    wxString value,
                            bool diskcheck){
   wxFileName dir=MakeBlockFilePath(value);

   if(diskcheck){
      // verify that there's no possible collision on disk.  If there
      // is, log the problem and return FALSE so that MakeBlockFileName 
      // can try again

      wxDir checkit(dir.GetFullPath());
      if(!checkit.IsOpened()) return FALSE;
      
      // this code is only valid if 'value' has no extention; that
      // means, effectively, AssignFile may be called with 'diskcheck'
      // set to true only if called from MakeFileBlockName().
      
      wxString filespec;
      filespec.Printf(wxT("%s.*"),value.c_str());
      if(checkit.HasFiles(filespec)){
         // collision with on-disk state!
         wxString collision;
         checkit.GetFirst(&collision,filespec);
         
         wxLogWarning(_("Audacity found an orphaned blockfile %s! \nPlease consider saving and reloading the project to perform a complete project check.\n"),
                      collision.c_str());
         
         return FALSE;
      }
   }
   fileName.Assign(dir.GetFullPath(),value);
   return TRUE;
}
Esempio n. 5
0
InexactDialog::InexactDialog(QWidget *parent, const char *name,bool _listbox)
  : QDialog(parent, name, TRUE)
{

  setCaption("Kscd");

  listbox = _listbox;
  if(listbox){
    list_box = new QListBox(this,"debugwindow");
    list_box->setGeometry(2,5,400, 300);
    connect(list_box,SIGNAL(highlighted(int)),SLOT(setStatusBar(int)));
  }
  else{
    edit = new QMultiLineEdit(this,"debugwindow");
    edit->setGeometry(2,5,400, 300);
  }


  text = new QLabel(this,"textlabel");
  text->setAlignment(WordBreak|AlignCenter);

  text->setText(klocale->translate("No exact match could be found. Please select the appropriate"\
		" CD from the list of choices presented below."));

  errorstring = klocale->translate("Please select a Disk Title or press Cancel");

  statuslabel = new QLabel( this, "statuslabel" );
  
  statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  statuslabel->setText( "" );
  statuslabel->setAlignment( AlignCenter );
  statuslabel->setGeometry(2, 307, 400, 20);
  //statusPageLabel->setFont( QFont("helvetica",12,QFont::Normal) );

  cancel_button = new QPushButton(this,"cancel_button");
  cancel_button->setGeometry(330,340,70,30);
  cancel_button->setText(klocale->translate("Cancel"));
  cancel_button->setFocus();

  ok_button = new QPushButton(this,"ok_button");
  ok_button->setGeometry(250,340,70,30);
  ok_button->setText(klocale->translate("OK"));
  //  ok_button->setFocus();


  connect(ok_button,SIGNAL(clicked()),SLOT(checkit()));
  connect(cancel_button,SIGNAL(clicked()),SLOT(reject()));

  returnstring = "";

  adjustSize();
  setMinimumSize(width(),height());
  
}
Esempio n. 6
0
void HullLibrary::extrude(btHullTriangle *t0,int v)
{
	int3 t= *t0;
	int n = m_tris.size();
	btHullTriangle* ta = allocateTriangle(v,t[1],t[2]);
	ta->n = int3(t0->n[0],n+1,n+2);
	m_tris[t0->n[0]]->neib(t[1],t[2]) = n+0;
	btHullTriangle* tb = allocateTriangle(v,t[2],t[0]);
	tb->n = int3(t0->n[1],n+2,n+0);
	m_tris[t0->n[1]]->neib(t[2],t[0]) = n+1;
	btHullTriangle* tc = allocateTriangle(v,t[0],t[1]);
	tc->n = int3(t0->n[2],n+0,n+1);
	m_tris[t0->n[2]]->neib(t[0],t[1]) = n+2;
	checkit(ta);
	checkit(tb);
	checkit(tc);
	if(hasvert(*m_tris[ta->n[0]],v)) removeb2b(ta,m_tris[ta->n[0]]);
	if(hasvert(*m_tris[tb->n[0]],v)) removeb2b(tb,m_tris[tb->n[0]]);
	if(hasvert(*m_tris[tc->n[0]],v)) removeb2b(tc,m_tris[tc->n[0]]);
	deAllocateTriangle(t0);

}
Esempio n. 7
0
int
main (void)
{
  char buf[128];
  int status;
  
  CLEAR (buf);
  status = checkit (buf, 10, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "foobar:9\0XXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 9, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "foobar:9\0XXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 8, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "foobar:\0XXXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 7, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "foobar\0XXXXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 6, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "fooba\0XXXXXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 2, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "f\0XXXXXXXXXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 1, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "\0XXXXXXXXXXXXX\0", 15) == 0);

  CLEAR (buf);
  status = checkit (buf, 0, "%s:%d", "foobar", 9);
  VERIFY (status==8 && memcmp (buf, "XXXXXXXXXXXXXX\0", 15) == 0);

  return 0;
}
Esempio n. 8
0
/*--------------------------------------------------------------*/
int main(int argc, char *argv[])
{
	register int i, j;
	char *p;

/*--------------------------------------------------------------*/
	local_flag = PASSED;

	fill();

	for (i = 0; i < 200; i++) {
		fill();
		p = &buf[400];
		memset(p, 0, i);
		if ((j = checkit(p)) != i) {
			tst_resm(TINFO,
				 "Not enough zero bytes, wanted %d, got %d", i,
				 j);
			local_flag = FAILED;
			break;
		}
		if (!p[-1] || !p[i]) {
			tst_resm(TINFO, "Boundary error, clear of %d", i);
			local_flag = FAILED;
		}
		if (local_flag == FAILED)
			break;
	}

	(local_flag == FAILED) ? tst_resm(TFAIL,
					  "Test failed") : tst_resm(TPASS,
								    "Test passed");
/*--------------------------------------------------------------*/
/* Clean up any files created by test before call to anyfail.	*/

	(local_flag == FAILED) ? tst_resm(TFAIL,
					  "Test failed") : tst_resm(TPASS,
								    "Test passed");
	tst_exit();
	/* THIS CALL DOES NOT RETURN - EXITS!!  */
	tst_exit();
}
Esempio n. 9
0
void CDDialog::save(){

  if(!checkit())
    return;

  QString path;

  InexactDialog *dialog;

  dialog = new InexactDialog(0,"Dialog",true);

  // Let's get rid of some ugly double slashes such as in 
  // /usr/local/kde/share/apps/kscd/cddb//rock 
  
  for(int i = 0; i < (int)pathlist.count();i++){
    QString temp = pathlist.at(i);
    temp = temp.replace( QRegExp("//"), "/" );
    pathlist.insert(i,temp);
    pathlist.remove(i+1);
  }

  dialog->insertList(pathlist);
  dialog->setErrorString((char *)klocale->translate("Please select a Category or press Cancel"));
  dialog->setTitle((char *)klocale->translate("Under which category would you like to store this CDDB entry?"));

  if(dialog->exec() != QDialog::Accepted){
    delete dialog;
    return;
  }

  dialog->getSelection(path);
  QString mag;
  mag.sprintf("%s/%08lx",path.data(),cdinfo.magicID);

  save_cddb_entry(mag,false);
  load();
  delete dialog;

}
int checkit(int r,int c,int i,int j,int l)
{
	//printf("str[%d]->%c==a[%d][%d]->%c check==%d\n",l,str[l],i,j,a[i][j],check[i][j]);
	if(l==10)
	{
		done=1;
		return;
	}
	if(done==1)
		return;
	if(a[i][j]==str[l])
	{
		l++;
		if(i-1>=0)
		{
			checkit(r,c,i-1,j,l);
			if(j-1>=0)
				checkit(r,c,i-1,j-1,l);
			if(j+1<c)
				checkit(r,c,i-1,j+1,l);
		}
		if(i+1<r)
		{
			checkit(r,c,i+1,j,l);
			if(j-1>=0)
				checkit(r,c,i+1,j-1,l);
			if(j+1<c)
				checkit(r,c,i+1,j+1,l);
		}
		if(j-1>=0)
			checkit(r,c,i,j-1,l);
		if(j+1<c)
			checkit(r,c,i,j+1,l);
	}
	return;
}
Esempio n. 11
0
/*--------------------------------------------------------------*/
int main(int argc, char *argv[])
{
	char *p, *q;

	setup();		/* temp file is now open        */
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[100];

	fill(p);
	q = &buf[800];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[-1] || p[LEN]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[-1] || q[LEN]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[800];

	fill(p);
	q = &buf[100];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[-1] || p[LEN]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[-1] || q[LEN]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[800];

	fill(p);
	q = &buf[850];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[-1]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[LEN]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[850];

	fill(p);
	q = &buf[800];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[LEN]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[-1]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();
/*--------------------------------------------------------------*/
/* Clean up any files created by test before call to anyfail.	*/

	anyfail();		/* THIS CALL DOES NOT RETURN - EXITS!!  */
	tst_exit();
}
Esempio n. 12
0
VOID
_cdecl main(
    int argc,
    char *argv[]
    )

{

    int i;

    for(i=0;i<255;i++){
        BSrc[i]=i;
        }
    SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);


    //
    // Non overlapping test
    //

    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 1);     checkit(BDest, BSrc, 1);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 2);     checkit(BDest, BSrc, 2);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 3);     checkit(BDest, BSrc, 3);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 4);     checkit(BDest, BSrc, 4);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 5);     checkit(BDest, BSrc, 5);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 6);     checkit(BDest, BSrc, 6);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 7);     checkit(BDest, BSrc, 7);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 8);     checkit(BDest, BSrc, 8);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 9);     checkit(BDest, BSrc, 9);    RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 10);    checkit(BDest, BSrc, 10);   RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 11);    checkit(BDest, BSrc, 11);   RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 12);    checkit(BDest, BSrc, 12);   RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 13);    checkit(BDest, BSrc, 13);   RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+1, 64);  checkit(BDest, BSrc+1, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+2, 64);  checkit(BDest, BSrc+2, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+3, 64);  checkit(BDest, BSrc+3, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+1, BSrc, 64);  checkit(BDest+1, BSrc, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+2, BSrc, 64);  checkit(BDest+2, BSrc, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+3, BSrc, 64);  checkit(BDest+3, BSrc, 64); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc, 63);    checkit(BDest, BSrc, 63);   RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+1, 63);  checkit(BDest, BSrc+1, 63); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+2, 63);  checkit(BDest, BSrc+2, 63); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest, BSrc+3, 63);  checkit(BDest, BSrc+3, 63); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+1, BSrc, 63);  checkit(BDest+1, BSrc, 63); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+2, BSrc, 63);  checkit(BDest+2, BSrc, 63); RtlFillMemory(BDest,1024,0xfe);
    RtlMoveMemory(BDest+3, BSrc, 63);  checkit(BDest+3, BSrc, 63); RtlFillMemory(BDest,1024,0xfe);

    //
    // Overlapping Test
    //

    ofilldst(); RtlMoveMemory(BDest, BDest+2, 4); ocheckit(BDest, BDest+2, 4);
    ofilldst(); RtlMoveMemory(BDest, BDest+64, 32); ocheckit(BDest, BDest+64, 32);
    ofilldst(); RtlMoveMemory(BDest, BDest+64, 33); ocheckit(BDest, BDest+64, 33);
    ofilldst(); RtlMoveMemory(BDest, BDest+64, 34); ocheckit(BDest, BDest+64, 34);
    ofilldst(); RtlMoveMemory(BDest, BDest+64, 35); ocheckit(BDest, BDest+64, 35);
    ofilldst(); RtlMoveMemory(BDest, BDest+64, 36); ocheckit(BDest, BDest+64, 36);
    ofilldst(); RtlMoveMemory(BDest, BDest+65, 32); ocheckit(BDest, BDest+65, 32);
    ofilldst(); RtlMoveMemory(BDest, BDest+66, 33); ocheckit(BDest, BDest+66, 33);
    ofilldst(); RtlMoveMemory(BDest, BDest+67, 34); ocheckit(BDest, BDest+67, 34);
    ofilldst(); RtlMoveMemory(BDest, BDest+68, 35); ocheckit(BDest, BDest+68, 35);
    ofilldst(); RtlMoveMemory(BDest, BDest+69, 36); ocheckit(BDest, BDest+69, 36);

    ofilldst(); RtlMoveMemory(BDest+1, BDest+64, 32); ocheckit(BDest+1, BDest+64, 32);
    ofilldst(); RtlMoveMemory(BDest+2, BDest+64, 33); ocheckit(BDest+2, BDest+64, 33);
    ofilldst(); RtlMoveMemory(BDest+3, BDest+64, 34); ocheckit(BDest+3, BDest+64, 34);
    ofilldst(); RtlMoveMemory(BDest+4, BDest+64, 35); ocheckit(BDest+4, BDest+64, 35);
    ofilldst(); RtlMoveMemory(BDest+5, BDest+64, 36); ocheckit(BDest+5, BDest+64, 36);

    ofilldst(); RtlMoveMemory(BDest+6, BDest+65, 32); ocheckit(BDest+6, BDest+65, 32);
    ofilldst(); RtlMoveMemory(BDest+7, BDest+66, 33); ocheckit(BDest+7, BDest+66, 33);
    ofilldst(); RtlMoveMemory(BDest+8, BDest+67, 34); ocheckit(BDest+8, BDest+67, 34);
    ofilldst(); RtlMoveMemory(BDest+9, BDest+68, 35); ocheckit(BDest+9, BDest+68, 35);

    ofilldst(); RtlMoveMemory(BDest+1, BDest+64, 32); ocheckit(BDest+1, BDest+64, 32);
    ofilldst(); RtlMoveMemory(BDest+2, BDest+64, 33); ocheckit(BDest+2, BDest+64, 33);
    ofilldst(); RtlMoveMemory(BDest+3, BDest+64, 34); ocheckit(BDest+3, BDest+64, 34);
    ofilldst(); RtlMoveMemory(BDest+4, BDest+64, 35); ocheckit(BDest+4, BDest+64, 35);
    ofilldst(); RtlMoveMemory(BDest+5, BDest+64, 36); ocheckit(BDest+5, BDest+64, 36);

    ofilldst(); RtlMoveMemory(BDest+6, BDest+65, 32); ocheckit(BDest+6, BDest+65, 32);
    ofilldst(); RtlMoveMemory(BDest+7, BDest+66, 33); ocheckit(BDest+7, BDest+66, 33);
    ofilldst(); RtlMoveMemory(BDest+8, BDest+67, 34); ocheckit(BDest+8, BDest+67, 34);
    ofilldst(); RtlMoveMemory(BDest+9, BDest+68, 35); ocheckit(BDest+9, BDest+68, 35);

    ofilldst(); RtlMoveMemory(BDest+1, BDest+65, 32); ocheckit(BDest+1, BDest+65, 32);
    ofilldst(); RtlMoveMemory(BDest+1, BDest+66, 33); ocheckit(BDest+1, BDest+66, 33);
    ofilldst(); RtlMoveMemory(BDest+1, BDest+67, 34); ocheckit(BDest+1, BDest+67, 34);
    ofilldst(); RtlMoveMemory(BDest+1, BDest+68, 35); ocheckit(BDest+1, BDest+68, 35);


    MemoryCopyTest(26);

    return;
}
Esempio n. 13
0
int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
{
	if(verts_count <4) return 0;
	if(vlimit==0) vlimit=1000000000;
	int j;
	btVector3 bmin(*verts),bmax(*verts);
	btAlignedObjectArray<int> isextreme;
	isextreme.reserve(verts_count);
	btAlignedObjectArray<int> allow;
	allow.reserve(verts_count);

	for(j=0;j<verts_count;j++) 
	{
		allow.push_back(1);
		isextreme.push_back(0);
		bmin.setMin (verts[j]);
		bmax.setMax (verts[j]);
	}
	btScalar epsilon = (bmax-bmin).length() * btScalar(0.001);
	btAssert (epsilon != 0.0);


	int4 p = FindSimplex(verts,verts_count,allow);
	if(p.x==-1) return 0; // simplex failed



	btVector3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) / btScalar(4.0);  // a valid interior point
	btHullTriangle *t0 = allocateTriangle(p[2],p[3],p[1]); t0->n=int3(2,3,1);
	btHullTriangle *t1 = allocateTriangle(p[3],p[2],p[0]); t1->n=int3(3,2,0);
	btHullTriangle *t2 = allocateTriangle(p[0],p[1],p[3]); t2->n=int3(0,1,3);
	btHullTriangle *t3 = allocateTriangle(p[1],p[0],p[2]); t3->n=int3(1,0,2);
	isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1;
	checkit(t0);checkit(t1);checkit(t2);checkit(t3);

	for(j=0;j<m_tris.size();j++)
	{
		btHullTriangle *t=m_tris[j];
		btAssert(t);
		btAssert(t->vmax<0);
		btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
		t->vmax = maxdirsterid(verts,verts_count,n,allow);
		t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
	}
	btHullTriangle *te;
	vlimit-=4;
	while(vlimit >0 && ((te=extrudable(epsilon)) != 0))
	{
		int3 ti=*te;
		int v=te->vmax;
		btAssert(v != -1);
		btAssert(!isextreme[v]);  // wtf we've already done this vertex
		isextreme[v]=1;
		//if(v==p0 || v==p1 || v==p2 || v==p3) continue; // done these already
		j=m_tris.size();
		while(j--) {
			if(!m_tris[j]) continue;
			int3 t=*m_tris[j];
			if(above(verts,t,verts[v],btScalar(0.01)*epsilon)) 
			{
				extrude(m_tris[j],v);
			}
		}
		// now check for those degenerate cases where we have a flipped triangle or a really skinny triangle
		j=m_tris.size();
		while(j--)
		{
			if(!m_tris[j]) continue;
			if(!hasvert(*m_tris[j],v)) break;
			int3 nt=*m_tris[j];
			if(above(verts,nt,center,btScalar(0.01)*epsilon)  || cross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]).length()< epsilon*epsilon*btScalar(0.1) )
			{
				btHullTriangle *nb = m_tris[m_tris[j]->n[0]];
				btAssert(nb);btAssert(!hasvert(*nb,v));btAssert(nb->id<j);
				extrude(nb,v);
				j=m_tris.size(); 
			}
		} 
		j=m_tris.size();
		while(j--)
		{
			btHullTriangle *t=m_tris[j];
			if(!t) continue;
			if(t->vmax>=0) break;
			btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
			t->vmax = maxdirsterid(verts,verts_count,n,allow);
			if(isextreme[t->vmax]) 
			{
				t->vmax=-1; // already done that vertex - algorithm needs to be able to terminate.
			}
			else
			{
				t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
			}
		}
		vlimit --;
	}
	return 1;
}
Esempio n. 14
0
File: memcpy01.c Progetto: kraj/ltp
int main(int argc, char *argv[])
{
	char *p, *q;

	tst_parse_opts(argc, argv, NULL, NULL);

	setup();		/* temp file is now open        */
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[100];

	fill(p);
	q = &buf[800];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[-1] || p[LEN]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[-1] || q[LEN]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();
/*--------------------------------------------------------------*/
	blenter();

	clearit();

	p = &buf[800];

	fill(p);
	q = &buf[100];
	memcpy(q, p, LEN);

	if (checkit(q)) {
		fprintf(temp, "\tcopy failed - missed data\n");
		local_flag = FAILED;
	}

	if (p[-1] || p[LEN]) {
		fprintf(temp, "\tcopy failed - 'to' bounds\n");
		local_flag = FAILED;
	}

	if (q[-1] || q[LEN]) {
		fprintf(temp, "\tcopy failed - 'from' bounds\n");
		local_flag = FAILED;
	}

	blexit();

	anyfail();
	tst_exit();
}
Esempio n. 15
0
void CDDialog::upload(){

  if(!checkit())
    return;

  /*
  switch( QMessageBox::information( this,klocale->translate("Message"),

klocale->translate(
"The submission you are about to make will go to the test server\n"\
"[email protected]. This is because this is the first release of\n"\
"the cddb addition to Kscd and I need to avoid corruption\n"\
"of the remote cddb data bases due to possible bugs in Kscd.\n"\
"Since we need about a 100 error free test submissions\n"\
"before we will be granted write acces to the 'true' cddb databases, 
I would like you ask you to upload as many test submissions as possible.\n"\
"You don't need to try to find a CD that is not in the database \n"\
"(thought that would be helpful),it suffices to submit existing\n"\
"entries with Kscd.\n"\
"After submission you should receive a mail notifying you of success or\n"\
"or failure of your submission. Should you receive a failure notice\n"\
"please forward the failure report to me: <*****@*****.**>\n"\
"Check back often for the availablity of a fully enabled version of kscd.\n"\
"Thank you for your support.\n"),
				    klocale->translate("OK"),
				    klocale->translate("Cancel"),
				    0,
				    1 ) ){

  case 0: 
    break;
  case 1: 
    return;
    break;
  }

  */


  InexactDialog *dialog;

  dialog = new InexactDialog(0,"Dialog",true);


  QStrList catlist;

  catlist.append("rock");
  catlist.append("classical");
  catlist.append("jazz");
  catlist.append("soundtrack");
  catlist.append("newage");
  catlist.append("blues");
  catlist.append("folk");
  catlist.append("country");
  catlist.append("reggae");
  catlist.append("misc");
  catlist.append("data");

  dialog->insertList(catlist);
  dialog->setErrorString((char *)klocale->translate("Please select a Category or press Cancel"));
  dialog->setTitle((char *)klocale->translate("To which category does the CD belong?"));
  if(dialog->exec() != QDialog::Accepted){
    delete dialog;
    return;
  }

  dialog->getSelection(submitcat);
  delete dialog;

  QString tempfile;
  tempfile = tempfile.sprintf("%s",tmpnam(0L));

  save_cddb_entry(tempfile,true);

  mykapp->processEvents();
  mykapp->flushX();


/*  QString subject;
  subject.sprintf("cddb %s %08lx",submitcat.data(),cdinfo.magicID);

  QString formatstr;
  //  formatstr = mailcmd + " [email protected]";
  formatstr = mailcmd;
  formatstr += " ";
  formatstr += submitaddress;
  */
  if(smtpConfigData->enabled){
      if(debugflag)
          printf("Submitting cddb entry via SMTP...\n");
      QFile file(tempfile);

      file.open(IO_ReadOnly);
      QTextStream ti(&file);

      QString s;
      QString subject;
      
      while (!ti.eof()){
          s += ti.readLine() + "\r\n";
//          if(!ti.eof()){
              //  mimetranslate(s);
//              to << s.data() << '\n';
 //         }
      }

//      smtpMailer = new SMTP;

      smtpMailer->setServerHost(smtpConfigData->serverHost.data());
      smtpMailer->setPort(smtpConfigData->serverPort.toInt());
      
      smtpMailer->setSenderAddress(smtpConfigData->senderAddress.data());
      smtpMailer->setRecipientAddress(submitaddress.data());
      
      subject.sprintf("cddb %s %08lx", submitcat.data(), cdinfo.magicID);
      smtpMailer->setMessageSubject(subject.data());
      smtpMailer->setMessageBody(s.data());

      smtpMailer->sendMessage();
      
      return;
  }

      
  QString cmd;
  //  cmd = cmd.sprintf("mail -s \"%s\" [email protected]",subject.data());
  //  cmd = cmd.sprintf("sendmail [email protected]");
  cmd = cmd.sprintf("sendmail -tU");
  //  cmd = cmd.sprintf(formatstr.data(),subject.data());

  if (debugflag ) printf(klocale->translate("Submitting cddb entry: %s\n"),cmd.data());
  
  FILE* mailpipe;
  mailpipe = popen(cmd.data(),"w");

  if(mailpipe == NULL){
    QString str;
    str.sprintf(klocale->translate("Could not pipe contents into:\n %s"),cmd.data());

    QMessageBox::critical(this, "Kscd", str.data());
    pclose(mailpipe);
    return;
    
  }
  
  QFile file(tempfile);
  //  QFile file2("/home/wuebben/test.txt"); // ******

  file.open(IO_ReadOnly);
  //file2.open(IO_ReadWrite); // ******
  QTextStream ti(&file);
  //QTextStream to(&file2); // ******

  QTextStream to(mailpipe,IO_WriteOnly );

  QString s;

  //to << "Content-Transfer-Encoding: quoted-printable\n";

  while ( !ti.eof() ) {
      s = ti.readLine();
      if(!ti.eof()){
          //  mimetranslate(s);
          to << s.data() << '\n';
      }
  }

  pclose(mailpipe);

  file.close();
  //  file2.close();   // *****

  unlink(tempfile.data());
  if ( debugflag ) printf("DONE SENDING\n");
}
Esempio n. 16
0
int
main (void)
{
  RESULT(checkit ("<%d>\n", 0x12345678));
  RESULT(printf ("<%d>\n", 0x12345678));

  RESULT(checkit ("<%200d>\n", 5));
  RESULT(printf ("<%200d>\n", 5));

  RESULT(checkit ("<%.300d>\n", 6));
  RESULT(printf ("<%.300d>\n", 6));

  RESULT(checkit ("<%100.150d>\n", 7));
  RESULT(printf ("<%100.150d>\n", 7));

  RESULT(checkit ("<%s>\n",
		  "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
777777777777777777333333333333366666666666622222222222777777777777733333"));
  RESULT(printf ("<%s>\n",
		 "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
777777777777777777333333333333366666666666622222222222777777777777733333"));

  RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
		  1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
  RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
		 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));

  RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
  RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));

  RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
  RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));

  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
		  75, 75, 75, 75, 75, 75, 75));
  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
		 75, 75, 75, 75, 75, 75, 75));

  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
		  75, 75, 75, 75, 75, 75, 75));
  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
		 75, 75, 75, 75, 75, 75, 75));

  RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
  RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));

#if defined(__GNUC__) || defined (HAVE_LONG_LONG)
  RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
  RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
  RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
  RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
#endif

#if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
  RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
		  1.23456, 1.234567890123456789L, 1.23456));
  RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
		 1.23456, 1.234567890123456789L, 1.23456));
#endif

  return 0;
}
Esempio n. 17
0
int main(int argc, char **argv)
{
	pid_t pid;
	int i = 0;
	int j = 0;
	int regions = 1;
	int state = 0;
	char *mem;
	mach_vm_address_t base;
	mach_vm_address_t past = 0;
	mach_vm_address_t addr;
	vm_region_t **vm_region_list;
	mach_port_t task;

	if (geteuid() != 0) {
		fprintf(stderr, "[-] are you root?\n");
		exit(1);
	}
	set_signal_handler();
	printf("[+] Looking for Self Service\n");
	pid = get_pid();
	if (!pid) {
		fprintf(stderr, "[-] Not found. exiting\n");
		exit(2);
	}
	printf("[+] Self Service found: %d\n", pid);

	task = attach(pid);
	printf("[+] ATTACHED TO PROCESS %d WITH TASK %d\n", pid, task);

	base = get_base_address(task);
	addr = base;
	while (regions) {
		vm_region_list = get_memory_map(task, addr, &regions);
		printf("[+] Found %d regions\n", regions);
		for (i = 0; i < regions; ++i) {
			if (past > vm_region_list[i]->address_start) {
				printf("\n[!] Looped around somehow, exiting gracefully\n\n");
				exit(256);
			}
			printf("[+] Region %d:%d;\n[+]\tType:\t%s\n[+]\tBase Address:\t%016llx\n[+]\tEnd Address:\t%016llx\n[+]\tSize:\t0x%llx (%lld bytes)\n[+]\tPermissions:\t%s \n",
			       j, i, user_tag_to_string(vm_region_list[i]->region_type), vm_region_list[i]->address_start, vm_region_list[i]->address_start + vm_region_list[i]->size,
			       vm_region_list[i]->size, vm_region_list[i]->size, get_protection(vm_region_list[i]->protection));
			if ((vm_region_list[i]->protection) & 1) {
				printf("[+]\tMaking Local Copy of Memory\n");
				mem = (char *)read_memory_allocate(task, vm_region_list[i]->address_start, vm_region_list[i]->size);
			} else {
				printf("[+]\t\tChanging memory permissions\n");
				state = vm_region_list[i]->protection;
				change_page_protection(task, vm_region_list[i]->address_start, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
				printf("[+]\t\tMaking Local Copy of Memory\n");
				mem = (char *)read_memory_allocate(task, vm_region_list[i]->address_start, vm_region_list[i]->size);
				printf("[+]\t\tChanging memory permissions back\n");
				change_page_protection(task, vm_region_list[i]->address_start, state);
			}
			printf("[+]\tSearching local copy for username and password string\n");
			checkit(mem, vm_region_list[i]->size);
			free(mem);
		}
		printf("[+] Completed searching %d regions\n", i);
		past = addr;
		addr += base;
		if (setjmp(buf)) {
			fprintf(stderr, "\n[!] Segfault at 0x%llX\n\n", addr);
			past = addr;
			addr = vm_region_list[i]->address_start + vm_region_list[i]->size;
		}
		j++;
	}
	printf("\n[+] Completed searching through allocated memory\n");
	return 0;

}
int main()
{
	int i,j;
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			scanf("%c",&c[i][j]);
			s[i][j] = c[i][j];
		}
		scanf("%*c");
	}
	int count = 0,check = 1;
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
			if(c[i][j]=='T')
			{
				init();
				if(!checkit(i,j))
				{
					check = 0;
					break;
				}
			}
		if(!check)
			break;
	}
	int done=0;
	if(check)
	{
		while(1)
		{
			done = 1;
			for(i=0;i<10;i++)
			{
				for(j=0;j<10;j++)
					if(c[i][j] == 'T')
					{
						done=0;
						break;
					}
				if(!done)
					break;
			}
			if(done)
				break;
			count++;
			for(i=0;i<10;i++)
				for(j=0;j<10;j++)
					if(c[i][j] == 'F')
					{
						if(i-1>=0 && c[i-1][j]=='T')
							s[i-1][j] = 'F';
						if(i+1<10 && c[i+1][j]=='T')
							s[i+1][j] = 'F';
						if(j-1>=0 && c[i][j-1]=='T')
							s[i][j-1] = 'F';
						if(j+1<10 && c[i][j+1]=='T')
							s[i][j+1] = 'F';
					}
			copy();
		}
	}
	printf("%d\n",check?count:-1);
	return 0;
}