Beispiel #1
0
int main(void)
{
  struct bar b;
  b.alpha = 42;
  b.tri.y = 42;

#if 0 /* generated code */
  /* TODO */
#else /* original code */
  fu(&b);
#endif

  return 0;
}
Beispiel #2
0
int Heuristic::run() const
{
  const int n = instance_.num_words();
  std::vector<Overlap> overlaps;

  std::vector<bool> prefix_used(n, false);
  std::vector<bool> suffix_used(n, false);
  std::vector<int> next(n, -1);

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j)
        continue;
      overlaps.push_back(Overlap(instance_.ov(i, j), i, j));
    }
  }

  std::sort(overlaps.begin(), overlaps.end());
  FindUnion fu(n);
  int size = 0;


  while(!overlaps.empty()){
    Overlap cur = overlaps.back();
    overlaps.pop_back();

    if(prefix_used[cur.right] || suffix_used[cur.left])
      continue;

    if(fu.find(cur.right) == fu.find(cur.left))
      continue;
    
    prefix_used[cur.right] = true;    
    suffix_used[cur.left] = true;
    next[cur.left] = cur.right;
    fu.sum(cur.left, cur.right);
    size += instance_[cur.left].size() - cur.len;
  }
  
  return size; 
}
expr_ref fpa2bv_model_converter_prec::convert_bv2fp(sort * s, expr * sgn, expr * exp, expr * sig) const {
    fpa_util fu(m);
    bv_util bu(m);
    unsynch_mpz_manager & mpzm = fu.fm().mpz_manager();
    unsynch_mpq_manager & mpqm = fu.fm().mpq_manager();

    expr_ref res(m);
    mpf fp_val;

    unsigned ebits = fu.get_ebits(s);
    unsigned sbits = fu.get_sbits(s);

    unsigned sgn_sz = 1;
    unsigned exp_sz = ebits;
    unsigned sig_sz = sbits - 1;

    rational sgn_q(0), sig_q(0), exp_q(0);

    if (sgn) bu.is_numeral(sgn, sgn_q, sgn_sz);
    if (exp) bu.is_numeral(exp, exp_q, exp_sz);
    if (sig) bu.is_numeral(sig, sig_q, sig_sz);

    // un-bias exponent
    rational exp_unbiased_q;
    exp_unbiased_q = exp_q - fu.fm().m_powers2.m1(ebits - 1);

    mpz sig_z; mpf_exp_t exp_z;
    mpzm.set(sig_z, sig_q.to_mpq().numerator());
    exp_z = mpzm.get_int64(exp_unbiased_q.to_mpq().numerator());

    fu.fm().set(fp_val, ebits, sbits, !mpqm.is_zero(sgn_q.to_mpq()), exp_z, sig_z);

    mpzm.del(sig_z);

    res = fu.mk_value(fp_val);

    TRACE("fpa2bv_mc", tout << "[" << mk_ismt2_pp(sgn, m) <<
          " " << mk_ismt2_pp(exp, m) <<
          " " << mk_ismt2_pp(sig, m) << "] == " <<
          mk_ismt2_pp(res, m) << std::endl;);
Beispiel #4
0
IGL_INLINE void igl::PolyVectorFieldFinder<DerivedV, DerivedF>::
minQuadWithKnownMini(const Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &Q,
                          const Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &f,
                     const Eigen::VectorXi isConstrained,
                          const Eigen::Matrix<std::complex<typename DerivedV::Scalar>, Eigen::Dynamic, 1> &xknown,
                          Eigen::Matrix<std::complex<typename DerivedV::Scalar>, Eigen::Dynamic, 1> &x)
{
  int N = Q.rows();

  int nc = xknown.rows();
  Eigen::VectorXi known; known.setZero(nc,1);
  Eigen::VectorXi unknown; unknown.setZero(N-nc,1);

  int indk = 0, indu = 0;
  for (int i = 0; i<N; ++i)
    if (isConstrained[i])
    {
      known[indk] = i;
      indk++;
    }
    else
    {
      unknown[indu] = i;
      indu++;
    }

  Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar>> Quu, Quk;

  igl::slice(Q,unknown, unknown, Quu);
  igl::slice(Q,unknown, known, Quk);


  std::vector<typename Eigen::Triplet<std::complex<typename DerivedV::Scalar> > > tripletList;

  Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > fu(N-nc,1);

  igl::slice(f,unknown, Eigen::VectorXi::Zero(1,1), fu);

  Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > rhs = (Quk*xknown).sparseView()+.5*fu;

  Eigen::SparseLU< Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar>>> solver;
  solver.compute(-Quu);
  if(solver.info()!=Eigen::Success)
  {
    std::cerr<<"Decomposition failed!"<<std::endl;
    return;
  }
  Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar>>  b  = solver.solve(rhs);
  if(solver.info()!=Eigen::Success)
  {
    std::cerr<<"Solving failed!"<<std::endl;
    return;
  }

  indk = 0, indu = 0;
  x.setZero(N,1);
  for (int i = 0; i<N; ++i)
    if (isConstrained[i])
      x[i] = xknown[indk++];
    else
      x[i] = b.coeff(indu++,0);

}
Beispiel #5
0
void Appl1::slotNextClicked()
{
    int z, o=0, asdf;
    QString xxxx,yyyy,zzzz;

    le1->setFocus();
    le1->setSelection(0,1);
    qDebug() << "slotNextClicked" ;
    xxxx=le1->text();
    yyyy=le2->text();
    a[k]=xxxx.toInt();
    b[k]=yyyy.toInt();
    yy[k]=xx[k][0] * 1000 + xx[k][1] * 100 + xx[k][2] * 10 + xx[k][3];

    //qDebug() << "x[k][0]=" << xx[k][0];
    //qDebug() << "x[k][1]=" << xx[k][1];
    //qDebug() << "x[k][2]=" << xx[k][2];
    //qDebug() << "x[k][3]=" << xx[k][3];
    //qDebug() << "yy[k]=" << yy[k];
    zzzz = asas;
    table->setItem(k, 0,new QTableWidgetItem(zzzz));
    table->setItem(k, 1,new QTableWidgetItem(xxxx+":"+yyyy));
    qDebug() << "b[k]=" << b[k];
    qDebug() << "k=" << k;
    if(b[k]==4)
        goto l04;

    k++;

    //ite++;
    yy[k]=yy[k-1];
    c:   q=0;
    if (yy[k]==9876)
    {
        yy[k]=122;
        o++;
    }
    //qDebug() << "o=" << o;
    if (o==2)
        //break
        goto l02;
    z=++yy[k];
    for (int i=0,r2=1000;i<=3;i++)
    {
        xx[k][i]=z/r2;
        z=z-z/r2*r2;
        r2=r2/10;
    }
    for (int i=1;i<=3;i++)
    {
        for (int j=0;j<=i-1;j++)
        {
            if (xx[k][i]==xx[k][j])
            {
                q=1;
                //break;
            }
        }
        //if (q==1)
            //break;
    }
    if (q==1)
    goto c;

    q=fu(k);
    if (q==1)
    goto c;
    //qDebug() << "yy[k]=" << yy[k];
    asdf = yy[k];
    xx[k][3] = asdf%10;
    asas[3] = xx[k][3]+48;
    asdf = asdf/10;
    xx[k][2] = asdf%10;
    asas[2] = xx[k][2]+48;
    asdf = asdf/10;
    xx[k][1] = asdf%10;
    asas[1] = xx[k][1]+48;
    asdf = asdf/10;
    xx[k][0] = asdf%10;
    asas[0] = xx[k][0]+48;
    asdf = asdf/10;
    //qDebug() << "x[k][0]=" << xx[k][0];
    //qDebug() << "x[k][1]=" << xx[k][1];
    //qDebug() << "x[k][2]=" << xx[k][2];
    //qDebug() << "x[k][3]=" << xx[k][3];
    l_try->setText(asas);
    goto l03;
    l02: qDebug() << "The End";
    l_error->show();
    l04: bttnNext->hide();
    fr21->hide();
    fr22->hide();
    l_more->show();
    bttnMore->show();
    bttnMore->setFocus();
    l03: ;
}
Beispiel #6
0
bool test_lin_indep(Shapeset *shapeset) {
	_F_
	printf("I. linear independency\n");

	UMFPackMatrix mat;
	UMFPackVector rhs;
	UMFPackLinearSolver solver(&mat, &rhs);

	ShapeFunction fu(shapeset), fv(shapeset);

	int n =
		Hex::NUM_VERTICES * 1 +			// 1 vertex fn
		Hex::NUM_EDGES * shapeset->get_num_edge_fns(H3D_MAX_ELEMENT_ORDER) +
		Hex::NUM_FACES * shapeset->get_num_face_fns(order2_t(H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER)) +
		shapeset->get_num_bubble_fns(Ord3(H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER));

	printf("number of functions = %d\n", n);

	int *fn_idx = new int [n];
	int m = 0;
	// vertex fns
	for (int i = 0; i < Hex::NUM_VERTICES; i++, m++)
		fn_idx[m] = shapeset->get_vertex_index(i);
	// edge fns
	for (int i = 0; i < Hex::NUM_EDGES; i++) {
		int order = H3D_MAX_ELEMENT_ORDER;
		int *edge_idx = shapeset->get_edge_indices(i, 0, order);
		for (int j = 0; j < shapeset->get_num_edge_fns(order); j++, m++)
			fn_idx[m] = edge_idx[j];
	}
	// face fns
	for (int i = 0; i < Hex::NUM_FACES; i++) {
		order2_t order(H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER);
		int *face_idx = shapeset->get_face_indices(i, 0, order);
		for (int j = 0; j < shapeset->get_num_face_fns(order); j++, m++)
			fn_idx[m] = face_idx[j];
	}
	// bubble
	Ord3 order(H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER, H3D_MAX_ELEMENT_ORDER);
	int *bubble_idx = shapeset->get_bubble_indices(order);
	for (int j = 0; j < shapeset->get_num_bubble_fns(order); j++, m++)
		fn_idx[m] = bubble_idx[j];


	// precalc structure
	mat.prealloc(n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			mat.pre_add_ij(i, j);
	mat.alloc();
	rhs.alloc(n);

	printf("assembling matrix ");

	for (int i = 0; i < n; i++) {
		fu.set_active_shape(fn_idx[i]);

		printf(".");
		fflush(stdout);			// prevent caching of output (to see that it did not freeze)

		for (int j = 0; j < n; j++) {
			fv.set_active_shape(fn_idx[j]);

			double value = l2_product(&fu, &fv);

			mat.add(i, j, value);
		}
	}
	printf("\n");

	for (int i = 0; i < n; i++)
		rhs.add(i, 0.0);

	printf("solving matrix\n");

	// solve the system
	if (solver.solve()) {
		double *sln = solver.get_solution();
		bool indep = true;
		for (int i = 1; i < n + 1; i++) {
			if (sln[i] >= EPS) {
				indep = false;
				break;
			}
		}

		if (indep)
			printf("ok\n");
		else
			printf("Shape functions are not linearly independent\n");
	}
	else {
		printf("Shape functions are not linearly independent\n");
	}

	delete [] fn_idx;

	return true;
}
Beispiel #7
0
int main()
{
   Function<void(*)()> fu(func1);
   eval(fu);

   Function<bool(*)(int, double&)> f(func);
   double y = 3.1415;
   std::cout << f(42, y) << std::endl;

   Function<void(Hello::*)(int)const> f1(&Hello::sayHello);
   Hello h;
   const Hello* h1 = &h;
   f1(*h1, 42);

   // get rid of this template arguments if possible...
   eval(bind(&Hello::sayHello1, ref(h)));
   double x = 3.1415;
   eval(bind(func, 3, x));
   std::cout << x << std::endl;

   x = 6.666667;
   bind(func, 4, _1)(x);
   std::cout << x << std::endl;

   bind(&Hello::sayHello, ref(h), 23)();
   bind(&Hello::sayHello, ref(h), _1)(33);
   bind(&Hello::sayHello, _1, 24)(h);  // FIXME here no pointer possible
   bind(&Hello::sayHello, _1, _2)(h, 22);

   std::vector<int> iv;
   iv.push_back(2);
   iv.push_back(4);
   iv.push_back(3);
   iv.push_back(1);
   std::for_each(iv.begin(), iv.end(), bind(printx, "%d\n", _1));
   
   double d = 123.123;
   Hello h2(42);   
   
   bind(&Hello::sayHello3, _1, 42, _2)(h2, d);
   std::cout << "d=" << d << std::endl;

   std::vector<Hello> hv;
   hv.push_back(Hello());
   hv.push_back(Hello());
   std::for_each(hv.begin(), hv.end(), bind(&Hello::doIt, _1)); 
   
   Function<bool(*)(double& d)> bf;
   std::cout << !!bf << std::endl;
   bf = bind(func, 4, _1);
   std::cout << !!bf << std::endl;
   d = 7.777;
   bf(d);   
   
   Function<void(*)(Hello&, double&)> bf1(bind(&Hello::sayHello3, _1, 42, _2));
   bf1(h, d);
   
   bind(f4, _2, _3, _4, _1)(1, 2, 3, 4);   
   
   std::vector<Hello*> hv1;
   hv1.push_back(new Hello(42));
   std::for_each(hv1.begin(), hv1.end(), bind(&Hello::sayHello, _1, 23));
   
   bind(&Hello::sayHello, hv1.front(), _1)(23);
   
   // FIXME any smart pointer does not work here!
   std::auto_ptr<Hello> ah(new Hello(11));
   Function<void(Hello::*)(int, double&)> fu1(&Hello::sayHello3);
   fu1(*ah, 42, d);
   
   return 0;
}
Beispiel #8
0
//std::vector <osg::Vec3> LeafGrower::grow_planes(osg::Vec3 origin, double height, int angle, bool maya)
std::vector <osg::Vec3> LeafGrower::grow_planes()
{
    std::vector <osg::Vec3> ret;
    if(!_root)
        return ret;

    //copy to avoid modification
    //BDLSkeletonNode *root = BDLSkeletonNode::copy_tree(_root);
    //BDLSkeletonNode::rectify_skeleton_tree(root, origin, height, angle, maya);
	BDLSkeletonNode *root = _root;

    //set the expected leaf size be 0.35 of the trunk's radius
    float leaf_size_hint = root->_radius * 0.35;

    //store for billboard data
    _all_pos.clear();

    //bfs
    std::queue <BDLSkeletonNode *> Queue;
    Queue.push(root);

    int ball_cnt = 0;
    float outgrow = 1.3f;

    //grow leaves only at tips or small radius nodes
    while(!Queue.empty())
    {
        BDLSkeletonNode *front = Queue.front();
        Queue.pop();

        for(unsigned int i=0; i<front->_children.size(); i++)
            Queue.push(front->_children[i]);

        //skip the root
        if(!front->_prev)
            continue;

        //graph's leafs only
        if(front->_children.size() == 0)
        {
            osg::Vec3 pos(front->_sx, front->_sy, front->_sz);
            osg::Vec3 pre(front->_prev->_sx, front->_prev->_sy, front->_prev->_sz); 
            osg::Vec3 mid = (pos+pre) / 2.0f;
            osg::Vec3 tangent = pos - pre;

            float cloud_width = tangent.length() * 0.50 * outgrow;
            tangent.normalize();

            //consider a plane with tangent as the normal and contains point pos
            //find basis u, v of this plane
            osg::Vec3 u(tangent.y(), -tangent.x(), 0.0);
            osg::Vec3 v = tangent ^ u;

            //consider another plane with u as normal and contains point pos
            //the basis of this plane is chosen as tangent and v
            //div_angle is the angle angle spanned by tangent and the root of the leaf
            double div_angle = (rand()%30-15+70)/180.0*M_PI;

            //number of ball of this node
            int no_leaf = 1;
            for(int i=1; i<=no_leaf; i++)
            {
                double angle = 360.0/no_leaf*i/180.0*M_PI;
                osg::Vec3 div = u*cos(angle) + v*sin(angle);
                div = tangent * cos(div_angle) + div * sin(div_angle);

                //frame: fu, fv, div, at pos
                osg::Vec3 fu(div.y(), -div.x(), 0.0f);
                fu.normalize();
                osg::Vec3 fv = div ^ fu;

                //cloud around this node
                std::vector <osg::Vec3> b_cloud;
                std::vector <float> weights;
                Transformer::sphere_points_transformed(b_cloud, weights, mid, cloud_width, tangent, 10-rand()%20, leaf_size_hint);
                //Transformer::sphere_points_transformed(b_cloud, weights, mid, cloud_width, tangent, -89, leaf_size_hint);

                //from points to leaf vertices
                for(unsigned j=0; j<b_cloud.size(); j++)
                {
                    osg::Vec3 b_p = b_cloud[j];

                    osg::Vec3 normal = b_p - mid;
                    normal.normalize();

                    osg::Vec3 normal2 = b_p - pos;
                    normal2.normalize();

                    //displace
                    float d_ratio = weights[j] > 0.5 ? 0.40 : 1.0f/outgrow;
                    b_p += normal2 * cloud_width * d_ratio * (weights[j]-0.5f);
                    float leaf_s = leaf_size_hint * (1.0-0.8*std::max(0.0f, weights[j]-0.5f));

                    //cloud pt inside segmentation?
                    if(false || _pruner.is_inside_ortho(b_p))
                    {
                        Transformer::points_to_leafs(ret, b_p, normal, leaf_s, true);

                        //for billboard data
                        _all_pos.push_back(b_p);
                    }
                }
            }

            ball_cnt++;
        }
        if(false)
            if(ball_cnt > 5)
                break;
    }
    if(false)
        printf("ball_cnt(%d)\n", ball_cnt);

    //delete copy
    //BDLSkeletonNode::delete_this(root);

    return ret;
}
Beispiel #9
0
main()
{
	int i,j,key,num,b[20],p;
 	char ch;
aa: 
	window(1,1,25,80);
	textbackground(LIGHTGREEN);
	textcolor(YELLOW);
	clrscr();
	fu(b);
	num=0;
	p=0;
	textcolor(LIGHTRED);
	gotoxy(18,1);
	cprintf("%c(UP) %c(DOWN) %c(LEFT) %c(RIGHT)",24,25,27,26);
	gotoxy(16,2);
	cprintf("Eat the numbers in your road whose sum is 7,");
	gotoxy(14,3);
	cprintf("and eat 7 in the end, then you will win the game!");
	textcolor(MAGENTA);
	for(i=4;i<21;i++)
		for(j=20;j<44;j++)
			if(k[i-4][j-20]==0)
			{
				gotoxy(j,i);
				cprintf("%c",219);
			}
			else if(k[i-4][j-20]!=1)
			{
				gotoxy(j,i);
				cprintf("%d",k[i-4][j-20]);
			}
	textcolor(YELLOW);
	i=5;
	j=21;
	gotoxy(j,i);
	cprintf("\1");
	gotoxy(33,5);
	cprintf("7");
	gotoxy(7,7);
	cprintf("num:%d",num);
	textcolor(WHITE);
	gotoxy(11,22);
	cprintf("Press any key to start game, Q key to quit...");
	ch=getch();
	if(ch=='Q'||ch=='q')
	{
		window(1,1,25,80);
		textbackground(BLACK);
		textcolor(LIGHTGRAY);
		clrscr();
		exit(0);
	}
	else
	{
		textcolor(YELLOW);
		gotoxy(11,22);
		cprintf("                                             ");
	}
	do
	{
		key=bioskey(0);
		sound(200);
		delay(1000);
		nosound();
		switch(key)
		{
			case DOWN:
			{
				if(k[i-4+1][j-20]==0)
					continue;
				if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
				{
					num+=k[i-4+1][j-20];
					b[p++]=i+j+1;
					gotoxy(7,7);
					cprintf("num:%d",num);
				}
				textcolor(YELLOW);
				gotoxy(j,i++);
				printf(" ");
				gotoxy(j,i);
				cprintf("\1");
				gotoxy(33,5);
				if(k[i-4][j-20]==7&&num==7)
					wingame();
				else if(num!=7&&k[i-4][j-20]==7)
				{
					lostgame(num);
					goto aa;
				}
				break; 
			}
			case UP:
			{
				if(k[i-4-1][j-20]==0)
					continue;
				if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
				{
					num+=k[i-4-1][j-20];
					b[p++]=i+j-1;
					gotoxy(7,7);
					cprintf("num:%d",num);
				}
				textcolor(YELLOW);
				gotoxy(j,i--);
				printf(" ");
				gotoxy(j,i);
				cprintf("\1");
				gotoxy(33,5);
				if(k[i-4][j-20]==7&&num==7)
					wingame();
				else if(num!=7&&k[i-4][j-20]==7)
				{
					lostgame(num);
					goto aa;
				}
				break; 
			}
			case LEFT:
			{
				if(k[i-4][j-20-1]==0)
					continue;
				if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
				{
					num+=k[i-4][j-20-1];
					b[p++]=i+j-1;
					gotoxy(7,7);
					cprintf("num:%d",num);
				}
				textcolor(YELLOW);
				gotoxy(j--,i);
				printf(" ");
				gotoxy(j,i);
				cprintf("\1");
				gotoxy(33,5);
				if(k[i-4][j-20]==7&&num==7)
					wingame();
				else if(num!=7&&k[i-4][j-20]==7)
				{
					lostgame(num);
					goto aa;
				}
				break; 
			}
			case RIGHT:
			{
				if(k[i-4][j-20+1]==0)
					continue;
				if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
				{
					num+=k[i-4][j-20+1];
					b[p++]=i+j+1;
					gotoxy(7,7);
					cprintf("num:%d",num);
				}
				textcolor(YELLOW);
				gotoxy(j++,i);
				printf(" ");
				gotoxy(j,i);
				cprintf("\1");gotoxy(33,5);
				if(k[i-4][j-20]==7&&num==7)
					wingame();
				else if(num!=7&&k[i-4][j-20]==7)
				{
					lostgame(num);
					goto aa;
				}
				break; 
			}
			default:
				continue;
		}
	}while(1);
}
Beispiel #10
0
QByteArray
DirectoryLister::html(const QString & root, const QString & _path)
{
    kpfDebug << "root: " << root << " path: " << _path << endl;

    QString path;

    if (_path.right(1) != "/")
        path = _path + "/";
    else
        path = _path;

    if (path[0] == '/')
        path + "";

    QDir d(root + path);

    if (!d.exists())
    {
        return buildHTML
               (
                   i18n("Error"),
                   i18n("Directory does not exist: %1 %2").arg(root).arg(path)
               );
    }

    const QFileInfoList * infoList =
        d.entryInfoList(QDir::DefaultFilter, QDir::Name | QDir::DirsFirst);

    if (0 == infoList)
    {
        return buildHTML
               (
                   i18n("Error"),
                   i18n("Directory unreadable: %1 %2").arg(root).arg(path)
               );
    }

    QString html;

    html  += "<table";
    html  += " width=\"100%\"";
    html  += " class=\"filelist\">\n";

    html  += "<tr>\n";
    html  += "<th align=\"left\" class=\"listheading\">Name</th>\n";
    html  += "<th align=\"left\" class=\"listheading\">Size</th>\n";
    html  += "</tr>\n";

    for (QFileInfoListIterator it(*infoList); it.current(); ++it)
    {
        static int counter = 0;

        QFileInfo * fi(it.current());

        if (
            (fi->fileName()[0] == '.')
            && ((fi->fileName() != "..") || path == "/")
        )
        {
            // Don't show hidden files
            continue;
        }

        ++counter;

        QString td_class = (counter % 2) ? "alt" : "norm";

        html += "<tr>\n";

        html += "<td class=\"" + td_class + "\">";

        QString item_class = QString((fi->isDir()) ? "direntry" : "fileentry");

        KURL fu(path+fi->fileName());
        html +=
            "<a href=\""
            + fu.encodedPathAndQuery()
            + (fi->isDir() ? "/" : "")
            + "\" class=\""
            + item_class
            + "\">";

        if (fi->fileName() != "..")
            html += QStyleSheet::escape(fi->fileName());
        else
            html += i18n("Parent Directory");

        html += "</a>";

        if (fi->isDir())
            html += "/";

        html += "</td>\n";

        html += "<td class=\"" + td_class + "\">";

        if (!fi->isDir())
            html
            += "<div class=\"sizeentry\">" + prettySize(fi->size()) + "</div>";

        html += "</td>\n";
        html += "</tr>\n";
    }

    html += "</table>\n";

    return buildHTML
           (
               i18n("Directory listing for %1").arg(QStyleSheet::escape(path)),
               html
           );
}
Beispiel #11
0
/*
 * +      +      +      -+-   +    +
 * |\    /|     / \      |    |\   |
 * | \  / |    /___\     |    | \  |
 * |  \/  |   /     \    |    |  \ |
 * |      |  /       \  -+-   |   \|
 */
int main()
{
	int i;
	for (i = MIN_FLOOR; i <= MAX_FLOOR; i++) {
		QUEUE[i].QL = &QUEUE[i];
		QUEUE[i].QR = &QUEUE[i];
	}
	WAIT.WL = &WAIT;
	WAIT.WR = &WAIT;
	WAIT.ent_time = 0;
	WAIT.inst = dummy_func;
	ELEVATOR.EL = &ELEVATOR;
	ELEVATOR.ER = &ELEVATOR;

	/* xlog_state("***** data structures *****"); */

	in_WAIT(0, E1, NO_ARG);

	for(i = 0; i < sizeof(users) / sizeof(users[0]) - 1; i++) {
		xlog(LOG_PLAIN, "IN:%d; OUT:%d; GIVEUPTIME:%d; INTERTIME: %d; %s\n",
		     users[i].IN,
		     users[i].OUT,
		     users[i].GIVEUPTIME,
		     users[i+1].ENTERTIME - users[i].ENTERTIME,
		     users[i].name);
		in_WAIT(users[i].ENTERTIME, U1, &users[i]);
	}

	/* xlog_state("***** data structures *****"); */

	xlog(LOG_PLAIN, "\n"
	     "=================================================="
	     "execute the WAIT list"
	     "=================================================="
	     "\n");
	current_step = WAIT.WR;
	for (; current_step != &WAIT; current_step = current_step->WR) {
		const char * p = get_func_info(current_step->inst, GET_FUNC_NAME);
		if (p[0] == 'E') {
			current_elevator_step = p[1] - '0' + 0xE0;

			assert(current_elevator_step >= 0xE1);
			assert(current_elevator_step <= 0xE9);
		}
		xlog_state("", 1);
		xlog(LOG_FUNC_NAME, " %s - %s\n",
		     get_func_info(current_step->inst, GET_FUNC_NAME),
		     get_func_info(current_step->inst, GET_FUNC_DESC));

		/* execute this node */
		if (p[0] == 'E') {
			funcE fe = (funcE)current_step->inst;
			assert(current_step->arg == 0);
			fe();
		}
		else if (p[0] == 'U') {
			funcU fu = (funcU)current_step->inst;
			fu(current_step->arg);
		}

		assert(current_elevator_step != 0xE9); /* see E9() */
	}
	xlog_state("", 1);

	/* done */
	xlog(LOG_CLOSE, "\nDONE.\n");
	exit(EXIT_SUCCESS);
}
Beispiel #12
0
void ru(i)
{
   if(fu(i++)!=5)abort();
   if(fu(++i)!=7)abort();
}