コード例 #1
0
ファイル: table.cpp プロジェクト: Foban/DataBase_Qt
Table::Table(QWidget *parent) :
    QWidget(parent),tableSize(0)
{
    table = new QTableWidget(0,5,this);
    QStringList labels;
    labels << "Mark" << "Color" << "Year" << "Status" << "Date of last repair";
    table->setHorizontalHeaderLabels(labels);

    newcartage = new QPushButton ("New cartage");
    save = new QPushButton ("Save");
    open = new QPushButton ("Open");

    connect(newcartage, SIGNAL(clicked()), this, SLOT(makeNewCartage()));
    connect(save, SIGNAL(clicked()), this, SLOT(saveTable()));
    connect(open, SIGNAL(clicked()), this, SLOT(openTable()));
    connect((QObject*)table->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(sortTable(int)));
    connect((QObject*)table->verticalHeader(), SIGNAL(sectionDoubleClicked(int)), this,SLOT(deleteDialogCartage()));
    connect(table, SIGNAL(cellChanged(int,int)), this, SLOT(changeData(int,int)));

    mainlayout = new QGridLayout;
    mainlayout->addWidget(table,0,0,1,3);
    mainlayout->addWidget(newcartage,1,0);
    mainlayout->addWidget(save,1,1);
    mainlayout->addWidget(open,1,2);
    setLayout(mainlayout);

}
コード例 #2
0
ファイル: TableMainWindow.cpp プロジェクト: assutech/isis3
  /**
   * This method will select a file, set it as the current file and save the
   * table.
   * 
   */
  void TableMainWindow::saveAsTable() {
    QString fn = QFileDialog::getSaveFileName((QWidget*)parent(),
                                            "Choose filename to save under",
                                            ".",
                                            "Text Files (*.txt)");
    QString filename;

    //Make sure the filename is valid
    if (!fn.isEmpty()) {
      if(!fn.endsWith(".txt")) {
        filename = fn + ".txt";
      } else {
        filename = fn;
      }
    }
    //The user cancelled, or the filename is empty
    else {
      return;
    }

    p_currentFile.setFileName( filename );

    p_save->setEnabled(true);
    saveTable();
  }
コード例 #3
0
ファイル: CQExperimentData.cpp プロジェクト: sachiinb/COPASI
void CQExperimentData::slotWeightMethod(int weightMethod)
{
  if (mpExperiment == NULL) return;

  if ((CExperiment::WeightMethod) weightMethod ==
      mpExperiment->getWeightMethod()) return;

  switch ((CExperiment::WeightMethod) weightMethod)
    {
      case CExperiment::VALUE_SCALING:
        mpTable->horizontalHeaderItem(COL_SCALE)->setText("Epsilon");
        break;

      default:
        mpTable->horizontalHeaderItem(COL_SCALE)->setText("Weight");
        break;
    }

  size_t Current =
    mpExperimentSetCopy->keyToIndex(mpExperiment->CCopasiParameter::getKey());
  size_t Next = Current + 1;

  // Find all experiments which are like this.
  while (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
    {
      CExperiment * pNext = mpExperimentSetCopy->getExperiment(Next);

      if (!isLikePreviousExperiment(pNext)) break;

      Next++;
    }

  // Update each of them.
  while (true)
    {
      Next--;

      CExperiment * pNext = mpExperimentSetCopy->getExperiment(Next);

      bool Changed = saveTable(pNext);

      if (Changed)
        {
          std::ifstream File;
          File.open(CLocaleString::fromUtf8(pNext->getFileName()).c_str());

          size_t CurrentLine = 1;
          pNext->read(File, CurrentLine);
          pNext->compile();
        }

      pNext->setWeightMethod((CExperiment::WeightMethod) weightMethod);
      pNext->calculateWeights();

      if (Next == Current) break;
    }

  loadTable(mpExperiment, false);
}
コード例 #4
0
// Loads the target file data, execs the dialog
//     and saves it again if Accept is clicked
int TargetSettingsDialog::exec()
{
	loadTable();
	if(QDialog::exec() == QDialog::Rejected)
		return QDialog::Rejected;
	saveTable();
	return QDialog::Accepted;
}
コード例 #5
0
// createTrans0
//---------------------------------------------------------------------------
void ColorTable::createTrans0(
    const int  &color1Percent,
    const int  &color2Percent,
    const char *filename)
{
    init(256 * 256);

    if(FileSystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(Exception e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );
    float color1        = float(color1Percent) / 100.0f;
    float color2        = float(color2Percent) / 100.0f;
    //int	  totalColors   = colorCount;
    //int   curColorIndex = 0;
    //int   num           = 0;
    //int   numInterval   = (totalColors) / 100;

    // Since the file was not found, create the color tables and dump
    // it to a file.
    unsigned curOffset = 0;

    for (unsigned index = 0; index < 256; index++) {
        const RGBColor col = Palette::color[index];

        for (unsigned indexPic = 0; indexPic < 256; indexPic++) {
            const RGBColor colPic = Palette::color[indexPic];

            curOffset = (int(index) << 8) + indexPic;

            RGBColor curColor((int) (color1 * col.red   + color2 * colPic.red),
                              (int) (color1 * col.green + color2 * colPic.green),
                              (int) (color1 * col.blue  + color2 * colPic.blue));

            // Makes the color table use color 0 as transparent.

            if (indexPic == 0) {
                setColor(curOffset, index);
            } else {

                setColor(curOffset, Palette::findNearestColor(curColor));
            }
        }
    }

    try {
        saveTable(filename);
    } catch(Exception e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s",
               filename, e.what()) );
    }
} // end ColorTable::createTrans0
コード例 #6
0
// createBrightenFilter
//---------------------------------------------------------------------------
void ColorTable::createBrightenFilter(
    const char *filename,
    const int  &brightness)
{
    assert(brightness > 0 && brightness <= 256);
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette '%s': %s", filename,
                  e.what()) );
        }
    }

    LOG ( ("Creating ColorTable '%s'.", filename) );
    // Since the file was not found, create the color tables and dump
    // it to a file.
    int   curOffset;
    int   curRed;
    int   curGreen;
    int   curBlue;
    float nb;        // The new brightness color.

    float fBrightness = float(brightness) / 256.0f;

    for (int y = 0; y < 256; y++) {
        for (int x = 0; x < 256; x++) {
            nb = float(x) * fBrightness;
            curOffset = (y * 256) + x;

            // !SOMDEDAY! Try holding a threshold when any value gets to 255.
            curRed   = (int) (nb + Palette::color[y].r);
            curGreen = (int) (nb + Palette::color[y].g);
            curBlue  = (int) (nb + Palette::color[y].b);

            if (curRed   > 255) curRed   = 255;
            if (curGreen > 255) curGreen = 255;
            if (curBlue  > 255) curBlue  = 255;
            //curColor = Palette::color[y];

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename,
               e.what()) );
    }
} // end createBrightenFilter
コード例 #7
0
// lightDark table builder logic.
// 0-----------Color (x)----------255
// |
// |
// brightness (y)
// |
// |
// 255
//---------------------------------------------------------------------------
void ColorTable::createLightDarkFilter(const char *filename)
{
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );

    int curOffset;
    int curRed;
    int curGreen;
    int curBlue;

    for (int y = 0; y < 256; y++) {
        int x;
        for (x = 0; x <= 128; x++) {
            curOffset = x + (y << 8);
            curRed   = Palette::color[y].r   * x / 128;
            curGreen = Palette::color[y].g * x / 128;
            curBlue  = Palette::color[y].b  * x / 128;

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
        for (x = 129; x < 256; x++) {
            curOffset = x + (y << 8);
            curRed   = Palette::color[y].r + ((255 - Palette::color[y].r) * (x-128) / 127);
            curGreen = Palette::color[y].g + ((255 - Palette::color[y].g) * (x-128) / 127);
            curBlue  = Palette::color[y].b + ((255 - Palette::color[y].b) * (x-128) / 127);

            setColor(curOffset, Palette::findNearestColor(curRed, curGreen, curBlue));
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename, e.what()) );
    }
} // end ColorTable::createLightDarkFilter
コード例 #8
0
ファイル: CQExperimentData.cpp プロジェクト: sachiinb/COPASI
void CQExperimentData::slotExprimentType(bool isSteadyState)
{
  if (!mpExperiment) return;

  if (isSteadyState)
    {
      mpBtnSteadystate->setFocus();
      mpExperiment->setExperimentType(CCopasiTask::steadyState);
    }
  else
    {
      mpBtnTimeCourse->setFocus();
      mpExperiment->setExperimentType(CCopasiTask::timeCourse);
    }

  saveTable(mpExperiment);

  // Undo the changes so that copy from and to work.
  if (isSteadyState)
    {
      mpExperiment->setExperimentType(CCopasiTask::timeCourse);
    }
  else
    {
      mpExperiment->setExperimentType(CCopasiTask::steadyState);
    }

  size_t i, imax = mpTable->rowCount();

  if (isSteadyState)
    for (i = 0; i < imax; i++)
      {
        CExperiment::Type Type = static_cast< CExperiment::Type >(mpTable->item((int) i, COL_TYPE_HIDDEN)->data(Qt::DisplayRole).toInt());

        if (Type == CExperiment::time)
          mpExperiment->getObjectMap().setRole(i, CExperiment::ignore);
      };

  loadTable(mpExperiment, true);
  return;
}
コード例 #9
0
// createDarkenFilter
//---------------------------------------------------------------------------
void ColorTable::createDarkenFilter(const char *filename, float fudgeValue)
{
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );
    // Since the file was not found, create the color tables and dump
    // it to a file.
    float    curPercent;
    int      curOffset;
    SDL_Color curColor;
    const float percent = fudgeValue;

    for (int y = 0; y < 256; y++) {
        for (int x = 0; x < 256; x++) {
            curPercent = (float(255 - x) / 255.0f) * percent + 1.0f - percent;
            curOffset  = (y * 256) + x;

            curColor.r   = (Uint8) (curPercent * float(Palette::color[y].r));
            curColor.g = (Uint8) (curPercent * float(Palette::color[y].g));
            curColor.b  = (Uint8) (curPercent * float(Palette::color[y].b));

            setColor(curOffset, Palette::findNearestColor(curColor.r, curColor.g, curColor.b));
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename,
               e.what()) );
    }
} // end createDarkenFilter
コード例 #10
0
int ReportTableBase::update(const ReportTableData &reportTableData)
{
  // load table
  if(loadTable() == ERROR)
    return ERROR;

  // check boundaries
//  if(reportTableData.updateRow < 0 || reportTableData.updateRow >= m_cells.size())
//    return ERROR;
//  if(reportTableData.updateCol < 0 || reportTableData.updateCol >= m_cells[reportTableData.updateRow].size())
//    return ERROR;

  // change data
//  m_cells[reportTableData.updateRow][reportTableData.updateCol] = reportTableData.updateText;

  // filter table, for a subset of rows
  applyFilter(reportTableData.filterCol, reportTableData.filterText);

  // iterate data
  TableIterator ti = begin();
  // cycle thru all rows
  for(; ti != end() ; ti++) {
    // get the row
    vector<string> &row = **ti;

    //cout << "Old value: " <<  row[reportTableData.updateCol] << endl;

    // process the row
    if(row.size() > reportTableData.updateCol)
      row[reportTableData.updateCol] = reportTableData.updateText;

    //cout << "New value: " <<  row[reportTableData.updateCol] << endl;
  }

  // save the table for future use
  return saveTable();
}
コード例 #11
0
ファイル: CQExperimentData.cpp プロジェクト: sachiinb/COPASI
bool CQExperimentData::saveExperiment(CExperiment * pExperiment, const bool & full)
{
  if (!pExperiment) return false;

  bool success = true;

  size_t Next =
    mpExperimentSetCopy->keyToIndex(pExperiment->CCopasiParameter::getKey()) + 1;

  if (Next < mpExperimentSetCopy->getExperimentCount() && mpCheckTo->isChecked())
    {
      CExperiment * pNext = mpExperimentSetCopy->getExperiment(Next);

      if (isLikePreviousExperiment(pNext))
        success &= saveExperiment(pNext, false);
    }

  QString value = mpEditName->text();
  int pos = value.length();

  if (full &&
      pExperiment->getObjectName() != TO_UTF8(value) &&
      mpValidatorName->validate(value, pos) == QValidator::Acceptable)
    {
      int current = mpBoxExperiment->currentRow();
      mpBoxExperiment->blockSignals(true);
      mpBoxExperiment->item(mShown)->setText(value);
      mpBoxExperiment->setCurrentRow(current);
      mpBoxExperiment->blockSignals(false);
      pExperiment->setObjectName(TO_UTF8(value));
    }

  if (mpCheckTab->isChecked())
    pExperiment->setSeparator("\t");
  else
    pExperiment->setSeparator(TO_UTF8(mpEditSeparator->text()));

  value = mpEditFirst->text();
  pos = value.length();

  if (full &&
      mpValidatorFirst->validate(value, pos) == QValidator::Acceptable)
    pExperiment->setFirstRow(value.toULong());

  value = mpEditLast->text();
  pos = value.length();

  if (full &&
      mpValidatorLast->validate(value, pos) == QValidator::Acceptable)
    pExperiment->setLastRow(value.toULong());

  value = mpEditHeader->text();
  pos = value.length();

  if (mpCheckHeader->isChecked() &&
      mpValidatorHeader->validate(value, pos) == QValidator::Acceptable)
    pExperiment->setHeaderRow(value.toULong());
  else
    {
      pExperiment->setHeaderRow(InvalidIndex);
      mpCheckHeader->setChecked(false);
    }

  if (mpBtnTimeCourse->isChecked())
    pExperiment->setExperimentType(CCopasiTask::timeCourse);
  else
    pExperiment->setExperimentType(CCopasiTask::steadyState);

  pExperiment->setWeightMethod((CExperiment::WeightMethod) mpBoxWeightMethod->currentIndex());

  mpFileInfo->sync();

  size_t First, Last;
  mpBtnExperimentAdd->setEnabled(mpFileInfo->getFirstUnusedSection(First, Last));

  mpValidatorName->saved();
  mpValidatorFirst->saved();
  mpValidatorLast->saved();
  mpValidatorHeader->saved();

  saveTable(pExperiment);

  return success;
}
コード例 #12
0
ファイル: TableMainWindow.cpp プロジェクト: assutech/isis3
  /** 
   * This creates the table main window.  The table and docking 
   * area are created here. It also adds the two default menus to 
   * the menu bar. Programmers can add more menus to the menu bar 
   * once an instance of this class is established. 
   */  
  void TableMainWindow::createTable() {
    #if defined(__APPLE__)
      setWindowFlags(Qt::Tool);
    #endif

    #if !defined(__APPLE__)
      setWindowFlags(Qt::Dialog);
    #endif

    statusBar()->setSizeGripEnabled(true);
    // Create the table widget 
    p_table = new QTableWidget(this);
    p_table->setAlternatingRowColors(true);
    setCentralWidget(p_table);   

   // Create the dock area 
    p_dock = new QDockWidget("Columns",this);
    p_dock->setObjectName("dock");
    p_dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    p_dock->setMinimumWidth(190);
    p_listWidget = new QListWidget(p_dock);
    p_dock->setWidget(p_listWidget);
    addDockWidget(Qt::LeftDockWidgetArea,p_dock,Qt::Vertical);
    connect(p_listWidget,SIGNAL(itemChanged(QListWidgetItem *)),
            this,SLOT(syncColumns()));
			
    // Create the file menu 
    QMenuBar *menuBar = this->menuBar();
    QMenu *fileMenu = menuBar->addMenu("&File");
    
    p_save = new QAction(this);
    p_save->setText("Save...");
    p_save->setShortcut(Qt::CTRL + Qt::Key_S);
    connect(p_save,SIGNAL(activated()),this,SLOT(saveTable()));
    p_save->setDisabled(true);
    
    QAction *saveas = new QAction(this);
    saveas->setText("Save As...");
    connect(saveas,SIGNAL(activated()),this,SLOT(saveAsTable()));
    
    QAction *load = new QAction(this);
    load->setText("Load...");
    connect(load,SIGNAL(activated()),this,SLOT(loadTable()));
    
    QAction *del = new QAction(this);
    del->setText("Delete Selected Row(s)");
    del->setShortcut(Qt::Key_Delete);
    connect(del,SIGNAL(activated()),this,SLOT(deleteRows()));
    
    QAction *clear = new QAction(this);
    clear->setText("Clear table");
    connect(clear,SIGNAL(activated()),this,SLOT(clearTable()));
    
    QAction *close = new QAction(this);
    close->setText("Close");
    connect(close,SIGNAL(activated()),this,SLOT(hide()));
    
    fileMenu->addAction(p_save);
    fileMenu->addAction(saveas);
    fileMenu->addAction(load);
    fileMenu->addAction(del);
    fileMenu->addAction(clear);
    fileMenu->addAction(close);

    //2009-01-12
    //If we have the Mainwindow flag set to Qt::Tool so that on Macs the 
    //table window always stays on top, then we can not access the
    //menu bar to the table window, so we need to add the file options
    //for the table to the tool bar.
    #if defined(__APPLE__)
     QToolBar *toolBar = new QToolBar();
     toolBar->addAction(p_save);
     toolBar->addAction(saveas);
     toolBar->addAction(load);
     toolBar->addAction(del);
     toolBar->addAction(clear);
     toolBar->addAction(close);
     this->addToolBar(toolBar);
   #endif 

    // Create the view menu
    QMenu *viewMenu = menuBar->addMenu("&View");
    QAction *cols = new QAction(this);
    cols->setText("Columns");
    connect(cols,SIGNAL(activated()),p_dock,SLOT(show()));
    viewMenu->addAction(cols);

    this->setMenuBar(menuBar);
    installEventFilter(this);
  }
コード例 #13
0
// create
//---------------------------------------------------------------------------
void ColorTable::create(
    const int  color1Percent,
    const int  color2Percent,
    const char *filename)
{
    init(256 * 256);

    if(filesystem::exists(filename)) {
        try {
            loadTable(filename);
            return;
        } catch(std::exception& e) {
            LOG( ("Error while loading palette'%s': %s", filename, e.what()) );
        }
    }

    LOG ( ("Creating colortable '%s'.", filename) );
    //float curPercent;
    //int	  totalColors   = colorCount;
    //int   curColorIndex = 0;
    //int   num           = 0;
    //int   numInterval   = (totalColors) / 100;

    // Since the file was not found, create the color tables and dump
    // it to a file.
    unsigned curOffset = 0;

    float color1 = float(color1Percent) / 100.0f;
    float color2 = float(color2Percent) / 100.0f;

    for (unsigned index = 0; index < 256; index++) {
        const SDL_Color col = Palette::color[index];

        for (unsigned indexPic = 0; indexPic < 256; indexPic++) {
            const SDL_Color colPic = Palette::color[indexPic];

            curOffset = (int(index) << 8) + indexPic;

//            SDL_Color curColor((Uint8) (color1 * col.r   + color2 * colPic.r),
//                              (Uint8) (color1 * col.g + color2 * colPic.g),
//                              (Uint8) (color1 * col.b  + color2 * colPic.b));
            SDL_Color curColor;
            curColor.r = (Uint8) (color1 * col.r + color2 * colPic.r);
            curColor.g = (Uint8) (color1 * col.g + color2 * colPic.g);
            curColor.b = (Uint8) (color1 * col.b + color2 * colPic.b);

            // Makes the color table use color 0 as transparent.
            if (indexPic == 0) {
                setColor(curOffset, index);

            } else {
                setColor(curOffset, Palette::findNearestColor(curColor.r, curColor.g, curColor.b));
            }

            // Display a progress update every 1%.
            /*if (num > numInterval)
            {
            	curColorIndex += numInterval;
            	curPercent = float(curColorIndex) / float(totalColors);
            	num = 0;
            } else num++;
            */
        }
    }

    try {
        saveTable(filename);
    } catch(std::exception& e) {
        LOG ( ("Caching of ColorTable '%s' failed: %s", filename,
               e.what()) );
    }
} // end ColorTable::create
コード例 #14
0
ファイル: libpcap.c プロジェクト: hc9725/my_etherdump
int main(){
    pcap_t *pt;
    char *dev;
    char errbuf[128];
    struct bpf_program fp;
    bpf_u_int32 maskp,netp;
    int ret,i=0,inum;
    int pcap_time_out=5;
    char filter[128];
    unsigned char *packet;
    struct pcap_pkthdr hdr;
    pcap_if_t *alldevs = NULL,*d;
    pid_t pid;
    char ch[10],str = 'n';
    attHead att_head;

    head = init_ip_list(head);
    att_head = init_attHead();
    if(pcap_findalldevs(&alldevs,errbuf)==-1) {
	fprintf(stderr,"find interface failed!\n");
	return;
    }
    for(d=alldevs;d;d=d->next){
	printf("%d. %s\n",++i,d->name);
      	if(d->description)
	    printf("(%s)\n",d->description);
      	else
	    printf("(no description available)\n");
    }
 
    if(i==1)
       	dev=alldevs->name;
    else {
      	printf("input a interface:(1-%d)",i);
      	scanf("%d",&inum);
      	if(inum<1||inum>i) {
	    printf("interface number out of range\n");
	    return;
      	}
       	for(d=alldevs,i=1;i<inum;d=d->next,i++);
	dev=d->name;
    }

    printf("dev:%s\n",dev);
    ret=pcap_lookupnet(dev,&netp,&maskp,errbuf);
    printf("");

    if(ret==-1){
      	fprintf(stderr,"%s\n",errbuf);
      	return;
    }
    pt=pcap_open_live(dev,BUFSIZ,1,pcap_time_out,errbuf);

    if(pt==NULL){
      	fprintf(stderr,"open error :%s\n",errbuf);
      	return;
    }

while(1) {
    printf("if you want to quit press y,else press any other key!\n");
    scanf("%c",&str);
    if(str == 'y')break;
  pid = vfork();
  if(pid < 0){
      printf("fail to fork\n");
  }else if(pid == 0){
      if(signal(SIGALRM,timer_handler) == SIG_ERR){
	  perror("can't set handler for SIGALRM\n");
	  exit(0);
      }
      alarm(1800);
      while(1){
      packet=(char *)pcap_next(pt,&hdr);
      if(packet==NULL) continue;
      else{
         printf("\n\n\n");
   	 printf("get a packet\n");
   	 ethernet_packet_callback(NULL,&hdr,packet); 
	 num++;
   	 printf("\n");
	 if(flag == arp){
	     insert_data(att_head,num,"arp","xxxxxxxx","broadcast");
//	     printMemory(att_head);
	     flag = 0;
	 }
	 else{
	     switch(flag){
		 case ip:
		     strcpy(ch,"ip");break;
		 case tcp:
		     strcpy(ch,"tcp");break;
		 case udp:
		     strcpy(ch,"udp");break;
		 case http:
		     strcpy(ch,"http");break;
		 case oicq:
		     strcpy(ch,"oicq");break;
		 case webqq:
		     strcpy(ch,"webqq");break;
		 case msnms:
		     strcpy(ch,"msnms");break;
		 default:
		     strcpy(ch,"xxx");
		     strcpy(srcip,"xxxxxxxx");
		     strcpy(desip,"xxxxxxxx");
		     other_num++;
		     other_bytes = other_bytes+hdr.len;
		     break;
	     }
		 insert_data(att_head,num,ch,srcip,desip);
//		 printMemory(att_head);
	         flag = 0;
	 }
     }
  	printf("\n");
	printf("其他包的总数:%d   其他包的总字节数:%ld\n",other_num,other_bytes);
  	printf("ip包的总数:%d   ip包的总字节数:%ld\n",ip_num,ip_bytes);
  	printf("arp包的总数:%d   arp包的总字节数:%ld\n",arp_num,arp_bytes);
  	printf("tcp包的总数:%d   tcp包的总字节数:%ld\n",tcp_num,tcp_bytes);
  	printf("udp包的总数:%d   udp包的总字节数:%ld\n",udp_num,udp_bytes);
  	printf("oicq包的总数:%d   oicq包的总字节数:%ld\n",oicq_num,oicq_bytes);
	printf("http包的总数:%d   http包的总字节数: %ld\n",http_num,http_bytes);
	printf("web qq包的总数:%d   web qq包的总字节数: %ld\n",webqq_num,webqq_bytes);
	printf("msnms包的总数:%d   msnms包的总字节数: %ld\n",msnms_num,msnms_bytes);
	display_ip_list(head);
      }
  } else{
      delete_ip_list(head,1);
      if(wait(NULL) == -1){
      	printf("fail to wait\n");
      	exit(1);
      }
   }
 }
 pcap_close(pt);
 saveTable(att_head);
 free_ip_list(head);
 free_data(att_head);
 return 0;
/*
 pt = pcap_open_offline("msn.pcap",errbuf);
 if(pt == NULL){
     printf("ERROR:could not open pcap file: %s\n",errbuf);
     exit(-1);
 }
 pcap_loop(pt,-1,&ethernet_packet_callback,NULL);
 pcap_close(pt);
 return 0;*/
}