本文整理汇总了C++中require_action函数的典型用法代码示例。如果您正苦于以下问题:C++ require_action函数的具体用法?C++ require_action怎么用?C++ require_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了require_action函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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 );
}
示例5: MICOInitNotificationCenter
OSStatus MICOInitNotificationCenter ( void * const inContext )
{
OSStatus err = kNoErr;
require_action(inContext, exit, err = kParamErr);
_Context = inContext;
exit:
return err;
}
示例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;
}
示例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 );
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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 );
}
示例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 );
}
示例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 );
}