コード例 #1
0
ファイル: Rf5.c プロジェクト: tsukud-y/estiva
static void estiva_std_Rnew5(void *x,size_t size)
{
  if( estiva_std_f5(x) == NULL )
    R5(x,calloc(1,size));
  if( estiva_std_f5(x) == NULL )
    abort();
}
コード例 #2
0
ファイル: Rf5.c プロジェクト: tsukud-y/estiva
void estiva_std_R5(void *x, void *y)
{ 
  int i;

  if ( y == NULL ) { 
    i = where(x);
    set(i,NULL,NULL); 
    if ( i == top ) top--;
  }
  else{
    R5(x,NULL);
    i = where(NULL);
    set(i,x,y); 
    if ( i == top ) {
      top++;
      if ( top >= limit ) {
        static void **tx, **ty;
        
        ary1(tx,limit); ary1(ty,limit);
        
        forall(0,i,top) tx[i] = x_array[i];
        forall(0,i,top) ty[i] = y_array[i];

        limit++;
        
        ary1(x_array,limit); ary1(y_array,limit);

        forall(0,i,top) x_array[i] = tx[i];
        forall(0,i,top) y_array[i] = ty[i];
      }
    }
  }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: alessandrocar/prog1
int main(int argc, char** argv) {
	Giornale G1(12.50, "Titolo1", false);
	Giornale G2(1.50, "Titolo2", true);
	Giornale G3(2.00, "Titolo3", false);
	Rivista R4(22.70, "Titolo4", false, "Editore4", "Periodo4");
	Rivista R5(11.50, "Titolo5", true, "Editore5", "Periodo5");
	Rivista R6(6.00, "Titolo6", false,  "Editore6", "Periodo6");
	Quotidiano Q7(6.35, "Titolo7", false, "Direttore7", true);
	Quotidiano Q8(9.99, "Titolo8", true, "Direttore8", false);
	Quotidiano Q9(5, "Titolo9", false, "Direttore9", true);
	
	cout<<"Polimorfismo:\n";
	Giornale * vett[9];
	vett[0] = &G1;
	vett[1] = &G2;
	vett[2] = &G3;
	vett[3] = &R4;
	vett[4] = &R5;
	vett[5] = &R6;
	vett[6] = &Q7;
	vett[7] = &Q8;
	vett[8] = &Q9;
	
	for(int i=0; i<9; i++) {
		cout << *vett[i] << "\n\n";
	}
	
	cout<<"\n\nPila:\n";
	Pila P;
	for(int i=0; i<9; i++) {
		P.push(vett[i]);
	}
	cout<<P;
	
	ofstream file;
	file.open("./test.txt", ios::out);
	if(!file) {
		cout<<"Errore apertura file.";
	} else {
		file << P;
	}
	file.close();
	
	Rivista R10(1.00, "Titolo10", false,  "Editore10", "Periodo10");
	Quotidiano Q11(1.35, "Titolo11", false, "Direttore11", true);
	
	P.push(&R10);
	
	cout<<"\n\nEccezione:\n";
	try {
		P.push(&Q11);
	} catch(SpaceOverflow e) {
		cout<<e.errorLog();
	}
	return 0;
}
コード例 #4
0
ファイル: flow-tool.c プロジェクト: nathanmkaya/ksh-arch
static int
ftfread(register Dssfile_t* file, register Dssrecord_t* record, Dssdisc_t* disc)
{
	register State_t*	state = (State_t*)file->data;
	register Netflow_t*	rp = &state->record;
	register char*		fp;
	size_t			n;
	Nftime_t		boot;

	while (!state->count--)
	{
		if (state->data = (char*)sfreserve(file->io, state->chunk * state->size, 0))
		{
			state->count = state->chunk;
			break;
		}
		if (!(n = sfvalue(file->io)))
			return 0;
		if (!(state->chunk = n / state->size))
		{
			if (disc->errorf)
				(*disc->errorf)(NiL, disc, 2, "%slast packet incomplete", cxlocation(file->dss->cx, record));
			return -1;
		}
		state->count = 0;
	}
	memset(rp, 0, sizeof(*rp));
	rp->set = NETFLOW_SET_src_addrv4|NETFLOW_SET_dst_addrv4|NETFLOW_SET_hopv4;
	fp = state->data;
	state->data += state->size;
	switch (state->version)
	{
	case 1:
		if (n = state->swap & 3)
		{
			swapmem(n, &R1(fp)->unix_secs, &R1(fp)->unix_secs, (char*)&R1(fp)->input - (char*)&R1(fp)->unix_secs);
			swapmem(n, &R1(fp)->dPkts, &R1(fp)->dPkts, (char*)&R1(fp)->srcport - (char*)&R1(fp)->dPkts);
			if (n &= 1)
			{
				swapmem(n, &R1(fp)->input, &R1(fp)->input, (char*)&R1(fp)->dPkts - (char*)&R1(fp)->input);
				swapmem(n, &R1(fp)->srcport, &R1(fp)->srcport, (char*)&R1(fp)->prot - (char*)&R1(fp)->srcport);
			}
		}
		rp->src_addrv4 = R1(fp)->srcaddr;
		rp->dst_addrv4 = R1(fp)->dstaddr;
		rp->hopv4 = R1(fp)->nexthop;
		rp->input = R1(fp)->input;
		rp->output = R1(fp)->output;
		rp->packets = R1(fp)->dPkts;
		rp->bytes = R1(fp)->dOctets;
		rp->first = R1(fp)->First;
		rp->last = R1(fp)->Last;
		rp->src_port = R1(fp)->srcport;
		rp->dst_port = R1(fp)->dstport;
		rp->flags = 0;
		rp->tcp_flags = R1(fp)->tcp_flags;
		rp->protocol = R1(fp)->prot;
		rp->src_tos = R1(fp)->tos;
		rp->time = R1(fp)->unix_secs;
		rp->nsec = R1(fp)->unix_nsecs;
		rp->uptime = R1(fp)->sysUpTime;
		break;
	case 5:
		if (n = state->swap & 3)
		{
			swapmem(n, &R5(fp)->unix_secs, &R5(fp)->unix_secs, (char*)&R5(fp)->input - (char*)&R5(fp)->unix_secs);
			swapmem(n, &R5(fp)->dPkts, &R5(fp)->dPkts, (char*)&R5(fp)->srcport - (char*)&R5(fp)->dPkts);
			if (n &= 1)
			{
				swapmem(n, &R5(fp)->input, &R5(fp)->input, (char*)&R5(fp)->dPkts - (char*)&R5(fp)->input);
				swapmem(n, &R5(fp)->srcport, &R5(fp)->srcport, (char*)&R5(fp)->prot - (char*)&R5(fp)->srcport);
				swapmem(n, &R5(fp)->src_as, &R5(fp)->src_as, (char*)(R5(fp)+1) - (char*)&R5(fp)->src_as);
			}
		}
		rp->src_addrv4 = R5(fp)->srcaddr;
		rp->dst_addrv4 = R5(fp)->dstaddr;
		rp->hopv4 = R5(fp)->nexthop;
		rp->input = R5(fp)->input;
		rp->output = R5(fp)->output;
		rp->packets = R5(fp)->dPkts;
		rp->bytes = R5(fp)->dOctets;
		rp->first = R5(fp)->First;
		rp->last = R5(fp)->Last;
		rp->src_port = R5(fp)->srcport;
		rp->dst_port = R5(fp)->dstport;
		rp->flags = 0;
		rp->tcp_flags = R5(fp)->tcp_flags;
		rp->protocol = R5(fp)->prot;
		rp->src_tos = R5(fp)->tos;
		rp->engine_type = R5(fp)->engine_type;
		rp->engine_id = R5(fp)->engine_id;
		rp->src_as16 = R5(fp)->src_as;
		rp->dst_as16 = R5(fp)->dst_as;
		rp->src_maskv4 = R5(fp)->src_mask;
		rp->dst_maskv4 = R5(fp)->dst_mask;
		rp->time = R5(fp)->unix_secs;
		rp->nsec = R5(fp)->unix_nsecs;
		rp->uptime = R5(fp)->sysUpTime;
		break;
	case 6:
		if (n = state->swap & 3)
		{
			swapmem(n, &R6(fp)->unix_secs, &R6(fp)->unix_secs, (char*)&R6(fp)->input - (char*)&R6(fp)->unix_secs);
			swapmem(n, &R6(fp)->dPkts, &R6(fp)->dPkts, (char*)&R6(fp)->srcport - (char*)&R6(fp)->dPkts);
			if (n &= 1)
			{
				swapmem(n, &R6(fp)->input, &R6(fp)->input, (char*)&R6(fp)->dPkts - (char*)&R6(fp)->input);
				swapmem(n, &R6(fp)->srcport, &R6(fp)->srcport, (char*)&R6(fp)->prot - (char*)&R6(fp)->srcport);
				swapmem(n, &R6(fp)->src_as, &R6(fp)->src_as, (char*)(R6(fp)+1) - (char*)&R6(fp)->src_as);
			}
		}
		rp->src_addrv4 = R6(fp)->srcaddr;
		rp->dst_addrv4 = R6(fp)->dstaddr;
		rp->hopv4 = R6(fp)->nexthop;
		rp->input = R6(fp)->input;
		rp->output = R6(fp)->output;
		rp->packets = R6(fp)->dPkts;
		rp->bytes = R6(fp)->dOctets;
		rp->first = R6(fp)->First;
		rp->last = R6(fp)->Last;
		rp->src_port = R6(fp)->srcport;
		rp->dst_port = R6(fp)->dstport;
		rp->flags = 0;
		rp->tcp_flags = R6(fp)->tcp_flags;
		rp->protocol = R6(fp)->prot;
		rp->src_tos = R6(fp)->tos;
		rp->engine_type = R6(fp)->engine_type;
		rp->engine_id = R6(fp)->engine_id;
		rp->src_as16 = R6(fp)->src_as;
		rp->dst_as16 = R6(fp)->dst_as;
		rp->src_maskv4 = R6(fp)->src_mask;
		rp->dst_maskv4 = R6(fp)->dst_mask;
		rp->time = R6(fp)->unix_secs;
		rp->nsec = R6(fp)->unix_nsecs;
		rp->uptime = R6(fp)->sysUpTime;
		break;
	case 7:
		if (n = state->swap & 3)
		{
			swapmem(n, &R7(fp)->unix_secs, &R7(fp)->unix_secs, (char*)&R7(fp)->input - (char*)&R7(fp)->unix_secs);
			swapmem(n, &R7(fp)->dPkts, &R7(fp)->dPkts, (char*)&R7(fp)->srcport - (char*)&R7(fp)->dPkts);
			if (n &= 1)
			{
				swapmem(n, &R7(fp)->input, &R7(fp)->input, (char*)&R7(fp)->dPkts - (char*)&R7(fp)->input);
				swapmem(n, &R7(fp)->srcport, &R7(fp)->srcport, (char*)&R7(fp)->prot - (char*)&R7(fp)->srcport);
				swapmem(n, &R7(fp)->src_as, &R7(fp)->src_as, (char*)(R7(fp)+1) - (char*)&R7(fp)->src_as);
			}
		}
		rp->src_addrv4 = R7(fp)->srcaddr;
		rp->dst_addrv4 = R7(fp)->dstaddr;
		rp->hopv4 = R7(fp)->nexthop;
		rp->input = R7(fp)->input;
		rp->output = R7(fp)->output;
		rp->packets = R7(fp)->dPkts;
		rp->bytes = R7(fp)->dOctets;
		rp->first = R7(fp)->First;
		rp->last = R7(fp)->Last;
		rp->src_port = R7(fp)->srcport;
		rp->dst_port = R7(fp)->dstport;
		rp->flags = 0;
		rp->tcp_flags = R7(fp)->tcp_flags;
		rp->protocol = R7(fp)->prot;
		rp->src_tos = R7(fp)->tos;
		rp->engine_type = R7(fp)->engine_type;
		rp->engine_id = R7(fp)->engine_id;
		rp->src_as16 = R7(fp)->src_as;
		rp->dst_as16 = R7(fp)->dst_as;
		rp->src_maskv4 = R7(fp)->src_mask;
		rp->dst_maskv4 = R7(fp)->dst_mask;
		rp->time = R7(fp)->unix_secs;
		rp->nsec = R7(fp)->unix_nsecs;
		rp->uptime = R7(fp)->sysUpTime;
		break;
	}
	boot = ((Nftime_t)rp->time * MS - (Nftime_t)rp->uptime) * US + (Nftime_t)rp->nsec;
	rp->start = boot + (Nftime_t)rp->first * US;
	rp->end = boot + (Nftime_t)rp->last * US;
	record->size = sizeof(*rp);
	record->data = rp;
	return 1;
}
コード例 #5
0
ファイル: FenPrincipale.cpp プロジェクト: jbfiot/rangers
FenPrincipale::FenPrincipale()
{	
	showMaximized();
	//showNormal();

	QMenu *menuFichier = menuBar()->addMenu("&Fichier");

	QAction *actionLoadImage = menuFichier->addAction("&Load Image");	
	actionLoadImage->setIcon(QIcon("Icons/fileopen.png"));
	menuFichier->addAction(actionLoadImage);

	QAction *actionExit = menuFichier->addAction("&Quitter");
	actionExit->setIcon(QIcon("Icons/fileclose.png"));
	menuFichier->addAction(actionExit);

	//QMenu *menuTools = menuBar()->addMenu("&Tools");

	QMenu *menuComm = menuBar()->addMenu("&Communication");

	QAction *actionSend = menuComm->addAction("&Send to server");	
	actionSend->setIcon(QIcon("Icons/ok.png"));

	// Création de la barre d'outils

    QToolBar *toolBarFichier = addToolBar("Fichier");
    toolBarFichier->addAction(actionLoadImage);
	toolBarFichier->addAction(actionExit);
	toolBarFichier->addSeparator();
	toolBarFichier->addAction(actionSend);
	
	QObject::connect(actionLoadImage, SIGNAL(triggered()), this, SLOT(LoadImageW()));
    QObject::connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
    QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(SendServer()));
	QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(ShowResults()));
    
	//
	// Création des docks
	//

	// dock IMAGE

	dockImage = new QDockWidget("Image", this);
	setCentralWidget(dockImage);

	ImageWidget = new QWidget;
	dockImage->setWidget(ImageWidget);

	// dock SERVEUR

	dockServeur = new QDockWidget("Serveur", this);
	addDockWidget(Qt::LeftDockWidgetArea, dockServeur);


	QWidget *paramDock = new QWidget;
	dockServeur->setWidget(paramDock);

	QSize s(220,20);

	adressServer1 = new QLineEdit(QString("138.195.102.25"));
	adressServer1->setMaximumSize(s);

	QHBoxLayout *adressLayout = new QHBoxLayout;
	adressLayout->addWidget(adressServer1);

	QWidget *adressWidget = new QWidget;
	adressWidget->setLayout(adressLayout);

	portAdressServer = new QLineEdit(QString("6006"));
	portAdressServer->setMaximumSize(s);

	QHBoxLayout *portLayout = new QHBoxLayout;
	portLayout->addWidget(portAdressServer);

	QWidget *portAdressWidget = new QWidget;
	portAdressWidget->setLayout(portLayout);

	QLabel *adressLabel = new QLabel("Adresse IP",paramDock);
	QLabel *portLabel = new QLabel("Port",paramDock);

	QPushButton *okServer = new QPushButton("Send");
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(SendServer()));
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(ShowResults()));

	QVBoxLayout *paramLayout = new QVBoxLayout(paramDock);
	paramLayout->addWidget(adressLabel);
	paramLayout->addWidget(adressWidget);
	paramLayout->addWidget(portLabel);
	paramLayout->addWidget(portAdressWidget);
	paramLayout->addWidget(okServer);
	paramLayout->setAlignment(Qt::AlignLeft);
	paramDock->setLayout(paramLayout);
	//dockServeur->setGeometry(QRect(100,200,200,250));
	dockServeur->setMaximumSize(250,200);

	// dock RESULTATS

	dockResults = new QDockWidget("Resultats",this);
	addDockWidget(Qt::RightDockWidgetArea, dockResults);
	dockResults->setMaximumWidth(250);

	WidgetResults = new QWidget;
	scrollArea = new QScrollArea;

	dockResults->setWidget(scrollArea);


	

	QPixmap *mini = new QPixmap(QString("test.jpg"));
	Result R(mini,98,"t");
	QPixmap *mini2 = new QPixmap(QString("9143.gif.jpg"));
	Result R2(mini2,95,"v");
	QPixmap *mini3 = new QPixmap(QString("test.jpg"));
	Result R3(mini3,92,"t");
	QPixmap *mini4 = new QPixmap(QString("test.jpg"));
	Result R4(mini4,90,"t");
	QPixmap *mini5 = new QPixmap(QString("test.jpg"));
	Result R5(mini5,88,"t");
	QPixmap *mini6 = new QPixmap(QString("test.jpg"));
	Result R6(mini6,86,"t");
	QPixmap *mini7 = new QPixmap(QString("test.jpg"));
	Result R7(mini7,84,"t");
	QPixmap *mini8 = new QPixmap(QString("test.jpg"));
	Result R8(mini8,82,"t");
	QPixmap *mini9 = new QPixmap(QString("test.jpg"));
	Result R9(mini9,81,"t");
	QPixmap *mini10 = new QPixmap(QString("test.jpg"));
	Result R10(mini10,79,"t");
	QPixmap *mini11 = new QPixmap(QString("test.jpg"));
	Result R11(mini11,78,"t");
	QPixmap *mini12 = new QPixmap(QString("test.jpg"));
	Result R12(mini12,77,"t");
	QPixmap *mini13 = new QPixmap(QString("test.jpg"));
	Result R13(mini13,76,"t");
	QPixmap *mini14 = new QPixmap(QString("test.jpg"));
	Result R14(mini14,75,"t");

	T.push_back(R);
	T.push_back(R2);
	T.push_back(R3);
	T.push_back(R4);
	T.push_back(R5);
	T.push_back(R6);
	T.push_back(R7);
	T.push_back(R8);
	T.push_back(R9);
	T.push_back(R10);
	T.push_back(R11);
	T.push_back(R12);
	T.push_back(R13);
	T.push_back(R14);

}