Exemple #1
0
//--------------------------------------------------------------------
  AEvent::AEvent() : AEventHeader()
//--------------------------------------------------------------------
  { 
  	fDebugLevel = "DEBUG"; 
    InitLogger("AEvent");
    SetDebugLevel(fDebugLevel,"AEvent");
  }
Exemple #2
0
void MyDialog2::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if (pScrollBar == (CScrollBar *)&m_DebugLevel)
		SetDebugLevel(m_DebugLevel.GetPos());
	
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
Exemple #3
0
//--------------------------------------------------------------------
  void AEvent::SetLevelDebug(std::string debugLevel)
//--------------------------------------------------------------------
  {

    fDebugLevel = debugLevel;
    SetDebugLevel(fDebugLevel,"AEvent");  
  }
Exemple #4
0
_Check_return_ ULONG CDbgView::HandleChange(UINT nID)
{
	ULONG i = CEditor::HandleChange(nID);

	if ((ULONG) -1 == i) return (ULONG) -1;

	switch (i)
	{
	case (DBGVIEW_TAGS):
		{
			ULONG ulTag = GetHexUseControl(DBGVIEW_TAGS);
			SetDebugLevel(ulTag); return true;
		}
		break;
	case (DBGVIEW_PAUSE):
		{
			m_bPaused = GetCheckUseControl(DBGVIEW_PAUSE);
		}
		break;

	default:
		break;
	}

	return i;
} // CDbgView::HandleChange
Exemple #5
0
/*****************************************************************
** 功    能:获取Ltcpsw接入模块配置文件
** 输入参数:
**     无
** 输出参数:
**     无
** 返 回 值: 
**     0                成功
**     -1               失败
** 作    者:彭建忠
** 日    期:2013/03/05
** 调用说明:
** 修改日志:
*******************************************************************/
int GetLtcpswIni()
{
    char    szFname[256];
    FILE    *fp;
    char    szTmp[50];
    char    szFlag[10];
    char    szLogFile[512];

    giDebug = 0;
    sprintf(szFname, "%s/etc/Ltcpsw.ini", getenv("HOME"));
    if (fp = fopen(szFname,"r"))
    {
        fscanf(fp,"%s%d", szTmp, &giDebug);
        fscanf(fp,"%s%s", szTmp, szLogFile);
        fscanf(fp,"%s%s", szTmp, gszHostPort );
        fscanf(fp,"%s%d", szTmp, &giTimeout);
        fscanf(fp,"%s%s", szTmp, szFlag);
        gcDefFlag = szFlag[0];
        fscanf(fp,"%s%s", szTmp, gszDefIp);
        fscanf(fp,"%s%s", szTmp, gszDefPort);
        fscanf(fp,"%s%d", szTmp, &giConnNum);
    }
    else
    {
        return -1;
    }

    if (giDebug >= 0 && giDebug <= 3)
    {
        SetDebugLevel(giDebug);
    }
    else
    {
        SetDebugLevel(0);
        giDebug = 0;
    }

    if ( giDebug )
    {
        sprintf(szTmp, "%s/", getenv("HOME") );
        strcat(szTmp, szLogFile);
        strcpy(szLogFile, szTmp);
        OpenLogFile(szLogFile);
    }

    return 0;
}
Exemple #6
0
/*****************************************************************
** 功    能:       读取密钥下载模块配置文件
** 输入参数:
**     无
** 输出参数:
**     无
** 返 回 值:
**     0:          成功
**    -1:          失败
** 作    者:彭建忠
** 日    期:2013/03/12
** 调用说明:
** 修改日志:
*******************************************************************/
int GetKeyDownIni()
{
    char    szFname[256];
    FILE    *fp;
    char    szTmp[50];
    char    szLogFile[512];

    giDebug = 0;
    sprintf(szFname, "%s/etc/KeyDown.ini", getenv("HOME"));
    if (fp = fopen(szFname,"r"))
    {
        fscanf(fp,"%s%d", szTmp, &giDebug);
        fscanf(fp,"%s%s", szTmp, szLogFile);
        fscanf(fp,"%s%s", szTmp, gszSrvPort );
        fscanf(fp,"%s%s", szTmp, gszUpCksIp );
        fscanf(fp,"%s%s", szTmp, gszUpCksPort );
        fscanf(fp,"%s%s", szTmp, gszMonIp );
        fscanf(fp,"%s%s", szTmp, gszMonPort );
        fscanf(fp,"%s%d", szTmp, &giTimeout);
        fclose(fp);
    }
    else
    {
        return -1;
    }

    if (giDebug >= 0 && giDebug <= 3)
    {
        SetDebugLevel(giDebug);
    }
    else
    {
        SetDebugLevel(0);
        giDebug = 0;
    }

    if ( giDebug )
    {
        sprintf(szTmp, "%s/", getenv("HOME") );
        strcat(szTmp, szLogFile);
        strcpy(szLogFile, szTmp);
        OpenLogFile(szLogFile);
    }

    return 0;
}
Exemple #7
0
//--------------------------------------------------------------------
  AEvent::AEvent(int evtNumber,
                 double trueEventEnergy, double recEventEnergy)
//--------------------------------------------------------------------
  {
    AEventHeader(evtNumber,trueEventEnergy,recEventEnergy);
    fDebugLevel = "DEBUG"; 
    InitLogger("AEvent");
    SetDebugLevel(fDebugLevel,"AEvent");
  }
Exemple #8
0
int main(int argc, char *argv[])
{
	if(SigUtil::Block(SIGINT) == false) {
		return -1;
	}
	if(SigUtil::Block(SIGTERM) == false) {
		return -1;
	}
	SetDebugLevel(DBG_LEVEL_DEBUG);
	Unittest test;
	test.Run();
	return 0;
}
Exemple #9
0
void ReadFromRegistry()
{
    HRESULT hRes = S_OK;
    HKEY hRootKey = NULL;

    WC_W32(RegOpenKeyEx(
               HKEY_CURRENT_USER,
               RKEY_ROOT,
               NULL,
               KEY_READ,
               &hRootKey));

    // Now that we have a root key, go get our values
    if (hRootKey)
    {
        int i = 0;

        for (i = 0 ; i < NUMRegKeys ; i++)
        {
            if (RegKeys[i].ulRegKeyType == regDWORD)
            {
                ReadDWORDFromRegistry(
                    hRootKey,
                    RegKeys[i].szKeyName,
                    &RegKeys[i].ulCurDWORD);
            }
            else if (RegKeys[i].ulRegKeyType == regSTRING)
            {
                ReadStringFromRegistry(
                    hRootKey,
                    RegKeys[i].szKeyName,
                    RegKeys[i].szCurSTRING,
                    _countof(RegKeys[i].szCurSTRING));
                if (RegKeys[i].szCurSTRING[0] == _T('\0'))
                {
                    EC_H(StringCchCopy(
                             RegKeys[i].szCurSTRING,
                             _countof(RegKeys[i].szCurSTRING),
                             RegKeys[i].szDefSTRING));
                }
            }
        }

        EC_W32(RegCloseKey(hRootKey));
    }

    SetDebugLevel(RegKeys[regkeyDEBUG_TAG].ulCurDWORD);
    DebugPrintVersion(DBGVersionBanner);
} // ReadFromRegistry
  //--------------------------------------------------------------------
  bool RoadWidthStudy::End()
  //--------------------------------------------------------------------
  {
    // Set the Debug Level
    SetDebugLevel(fDebug);

    log4cpp::Category& klog = log4cpp::Category::getRoot();
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::End()";
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Number of events with just One Road:";
    for (int width=fMinWidth; width<fMaxWidth+1; width++)
      klog << log4cpp::Priority::INFO << "           Width: "
           << width << " -> " << fRoadWidthStudy_Evts1Road_H1->GetBinContent(width+1);

    return true;
  }
Exemple #11
0
	AParticle::AParticle(int Id, std::string name, 
											bool isPrimary, double charge, 
         							TVector3 vertex, 
         							TLorentzVector p4,
                      int motherID)
  {
 		SetID(Id);
  	SetParticleName(name);
  	SetIsPrimary(isPrimary);
 		SetCharge(charge);
 		SetVertex(vertex);
  	SetP4(p4);
    SetMotherID(motherID);
    InitLogger("Aparticle");
    fDebug = "WARN";
    SetDebugLevel(fDebug,"Aparticle");
  }
  //--------------------------------------------------------------------
  bool RoadWidthStudy::Init()
  //--------------------------------------------------------------------
  {
    // Set the Debug Level
    SetDebugLevel(fDebug);

    log4cpp::Category& klog = log4cpp::Category::getRoot();
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Init()";
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Detector X Size = " << fMinDetX << " , " << fMaxDetX;
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Detector Y Size = " << fMinDetY << " , " << fMaxDetY;
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Detector Z Size = " << fMinDetZ << " , " << fMaxDetZ;
    klog << log4cpp::Priority::INFO << "RoadWidthStudy::Studying Widths from "
         << fMinWidth << " to " << fMaxWidth << " mm";

    std::pair<double,double> xRange;
    std::pair<double,double> yRange;
    std::pair<double,double> zRange;
    xRange.first  = fMinDetX;
    xRange.second = fMaxDetX;
    yRange.first  = fMinDetY;
    yRange.second = fMaxDetY;
    zRange.first  = fMinDetZ;
    zRange.second = fMaxDetZ;

    std::vector< std::pair<double,double> > detSize;
    detSize.push_back(xRange);
    detSize.push_back(yRange);
    detSize.push_back(zRange);

    // Init Paolina Stuff
    PSvc::Instance().Init("INFO", detSize);

    // Setting Titles to Histogram Axis
    fRoadWidthStudy_Evts1Road_H1->SetXTitle("Road Width [mm]");

    return true;
  }
  //--------------------------------------------------------------------
  bool RoadWidthStudy::Execute()
  //--------------------------------------------------------------------
  {
    // Set the Debug Level
    SetDebugLevel(fDebug);

    log4cpp::Category& klog = log4cpp::Category::getRoot();
    klog << log4cpp::Priority::DEBUG << "RoadWidthStudy::Execute()";

    // If only one RTrack, No computing needed
    std::vector <ARTrack*> tracks = ASvc::Instance().GetRTracks();
    int numTracks = tracks.size();
    if (numTracks == 1) {
      for (int width=fMinWidth; width<fMaxWidth+1; width++)
        fRoadWidthStudy_Evts1Road_H1->AddBinContent(width+1);
      return true;
    }

/*
    // METHOD BASED ON PAOLINA
    for (int width=fMinWidth; width<fMaxWidth+1; width++) {
      std::vector<double> fVoxelSize;
      fVoxelSize.push_back(width);
      fVoxelSize.push_back(width);
      fVoxelSize.push_back(width);

      std::vector<std::pair<TVector3,double> >  voxels;
      voxels = PSvc::Instance().ComputePaolinaVoxels(ISvc::Instance().GetTrueHits(), fVoxelSize);
      if (voxels.size() > 0) {
        std::vector<paolina::Track*> tracks = PSvc::Instance().ComputePaolinaTracks();
        if (tracks.size() == 1) fRoadWidthStudy_Evts1Road_H1->AddBinContent(width+1);
      }
    }
*/

    // METHOD BASED ON EUCLIDEAN DISTANCE OF RTracks
    // Generating the Distance Matrix
    TMatrix distMatrix = TMatrix(numTracks, numTracks);
    for (int i=0; i<numTracks-1; i++) {
      for (int j=i+1; j<numTracks; j++) {
        double trkDist = ASvc::Instance().GetTracksDist(tracks[i], tracks[j]);
        distMatrix(i,j) = distMatrix(j,i) = trkDist;
        //std::cout << "Dist (" << i << " , " << j << "): " << trkDist << std::endl;
      }
    }

    // Generating the Minimum Distance Vector
    TVector minDistVector(numTracks);
    for (int i=0; i<numTracks; i++) {
      double minDist = 1000.;
      for (int j=0; j<numTracks; j++) {
        if (i != j) 
          if (distMatrix(i,j) < minDist) minDist = distMatrix(i,j);
      }
      minDistVector(i) = minDist;
      //std::cout << "Min Dist " << i << ": " << minDist << std::endl;
    }

    // Starting the study for every Width
    for (int width=fMinWidth; width<fMaxWidth+1; width++) {
      //std::cout << "Study of Width: " << width << std::endl;

      // First Check: Some RTrack Too Far From the Rest ??
      bool firstCheck = true;
      for (int i=0; i<numTracks; i++) {
        if (minDistVector(i) > width) {
          firstCheck = false;
          //std::cout << "First Check False for RTrack: " << i << std::endl;
          break;
        }
      }

      // Second Check: All RTracks connected ??
      if (firstCheck == true) {
        // If there are only 2, they are connected
        if (numTracks == 2) fRoadWidthStudy_Evts1Road_H1->AddBinContent(width+1);

        else {
          // Initializing vectors
          std::vector<int> connected;
          connected.push_back(0);
          std::vector<int> notConnected;
          for (int i=1; i<numTracks; i++) notConnected.push_back(i);

          // Checking connections
          bool gotConnection;
          do {
            gotConnection = false;
            for (int i=0; i<notConnected.size(); i++) {
              for (int j=0; j<connected.size(); j++) {
                double dist = distMatrix(notConnected[i], connected[j]);
                if (dist < width) {
                  gotConnection = true;
                  //std::cout << "  Connection of " << notConnected[i] << std::endl;
                  connected.push_back(notConnected[i]);
                  notConnected.erase(notConnected.begin()+i);
                  break;
                }
              }
              if (gotConnection) break;
            }
            //std::cout << "Sizes: " << connected.size() << " " << notConnected.size() << std::endl;
          } while (gotConnection and (notConnected.size()>0));

          // If every RTrack is connected -> Evt OK
          int nons = notConnected.size();
          if (nons==0) {
            fRoadWidthStudy_Evts1Road_H1->AddBinContent(width+1);
            //std::cout << "All RTracks Connected Among Them" << std::endl;
          }
          //else {
          //  std::cout << "RTracks not Connected With The Others: ";
          //  for (int i=0; i<nons; i++) std::cout << notConnected[i] << ", ";
          //  std::cout << std::endl;
          //}

        }
      }
    } // Widths
    
   
    return true;
  }
Exemple #14
0
 AParticle::AParticle()
 {
   InitLogger("Aparticle");
   fDebug = "WARN";
   SetDebugLevel(fDebug,"Aparticle");
 }
Exemple #15
0
 void AParticle::SetLevelDebug(std::string debugLevel)
 {
   fDebug = debugLevel;
   SetDebugLevel(fDebug,"Aparticle"); 
 }
Exemple #16
0
/* execute an io command */
INT
io_execute(IO_CMD *cmd, VOID *Irp_1)
{
	IRP		*Irp = (IRP*)Irp_1;

    D_LOG(D_ENTRY, ("io_execute: entry, cmd: 0x%p", cmd));

    /* check signature & version */
    if ( cmd->sig != IO_CMD_SIG )
        return(IO_E_BADSIG);
    if ( (cmd->ver_major != IO_VER_MAJOR) ||
         (cmd->ver_minor != IO_VER_MINOR) )
        return(IO_E_BADVER);

    D_LOG(D_ALWAYS, ("io_execute: opcode: 0x%x, cm: 0x%p, idd: 0x%p", \
                                        cmd->opcode, cmd->cm, cmd->idd));
    D_LOG(D_ALWAYS, ("io_execute: args: 0x%x 0x%x 0x%x 0x%x", \
                        cmd->arg[0], cmd->arg[1], cmd->arg[2], cmd->arg[3]));


    /* clear status, assume success */
    cmd->status = IO_E_SUCC;

    /* branch on opcode */
    switch ( cmd->opcode )
    {
	
        case IO_CMD_ENUM_ADAPTERS :
            cmd->status = IoEnumAdapter(cmd);
            break;

		case IO_CMD_ENUM_CM:
			cmd->status = IoEnumCm(cmd);
			break;

        case IO_CMD_ENUM_IDD :
            cmd->status = IoEnumIdd(cmd);
            break;

        case IO_CMD_TRC_RESET :
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_RESET, (ULONG)cmd->idd);
            break;

        case IO_CMD_TRC_STOP :
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_STOP, (ULONG)cmd->idd);
            break;

        case IO_CMD_TRC_START :
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_START, (ULONG)cmd->idd);
            break;

        case IO_CMD_TRC_SET_FILT :
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_SET_FILTER, cmd->arg[0]);
            break;

        case IO_CMD_IDD_RESET_AREA :
            cmd->status = idd_reset_area(cmd->idd);
            break;

        case IO_CMD_IDD_GET_AREA :
            cmd->status = idd_get_area(cmd->idd, cmd->arg[0], NULL, NULL);
            break;

        case IO_CMD_IDD_GET_STAT :
            cmd->status = idd_get_area_stat(cmd->idd, &cmd->val.IddStat);
            break;

		case IO_CMD_TRC_CREATE:
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_CREATE, cmd->arg[0]);
			break;

		case IO_CMD_TRC_DESTROY:
            cmd->status = trc_control(cmd->idd,
                                        TRC_OP_DESTROY, cmd->arg[0]);
			break;

        case IO_CMD_TRC_GET_STAT :
            cmd->status = trc_get_status(idd_get_trc(cmd->idd),
                                        &cmd->val.trc_stat);
            break;

        case IO_CMD_TRC_GET_ENT :
            cmd->status = trc_get_entry(idd_get_trc(cmd->idd),
                                        cmd->arg[0], &cmd->val.trc_ent);
            break;

		case IO_CMD_DBG_LEVEL :
			SetDebugLevel(cmd);
			break;

		case IO_CMD_DO_IDP_CMD:
			DbgPrint("DoIdpCmd: Cmd: 0x%x\n", cmd->arg[0]);
			if (cmd->idd && ((IDD*)cmd->idd)->btype != IDD_BT_DATAFIREU)
			{
				switch (cmd->arg[0])
				{
					case GET_IDP_IO_VALUE:
						cmd->val.IdpRaw.uc = IdpGetUByteIO(cmd->idd,
						                     cmd->val.IdpRaw.us);
						cmd->status = IO_E_SUCC;
						break;


					case GET_IDP_BUFFER:
						IdpGetBuffer(cmd->idd,
				                     cmd->val.IdpRaw.Bank,
									 cmd->val.IdpRaw.Page,
									 cmd->val.IdpRaw.Address,
									 cmd->val.IdpRaw.Length,
									 cmd->val.IdpRaw.Buffer);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case SET_IDP_IO_VALUE:
						IdpPutUByteIO(cmd->idd,
						              (USHORT)cmd->val.IdpRaw.Address,
						              cmd->val.IdpRaw.uc);
						cmd->status = IO_E_SUCC;
						break;

					case SET_IDP_BUFFER:
						IdpPutBuffer(cmd->idd,
				                     cmd->val.IdpRaw.Bank,
									 cmd->val.IdpRaw.Page,
									 cmd->val.IdpRaw.Address,
									 cmd->val.IdpRaw.Length,
									 cmd->val.IdpRaw.Buffer);
			
						cmd->status = IO_E_SUCC;
						break;

					default:
						cmd->status = IO_E_BADCMD;
						break;
				}
			}
			else
				cmd->status = IO_E_BADIDD;
			break;

		case IO_CMD_DO_ADP_CMD:
			if (cmd->idd && ((IDD*)cmd->idd)->btype == IDD_BT_DATAFIREU)
			{
				switch (cmd->arg[0])
				{
					case GET_ADP_UCHAR:
						cmd->val.AdpRaw.uc = AdpGetUByte(cmd->idd,
											 cmd->val.AdpRaw.Address);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case GET_ADP_USHORT:
						cmd->val.AdpRaw.us = AdpGetUShort(cmd->idd,
											 cmd->val.AdpRaw.Address);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case GET_ADP_ULONG:
						cmd->val.AdpRaw.ul = AdpGetULong(cmd->idd,
											 cmd->val.AdpRaw.Address);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case GET_ADP_BUFFER:
						AdpGetBuffer(cmd->idd,
									 cmd->val.AdpRaw.Buffer,
									 cmd->val.AdpRaw.Address,
									 cmd->val.AdpRaw.Length
									 );
			
						cmd->status = IO_E_SUCC;
						break;
			
					case SET_ADP_UCHAR:
						AdpPutUByte(cmd->idd,
									cmd->val.AdpRaw.Address,
									cmd->val.AdpRaw.uc);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case SET_ADP_USHORT:
						AdpPutUShort(cmd->idd,
									 cmd->val.AdpRaw.Address,
									 cmd->val.AdpRaw.us);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case SET_ADP_ULONG:
						AdpPutULong(cmd->idd,
									cmd->val.AdpRaw.Address,
									cmd->val.AdpRaw.ul);
			
						cmd->status = IO_E_SUCC;
						break;
			
					case SET_ADP_BUFFER:
						AdpPutBuffer(cmd->idd,
									 cmd->val.AdpRaw.Address,
									 cmd->val.AdpRaw.Buffer,
									 cmd->val.AdpRaw.Length);
			
						cmd->status = IO_E_SUCC;
						break;

					default:
						cmd->status = IO_E_BADCMD;
						break;
				}
			}
			else
				cmd->status = IO_E_BADIDD;

			break;

        default :
            cmd->status = IO_E_BADCMD;
            break;
    }

    /* return status code */
    return((INT)cmd->status);
}
Exemple #17
0
void ADebug::SetLevelDebug(std::string debug)
  {
    fDebug = debug;  
    SetDebugLevel(debug);  
  }
Exemple #18
0
int MyDialog2::OpenConfigFile(CString PathName)
{
	struct ip_prefix_list *Hna;
	struct olsr_if *Int, *PrevInt;
	struct olsr_msg_params *MsgPar;
	int NumInt = m_InterfaceList.GetItemCount();
	int i;
	CString IntName;
	CString Conv;

	if (Conf != NULL)
		olsrd_free_cnf(Conf);

	if (olsrd_parse_cnf(PathName) < 0)
		return -1;

	Conf = olsr_cnf;

	for (i = 0; i < NumInt; i++)
		m_InterfaceList.SetCheck(i, FALSE);

	for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
	{
		IntName = Int->name;
		IntName.MakeUpper();

		for (i = 0; i < NumInt; i++)
		{
			if (m_InterfaceList.GetItemText(i, 0).Mid(0, 4) == IntName)
				m_InterfaceList.SetCheck(i, TRUE);
		}
	}

	Int = Conf->interfaces;

	MsgPar = &Int->cnf->hello_params;

	Conv.Format("%.2f", MsgPar->emission_interval);
	m_HelloInt.SetWindowText(Conv);

	Conv.Format("%.2f", MsgPar->validity_time);
	m_HelloHold.SetWindowText(Conv);

	MsgPar = &Int->cnf->tc_params;
	
	Conv.Format("%.2f", MsgPar->emission_interval);
	m_TcInt.SetWindowText(Conv);

	Conv.Format("%.2f", MsgPar->validity_time);
	m_TcHold.SetWindowText(Conv);

	MsgPar = &Int->cnf->mid_params;
	
	Conv.Format("%.2f", MsgPar->emission_interval);
	m_MidInt.SetWindowText(Conv);

	Conv.Format("%.2f", MsgPar->validity_time);
	m_MidHold.SetWindowText(Conv);

	MsgPar = &Int->cnf->hna_params;
	
	Conv.Format("%.2f", MsgPar->emission_interval);
	m_HnaInt.SetWindowText(Conv);

	Conv.Format("%.2f", MsgPar->validity_time);
	m_HnaHold.SetWindowText(Conv);

	SetDebugLevel(Conf->debug_level);

	Conv.Format("%.2f", Conf->pollrate);
	m_PollInt.SetWindowText(Conv);

	Conv.Format("%d", Conf->mpr_coverage);
	m_MprCov.SetWindowText(Conv);

	m_TcRed.SetCurSel(Conf->tc_redundancy);

	m_LqAlgo.SetCurSel(m_LqAlgo.FindStringExact(-1, Conf->lq_algorithm));

	m_HystCheck.SetCheck(Conf->use_hysteresis);

	Conv.Format("%.2f", Conf->hysteresis_param.scaling);
	m_HystScaling.SetWindowText(Conv);

	Conv.Format("%.2f", Conf->hysteresis_param.thr_high);
	m_HystThresholdHigh.SetWindowText(Conv);

	Conv.Format("%.2f", Conf->hysteresis_param.thr_low);
	m_HystThresholdLow.SetWindowText(Conv);

	OnHystCheck();

	m_FishEyeCheck.SetCheck(Conf->lq_fish > 0);

	m_EtxCheck.SetCheck(Conf->lq_level > 0);

#if 0
	Conv.Format("%d", Conf->lq_wsize);
	m_EtxWindowSize.SetWindowText(Conv);
#endif

	m_EtxRadio1.SetCheck(Conf->lq_level == 1);
	m_EtxRadio2.SetCheck(Conf->lq_level == 0 || Conf->lq_level == 2);

	OnEtxCheckWorker();

	m_InternetCheck.SetCheck(FALSE);

	for (Hna = Conf->hna_entries; Hna != NULL; Hna = Hna->next)
		if (0 == Hna->net.prefix_len &&
			m_InternetCheck.IsWindowEnabled())
		m_InternetCheck.SetCheck(TRUE);

	PrevInt = NULL;

	for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
	{
		IntName = Int->name;

		if (IntName.CompareNoCase("GUI") == 0)
			break;

		PrevInt = Int;
	}

	if (Int != NULL)
	{
		if (PrevInt == NULL)
			Conf->interfaces = Int->next;

		else
			PrevInt->next = Int->next;

		win32_olsrd_free(Int);
	}

	return 0;
}
Exemple #19
0
void DebugPreflight(const char *logname, bool redirect, int level, int perms)
{
	// If we've preflighted already, just return
	if (gPreflighted) return;

	_DebugEnter();
	
	if (!gOutputFILE)
		gOutputFILE = stderr;
	if (!gOutputFileNo)
		gOutputFileNo = STDERR_FILENO;
	
	// Ignore logfile directives on iOS -- we always go to stderr
#if !TARGET_OS_IPHONE
	if (logname && *logname)
	{
		char	buffer[PATH_MAX*2+1] = {0};
	
		// Determine where the log file will go
		if (*logname != '/')
		{
			const char * home = getenv("HOME");
		
			if (! geteuid())
				strcpy(buffer, "/var/log/");
			else if (home)
			{
#if __APPLE__
				snprintf(buffer, sizeof(buffer), "%s/Library/Logs/", home);
#else
				snprintf(buffer, sizeof(buffer), "%s/log/", home);
#endif // __APPLE__
				mkdir(buffer, 0700);
			}
		}
		strncat(buffer, logname, sizeof(buffer)-strlen(buffer)-1);
		if (! strstr(logname, ".log") && ! strstr(logname, ".txt"))
			strncat(buffer, ".log", sizeof(buffer)-strlen(buffer)-1);
		
		// Close the previous file
		if (gOutputFILE && (gOutputFILE != stderr))
			fclose(gOutputFILE);
	
		if ((strlen(buffer) <= PATH_MAX) && (gOutputFILE = fopen(buffer, "a")))
		{
			// Open a new file and use it's file descriptor for our logging
			setvbuf(gOutputFILE, NULL, _IOLBF, 0);
			gOutputFileNo = fileno(gOutputFILE);
			fchmod(gOutputFileNo, (perms) ? perms : 0600);
		}
		else
		{
			// Default back to stderr
			gOutputFILE = stderr;
			gOutputFileNo = STDERR_FILENO;
		}
	}
#endif // !TARGET_OS_IPHONE
	
	if (!gPreflighted)
	{
		time_t		now;
		char		stamp[26] = "";
		char		name[PATH_MAX] = "";
		char		vers[32] = "";
		CFStringRef cfstr = NULL;

		// Print a pretty header
		time(&now);
		ctime_r(&now, stamp);
		strtok(stamp, "\n");
		fprintf(gOutputFILE, "--- Log opened %s ---\n", stamp);

#if TARGET_OS_MAC || TARGET_OS_IPHONE
		if ((cfstr = (CFStringRef) CFBundleGetValueForInfoDictionaryKey(
				CFBundleGetMainBundle(), CFSTR("CFBundleName"))))
			CFStringGetCString(cfstr, name, sizeof(name), kCFStringEncodingUTF8);
		if ((cfstr = (CFStringRef) CFBundleGetValueForInfoDictionaryKey(
				CFBundleGetMainBundle(), CFSTR("CFBundleVersion"))))
			CFStringGetCString(cfstr, vers, sizeof(vers), kCFStringEncodingUTF8);
		if (*name)
			fprintf(gOutputFILE, "--- %s %s ---\n", name, vers);
#endif // TARGET_OS_MAC || TARGET_OS_IPHONE
#if TARGET_OS_MAC && !TARGET_CPU_ARM && !TARGET_CPU_ARM64
		else
		{
			// Handle non-bundle processes (daemons, command-line tools)
			proc_name(getpid(), name, (uint32_t) sizeof(name));
			if (*name) 
  #if defined(VERSION)
				fprintf(gOutputFILE, "--- %s %s ---\n", name, VERSION);
  #else
				fprintf(gOutputFILE, "--- %s ---\n", name);
  #endif // VERSION
		}
#endif // TARGET_OS_MAC && !TARGET_CPU_ARM && !TARGET_CPU_ARM64

		// Ensure this has been preflighted as well
		if (gDebugLevel == 1)
			SetDebugLevel(level);
		else
			DebugLevel();
		
		gPreflighted = true;
	}

CLEANUP:
	_DebugLeave();
}