コード例 #1
0
ファイル: t50.c プロジェクト: aziem/wrapped-intervals
int main(){

  int p1,p2;
  int x1,y1;

  INTERVAL(p1,x1,-10,20); 
  INTERVAL(p2,y1,0,23456789); 
    
  while (x1 < y1){
      x1 = x1 << 4;
  }
  return x1;
}
コード例 #2
0
INTERVAL(dttm) CACObject :: VersionIntervall (uint16 version_nr )
{
  INTERVAL(dttm)   timeint;
#ifndef IF_Class  // client version

  if ( IsValid() )
  {
    if ( !csconnection )                                 
      SDBSET(517)
    else
    {
      LockSendParms().Fill(version_nr);
      if ( !CConnection()->SendCSMessage(this,S_CACObject,SF_CACObject_VersionIntervall_ci) )
      {
        timeint.get_low()  = Get_rec_result()[0].GetTimestamp(csconnection->get_conversion());
        timeint.get_high() = Get_rec_result()[1].GetTimestamp(csconnection->get_conversion());
      }
      UnlockSendParms();
    }
  }
  return(timeint);
  
#else             // server version
  
  timeint = ((SC_DBObject *)cso_ptr)->VersionIntervall(
                  (*parms)[1].GetUShort(connection->get_conversion())
            );
   
  result->Fill(timeint.get_low(),timeint.get_high());

  return(NO);

#endif

}
コード例 #3
0
INTERVAL CTimeServerAnnouncementsSet::getInterval() const
{
	int n = m_interval->GetCurrentSelection();
	if (n == wxNOT_FOUND)
		return INTERVAL_15MINS;

	return INTERVAL(n);
}
コード例 #4
0
CTimeServerConfig::CTimeServerConfig(wxConfigBase* config, const wxString& name) :
m_config(config),
m_name(wxT("/")),
m_callsign(DEFAULT_CALLSIGN),
m_sendA(DEFAULT_SENDA),
m_sendB(DEFAULT_SENDB),
m_sendC(DEFAULT_SENDC),
m_sendD(DEFAULT_SENDD),
m_sendE(DEFAULT_SENDE),
m_address(DEFAULT_ADDRESS),
m_language(DEFAULT_LANGUAGE),
m_format(DEFAULT_FORMAT),
m_interval(DEFAULT_INTERVAL),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
	wxASSERT(config != NULL);

	if (!name.IsEmpty())
		m_name = wxT("/") + name + wxT("/");

	m_config->Read(m_name + KEY_CALLSIGN, &m_callsign, DEFAULT_CALLSIGN);

	m_config->Read(m_name + KEY_SENDA, &m_sendA, DEFAULT_SENDA);

	m_config->Read(m_name + KEY_SENDB, &m_sendB, DEFAULT_SENDB);

	m_config->Read(m_name + KEY_SENDC, &m_sendC, DEFAULT_SENDC);

	m_config->Read(m_name + KEY_SENDD, &m_sendD, DEFAULT_SENDD);

	m_config->Read(m_name + KEY_SENDE, &m_sendE, DEFAULT_SENDE);

	m_config->Read(m_name + KEY_ADDRESS, &m_address, DEFAULT_ADDRESS);

	long temp;
	m_config->Read(m_name + KEY_LANGUAGE, &temp, long(DEFAULT_LANGUAGE));
	m_language = LANGUAGE(temp);

	m_config->Read(m_name + KEY_FORMAT, &temp, long(DEFAULT_FORMAT));
	m_format = FORMAT(temp);

	m_config->Read(m_name + KEY_INTERVAL, &temp, long(DEFAULT_INTERVAL));
	m_interval = INTERVAL(temp);

	m_config->Read(m_name + KEY_WINDOW_X, &temp, long(DEFAULT_WINDOW_X));
	m_x = int(temp);

	m_config->Read(m_name + KEY_WINDOW_Y, &temp, long(DEFAULT_WINDOW_Y));
	m_y = int(temp);
}
コード例 #5
0
ファイル: raw.c プロジェクト: kejiewei/eresi
/**
 * Retreive the file offset from the virtual address 
 * @param file
 * @param vaddr
 * @return
 */
int		elfsh_get_foffset_from_vaddr(elfshobj_t *file, eresi_Addr vaddr)
{
  elfshsect_t	*actual;
  
  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  if (!vaddr)
    PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
  for (actual = file->sectlist; actual; actual = actual->next)
    if (INTERVAL(actual->shdr->sh_addr, vaddr, 
		 actual->shdr->sh_addr + actual->shdr->sh_size))
      PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 
			 (actual->shdr->sh_offset + 
			  (vaddr - actual->shdr->sh_addr)));
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}
コード例 #6
0
ファイル: mapper.cpp プロジェクト: caosuomo/rads
class HenonMapper
{
  vector<double> params;

  template <class T>
  vector<T> map_point(const vector<T> &v)
  {
	vector<T> w(2);
    w[0] = 1 - params[0] * pow(v[0],2) + v[1];
	w[1] = params[1] * v[0];
	return w;
  }

  vector<vector<T> > map_points(const vector<vector<T> > &v)
  {
	vector<vector<T> > w(v.size());
	for (int i=0; i<v.size(); i++)
	  w[i] = map(v[i]);
  }
}

int main()
{
  HenonMapper hm;

  vector<double> v(2);
  cout << "enter x: ";
  cin >> v[0];
  cout << "enter y: ";
  cin >> v[1];

  cout << "henon(" << v << ") = " << hm.map_point(v) << endl;

  vector<INTERVAL> w(2);
  for (int i; i<v.size(); i++)
	w[i] = INTERVAL(v[i]);

  cout << "henon(" << w << ") = " << hm.map_point(w) << endl;
  return 0;
}
コード例 #7
0
ファイル: vSDP_struct.cpp プロジェクト: nberth/apron4opam
//----------------------------------------------------------------------
void RectangularMatrix::setRow(GeneralVector& vec, int i)
{
  if ((isSparse && !(vec.isSparse)) || (!isSparse && (vec.isSparse))) 			//logical XOR
    fprintf(stdout, "RectangularMatrix: attempt to assign a vector to a matrix row with different sparse mode.\n");
  if (isSparse)
  {
    int vectorNonZeroCount = vec.svec.colStarts[ColDimension(vec.svec)];
    int matrixNonZeroCount = smat.colStarts[ColDimension(smat)];
    int *coln = vec.svec.rowIndices;
    if (matrixNonZeroCount+vectorNonZeroCount > Allocated(smat))
      IncAlloc(smat, matrixNonZeroCount + vectorNonZeroCount - Allocated(smat));
    for (int j=0; j<vectorNonZeroCount; j++)
    {
      BIASINTERVAL buf = vec.svec.theElements[j];
      SetElement(smat, i, coln[j]+1, INTERVAL(BiasInf(&buf), BiasSup(&buf)));
    }
  }
  else
  {
    SetRow(dmat, i, vec.dvec);
  }
}
コード例 #8
0
/**
 * Get function addr list from call search basic
 * @param file target file
 * @param addr address list
 */
int			elfsh_addr_get_func_list(elfshobj_t *file, eresi_Addr **addr)
{
  int 			ret;
  int			index;
  asm_instr		instr;
  elfsh_SAddr		foffset;
  elfsh_Word		len;
  char			*base;
  asm_processor		proc;
  eresi_Addr		base_vaddr, caddr;
  u_char		found = 0;
  elfshsect_t		*text;
  eresi_Addr		*vaddr;
  const int		astep = 20;
  u_int			apos = 0;
  btree_t		*broot = NULL;
  u_int			diff;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  if (!file || !addr)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		 "Invalid parameters", -1);

  /* Search entrypoint section, our address must be in this section */
  text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &foffset);

  if (!text)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		 "Cannot find parent section from entry point", -1);
  
  if (!elfsh_get_anonymous_section(file, text))
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		 "Unable to get an anonymous section", -1);
  
  base = elfsh_readmem(text);
  len = text->shdr->sh_size;

  /* Get the virtual address */
  base_vaddr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(text) ?
		file->rhdr.base + elfsh_get_section_addr(text->shdr) :
		elfsh_get_section_addr(text->shdr));

  /* Setup asm_processor structure */
  if (etrace_setup_proc(file, &proc) < 0)
        PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		 "Failed during proc structure setup", -1);

  XALLOC(__FILE__, __FUNCTION__, __LINE__, vaddr, sizeof(eresi_Addr)*astep, -1);
  
  /* Despite the fact that we choose the right architecture to init asm,
     Our approach is totally architecture independant as we search using
     global type ASM_TYPE_CALLPROC and we know that op[0].imm will contain a
     relative value. */
  for (index = 0; index < len; index += ret)
    {
      /* Read an instruction */
      if ((ret = asm_read_instr(&instr, (u_char *) (base + index), len -  index, &proc)))
	{
	  /* Global assembler filter */
	  if ((instr.type & ASM_TYPE_CALLPROC)
	      && instr.op[0].imm != 0)
	    {
	      caddr = base_vaddr + index + instr.op[0].imm + instr.len;

	      /* Found a call check its local */
	      if (INTERVAL(base_vaddr, caddr, base_vaddr + len))
		{
		  found = 1;

		  diff = (u_int) caddr;

		  /* Avoid double entrie */
		  if (btree_get_elem(broot, diff) != NULL)
		    goto next;

		  btree_insert(&broot, diff, (void *)0x1);

		  /* Next will be the last of the current list
		     then realloc */
		  if ((apos+1) % astep == 0)
		    {
		      XREALLOC(__FILE__, __FUNCTION__, __LINE__, vaddr, vaddr,
			       sizeof(eresi_Addr)*(apos+1+astep), -1);

		      /* Blank new elements */
		      memset(&vaddr[apos], 0x00, astep*sizeof(eresi_Addr));
		    }

		  vaddr[apos++] = caddr;
		}
	    }
	}

    next:

      if (ret <= 0)
	ret = 1;
    }

  /* If nothing found we free allocated buffer and
     return an error */
  if (!found)
    {
      XFREE(__FILE__, __FUNCTION__, __LINE__, vaddr);
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		   "No call internal found", -3);
    }
  
  btree_free(broot, 0);

  *addr = vaddr;
  
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}
コード例 #9
0
/**
 * Search a call for a given address
 * @param file target file
 * @param addr supose to be a function
 */
int			elfsh_addr_is_called(elfshobj_t *file, eresi_Addr addr)
{
  int 			ret;
  int			index;
  asm_instr		instr;
  elfsh_SAddr		foffset;
  elfsh_Word		len;
  char			*base;
  asm_processor		proc;
  eresi_Addr		base_vaddr;
  u_char		found = 0;
  elfshsect_t		*text;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  if (!file)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		 "Invalid parameter", -1);

  /* Search entrypoint section, our address must be in this section */
  text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &foffset);

  if (!text)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		 "Cannot find parent section from entry point", -1);
  
  if (!elfsh_get_anonymous_section(file, text))
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		 "Unable to get an anonymous section", -1);
  
  base = elfsh_readmem(text);
  len = text->shdr->sh_size;

  /* Get the virtual address */
  base_vaddr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(text) ?
		file->rhdr.base + elfsh_get_section_addr(text->shdr) :
		elfsh_get_section_addr(text->shdr));

  /* Our address is valid ? */
  if (!INTERVAL(base_vaddr, addr, (base_vaddr + len)))
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		 "Not in entrypoint section", -4);

  /* Setup asm_processor structure */
  if (etrace_setup_proc(file, &proc) < 0)
        PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		 "Failed during proc structure setup", -1);
  
  /* Despite the fact that we choose the right architecture to init asm,
     Our approach is totally architecture independant as we search using
     global type ASM_TYPE_CALLPROC and we know that op[0].imm will contain a
     relative value. */
  for (index = 0; index < len; index += ret)
    {
      /* Read an instruction */
      if ((ret = asm_read_instr(&instr, (u_char *) (base + index), len -  index, &proc)))
	{
	  /* Global assembler filter */
	  if ((instr.type & ASM_TYPE_CALLPROC)
	      && instr.op[0].imm != 0)
	    {
	      /* Found the correct call */
	      if (base_vaddr + index + instr.op[0].imm + instr.len == addr)
		{
		  found = 1;
		  break;
		}
	    }
	}

      if (ret <= 0)
	ret = 1;
    }

  if (!found)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		 "No call found", -3);

  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}
コード例 #10
0
CTimeServerConfig::CTimeServerConfig(const wxString& dir, const wxString& name) :
m_fileName(),
m_callsign(DEFAULT_CALLSIGN),
m_sendA(DEFAULT_SENDA),
m_sendB(DEFAULT_SENDB),
m_sendC(DEFAULT_SENDC),
m_sendD(DEFAULT_SENDD),
m_sendE(DEFAULT_SENDE),
m_address(DEFAULT_ADDRESS),
m_language(DEFAULT_LANGUAGE),
m_format(DEFAULT_FORMAT),
m_interval(DEFAULT_INTERVAL),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
	wxASSERT(!dir.IsEmpty());

	wxString fileName = CONFIG_FILE_NAME;
	if (!name.IsEmpty())
		fileName = CONFIG_FILE_NAME + wxT("_") + name;

	m_fileName.Assign(dir, fileName);

	wxTextFile file(m_fileName.GetFullPath());

	bool exists = file.Exists();
	if (!exists)
		return;

	bool ret = file.Open();
	if (!ret) {
		wxLogError(wxT("Cannot open the config file - %s"), m_fileName.GetFullPath().c_str());
		return;
	}

	long temp;

	wxString str = file.GetFirstLine();

	while (!file.Eof()) {
		if (str.GetChar(0U) == wxT('#')) {
			str = file.GetNextLine();
			continue;
		}

		int n = str.Find(wxT('='));
		if (n == wxNOT_FOUND) {
			str = file.GetNextLine();
			continue;
		}

		wxString key = str.Left(n);
		wxString val = str.Mid(n + 1U);

		if (key.IsSameAs(KEY_CALLSIGN)) {
			m_callsign = val;
		} else if (key.IsSameAs(KEY_SENDA)) {
			val.ToLong(&temp);
			m_sendA = temp == 1L;
		} else if (key.IsSameAs(KEY_SENDB)) {
			val.ToLong(&temp);
			m_sendB = temp == 1L;
		} else if (key.IsSameAs(KEY_SENDC)) {
			val.ToLong(&temp);
			m_sendC = temp == 1L;
		} else if (key.IsSameAs(KEY_SENDD)) {
			val.ToLong(&temp);
			m_sendD = temp == 1L;
		} else if (key.IsSameAs(KEY_SENDE)) {
			val.ToLong(&temp);
			m_sendE = temp == 1L;
		} else if (key.IsSameAs(KEY_ADDRESS)) {
			m_address = val;
		} else if (key.IsSameAs(KEY_LANGUAGE)) {
			val.ToLong(&temp);
			m_language = LANGUAGE(temp);
		} else if (key.IsSameAs(KEY_FORMAT)) {
			val.ToLong(&temp);
			m_format = FORMAT(temp);
		} else if (key.IsSameAs(KEY_INTERVAL)) {
			val.ToLong(&temp);
			m_interval = INTERVAL(temp);
		} else if (key.IsSameAs(KEY_WINDOW_X)) {
			val.ToLong(&temp);
			m_x = int(temp);
		} else if (key.IsSameAs(KEY_WINDOW_Y)) {
			val.ToLong(&temp);
			m_y = int(temp);
		}

		str = file.GetNextLine();
	}

	file.Close();
}