Esempio n. 1
0
File: track.c Progetto: DINKIN/mongo
/*
 * sum_latency --
 *	Sum latency for a set of threads.
 */
static void
sum_latency(WTPERF *wtperf, size_t field_offset, TRACK *total)
{
	WTPERF_THREAD *thread;
	TRACK *trk;
	int64_t i;
	u_int j;

	memset(total, 0, sizeof(*total));

	for (i = 0, thread = wtperf->workers;
	    thread != NULL && i < wtperf->workers_cnt; ++i, ++thread) {
		trk = (TRACK *)((uint8_t *)thread + field_offset);

		for (j = 0; j < ELEMENTS(trk->us); ++j) {
			total->ops += trk->us[j];
			total->us[j] += trk->us[j];
		}
		for (j = 0; j < ELEMENTS(trk->ms); ++j) {
			total->ops += trk->ms[j];
			total->ms[j] += trk->ms[j];
		}
		for (j = 0; j < ELEMENTS(trk->sec); ++j) {
			total->ops += trk->sec[j];
			total->sec[j] += trk->sec[j];
		}
	}
}
Esempio n. 2
0
/**
 * find_charset_map:
 * @charset: An 8bit charset.
 *
 * Find charset -> UCS-2 map.
 *
 * Returns: Pointer to the map, #NULL when not found.
 **/
static const EncaUnicodeMap*
find_charset_map(int charset)
{
  static int charset_id[ELEMENTS(UNICODE_MAP)];
  static int charset_id_initialized = 0;
  size_t i;

  if (charset < 0)
    return NULL;

  if (!charset_id_initialized) {
    for (i = 0; i < ELEMENTS(UNICODE_MAP); i++) {
      charset_id[i] = enca_name_to_charset(UNICODE_MAP[i].name);
      assert(charset_id[i] != ENCA_CS_UNKNOWN);
    }
    charset_id_initialized = 1;
  }

  for (i = 0; i < ELEMENTS(UNICODE_MAP); i++) {
    if (charset_id[i] == charset)
      return UNICODE_MAP + i;
  }

  return NULL;
}
Esempio n. 3
0
/*===========================================================================*
 *				pt_sanitycheck		     		     *
 *===========================================================================*/
PUBLIC void pt_sanitycheck(pt_t *pt, char *file, int line)
{
    /* Basic pt sanity check. */
    int i;
    int slot;

    MYASSERT(pt);
    MYASSERT(pt->pt_dir);
    MYASSERT(pt->pt_dir_phys);

    for(slot = 0; slot < ELEMENTS(vmproc); slot++) {
        if(pt == &vmproc[slot].vm_pt)
            break;
    }

    if(slot >= ELEMENTS(vmproc)) {
        vm_panic("pt_sanitycheck: passed pt not in any proc", NO_NUM);
    }

    MYASSERT(usedpages_add(pt->pt_dir_phys, I386_PAGE_SIZE) == OK);

    for(i = proc_pde; i < I386_VM_DIR_ENTRIES; i++) {
        if(pt->pt_pt[i]) {
            if(!(pt->pt_dir[i] & I386_VM_PRESENT)) {
                printf("slot %d: pt->pt_pt[%d] = 0x%lx, but pt_dir entry 0x%lx\n",
                       slot, i, pt->pt_pt[i], pt->pt_dir[i]);
            }
            MYASSERT(pt->pt_dir[i] & I386_VM_PRESENT);
            MYASSERT(usedpages_add(I386_VM_PFA(pt->pt_dir[i]),
                                   I386_PAGE_SIZE) == OK);
        } else {
            MYASSERT(!(pt->pt_dir[i] & I386_VM_PRESENT));
        }
    }
}
Esempio n. 4
0
void CServerSession::RunSession( SOCKET sock )
{
    char buf[MAXCMDBUF];
    CNcpMessage* pMsg = (CNcpMessage*)buf;

    //initialize the state and socket.
    ASSERT( m_sock==0 );
    m_sock = sock;
    m_state = NCPS_CLOSED;

    while( true ) {
        pMsg->Recv( m_sock, ELEMENTS(buf) );

        if( m_state==NCPS_CLOSED ) {
            if( pMsg->GetCmd()!=CM_LOGON ) {
                pMsg->Init( CM_ACK );
                pMsg->SetRet( E_UNKNOWN );
                pMsg->Send( m_sock );
                continue;
            }
        }

        PumpMessage( pMsg, ELEMENTS(buf) );

        if( m_state==NCPS_CLOSED )break;
    }
}
Esempio n. 5
0
uint8_t
smtp_tree_words_conds (struct pkt_desc * const pkt)
{
  /* conditions data */
  /* last element HAS to be empty == "\0", it is termination */
  static const char *const mc_words_smtp[] = { "SMTP", "smtp", "" };	/* no need for ESMTP */
  static const char *const mc_words_mail[] = { "mail", "MAIL", "Mail", "" };
  static const char *const mc_words_server[] =
    { "Postfix", "Sendmail", "postffix", "sendmail", "" };
  static const char *const mc_words_os[] =
    { "GNU", "Debian", "debian", "windows", "Windows", "" };
  static const char *const *const mc_words[] =
    { mc_words_smtp, mc_words_mail, mc_words_server, mc_words_os };

  uint8_t conds = 0;
  size_t i;

  for (i = 0; i < ELEMENTS (mc_words); ++i)
    {
      size_t j;

      for (j = 0; mc_words[i][j][0] != '\0'; ++j)
	{
	  if (memmem
	      (OFFSETED (pkt), REMAINING (pkt), mc_words[i][j],
	       strlen (mc_words[i][j])))
	    {
	      BIT_SET (conds, (ELEMENTS (mc_words) - 1) - i);
	      break;
	    }
	}
    }

  return conds;
}
Esempio n. 6
0
int CClientSession::DoGetFile( const char* strSrc, const char* strDst )
{
    char buf[MAXPATH+sizeof(CNcpMessage)];
    CNcpMessage* pMsg = (CNcpMessage*)buf;

    //step 1. request passive mode to get the data channel address
    short dataport=0;

    int nRet = DoPassive( &dataport );
    if( FAILED(nRet) )return nRet;

    //step 2. send the put file command.
    pMsg->Init( CM_GETFILE );
    strcpy( pMsg->GetData(), strSrc );
    pMsg->SetDataSize( strlen(strSrc)+1 );
    pMsg->Send( m_sock );

    //wait for the return code and check it
    if( !pMsg->Recv( m_sock, ELEMENTS(buf) ) ) {
        return E_BROKEN;		//broken connection
    }

    ASSERT( pMsg->IsAck() );
    if( pMsg->IsFailed() ) {
        return pMsg->GetRet();
    }

    //step 3. now the server agrees on the file transfer, connect the data channel and send file
    SOCKADDR_IN addr;
    socklen_t nlen = sizeof(SOCKADDR_IN);
    GetPeerName( m_sock, (SOCKADDR*)&addr, &nlen );
    addr.sin_port = htons( dataport );

    SOCKET sockdata;
    //import, must retry the socket initilization a few times.
    int i;
    for( i=0; i<MAXRETRY; i++ ) {
        sockdata = Socket( PF_INET, SOCK_STREAM, 0 );
        ASSERT( sockdata!=INVALID_SOCKET );

        if( ::connect( sockdata, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN) )==0 )break;
        closesocket( sockdata );
    }
    if( i>=MAXRETRY )throw new CSockException();

    int nLen = RecvFileEx( sockdata, strDst, m_nFileMode );
    closesocket( sockdata );

    //step 4. exchange the error code.
    pMsg->Init( CM_ACK, nLen );
    pMsg->Send( m_sock );

    //wait for the return code and check it
    if( !pMsg->Recv( m_sock, ELEMENTS(buf) ) ) {
        return E_BROKEN;		//broken connection
    }

    ASSERT( pMsg->IsAck() );
    return pMsg->GetRet();
}
Esempio n. 7
0
bool
	Random::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting Random::Instance test..."));

#define RANDOM_TEST_COUNT 10000

	int i;
	for (i=0; i<RANDOM_TEST_COUNT; ++i)
	{
		Scalar r = Random::Instance->GetFraction();
		Test_Assumption(r >= 0.0f && r < 1.0f);
	}

	int array[10];
	for (i = 0; i<ELEMENTS(array); ++i)
	{
		array[i] = 0;
	}

	for (i = 0; i<RANDOM_TEST_COUNT; ++i)
	{
		int r = Random::Instance->GetLessThan(ELEMENTS(array));
		Test_Assumption(r >= 0 && r < ELEMENTS(array));
		++array[r];
	}

	return true;
}
Esempio n. 8
0
/******************************************************************************
 * Securely delete the given file. This involves overwriting it with various
 * bits, truncating it, and then unlinking it. Return non-zero if there is
 * an error during this process.
 */
int secdel(const char* filename) {
  static unsigned char buf[256];
  static unsigned char bytes[]={0xaa,0x55};
  struct stat sb;
  unsigned char ch;
  unsigned long fsize; /* (size of file) / 256 */
  int f,i,j,rc;

  if ((f=open(filename,O_RDWR))<0) return errno;
  if (fstat(f,&sb)) return errno;
  fsize=sb.st_size/sizeof(buf)+1;
  for(i=0;i<=ELEMENTS(bytes);++i) {
    if (i<ELEMENTS(bytes))
      memset(buf,bytes[i],sizeof(buf));
    else {
      srand(time(NULL)); /* In case sranddev() fails. */
      /*sranddev(); not supported on Linux */
      for(j=0;j<ELEMENTS(buf);++j)
	buf[j]=(unsigned char)(rand()&0xff);
    }
    for(j=0;j<fsize;++j)
      write(f,(void*)buf,sizeof(buf));
  }
  close(f);

  /* Truncate this file to 0 bytes. */
  f=open(filename,O_RDWR|O_TRUNC);
  close(f);

  /* Remove this file from the filesystem. */
  rc=unlink(filename);
  return rc;
} /* int secdel(const char* filename) */
Esempio n. 9
0
cSatipPluginSetup::cSatipPluginSetup()
: detachedModeM(SatipConfig.GetDetachedMode()),
  deviceCountM(0),
  operatingModeM(SatipConfig.GetOperatingMode()),
  ciExtensionM(SatipConfig.GetCIExtension()),
  eitScanM(SatipConfig.GetEITScan()),
  numDisabledSourcesM(SatipConfig.GetDisabledSourcesCount()),
  numDisabledFiltersM(SatipConfig.GetDisabledFiltersCount())
{
  debug1("%s", __PRETTY_FUNCTION__);
  operatingModeTextsM[cSatipConfig::eOperatingModeOff]    = tr("off");
  operatingModeTextsM[cSatipConfig::eOperatingModeLow]    = tr("low");
  operatingModeTextsM[cSatipConfig::eOperatingModeNormal] = tr("normal");
  operatingModeTextsM[cSatipConfig::eOperatingModeHigh]   = tr("high");
  for (unsigned int i = 0; i < ELEMENTS(cicamsM); ++i)
      cicamsM[i] = SatipConfig.GetCICAM(i);
  for (unsigned int i = 0; i < ELEMENTS(ca_systems_table); ++i)
      cicamTextsM[i] = ca_systems_table[i].description;
  if (numDisabledSourcesM > MAX_DISABLED_SOURCES_COUNT)
     numDisabledSourcesM = MAX_DISABLED_SOURCES_COUNT;
  for (int i = 0; i < MAX_DISABLED_SOURCES_COUNT; ++i)
      disabledSourcesM[i] = SatipConfig.GetDisabledSources(i);
  if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE)
     numDisabledFiltersM = SECTION_FILTER_TABLE_SIZE;
  for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
      disabledFilterIndexesM[i] = SatipConfig.GetDisabledFilters(i);
      disabledFilterNamesM[i] = tr(section_filter_table[i].description);
      }
  SetMenuCategory(mcSetupPlugins);
  Setup();
  SetHelp(trVDR("Button$Scan"), NULL, tr("Button$Devices"), trVDR("Button$Info"));
}
Esempio n. 10
0
bool CServerSession::OnSoftLink( CNcpMessage* pMsg, int nBufSize )
{
    char path_src[MAXPATH], path_lnk[MAXPATH];

    //parse the parameters
    string strSrc = pMsg->GetData();
    string strLnk = pMsg->GetData()+strSrc.size()+1;

    if( IsAbsDir( strSrc.c_str() ) ) {
        strcpy( path_src, strSrc.c_str() );
    } else {
        strcpy( path_src, m_strCurDir.c_str() );
        CatDir( path_src, strSrc.c_str(), path_src, ELEMENTS(path_src) );
    }
    if( IsAbsDir( strLnk.c_str() ) ) {
        strcpy( path_lnk, strLnk.c_str() );
    } else {
        strcpy( path_lnk, m_strCurDir.c_str() );
        CatDir( path_lnk, strLnk.c_str(), path_lnk, ELEMENTS(path_lnk) );
    }

    int nRet = 0;
#ifdef _WIN32
    nRet = E_NOSUPT;
#else
    symlink( path_src, path_lnk );
    nRet = S_OK;
#endif

    //send back the return code.
    pMsg->Init( CM_ACK, nRet );
    pMsg->Send( m_sock );

    return SUCCEEDED(nRet);
}
Esempio n. 11
0
void cSatipPluginSetup::Setup(void)
{
  int current = Current();

  Clear();
  helpM.Clear();

  Add(new cMenuEditStraItem(tr("Operating mode"), &operatingModeM, ELEMENTS(operatingModeTextsM), operatingModeTextsM));
  helpM.Append(tr("Define the used operating mode for all SAT>IP devices:\n\noff - devices are disabled\nlow - devices are working at the lowest priority\nnormal - devices are working within normal parameters\nhigh - devices are working at the highest priority"));

  if (operatingModeM) {
     Add(new cMenuEditBoolItem(tr("Enable CI extension"), &ciExtensionM));
     helpM.Append(tr("Define whether a CI extension shall be used.\n\nThis setting enables integrated CI/CAM handling found in some SAT>IP hardware (e.g. Digital Devices OctopusNet)."));

     for (unsigned int i = 0; ciExtensionM && i < ELEMENTS(cicamsM); ++i) {
         Add(new cMenuEditStraItem(*cString::sprintf(" %s #%d", tr("CI/CAM"), i + 1), &cicamsM[i], ELEMENTS(cicamTextsM), cicamTextsM));
         helpM.Append(tr("Define a desired CAM type for the CI slot.\n\nThe '---' option lets SAT>IP hardware do the auto-selection."));
         }

     Add(new cMenuEditBoolItem(tr("Enable EPG scanning"), &eitScanM));
     helpM.Append(tr("Define whether the EPG background scanning shall be used.\n\nThis setting disables the automatic EIT scanning functionality for all SAT>IP devices."));

     Add(new cMenuEditIntItem(tr("Disabled sources"), &numDisabledSourcesM, 0, MAX_DISABLED_SOURCES_COUNT, tr("none")));
     helpM.Append(tr("Define number of sources to be disabled.\n\nSAT>IP servers might not have all satellite positions available and such sources can be blacklisted here."));

     for (int i = 0; i < numDisabledSourcesM; ++i) {
         Add(new cSatipEditSrcItem(*cString::sprintf(" %s %d", trVDR("Source"), i + 1), &disabledSourcesM[i]));
         helpM.Append(tr("Define a source to be blacklisted."));
         }

     Add(new cMenuEditIntItem(tr("Disabled filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE, tr("none")));
     helpM.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process."));

     for (int i = 0; i < numDisabledFiltersM; ++i) {
         Add(new cMenuEditStraItem(*cString::sprintf(" %s %d", tr("Filter"), i + 1), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM));
         helpM.Append(tr("Define an ill-behaving filter to be blacklisted."));
         }
     }
  Add(new cMenuEditStraItem(tr("Transport mode"), &transportModeM, ELEMENTS(transportModeTextsM), transportModeTextsM));
  helpM.Append(tr("Define which transport mode shall be used.\n\nUnicast, Multicast, RTP-over-TCP"));
  Add(new cOsdItem(tr("Active SAT>IP servers:"), osUnknown, false));
  helpM.Append("");

  detachedModeM = SatipConfig.GetDetachedMode();
  if (!detachedModeM) {
     cSatipServers *servers = cSatipDiscover::GetInstance()->GetServers();
     deviceCountM = servers->Count();
     for (cSatipServer *s = servers->First(); s; s = servers->Next(s)) {
         Add(new cSatipServerItem(s));
         helpM.Append("");
         }
     }

  SetCurrent(Get(current));
  Display();
}
Esempio n. 12
0
static void TermState_Fail(TermState *state)
{
	assert(state->alt_stack_pos>0);
	--state->alt_stack_pos;
	assert(state->alt_stack_pos<(int)ELEMENTS(state->alt_stack));
	state->proc = state->alt_stack[state->alt_stack_pos];
	assert(state->alt_stack_pos<(int)ELEMENTS(state->bufpos_stack));
	state->bufpos = state->bufpos_stack[state->alt_stack_pos];
	assert(state->alt_stack_pos<(int)ELEMENTS(state->cont_stack_pos_stack));
	state->cont_stack_pos = state->cont_stack_pos_stack[state->alt_stack_pos];
}
Esempio n. 13
0
static void TermState_PushAlternative(TermState *state,TermStateProc *proc)
{
	assert(state->alt_stack_pos<(int)ELEMENTS(state->bufpos_stack));
	state->bufpos_stack[state->alt_stack_pos] =
		TermState_PrevBufPos(state,state->bufpos);
	assert(state->alt_stack_pos<(int)ELEMENTS(state->alt_stack));
	state->alt_stack[state->alt_stack_pos] = proc;
	assert(state->alt_stack_pos<(int)ELEMENTS(state->cont_stack_pos_stack));
	state->cont_stack_pos_stack[state->alt_stack_pos] = state->cont_stack_pos;
	++state->alt_stack_pos;
}
Esempio n. 14
0
GShell * new_ronny(GShell *ronny,int Setup)
{
   if (!ronny) ronny = new GShell;
   ronny->Make(ELEMENTS(ronny_points),(Point*) ronny_points,
		ELEMENTS(ronny_faces),ronny_faces);
   if (Setup) {
      ronny->ComputeFaceNormals();
      ronny->ComputeVertexNormals();
      ronny->ComputeBounds();
   }
   return (ronny);
}
Esempio n. 15
0
void MCS_list_registry(MCExecPoint& p_context)
{
	char *t_full_key;
	t_full_key = p_context . getsvalue() . clone();

	p_context . clear();

	char *t_root_key;
	t_root_key = t_full_key;
	
	char *t_child_key;
	t_child_key = strchr(t_full_key, '\\');
	if (t_child_key != NULL)
		*t_child_key++ = '\0';
	else
		t_child_key = NULL;

	uint2 i;
	MCString s = t_root_key;
	for (i = 0 ; i < ELEMENTS(Regkeys) ; i++)
		if (s == Regkeys[i].token)
			break;

	HKEY t_key;
	if (i >= ELEMENTS(Regkeys) || RegOpenKeyExA(Regkeys[i] . key, t_child_key, 0, KEY_READ, &t_key) != ERROR_SUCCESS)
	{
		MCresult -> sets("bad key");
		delete t_full_key;
		return;
	}

	DWORD t_index;
	t_index = 0;
	for(;;)
	{
		LONG t_result;
		char t_name[256];
		DWORD t_name_length;
		t_name_length = 256;
		t_result = RegEnumKeyExA(t_key, t_index, t_name, &t_name_length, NULL, NULL, NULL, NULL);
		if (t_result == ERROR_NO_MORE_ITEMS)
			break;
		p_context . concatchars(t_name, t_name_length, EC_RETURN, t_index == 0);
		t_index += 1;
	}

	RegCloseKey(t_key);
	delete t_full_key;
}
Esempio n. 16
0
bool CServerSession::OnLogOn( CNcpMessage* pMsg, int nBufSize )
{
    char path[MAXPATH];

    //parse parameters
    int nFileMode = pMsg->GetRet();
    string strUser = (char*)pMsg->GetData();
    string strPass = (char*)( pMsg->GetData()+strUser.size()+1 );

    //get home path
#ifdef _WIN32
    GetModuleFileName( NULL, path, ELEMENTS(path) );
    char* p = strrchr( path, '\\' );
    if( p!=NULL )*p = '\0';
#else
    getcwd( path, ELEMENTS(path) );
#endif
    CatDir( path, strUser.c_str(), path, ELEMENTS(path) );	//now path is the current home path.

    //make home directory if necessary
    int nRet = S_OK;
    if( !IsDirExist(path) ) {
        if( MkDir( path )!=0 ) {
            nRet = E_ACCES;
        }
    }
    m_strHomeDir = path;
    m_strCurDir = m_strHomeDir;
    m_nFileMode = nFileMode;

    if( SUCCEEDED(nRet) && !IsDirExist(m_strHomeDir.c_str()) ) {
        nRet = E_NOUSER;
    }
    pMsg->Init( CM_ACK, nRet );
    pMsg->Send( m_sock );

    //switch established
    if( SUCCEEDED(nRet) ) {
        m_state = NCPS_ESTABLISHED;
        if( strcmp( strUser.c_str(), "root" )==0 )m_bRootUsr = true;

        ASSERT( m_pServApp );
        //lock the same user logon from other hosts.
        m_pLocker = m_pServApp->GetSessionLocker( strUser.c_str() );
        m_pLocker->Lock();
    }
    return SUCCEEDED(nRet);
}
Esempio n. 17
0
bool CHostSet::Add( IN_ADDR addrHost, bool bIsAlive )
{
	char buf[MAXLINE];
	//get local host address
	gethostname( buf, ELEMENTS(buf) );
	hostent* phent = gethostbyname( buf );
	IN_ADDR addrloc;
	bcopy( phent->h_addr, &addrloc, sizeof(IN_ADDR) );

	//force not using local host. avoid treat local host as a computation node
	if( !IsUseLocalHost() ){
		if( addrloc.S_un.S_addr==addrHost.S_un.S_addr )return false;
	}

//	CHostObject* pHostObj = new CHostObject( addrHost, this );
//	if( m_trHosts.Search( pHostObj )==NULL ){
	if( m_trHosts.SearchByKey( addrHost )==NULL ){
		CHostObject* pHostObj = new CHostObject( addrHost, this );
		m_trHosts.Insert( pHostObj );

		if( bIsAlive ){
			m_trAliveHosts.Insert( pHostObj );
			ReleaseSemaphore( m_smAlives );
		}else{
			m_trDeadHosts.Insert( pHostObj );
		}
		return true;
	}

//	delete pHostObj;
	return false;
}
Esempio n. 18
0
static void TermState_Continue(TermState *state)
{
	assert(state->cont_stack_pos>0);
	--state->cont_stack_pos;
	assert(state->cont_stack_pos<(int)ELEMENTS(state->cont_stack));
	state->proc = state->cont_stack[state->cont_stack_pos];
}
Esempio n. 19
0
bool CServerSession::OnChMod( CNcpMessage* pMsg, int nBufSize )
{
    char path[MAXPATH];

    //parse the parameters
    int nMode = pMsg->GetRet();
    char* pName = (char*)pMsg->GetData();
    if( IsAbsDir( pName ) ) {
        strcpy( path, pName );
    } else {
        CatDir( m_strCurDir.c_str(), pName, path, ELEMENTS(path) );
    }

    //translate nMode to system independent mode;
    int nSysMode = 0;
    if( IsSet( nMode, 0x400 ) )nSysMode |= S_IREAD;
    if( IsSet( nMode, 0x200 ) )nSysMode |= S_IWRITE;
    if( IsSet( nMode, 0x100 ) )nSysMode |= S_IEXEC;

    int nRet = S_OK;
    if( chmod( path, nSysMode )!=0 ) {
        nRet = E_NOENT;
    }

    pMsg->Init( CM_ACK, nRet );
    //acknowledge the command
    pMsg->Send( m_sock );

    return SUCCEEDED( nRet );
}
/// <summary>Return the list of supported geometry types. For example, if a client wanted to know if a provider supported
/// multi-polygons, it would call GetGeometryTypes and check if the MultiPolygon type was listed.</summary>
/// <param name="length">Output the number of geometry types.</param> 
/// <returns>Returns the list of geometry types</returns> 
FdoGeometryType* SuperMapGeometryCapabilities::GetGeometryTypes (FdoInt32& length)
{
	TRACE(_T("调用 SuperMapGeometryCapabilities::GetGeometryTypes()... \n"));
    static const FdoGeometryType geomTypes[] =
    {
	
        FdoGeometryType_Point,
        FdoGeometryType_LineString,
        FdoGeometryType_Polygon,
        FdoGeometryType_MultiPoint,			
        FdoGeometryType_MultiLineString,	// 支持多点、多线
		FdoGeometryType_MultiPolygon,

		FdoGeometryType_MultiGeometry

		/*shp
		FdoGeometryType_Point,
        FdoGeometryType_LineString,
        FdoGeometryType_Polygon,
        FdoGeometryType_MultiPoint,
        FdoGeometryType_MultiLineString,
		*/
	};

    length = ELEMENTS(geomTypes);
    return ((FdoGeometryType *)geomTypes);
}
Esempio n. 21
0
bool checkCASystem(unsigned int cicamP, int caidP)
{
  // always skip the first row
  if ((cicamP > 0) && (cicamP < ELEMENTS(ca_systems_table)))
     return ((caidP >= ca_systems_table[cicamP].start) && (caidP <= ca_systems_table[cicamP].end));
  return false;
}
Esempio n. 22
0
////////////////////////////////////////////////////////////////////////////////
// funcload()
//
// This function is called to define all function names in the ADS
// function table.  Each named function will be callable from lisp or
// invokable from another ADS application.
//
static int
funcload()
{
    unsigned short i;
    AvErrorCode retval;
    static int sbInitialized = FALSE;

    // AVLIB: we must call av_loadlib() to assure that Render.arx
    // is loaded.
    //
    if (!sbInitialized) {
        retval = av_loadlib();
        if (retval != AvRetNorm) {
            acdbFail("Library initialization failed.\n");
            return RTERROR;
        }
        sbInitialized = TRUE;
    }
    
    // call acedDefun() for each function name 
    // in gFunctionTable

    for (i = 0; i < ELEMENTS(gFunctionTable); i++) {
        if (acedDefun(gFunctionTable[i].name, (short)i) != RTNORM)
            return RTERROR;
    }

    return RTNORM;
}
Esempio n. 23
0
unsigned int cSatipConfig::GetDisabledSourcesCount(void) const
{
  unsigned int n = 0;
  while ((n < ELEMENTS(disabledSourcesM) && (disabledSourcesM[n] != cSource::stNone)))
        n++;
  return n;
}
Esempio n. 24
0
unsigned int cSatipConfig::GetDisabledFiltersCount(void) const
{
  unsigned int n = 0;
  while ((n < ELEMENTS(disabledFiltersM) && (disabledFiltersM[n] != -1)))
        n++;
  return n;
}
Esempio n. 25
0
static void
Init(void)
{
   const char *extensions[3] = {
      "GL_ARB_depth_texture",
      "GL_ARB_texture_cube_map",
      "GL_EXT_framebuffer_object"
   };
   int i;

   for (i = 0; i < ELEMENTS(extensions); i++) {
      if (!glutExtensionSupported(extensions[i])) {
         printf("Sorry, this demo requires %s\n", extensions[i]);
         exit(1);
      }
   }

   glEnable(GL_DEPTH_TEST);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);

   GenerateCylinders();

   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
}
Esempio n. 26
0
/*===========================================================================*
 *				pt_bind			     		     *
 *===========================================================================*/
PUBLIC int pt_bind(pt_t *pt, struct vmproc *who)
{
    int slot, ispt;
    u32_t phys;

    /* Basic sanity checks. */
    vm_assert(who);
    vm_assert(who->vm_flags & VMF_INUSE);
    vm_assert(pt);

    slot = who->vm_slot;
    vm_assert(slot >= 0);
    vm_assert(slot < ELEMENTS(vmproc));
    vm_assert(slot < I386_VM_PT_ENTRIES);

    phys = pt->pt_dir_phys & I386_VM_ADDR_MASK;
    vm_assert(pt->pt_dir_phys == phys);

    /* Update "page directory pagetable." */
    page_directories[slot] = phys | I386_VM_PRESENT|I386_VM_WRITE;

#if 0
    printf("VM: slot %d has pde val 0x%lx\n", slot, page_directories[slot]);
#endif
    /* Tell kernel about new page table root. */
    return sys_vmctl(who->vm_endpoint, VMCTL_I386_SETCR3,
                     pt ? pt->pt_dir_phys : 0);
}
Esempio n. 27
0
GLenum
nameToFactor(string& name) {
	for (unsigned int i = 0; i < ELEMENTS(factorNames); ++i)
		if (factorNames[i].name == name)
			return factorNames[i].token;
	assert(0);
	return GL_ZERO;
} // nameToFactor
Esempio n. 28
0
cSatipConfig::cSatipConfig(void)
: operatingModeM(eOperatingModeLow),
  traceModeM(eTraceModeNormal),
  ciExtensionM(0),
  eitScanM(1),
  useBytesM(1),
  detachedModeM(false),
  disableServerQuirksM(false),
  useSingleModelServersM(false)
{
  for (unsigned int i = 0; i < ELEMENTS(cicamsM); ++i)
      cicamsM[i] = 0;
  for (unsigned int i = 0; i < ELEMENTS(disabledSourcesM); ++i)
      disabledSourcesM[i] = cSource::stNone;
  for (unsigned int i = 0; i < ELEMENTS(disabledFiltersM); ++i)
      disabledFiltersM[i] = -1;
}
Esempio n. 29
0
/* doMenu items
About Hypercard..., New Stack..., Open Stack..., Close Stack, Save A
Copy..., Compact Stack, Protect Stack..., Delete Stack..., Page
Setup..., Print Field..., Print Card, Print Stack..., Print Report...,
Quit Hypercard, Undo, Cut, Copy, Paste, New Card, Delete Card, Cut
Card, Copy Card, Text Style..., Background, Icon..., Back, Home, Help,
recent, First, Prev, Next, Last, Find..., Message, Scroll, Next
Window, Button Info..., Field Info..., Card Info..., Bkgnd Info...,
Stack Info..., Bring Closer, Send Farther, New Button, New Field, New
Background, Plain, Bold, Italic, Underline, Outline, Shadow, Condense,
Extend, Group, Other..., Select, Select All, Fill, Invert, Pickup,
Darken, Lighten, Trace Edges, Rotate Left, Rotate Right, Flip
Vertical, Flip Horizontal, Opaque, Transparent, Keep, Revert, grid,
Fatbits, Power Keys, Line Size..., brush Shape..., Edit pattern...,
Polygon Sides..., Draw filled, Draw centered, Draw multiple, Rotate,
Slant, distort, Perspective, Import Paint..., Export Paint..., New
Icon, Close Icon Editor, Duplicate Icon, Cut Icon, Copy Icon, Erase,
Frame, Gray, Mirror Horizontal, Mirror Vertical, Rotate 90, Shadow,
Delete Report, Cut Report, Copy Report, Report Items..., Report
Name..., New Report, New Item, Item Info..., Close Script, Save
Script, Revert To Saved, Print Script, Find Again, Find Selection,
Scroll To Selection, Replace..., Replace Again, Comment, Uncomment,
Set Checkpoint, Step, Step Into, Trace, Go, Trace Delay..., Abort,
Variable Watcher, Message Watcher
*/
const char *MCDoMenu::lookup(const MCString &s)
{
	uint2 size = ELEMENTS(domenu_table);
	while(size--)
		if (s == domenu_table[size].token)
			return domenu_table[size].command;
	return NULL;
}
Esempio n. 30
0
void PrintNetfEntry( NETF_ENTRY* pentry )
{
	time_t mtime = pentry->fstat.nfs_mtime;
	struct tm* newtime = localtime( &(mtime) );
	char buf[_MAX_LINE];
	strftime( buf, ELEMENTS(buf), "%m/%d/%y %I:%M %p", newtime );
	cout<<buf<<"\t"<<pentry->fname<<"\t"<<pentry->fstat.nfs_size<<endl;
}