当前位置: 首页>>代码示例>>C++>>正文


C++ ELEMENTS函数代码示例

本文整理汇总了C++中ELEMENTS函数的典型用法代码示例。如果您正苦于以下问题:C++ ELEMENTS函数的具体用法?C++ ELEMENTS怎么用?C++ ELEMENTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ELEMENTS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sum_latency

/*
 * 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];
		}
	}
}
开发者ID:DINKIN,项目名称:mongo,代码行数:32,代码来源:track.c

示例2: find_charset_map

/**
 * 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;
}
开发者ID:ShiftMediaProject,项目名称:enca,代码行数:33,代码来源:unicodemap.c

示例3: pt_sanitycheck

/*===========================================================================*
 *				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));
        }
    }
}
开发者ID:michalwojciech,项目名称:cs170s10proj2,代码行数:38,代码来源:pagetable.c

示例4: ASSERT

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;
    }
}
开发者ID:EISALab,项目名称:MIIGAgroundwater,代码行数:27,代码来源:ncpsession.cpp

示例5: smtp_tree_words_conds

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;
}
开发者ID:jwrona,项目名称:protoident,代码行数:35,代码来源:smtp.c

示例6: DoPassive

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();
}
开发者ID:EISALab,项目名称:MIIGAgroundwater,代码行数:60,代码来源:ncpsession.cpp

示例7: secdel

/******************************************************************************
 * 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) */
开发者ID:jeffclough,项目名称:handy,代码行数:38,代码来源:secdel.c

示例8: detachedModeM

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"));
}
开发者ID:paluseb,项目名称:vdr-plugin-satip,代码行数:32,代码来源:setup.c

示例9: strcpy

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);
}
开发者ID:EISALab,项目名称:MIIGAgroundwater,代码行数:35,代码来源:ncpsession.cpp

示例10: Current

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();
}
开发者ID:rofafor,项目名称:vdr-plugin-satip,代码行数:56,代码来源:setup.c

示例11: TermState_Fail

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];
}
开发者ID:wosigh,项目名称:terminal,代码行数:11,代码来源:termstate.c

示例12: TermState_PushAlternative

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;
}
开发者ID:wosigh,项目名称:terminal,代码行数:11,代码来源:termstate.c

示例13: new_ronny

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);
}
开发者ID:deepmatrix,项目名称:blaxxun-cc3d,代码行数:12,代码来源:ronny.cpp

示例14: MCS_list_registry

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;
}
开发者ID:Bjoernke,项目名称:livecode,代码行数:49,代码来源:sysw32registry.cpp

示例15: GetModuleFileName

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);
}
开发者ID:EISALab,项目名称:MIIGAgroundwater,代码行数:48,代码来源:ncpsession.cpp


注:本文中的ELEMENTS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。