• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ require_action函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CCSymmetricKeyWrap

int  
CCSymmetricKeyWrap( CCWrappingAlgorithm algorithm, 
				   const uint8_t *iv, const size_t ivLen,
				   const uint8_t *kek, size_t kekLen,
				   const uint8_t *rawKey, size_t rawKeyLen,
				   uint8_t  *wrappedKey, size_t *wrappedKeyLen)
{
    uint32_t n = rawKeyLen / 8; /* key size in 64 bit blocks */
    uint64_t (*R)[2]; /* R is a two-dimensional array, with n rows of 2 columns */
    int i, j, err;
	
	// allocate R
	R = calloc(n, sizeof(uint64_t[2])); 
    require_action(R, out, err = -1);
    // don't wrap with something smaller
    require_action(rawKeyLen >= kekLen, out, err = -1);
    // kek multiple of 64 bits: 128, 192, 256
    require_action(kekLen == 16 || kekLen == 24 || kekLen == 32, out, err = -1);
    // wrapped_key_len 64 bits larger than key_len
    require_action(wrappedKeyLen && (*wrappedKeyLen >= rawKeyLen + 64/8), out, err = -1);

    // R[0][1] = P[0] ... R[1][n-1] = P[n-1]
    for (i = 0; i < n; i++)
        memcpy(&R[i][1], rawKey + (64/8) * i, (64/8));

	uint64_t kek_iv = pack64(iv, ivLen);
	
    R[0][0] = kek_iv;

    for (j = 0; j < 6; j++) {
        for (i = 0; i < n; i++)
        {
            require_action(aes_operation(true, kek, kekLen, (uint8_t*)&R[i][0]), out, err = -1);
            R[(i + 1) % n][0] = R[i][0] ^ _OSSwapInt64((n*j)+i+1);
        }
    }
	
    // write output
    memcpy(wrappedKey, &R[0][0], 8);
    for (i = 0; i < n; i++)
        memcpy(wrappedKey + 8 + i * 8, &R[i][1], 8);

    err = 0;
out:
    if (R) free(R);
    return err;
}
开发者ID:010001111,项目名称:darling,代码行数:47,代码来源:CommonSymmetricKeywrap.c


示例2: catch

STDMETHODIMP CDNSSD::NATPortMappingCreate(DNSSDFlags flags, ULONG ifIndex, DNSSDAddressFamily addressFamily, DNSSDProtocol protocol, USHORT internalPort, USHORT externalPort, ULONG ttl, INATPortMappingListener *listener, IDNSSDService **service)
{
	CComObject<CDNSSDService>	*	object			= NULL;
	DNSServiceRef					sref			= NULL;
	DNSServiceProtocol				prot			= 0;
	DNSServiceErrorType				err				= 0;
	HRESULT							hr				= 0;

	// Initialize
	*service = NULL;

	try
	{
		object = new CComObject<CDNSSDService>();
	}
	catch ( ... )
	{
		object = NULL;
	}

	require_action( object != NULL, exit, err = kDNSServiceErr_NoMemory );
	hr = object->FinalConstruct();
	require_action( hr == S_OK, exit, err = kDNSServiceErr_Unknown );
	object->AddRef();

	prot = ( addressFamily | protocol );

	err = DNSServiceNATPortMappingCreate( &sref, flags, ifIndex, prot, internalPort, externalPort, ttl, ( DNSServiceNATPortMappingReply ) &NATPortMappingReply, object );
	require_noerr( err, exit );

	object->SetServiceRef( sref );
	object->SetListener( listener );

	err = object->Run();
	require_noerr( err, exit );

	*service = object;

exit:

	if ( err && object )
	{
		object->Release();
	}

	return err;
}
开发者ID:Apple-FOSS-Mirror,项目名称:mDNSResponder,代码行数:47,代码来源:DNSSD.cpp


示例3: ConfigIncommingJsonMessage

OSStatus ConfigIncommingJsonMessage( const char *input, mico_Context_t * const inContext )
{
  OSStatus err = kNoErr;
  json_object *new_obj;
  config_delegate_log_trace();

  new_obj = json_tokener_parse(input);
  require_action(new_obj, exit, err = kUnknownErr);
  config_delegate_log("Recv config object=%s", json_object_to_json_string(new_obj));
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  json_object_object_foreach(new_obj, key, val) {
    if(!strcmp(key, "Device Name")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.name, json_object_get_string(val), maxNameLen);
    }else if(!strcmp(key, "RF power save")){
      inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable = json_object_get_boolean(val);
    }else if(!strcmp(key, "MCU power save")){
      inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable = json_object_get_boolean(val);
    }else if(!strcmp(key, "Bonjour")){
      inContext->flashContentInRam.micoSystemConfig.bonjourEnable = json_object_get_boolean(val);
    }else if(!strcmp(key, "Wi-Fi")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.ssid, json_object_get_string(val), maxSsidLen);
      inContext->flashContentInRam.micoSystemConfig.channel = 0;
      memset(inContext->flashContentInRam.micoSystemConfig.bssid, 0x0, 6);
      inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO;
      memcpy(inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.user_key, maxKeyLen);
      inContext->flashContentInRam.micoSystemConfig.keyLength = inContext->flashContentInRam.micoSystemConfig.user_keyLength;
    }else if(!strcmp(key, "Password")){
      inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO;
      strncpy(inContext->flashContentInRam.micoSystemConfig.key, json_object_get_string(val), maxKeyLen);
      strncpy(inContext->flashContentInRam.micoSystemConfig.user_key, json_object_get_string(val), maxKeyLen);
      inContext->flashContentInRam.micoSystemConfig.keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key);
      inContext->flashContentInRam.micoSystemConfig.user_keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key);
    }else if(!strcmp(key, "DHCP")){
      inContext->flashContentInRam.micoSystemConfig.dhcpEnable   = json_object_get_boolean(val);
    }else if(!strcmp(key, "IP address")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.localIp, json_object_get_string(val), maxIpLen);
    }else if(!strcmp(key, "Net Mask")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.netMask, json_object_get_string(val), maxIpLen);
    }else if(!strcmp(key, "Gateway")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.gateWay, json_object_get_string(val), maxIpLen);
    }else if(!strcmp(key, "DNS Server")){
      strncpy(inContext->flashContentInRam.micoSystemConfig.dnsServer, json_object_get_string(val), maxIpLen);   
    }/*else if(!strcmp(key, "Baurdrate")){
      inContext->flashContentInRam.appConfig.fogcloudConfig.USART_BaudRate = json_object_get_int(val);
    } */else if(!strcmp(key, "loginId")){
      strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.loginId, json_object_get_string(val), MAX_SIZE_LOGIN_ID); 
    } else if(!strcmp(key, "devpasswd")){
      strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.devPasswd, json_object_get_string(val), MAX_SIZE_DEV_PASSWD); 
    } else if(!strcmp(key, "userToken")){
      strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.userToken, json_object_get_string(val), MAX_SIZE_USER_TOKEN); 
    }else{
    }
  }
  json_object_put(new_obj);
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);

exit:
  return err; 
}
开发者ID:hujg,项目名称:mico_v2.2.0,代码行数:59,代码来源:MICOConfigDelegate.c


示例4: DNSServiceDomainEnumerationCreate

dns_service_discovery_ref
	DNSServiceDomainEnumerationCreate(
		int 								inRegistrationDomains,
		DNSServiceDomainEnumerationReply	inCallBack,
		void *								inContext )
{
	DNSStatus						err;
	dns_service_discovery_ref		result;
	dns_service_discovery_ref		obj;
	DNSBrowserRef					browser;
	DNSBrowserFlags					flags;
	
	result 	= NULL;
	browser	= NULL;
	
	// Allocate and initialize the object.
	
	obj = (dns_service_discovery_ref) malloc( sizeof( *obj ) );
	require_action( obj, exit, err = kDNSNoMemoryErr );
	
	obj->type 		= kDNSServiceDiscoveryObjectTypeDomainEnumeration;
	obj->ref 		= NULL;
	obj->callback	= inCallBack;
	obj->context	= inContext;
	
	// Create the underlying browser and start searching for domains.
	
	err = DNSBrowserCreate( 0, DNSServiceDomainEnumerationPrivateCallBack, obj, &browser );
	require_noerr( err, exit ); 
	obj->ref = browser;
	
	if( inRegistrationDomains )
	{
		flags = kDNSBrowserFlagRegistrationDomainsOnly;
	}
	else
	{
		flags = 0;
	}
	err = DNSBrowserStartDomainSearch( browser, flags );
	require_noerr( err, exit ); 
		
	// Success!
	
	result		= obj;
	browser		= NULL;
	obj			= NULL;
	
exit:
	if( browser )
	{
		DNSBrowserRelease( browser, 0 );
	}
	if( obj )
	{
		DNSServiceDiscoveryDeallocate( obj );
	}
	return( result );
}
开发者ID:pjjw,项目名称:iTunes-qsplugin,代码行数:59,代码来源:DNSServiceDiscovery.c


示例5: MICOInitNotificationCenter

OSStatus MICOInitNotificationCenter  ( void * const inContext )
{
  OSStatus err = kNoErr;
  require_action(inContext, exit, err = kParamErr);
  _Context = inContext;
exit:
  return err;
}
开发者ID:MrZANE42,项目名称:WiFiMCU,代码行数:8,代码来源:MICONotificationCenter.c


示例6: application_start

int application_start(void)
{
  app_log_trace();
  OSStatus err = kNoErr;
  mico_uart_config_t uart_config;
  app_context_t* app_context;
  mico_Context_t* mico_context;

  /* Create application context */
  app_context = ( app_context_t *)calloc(1, sizeof(app_context_t) );
  require_action( app_context, exit, err = kNoMemoryErr );

  /* Create mico system context and read application's config data from flash */
  mico_context = mico_system_context_init( sizeof( application_config_t) );
  app_context->appConfig = mico_system_context_get_user_data( mico_context );

  /* mico system initialize */
  err = mico_system_init( mico_context );
  require_noerr( err, exit );
  
  /* Initialize service dsicovery */
  err = MICOStartBonjourService( Station, app_context );
  require_noerr( err, exit );

  /* Protocol initialize */
  sppProtocolInit( app_context );

  /*UART receive thread*/
  uart_config.baud_rate    = app_context->appConfig->USART_BaudRate;
  uart_config.data_width   = DATA_WIDTH_8BIT;
  uart_config.parity       = NO_PARITY;
  uart_config.stop_bits    = STOP_BITS_1;
  uart_config.flow_control = FLOW_CONTROL_DISABLED;
  if(mico_context->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable == true)
    uart_config.flags = UART_WAKEUP_ENABLE;
  else
    uart_config.flags = UART_WAKEUP_DISABLE;
  ring_buffer_init  ( (ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, UART_BUFFER_LENGTH );
  MicoUartInitialize( UART_FOR_APP, &uart_config, (ring_buffer_t *)&rx_buffer );
  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART Recv", uartRecv_thread, STACK_SIZE_UART_RECV_THREAD, (void*)app_context );
  require_noerr_action( err, exit, app_log("ERROR: Unable to start the uart recv thread.") );

 /* Local TCP server thread */
 if(app_context->appConfig->localServerEnable == true){
   err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Server", localTcpServer_thread, STACK_SIZE_LOCAL_TCP_SERVER_THREAD, (void*)app_context );
   require_noerr_action( err, exit, app_log("ERROR: Unable to start the local server thread.") );
 }

  /* Remote TCP client thread */
 if(app_context->appConfig->remoteServerEnable == true){
   err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Remote Client", remoteTcpClient_thread, STACK_SIZE_REMOTE_TCP_CLIENT_THREAD, (void*)app_context );
   require_noerr_action( err, exit, app_log("ERROR: Unable to start the remote client thread.") );
 }

exit:
  mico_rtos_delete_thread(NULL);
  return err;
}
开发者ID:SergeyPopovGit,项目名称:MICO,代码行数:58,代码来源:MICOAppEntrance.c


示例7: InstallNSP

OSStatus	InstallNSP( const char *inName, const char *inGUID, const char *inPath )
{
	OSStatus		err;
	size_t			size;
	WSADATA			wsd;
	WCHAR			name[ 256 ];
	GUID			guid;
	WCHAR			path[ MAX_PATH ];
	
	require_action( inName && ( *inName != '\0' ), exit, err = kParamErr );
	require_action( inGUID && ( *inGUID != '\0' ), exit, err = kParamErr );
	require_action( inPath && ( *inPath != '\0' ), exit, err = kParamErr );
	
	size = strlen( inName );
	require_action( size < sizeof_array( name ), exit, err = kSizeErr );
	CharToWCharString( inName, name );
	
	err = StringToGUID( inGUID, &guid );
	require_noerr( err, exit );
	
	size = strlen( inPath );
	require_action( size < sizeof_array( path ), exit, err = kSizeErr );
	CharToWCharString( inPath, path );
	
	err = WSAStartup( MAKEWORD( 2, 2 ), &wsd );
	err = translate_errno( err == 0, errno_compat(), WSAEINVAL );
	require_noerr( err, exit );
	
	err = WSCInstallNameSpace( name, path, NS_DNS, 1, &guid );
	err = translate_errno( err == 0, errno_compat(), WSAEINVAL );
	WSACleanup();
	require_noerr( err, exit );
	
	if (!gToolQuietMode)
	{
		fprintf( stderr, "Installed NSP \"%s\" (%s) at %s\n", inName, inGUID, inPath );
	}
	
exit:
	if( err != kNoErr )
	{
		fprintf( stderr, "### FAILED (%d) to install \"%s\" (%s) Name Space Provider at %s\n", err, inName, inGUID, inPath );
	}
	return( err );
}
开发者ID:Paxxi,项目名称:mDNSResponder,代码行数:45,代码来源:NSPTool.c


示例8: homeKitListener_thread

void homeKitListener_thread(void *inContext)
{
  ha_log_trace();
  OSStatus err = kUnknownErr;
  int j;
  Context = inContext;
  struct sockaddr_t addr;
  int sockaddr_t_size;
  fd_set readfds;
  char ip_address[16];
  
  int homeKitlistener_fd = -1;
  //HKSetPassword (password, strlen(password));
  HKSetVerifier(verifier, sizeof(verifier), salt, sizeof(salt));

  Context->appStatus.haPairSetupRunning = false;
  HKCharacteristicInit(inContext);
  /*Establish a TCP server fd that accept the tcp clients connections*/ 
  homeKitlistener_fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
  require_action(IsValidSocket( homeKitlistener_fd ), exit, err = kNoResourcesErr );
  addr.s_ip = INADDR_ANY;
  addr.s_port = HA_SERVER_PORT;
  err = bind(homeKitlistener_fd, &addr, sizeof(addr));
  require_noerr( err, exit );

  err = listen(homeKitlistener_fd, 0);
  require_noerr( err, exit );

  ha_log("HomeKit Server established at port: %d, fd: %d", HA_SERVER_PORT, homeKitlistener_fd);
  
  while(1){
    FD_ZERO(&readfds);
    FD_SET(homeKitlistener_fd, &readfds);
    select(1, &readfds, NULL, NULL, NULL);

    /*Check tcp connection requests */
    if(FD_ISSET(homeKitlistener_fd, &readfds)){
      sockaddr_t_size = sizeof(struct sockaddr_t);
      j = accept(homeKitlistener_fd, &addr, &sockaddr_t_size);
      if (j > 0) {
        inet_ntoa(ip_address, addr.s_ip );
        ha_log("HomeKit Client %s:%d connected, fd: %d", ip_address, addr.s_port, j);
        ha_log("memory>>>>>>>>: %d", mico_memory_info()->free_memory);
        err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "HomeKit Client", homeKitClient_thread, 0x1000, &j);  
        if(err != kNoErr){
          ha_log("HomeKit Client for fd %d create failed", j);
          SocketClose(&j);
        }
      }
    }
   }

exit:
    ha_log("Exit: HomeKit Server exit with err = %d", err);
    mico_rtos_delete_thread(NULL);
    return;
}
开发者ID:hujg,项目名称:mico_v2.2.0,代码行数:57,代码来源:HomeKitServer.c


示例9: requestqueue_enqueue_download

int requestqueue_enqueue_download(struct node_entry *node, struct ReadStreamRec *readStreamRecPtr)
{
	int error, error2;
	webdav_requestqueue_element_t * request_element_ptr;
	pthread_t request_thread;

	error = pthread_mutex_lock(&requests_lock);
	require_noerr_action(error, pthread_mutex_lock, webdav_kill(-1));

	request_element_ptr = malloc(sizeof(webdav_requestqueue_element_t));
	require_action(request_element_ptr != NULL, malloc_request_element_ptr, error = EIO);

	request_element_ptr->type = WEBDAV_DOWNLOAD_TYPE;
	request_element_ptr->element.download.node = node;
	request_element_ptr->element.download.readStreamRecPtr = readStreamRecPtr;
	
	/* Insert downloads at head of request queue. They must be executed immediately since the download is holding a stream reference. */
	request_element_ptr->next = waiting_requests.item_head;
	++(waiting_requests.request_count);

	if ( waiting_requests.item_head == NULL ) {
		/* request queue was empty */
		waiting_requests.item_head = waiting_requests.item_tail = request_element_ptr;
	}
	else {
		/* this request is the new head */
		waiting_requests.item_head = request_element_ptr;
	}

	if (gIdleThreadCount > 0) {
		/* Already have one or more threads just waiting for work to do.  Just kick the requests_condvar to wake 
		up the threads */
		error = pthread_cond_signal(&requests_condvar);
		require_noerr(error, pthread_cond_signal);
	}
	else {
		/* No idle threads, so try to create one if we have not reached out maximum number of threads */
		if (gCurrThreadCount < WEBDAV_REQUEST_THREADS) {
			error = pthread_create(&request_thread, &gRequest_thread_attr, (void *) handle_request_thread, (void *) NULL);
			require_noerr(error, pthread_create_signal);

			gCurrThreadCount += 1;
		}
	}

pthread_create_signal:
pthread_cond_signal:
malloc_request_element_ptr:

	error2 = pthread_mutex_unlock(&requests_lock);
	require_noerr_action(error2, pthread_mutex_unlock, error = (error == 0) ? error2 : error; webdav_kill(-1));

pthread_mutex_unlock:
pthread_mutex_lock:

	return (error);
}
开发者ID:aosm,项目名称:webdavfs,代码行数:57,代码来源:webdav_requestqueue.c


示例10: kxld_vtable_init

kern_return_t 
kxld_vtable_init(KXLDVTable *vtable, const KXLDSym *vtable_sym, 
    const KXLDObject *object, const KXLDDict *defined_cxx_symbols)
{
    kern_return_t rval = KERN_FAILURE;
    const KXLDArray *extrelocs = NULL;
    const KXLDRelocator *relocator = NULL;
    const KXLDSect *vtable_sect = NULL;
    char *demangled_name = NULL;
    size_t demangled_length = 0;

    check(vtable);
    check(vtable_sym);
    check(object);

    relocator = kxld_object_get_relocator(object);

    vtable_sect = kxld_object_get_section_by_index(object, 
        vtable_sym->sectnum);
    require_action(vtable_sect, finish, rval=KERN_FAILURE);

    vtable->name = vtable_sym->name;
    vtable->vtable = vtable_sect->data + 
        kxld_sym_get_section_offset(vtable_sym, vtable_sect);

    if (kxld_object_is_linked(object)) {
        rval = init_by_entries(vtable, relocator, defined_cxx_symbols);
        require_noerr(rval, finish);

        vtable->is_patched = TRUE;
    } else {
        if (kxld_object_is_final_image(object)) {
            extrelocs = kxld_object_get_extrelocs(object);
            require_action(extrelocs, finish,
                rval=KERN_FAILURE;
                kxld_log(kKxldLogPatching, kKxldLogErr, 
                    kKxldLogMalformedVTable, 
                    kxld_demangle(vtable->name, 
                        &demangled_name, &demangled_length)));

            rval = init_by_entries_and_relocs(vtable, vtable_sym, 
                relocator, extrelocs, defined_cxx_symbols);
            require_noerr(rval, finish);
        } else {
            require_action(kxld_sect_get_num_relocs(vtable_sect) > 0, finish,
                rval=KERN_FAILURE;
                kxld_log(kKxldLogPatching, kKxldLogErr, 
                    kKxldLogMalformedVTable, 
                    kxld_demangle(vtable->name, 
                        &demangled_name, &demangled_length)));

            rval = init_by_relocs(vtable, vtable_sym, vtable_sect, relocator);
            require_noerr(rval, finish);
        }
        
        vtable->is_patched = FALSE;
    }
开发者ID:Prajna,项目名称:xnu,代码行数:57,代码来源:kxld_vtable.c


示例11: CMSDecoderCopySignerTimestampCertificates

/*
 * Obtain an array of the certificates in a timestamp response. Elements of the
 * returned array are SecCertificateRefs. The caller must CFRelease the returned
 * array. This timestamp is an authenticated timestamp provided by
 * a timestamping authority.
 *
 * Returns errSecParam if the CMS message was not signed or if signerIndex
 * is greater than the number of signers of the message minus one. It returns
 * errSecItemNotFound if no certificates were found.
 *
 * This cannot be called until after CMSDecoderFinalizeMessage() is called. 
 */
OSStatus CMSDecoderCopySignerTimestampCertificates(
                                                   CMSDecoderRef		cmsDecoder,
                                                   size_t				signerIndex,            /* usually 0 */
                                                   CFArrayRef          *certificateRefs)       /* RETURNED */
{
    OSStatus status = errSecParam;
	SecCmsMessageRef cmsg = NULL;
	SecCmsSignedDataRef signedData = NULL;
    int numContentInfos = 0;
    CFIndex tsn = 0;
    bool good = false;
    
    require(cmsDecoder && certificateRefs, xit);
	require_noerr(CMSDecoderGetCmsMessage(cmsDecoder, &cmsg), xit);
    numContentInfos = SecCmsMessageContentLevelCount(cmsg);
    for (int dex = 0; !signedData && dex < numContentInfos; dex++)
    {
        SecCmsContentInfoRef ci = SecCmsMessageContentLevel(cmsg, dex);
        SECOidTag tag = SecCmsContentInfoGetContentTypeTag(ci);
        if (tag == SEC_OID_PKCS7_SIGNED_DATA)
            if ((signedData = SecCmsSignedDataRef(SecCmsContentInfoGetContent(ci))))
                if (SecCmsSignerInfoRef signerInfo = SecCmsSignedDataGetSignerInfo(signedData, (int)signerIndex))
                {
                    CFArrayRef certList = SecCmsSignerInfoGetTimestampCertList(signerInfo);
                    require_action(certList, xit, status = errSecItemNotFound);
                    CFMutableArrayRef certs = CFArrayCreateMutableCopy(kCFAllocatorDefault, CFArrayGetCount(certList), certList);
                    
                    if(certs){
                        //reorder certificates:
                        tsn = CFArrayGetCount(certs);
                        good = tsn > 0 && Security::CodeSigning::isAppleCA(SecCertificateRef(CFArrayGetValueAtIndex(certs, tsn-1)));
                        
                        if ( good == false )
                        {
                            //change TS certificate ordering.
                            for (CFIndex n = 0; n < tsn; n++)
                            {
                                if (SecCertificateRef tsRoot = SecCertificateRef(CFArrayGetValueAtIndex(certs, n)))
                                    if ((good = Security::CodeSigning::isAppleCA(tsRoot))) {
                                        CFArrayExchangeValuesAtIndices(certs, n, tsn-1);
                                        break;
                                    }
                            }
                        }
                        
                        *certificateRefs = CFArrayCreateCopy(kCFAllocatorDefault, certs);
                        CFRelease(certs);
                        status = errSecSuccess;
                    }
                    break;
                }
    }
    
    
    xit:
        return status;
    }
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:69,代码来源:CMSDecoder.cpp


示例12: requestqueue_enqueue_server_ping

int requestqueue_enqueue_server_ping(u_int32_t delay)
{
	int error, error2;
	webdav_requestqueue_element_t * request_element_ptr;
	pthread_t request_thread;

	error = pthread_mutex_lock(&requests_lock);
	require_noerr_action(error, pthread_mutex_lock, webdav_kill(-1));

	request_element_ptr = malloc(sizeof(webdav_requestqueue_element_t));
	require_action(request_element_ptr != NULL, malloc_request_element_ptr, error = EIO);

	request_element_ptr->type = WEBDAV_SERVER_PING_TYPE;
	request_element_ptr->element.serverping.delay = delay;
	
	/* Insert server pings at head of request queue. They must be executed immediately since they are */
	/* used to detect when connectivity to the host has been restored. */
	request_element_ptr->next = waiting_requests.item_head;
	++(waiting_requests.request_count);

	if ( waiting_requests.item_head == NULL ) {
		/* request queue was empty */
		waiting_requests.item_head = waiting_requests.item_tail = request_element_ptr;
	}
	else {
		/* this request is the new head */
		waiting_requests.item_head = request_element_ptr;
	}

	if (gIdleThreadCount > 0) {
		/* Already have one or more threads just waiting for work to do.  Just kick the requests_condvar to wake 
		up the threads */
		error = pthread_cond_signal(&requests_condvar);
		require_noerr(error, pthread_cond_signal);
	}
	else {
		/* No idle threads, so try to create one if we have not reached out maximum number of threads */
		if (gCurrThreadCount < WEBDAV_REQUEST_THREADS) {
			error = pthread_create(&request_thread, &gRequest_thread_attr, (void *) handle_request_thread, (void *) NULL);
			require_noerr(error, pthread_create_signal);

			gCurrThreadCount += 1;
		}
	}

pthread_create_signal:
pthread_cond_signal:
malloc_request_element_ptr:

	error2 = pthread_mutex_unlock(&requests_lock);
	require_noerr_action(error2, pthread_mutex_unlock, error = (error == 0) ? error2 : error; webdav_kill(-1));

pthread_mutex_unlock:
pthread_mutex_lock:

	return (error);
}
开发者ID:aosm,项目名称:webdavfs,代码行数:57,代码来源:webdav_requestqueue.c


示例13: curve25519_test

OSStatus	curve25519_test( int print )
{
	OSStatus			err;
	uint8_t				e[ 32 ], k[ 32 ], ek[ 32 ], ek2[ 32 ];
	size_t				i, j, len;
	CFAbsoluteTime		t = 0;
	
	for( i = 0; i < countof( kCurve25519TestVectors ); ++i )
	{
		const curve25519_test_vector * const 	tv = &kCurve25519TestVectors[ i ];
		
		err = HexToData( tv->e, kSizeCString, kHexToData_NoFlags, e, sizeof( e ), &len, NULL, NULL );
		require_noerr( err, exit );
		require_action( len == 32, exit, err = kSizeErr );
		
		err = HexToData( tv->k, kSizeCString, kHexToData_NoFlags, k, sizeof( k ), &len, NULL, NULL );
		require_noerr( err, exit );
		require_action( len == 32, exit, err = kSizeErr );
		
		err = HexToData( tv->ek, kSizeCString, kHexToData_NoFlags, ek, sizeof( ek ), &len, NULL, NULL );
		require_noerr( err, exit );
		require_action( len == 32, exit, err = kSizeErr );
		
		memset( ek2, 0, sizeof( ek2 ) );
		curve25519_donna( ek2, e, k );
		require_action( memcmp( ek, ek2, 32 ) == 0, exit, err = kMismatchErr );
		
		if( print )
		{
			for( j = 0; j < 32; ++j ) printf( "%02x", e[ j ] );  printf( " " );
			for( j = 0; j < 32; ++j ) printf( "%02x", k[ j ] );  printf( " " );
			for( j = 0; j < 32; ++j ) printf( "%02x", ek[ j ] ); printf( "\n" );
		}
	}
	
	t = CFAbsoluteTimeGetCurrent();
	err = curve25519_djb_test( print );
	require_noerr( err, exit );
	t = CFAbsoluteTimeGetCurrent() - t;
	
exit:
	FPrintF( stdout, "%###s: %s (%f seconds)\n", __ROUTINE__, !err ? "PASSED" : "FAILED", t );
	return( err );
}
开发者ID:bangkr,项目名称:MiCO_ELink407,代码行数:44,代码来源:curve25519-donna-test.c


示例14: tcp_client_thread

void tcp_client_thread(void *arg)
{
  OSStatus err = kNoErr;
  int fd = (int)arg;
  int len = 0;
  fd_set readfds;
  char *buf = NULL; 
  struct timeval_t t;
  
  buf=(char*)malloc(1024);
  require_action(buf, exit, err = kNoMemoryErr); 
  
  t.tv_sec = 5;
  t.tv_usec = 0;
  
  while(1)
  {
    FD_ZERO(&readfds);
    FD_SET(fd, &readfds);
    
    require_action( select(1, &readfds, NULL, NULL, &t) >= 0, exit, err = kConnectionErr );
    
    if( FD_ISSET( fd, &readfds ) ) /*one client has data*/
    {
      len = recv( fd, buf, 1024, 0 );
      require_action( len >= 0, exit, err = kConnectionErr );
      
      if( len == 0){
        tcp_server_log( "TCP Client is disconnected, fd: %d", fd );
        goto exit;
      }  
      
      tcp_server_log("fd: %d, recv data %d from client", fd, len);
      len = send( fd, buf, len, 0 );
      tcp_server_log("fd: %d, send data %d to client", fd, len);
    }
  }
exit:
  if( err != kNoErr ) tcp_server_log( "TCP client thread exit with err: %d", err );
  if( buf != NULL ) free( buf );
  SocketClose( &fd );
  mico_rtos_delete_thread( NULL );
}
开发者ID:robbie-cao,项目名称:MiCO,代码行数:43,代码来源:tcp_server.c


示例15: MFiSAP_Create

OSStatus    MFiSAP_Create( MFiSAPRef *outRef, uint8_t inVersion )
{
    OSStatus        err;
    MFiSAPRef       obj;
    
    require_action( inVersion == kMFiSAPVersion1, exit, err = kVersionErr );
    
    obj = (MFiSAPRef) calloc( 1, sizeof( *obj ) );
    require_action( obj, exit, err = kNoMemoryErr );
    
    obj->state   = kMFiSAPState_Init;
    obj->version = inVersion;
    
    *outRef = obj;
    err = kNoErr;
    
exit:
    return( err );
}
开发者ID:Vampireyifeng,项目名称:MICO,代码行数:19,代码来源:MFiSAPServer.c


示例16: localTcpServer_thread

void localTcpServer_thread(void *inContext)
{
  server_log_trace();
  OSStatus err = kUnknownErr;
  int i, j;
  Context = inContext;
  struct sockaddr_t addr;
  int sockaddr_t_size;
  fd_set readfds;
  char ip_address[16];
  
  int localTcpListener_fd = -1;

  for(i=0; i < MAX_Local_Client_Num; i++) 
    Context->appStatus.loopBack_PortList[i] = 0;

  /*Establish a TCP server fd that accept the tcp clients connections*/ 
  localTcpListener_fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
  require_action(IsValidSocket( localTcpListener_fd ), exit, err = kNoResourcesErr );
  addr.s_ip = INADDR_ANY;
  addr.s_port = Context->flashContentInRam.appConfig.localServerPort;
  err = bind(localTcpListener_fd, &addr, sizeof(addr));
  require_noerr( err, exit );

  err = listen(localTcpListener_fd, 0);
  require_noerr( err, exit );

  server_log("Server established at port: %d, fd: %d", Context->flashContentInRam.appConfig.localServerPort, localTcpListener_fd);

  FD_ZERO(&readfds);
  FD_SET(localTcpListener_fd, &readfds);  
  
  while(1){
    
    select(1, &readfds, NULL, NULL, NULL);

    /*Check tcp connection requests */
    if(FD_ISSET(localTcpListener_fd, &readfds)){
      sockaddr_t_size = sizeof(struct sockaddr_t);
      j = accept(localTcpListener_fd, &addr, &sockaddr_t_size);
      if (j > 0) {
        inet_ntoa(ip_address, addr.s_ip );
        server_log("Client %s:%d connected, fd: %d", ip_address, addr.s_port, j);

        if(kNoErr != mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Clients", localTcpClient_thread, 0x500, &j) ) 
          SocketClose(&j);
      }
    }
   }

exit:
    server_log("Exit: Local controller exit with err = %d", err);
    mico_rtos_delete_thread(NULL);
    return;
}
开发者ID:1220749046,项目名称:MICO,代码行数:55,代码来源:LocalTcpServer.c


示例17: platform_uart_receive_bytes

OSStatus platform_uart_receive_bytes( platform_uart_driver_t* driver, uint8_t* data_in, uint32_t expected_data_size, uint32_t timeout_ms )
{
  OSStatus err = kNoErr;

  platform_mcu_powersave_disable();

  require_action_quiet( ( driver != NULL ) && ( data_in != NULL ) && ( expected_data_size != 0 ), exit, err = kParamErr);
  require_action_quiet( driver->rx_ring_buffer != NULL , exit, err = kUnsupportedErr);

  while ( expected_data_size != 0 )
  {
    uint32_t transfer_size = MIN(driver->rx_ring_buffer->size / 2, expected_data_size);

    /* Check if ring buffer already contains the required amount of data. */
    if ( transfer_size > ring_buffer_used_space( driver->rx_ring_buffer ) )
    {
      /* Set rx_size and wait in rx_complete semaphore until data reaches rx_size or timeout occurs */
      driver->rx_size = transfer_size;

      if ( mico_rtos_get_semaphore( &driver->rx_complete, timeout_ms ) != kNoErr )
      {
        driver->rx_size = 0;
        err = kTimeoutErr;
        goto exit;
      }

      /* Reset rx_size to prevent semaphore being set while nothing waits for the data */
      driver->rx_size = 0;
    }

    expected_data_size -= transfer_size;

    // Grab data from the buffer
    do
    {
      uint8_t* available_data;
      uint32_t bytes_available;

      ring_buffer_get_data( driver->rx_ring_buffer, &available_data, &bytes_available );
      bytes_available = MIN( bytes_available, transfer_size );
      memcpy( data_in, available_data, bytes_available );
      transfer_size -= bytes_available;
      data_in = ( (uint8_t*)data_in + bytes_available );
      ring_buffer_consume( driver->rx_ring_buffer, bytes_available );
    }
    while ( transfer_size != 0 );
  }

  require_action( expected_data_size == 0, exit, err = kReadErr);

exit:
  platform_mcu_powersave_enable();
  return err;

}
开发者ID:gjw09043108,项目名称:MICO,代码行数:55,代码来源:platform_uart.c


示例18: requestqueue_enqueue_seqwrite_manager

int requestqueue_enqueue_seqwrite_manager(struct stream_put_ctx *ctx)
{
	int error, error2;
	webdav_requestqueue_element_t * request_element_ptr;
	pthread_t request_thread;

	error = pthread_mutex_lock(&requests_lock);
	require_noerr_action(error, pthread_mutex_lock, webdav_kill(-1));

	request_element_ptr = malloc(sizeof(webdav_requestqueue_element_t));
	require_action(request_element_ptr != NULL, malloc_request_element_ptr, error = EIO);

	request_element_ptr->type = WEBDAV_SEQWRITE_MANAGER_TYPE;
	request_element_ptr->element.seqwrite_read_rsp.ctx = ctx;
	
	request_element_ptr->next = waiting_requests.item_head;
	++(waiting_requests.request_count);

	if ( waiting_requests.item_head == NULL ) {
		/* request queue was empty */
		waiting_requests.item_head = waiting_requests.item_tail = request_element_ptr;
	}
	else {
		/* this request is the new head */
		waiting_requests.item_head = request_element_ptr;
	}

	if (gIdleThreadCount > 0) {
		/* Already have one or more threads just waiting for work to do.  Just kick the requests_condvar to wake 
		up the threads */
		error = pthread_cond_signal(&requests_condvar);
		require_noerr(error, pthread_cond_signal);
	}
	else {
		/* No idle threads, so try to create one if we have not reached out maximum number of threads */
		if (gCurrThreadCount < WEBDAV_REQUEST_THREADS) {
			error = pthread_create(&request_thread, &gRequest_thread_attr, (void *) handle_request_thread, (void *) NULL);
			require_noerr(error, pthread_create_signal);

			gCurrThreadCount += 1;
		}
	}

pthread_create_signal:
pthread_cond_signal:
malloc_request_element_ptr:

	error2 = pthread_mutex_unlock(&requests_lock);
	require_noerr_action(error2, pthread_mutex_unlock, error = (error == 0) ? error2 : error; webdav_kill(-1));

pthread_mutex_unlock:
pthread_mutex_lock:

	return (error);
}
开发者ID:aosm,项目名称:webdavfs,代码行数:55,代码来源:webdav_requestqueue.c


示例19: require_action

void DNSSD_API
CDNSSD::NATPortMappingReply
    (
    DNSServiceRef                    sdRef,
    DNSServiceFlags                  flags,
    uint32_t                         ifIndex,
    DNSServiceErrorType              errorCode,
    uint32_t                         externalAddress,   /* four byte IPv4 address in network byte order */
    DNSServiceProtocol               protocol,
    uint16_t                         internalPort,
    uint16_t                         externalPort,      /* may be different than the requested port     */
    uint32_t                         ttl,               /* may be different than the requested ttl      */
    void                             *context
    )
{
	CComObject<CDNSSDService> * service;
	int err;
	
	service = ( CComObject< CDNSSDService>* ) context;
	require_action( service, exit, err = kDNSServiceErr_Unknown );

	if ( !service->Stopped() )
	{
		INATPortMappingListener * listener;

		listener = ( INATPortMappingListener* ) service->GetListener();
		require_action( listener, exit, err = kDNSServiceErr_Unknown );

		if ( !errorCode )
		{
			listener->MappingCreated( service, ( DNSSDFlags ) flags, ifIndex, externalAddress, ( DNSSDAddressFamily ) ( protocol & 0x8 ), ( DNSSDProtocol ) ( protocol & 0x80 ), internalPort, externalPort, ttl  );
		}
		else
		{
			listener->MappingFailed( service, ( DNSSDError ) errorCode );
		}
	}

exit:

	return;
}
开发者ID:Apple-FOSS-Mirror,项目名称:mDNSResponder,代码行数:42,代码来源:DNSSD.cpp


示例20: plugtest_obs_handler

smcp_status_t
plugtest_obs_handler(
	struct plugtest_server_s *self
) {
	smcp_status_t ret = SMCP_STATUS_NOT_ALLOWED;
	smcp_method_t method = smcp_inbound_get_code();

	if(method==COAP_METHOD_GET) {
		char* content = NULL;
		coap_size_t max_len = 0;

		ret = smcp_outbound_begin_response(COAP_RESULT_205_CONTENT);
		require_noerr(ret, bail);

		ret = smcp_outbound_add_option_uint(COAP_OPTION_CONTENT_TYPE, COAP_CONTENT_TYPE_TEXT_PLAIN);
		require_noerr(ret, bail);

		if(!smcp_timer_is_scheduled(smcp_get_current_instance(), &self->obs_timer))
			plugtest_obs_timer_callback(smcp_get_current_instance(),self);

		ret = smcp_observable_update(&self->observable,PLUGTEST_OBS_KEY);
		check_noerr(ret);

		ret = smcp_outbound_add_option_uint(COAP_OPTION_MAX_AGE,10);
		require_noerr(ret, bail);

		content = smcp_outbound_get_content_ptr(&max_len);
		require_action(content!=NULL, bail, ret = SMCP_STATUS_FAILURE);

		require_action(max_len>11, bail, ret = SMCP_STATUS_MESSAGE_TOO_BIG);

		ret = smcp_outbound_set_content_len(
			(coap_size_t)strlen(uint32_to_dec_cstr(content, (uint32_t)time(NULL)))
		);
		require_noerr(ret, bail);

		ret = smcp_outbound_send();
		require_noerr(ret, bail);
	}
bail:
	return ret;
}
开发者ID:robbie-cao,项目名称:smcp,代码行数:42,代码来源:plugtest-server.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ require_action_quiet函数代码示例发布时间:2022-05-30
下一篇:
C++ require函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap