Esempio n. 1
0
File: xlog.c Progetto: zeus911/xlog
void signal_process (int sig) {
        if(sig != SIGALRM){
             exit(10);
        }
        long  offset = ftell(xlogFp);
        char offsetStr[50];
	ltoa(offset, offsetStr, 10);
        if ( offset != -1 ) {
                xFile(offset_log, offsetStr, 1);
        }

        if (xlogFp) {
                signal(SIGALRM, signal_process);
                alarm(1);
        }
}
void InstalledProgramsForm::on_pushButton_clicked()
{
    QString xFilePath = QFileDialog::getSaveFileName(this, tr("Сохранить файл"),
                                                     mUI->CompName->text() + ".html",
                                                     tr("Файлы (*.html)"));

    QFile xFile(xFilePath);
    if(xFile.exists() == true) xFile.remove();
    xFile.open(QFile::WriteOnly);

    QTextStream xOut(&xFile);
    xOut<<"<html><body><h4>"<<tr("Oтчет о программном обеспечении")<<"</h4>"
            <<tr("Имя компьютера: ")
            <<mUI->CompName->text()
            <<"<br>"<<tr("IP-адресс: ")
            <<mUI->CompIPAddress->text()<<endl;
    xOut<<"<table border=1 cellpadding=5px style='border:solid; border-collapse:collapse;' >"<<endl;

    xOut<<"<tr>";
    xOut<<"<td>"<<tr("Имя программы");
    xOut<<"<td>"<<tr("Отображаемая версия");
    xOut<<"<td>"<<tr("Разработчик");
    xOut<<"<td>"<<tr("Дата установки");
    xOut<<"<td>"<<tr("Путь установки");
    xOut<<"<td>"<<tr("Ключ в реестре");
    xOut<<endl;

    for(int i = 0; i < mUI->ProgramsList->rowCount(); i++)
    {
        xOut<<"<tr>";
        xOut<<"<td>"<<mUI->ProgramsList->item(i,0)->text();
        xOut<<"<td>"<<mUI->ProgramsList->item(i,1)->text();
        xOut<<"<td>"<<mUI->ProgramsList->item(i,2)->text();
        xOut<<"<td>"<<mUI->ProgramsList->item(i,3)->text();
        xOut<<"<td>"<<mUI->ProgramsList->item(i,4)->text();
        xOut<<"<td>"<<mUI->ProgramsList->item(i,5)->text();
        xOut<<endl;
    }

    xOut<<"</table>"<<endl;
    xOut<<"</body></html>";
    xFile.flush();
    xFile.close();
}
void InstalledProgramsForm::setProgramList(QString xFilePath)
{
    QDomDocument xDomDocument("xml");

    QFile xFile(xFilePath);
    xFile.open(QIODevice::ReadOnly);
    xDomDocument.setContent(&xFile);
    xFile.close();

    QDomElement xRootElement = xDomDocument.documentElement();

    for(QDomElement xProgramElement = xRootElement.firstChildElement("InstalledProgram"); xProgramElement.isNull() == false; xProgramElement = xProgramElement.nextSiblingElement("InstalledProgram"))
    {
        if(xProgramElement.attribute("DisplayName", "") != "")
        {
            QString mRegisterPath = xProgramElement.attribute("RegisterPath", tr("данные отсутствуют"));
            QString mDisplayName = xProgramElement.attribute("DisplayName", tr("данные отсутствуют"));
            QString mDisplayVersion = xProgramElement.attribute("DisplayVersion", tr("данные отсутствуют"));
            QString mInstallLocation = xProgramElement.attribute("InstallLocation", tr("данные отсутствуют"));
            QString mInstallDate = xProgramElement.attribute("InstallDate", tr("данные отсутствуют"));
            QString mPublisher = xProgramElement.attribute("Publisher", tr("данные отсутствуют"));

            mUI->ProgramsList->insertRow(0);
            QTableWidgetItem *xDisplayName = new QTableWidgetItem(mDisplayName);
            QTableWidgetItem *xDisplayVersion = new QTableWidgetItem(mDisplayVersion);
            QTableWidgetItem *xPublisher = new QTableWidgetItem(mPublisher);
            QTableWidgetItem *xInstallDate = new QTableWidgetItem(mInstallDate);
            QTableWidgetItem *xInstallLocation = new QTableWidgetItem(mInstallLocation);
            QTableWidgetItem *xRegisterPath = new QTableWidgetItem(mRegisterPath);
            mUI->ProgramsList->setItem(0, 0, xDisplayName);
            mUI->ProgramsList->setItem(0, 1, xDisplayVersion);
            mUI->ProgramsList->setItem(0, 2, xPublisher);
            mUI->ProgramsList->setItem(0, 3, xInstallDate);
            mUI->ProgramsList->setItem(0, 4, xInstallLocation);
            mUI->ProgramsList->setItem(0, 5, xRegisterPath);
        }
    }
}
Esempio n. 4
0
BOOL CImageImpl::Load(IStream* pStream)
{
    USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST);

    Clear();

    CxIStreamFile xFile(pStream);
    m_pImage = new CxImage;
    m_pImage->SetRetreiveAllFrames(true);
    ENUM_CXIMAGE_FORMATS enFormat = CheckFormat(&xFile);
    if (! m_pImage->Decode(&xFile, enFormat)) 
    {
        Clear();
        return FALSE;
    }

    LONG lNumFrames = m_pImage->GetNumFrames();
    if (lNumFrames <= 1)
        return TRUE;

    m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
    return TRUE;
}
Esempio n. 5
0
File: xlog.c Progetto: zeus911/xlog
void addLog (char *msg) {
	xFile(file_log, msg, 2);
}
Esempio n. 6
0
  /**
   * Make a root plot of the experimental ratio and the 
   * calculated values
   */
void ratio::PlotFit()
{
#ifdef root
  TCanvas *canvas = new TCanvas("fit");
  canvas->SetLogx();
  TH2S * frame = new TH2S("frame","",10,5,300,10,-.02,.15);
  frame->GetXaxis()->SetTitle("E_{lab}");
  frame->GetYaxis()->
         SetTitle("(#sigma_{2}-#sigma_{1})/(#sigma_{2}+#sigma_{1})");
  frame->SetStats(kFALSE);
  frame->Draw();

  ofstream xFile("ratiox.dat");
  xFile << Ndata << endl;
  if (Ndata > 0)
    {
     double xExp[Ndata];
     double yExp[Ndata];
     double xErrorExp[Ndata];
     double yErrorExp[Ndata];

     for (int i=0;i<Ndata;i++)
       {
         xExp[i] = Rdata[i].energyLab;
         yExp[i] = Rdata[i].x;
         xErrorExp[i] = 0.;
         yErrorExp[i] = Rdata[i].sigma;
         xFile << xExp[i] << " " << yExp[i] << " " << yErrorExp[i] << endl;
       }

     TGraphErrors * graphExp = new TGraphErrors(Ndata,xExp,yExp,xErrorExp,
                                  yErrorExp);
     graphExp->SetMarkerStyle(21);
     graphExp->Draw("P");
    }
  xFile.close();
  ofstream ofFile("ratio.dat");
  int const Npoints = 100;
  double xFit[Npoints];
  double yFit[Npoints];
  double xStart = log(5.);
  double xStop = log(300);
  for (int i=0;i<Npoints;i++)
    {
      double xx = (xStop-xStart)/((double)Npoints)*(double)i + xStart;
      double Elab = exp(xx);
      xFit[i] = Elab;
      yFit[i] = getRatio(Elab);
      ofFile << xFit[i] << " " << yFit[i] << endl;
    }
  TGraph * graph = new TGraph(Npoints,xFit,yFit);
  graph->Draw("L");

  canvas->Write();

  ofFile.close();
  ofFile.clear();


  

#endif
}
Esempio n. 7
0
bool CDirList::CreateFileName(bool bForce)
{
  bool bDone = false;
  if((!bForce) && m_sFileName.Len())
  {
    bDone = true;
  }
//  else if(!wxFileName::Mkdir(m_sDirSave,0755,wxPATH_MKDIR_FULL))
//  {
//    bDone = false;
//  }
  else
  {
    wxString sPathBase = GetSavePath(true);
    if(!sPathBase.IsEmpty())
    {
      wxString sName(sPathBase);
      wxString sPath;
      nwxFileUtil::NoEndWithSeparator(&sName);
      wxFileName fn(sName);
      sName = fn.GetFullName();
      sName.Replace(" ","_",true);
      if(sName.IsEmpty())
      {
        wxASSERT_MSG(
          false,"Problem with CDirList::CreateFileName()");
        sName = "run_";
      }
      else
      {
        sName.Append("_");
      }
      wxString sFullName;
      wxString sExt(EXT_BATCH);
      int nAdd = 0;
      sPathBase.Append(sName);
      bool bDoneLoop = false;
      while(!bDoneLoop)
      {
        sPath = sPathBase;
        sPath.Append(GetTimeStamp(nAdd));
        sPath.Append(sExt);
        sFullName = nwxFileUtil::SetupFileName(sPath,sExt);
        if(sFullName.IsEmpty())
        {
          bDoneLoop = true; // end loop
          wxASSERT_MSG(false,
            "sFullName is Empty in CDirList::CreateFileName()");
        }
        else if(wxFileName::FileExists(sFullName))
        {
          nAdd++;
        }
        else
        {
          wxFile xFile(sFullName.wc_str(),wxFile::write_excl);
          if(!xFile.IsOpened())
          {
            wxString s("Cannot create file: ");
            s.Append(sFullName);
            wxASSERT_MSG(false,s);
          }
          else
          {
            m_sFileName = sFullName;
            bDone = true;
          }
          bDoneLoop = true;
        }
      }
    }
    else
    {
      wxASSERT_MSG(
          false,"empty path in CDirList::CreateFileName()");
    }
  }
  return bDone;
}
bool NFCCommonConfigModule::LoadConfig(const std::string& strFile)
{
	try
	{
		rapidxml::file<> xFile(strFile.c_str());
		rapidxml::xml_document<> xDoc;
		xDoc.parse<0>(xFile.data());

		rapidxml::xml_node<>* pRoot = xDoc.first_node();
		if (NULL == pRoot)
		{
			return false;
		}

		for (rapidxml::xml_node<>* pRootNode = pRoot->first_node(); pRootNode; pRootNode = pRootNode->next_sibling())
		{
			if (pRootNode)
			{
				rapidxml::xml_attribute<>* pNameAttribute = pRootNode->first_attribute("Name");
				if (NULL == pNameAttribute)
				{
					//foreach

					continue;
				}

				std::string strName = pNameAttribute->value();
				NF_SHARE_PTR<CStructInfo> pAppSDKConfigInfo = mmData.GetElement(strName);
				if (!pAppSDKConfigInfo)
				{
					pAppSDKConfigInfo = NF_SHARE_PTR<CStructInfo>(NF_NEW CStructInfo());
					mmData.AddElement(strName, pAppSDKConfigInfo);
				}

				
				for (rapidxml::xml_attribute<>* pAttribute = pRootNode->first_attribute(); pAttribute; pAttribute = pAttribute->next_attribute())
				{
					if (pAttribute)
					{
						const char* pstrConfigName = pAttribute->name();
						const char* pstrConfigValue = pAttribute->value();

						pAppSDKConfigInfo->mmStructAttribute.AddElement(pstrConfigName, NF_SHARE_PTR<std::string>(NF_NEW std::string(pstrConfigValue)));
					}
				}

				
				for (rapidxml::xml_node<>* pSDKInterfaceNode = pRootNode->first_node(); pSDKInterfaceNode; pSDKInterfaceNode = pSDKInterfaceNode->next_sibling())
				{
					if (pSDKInterfaceNode)
					{
						if (pSDKInterfaceNode->first_attribute("Name") != NULL)
						{
							std::string strStructItemName = pSDKInterfaceNode->first_attribute("Name")->value();   
							NF_SHARE_PTR<CAttributeList> pConfigData = pAppSDKConfigInfo->GetElement(strStructItemName);
							if (!pConfigData)
							{
								pConfigData = NF_SHARE_PTR<CAttributeList>(NF_NEW CAttributeList());
								pAppSDKConfigInfo->AddElement(strStructItemName, pConfigData);
							}

							for (rapidxml::xml_attribute<>* pAttribute = pSDKInterfaceNode->first_attribute(); pAttribute; pAttribute = pAttribute->next_attribute())
							{
								if (pAttribute)
								{
									const char* pstrConfigName = pAttribute->name();
									const char* pstrConfigValue = pAttribute->value();

									pConfigData->AddElement(pstrConfigName, NF_SHARE_PTR<std::string>(NF_NEW std::string(pstrConfigValue)));
								}
							}
						}
					}
				}
			}
		}
	}
	catch(...)
	{
		return false;
	}

	return true;
}