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

C++ require函数代码示例

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

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



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

示例1: require

bool
IOSCSITape::LOAD_UNLOAD(
	SCSITaskIdentifier	request,
	SCSICmdField1Bit	IMMED,
	SCSICmdField1Bit	HOLD,
	SCSICmdField1Bit	EOT,
	SCSICmdField1Bit	RETEN,
	SCSICmdField1Bit	LOAD,
	SCSICmdField1Byte	CONTROL)
{
	bool result = false;
	
	require(IsParameterValid(IMMED, kSCSICmdFieldMask1Bit), ErrorExit);
	require(IsParameterValid(HOLD, kSCSICmdFieldMask1Bit), ErrorExit);
	require(IsParameterValid(EOT, kSCSICmdFieldMask1Bit), ErrorExit);
	require(IsParameterValid(RETEN, kSCSICmdFieldMask1Bit), ErrorExit);
	require(IsParameterValid(LOAD, kSCSICmdFieldMask1Bit), ErrorExit);
	require(IsParameterValid(CONTROL, kSCSICmdFieldMask1Byte), ErrorExit);
	
	SetCommandDescriptorBlock(request, 
							  kSCSICmd_LOAD_UNLOAD, 
							  IMMED, 
							  0x00, 
							  0x00, 
							  (HOLD  << 3) |
							  (EOT   << 2) |
							  (RETEN << 1) |
							   LOAD, 
							  CONTROL);
	
	SetDataTransferDirection(request, kSCSIDataTransfer_NoDataTransfer);
	
	SetTimeoutDuration(request, SCSI_MOTION_TIMEOUT);
	
	result = true;
	
ErrorExit:
	
	return result;
}
开发者ID:cyranodb,项目名称:ioscsitape,代码行数:40,代码来源:IOSCSITape.cpp


示例2: pairing_node_init

pairing_node_t
pairing_node_init(
	pairing_node_t self,
	nyoci_node_t parent,
	const char* name,
	const char* path
) {
	FILE* file = fopen(path, "r");
	char* line = NULL;
	size_t line_len = 0;

	NYOCI_LIBRARY_VERSION_CHECK();

	require(name != NULL, bail);

	require(self || (self = pairing_node_alloc()), bail);
	require(nyoci_node_init(
			&self->node,
			(void*)parent,
			name
	), bail);

	self->node.has_link_content = 1;
//	self->node.is_observable = 1;
	self->interface = nyoci_get_current_instance();

	smcp_pairing_mgr_init(&self->pairing_mgr, self->interface);

	((nyoci_node_t)&self->node)->request_handler = (void*)&smcp_pairing_mgr_request_handler;
	((nyoci_node_t)&self->node)->context = (void*)&self->pairing_mgr;

	self->next_observer_refresh = nyoci_plat_cms_to_timestamp(NYOCI_OBSERVATION_KEEPALIVE_INTERVAL - MSEC_PER_SEC);

	require(file != NULL, bail);

	while(!feof(file) && (line=fgetln(file,&line_len))) {
		char *cmd = get_next_arg(line, &line);
		if (!cmd) {
			continue;
		} else if (strcaseequal(cmd, "Pairing")) {
			char* pairing_id_str = get_next_arg(line, &line);
			char* pairing_local_path_str = get_next_arg(line, &line);
			char* pairing_remote_url_str = get_next_arg(line, &line);
			char* pairing_enabled_str = get_next_arg(line, &line);
			char* pairing_content_type_str = get_next_arg(line, &line);
			if ( (pairing_id_str == NULL)
			  || (pairing_local_path_str == NULL)
			  || (pairing_remote_url_str == NULL)
			  || (pairing_enabled_str == NULL)
			  || (pairing_content_type_str == NULL)
			) {
				break;
			}
			smcp_pairing_t pairing = smcp_pairing_mgr_new_pairing(
				&self->pairing_mgr,
				pairing_local_path_str,
				pairing_remote_url_str,
				(uint8_t)atoi(pairing_id_str)
			);

			smcp_pairing_set_content_type(pairing, (coap_content_type_t)atoi(pairing_content_type_str));

			if (atoi(pairing_enabled_str) != 0) {
				smcp_pairing_set_enabled(pairing, true);
			}

			smcp_pairing_set_stable(pairing, true);
		}
	}

bail:
	if (path && (path[0] != 0)) {
		self->pairing_mgr.commit_stable_pairings = (void*)&pairing_node_commit_stable;
		self->pairing_mgr.context = strdup(path);
	}

	if (file) {
		fclose(file);
	}

	return self;
}
开发者ID:darconeous,项目名称:smcp,代码行数:82,代码来源:pairing-node.c


示例3: require

void Nes_Fme7_Apu::run_until( blip_time_t end_time )
{
	require( end_time >= last_time );
	
	for ( int index = 0; index < osc_count; index++ )
	{
		int mode = regs [7] >> index;
		int vol_mode = regs [010 + index];
		int volume = amp_table [vol_mode & 0x0F];
		
		Blip_Buffer* const osc_output = oscs [index].output;
		if ( !osc_output )
			continue;
		
		// check for unsupported mode
		#ifndef NDEBUG
			if ( (mode & 011) <= 001 && vol_mode & 0x1F )
				dprintf( "FME7 used unimplemented sound mode: %02X, vol_mode: %02X\n",
						mode, vol_mode & 0x1F );
		#endif
		
		if ( (mode & 001) | (vol_mode & 0x10) )
			volume = 0; // noise and envelope aren't supported
		
		// period
		int const period_factor = 16;
		unsigned period = (regs [index * 2 + 1] & 0x0F) * 0x100 * period_factor +
				regs [index * 2] * period_factor;
		if ( period < 50 ) // around 22 kHz
		{
			volume = 0;
			if ( !period ) // on my AY-3-8910A, period doesn't have extra one added
				period = period_factor;
		}
		
		// current amplitude
		int amp = volume;
		if ( !phases [index] )
			amp = 0;
		
		{
			int delta = amp - oscs [index].last_amp;
			if ( delta )
			{
				oscs [index].last_amp = amp;
				osc_output->set_modified();
				synth.offset( last_time, delta, osc_output );
			}
		}
		
		blip_time_t time = last_time + delays [index];
		if ( time < end_time )
		{
			int delta = amp * 2 - volume;
			osc_output->set_modified();
			if ( volume )
			{
				do
				{
					delta = -delta;
					synth.offset_inline( time, delta, osc_output );
					time += period;
				}
				while ( time < end_time );
				
				oscs [index].last_amp = (delta + volume) >> 1;
				phases [index] = (delta > 0);
			}
			else
			{
				// maintain phase when silent
				int count = (end_time - time + period - 1) / period;
				phases [index] ^= count & 1;
				time += count * period;
			}
		}
开发者ID:Gardenya,项目名称:deadbeef,代码行数:76,代码来源:Nes_Fme7_Apu.cpp


示例4: PrintSMARTData

IOReturn
PrintSMARTData ( io_service_t service )
{

    IOCFPlugInInterface     **              cfPlugInInterface       = NULL;
    IOATASMARTInterface     **              smartInterface          = NULL;
    HRESULT herr                            = S_OK;
    IOReturn err                                     = kIOReturnSuccess;
    SInt32 score                           = 0;
    Boolean conditionExceeded       = false;
    CFStringRef description                     = NULL;
    UInt8 buffer[512];
    UInt32 bytesRead;
    ATASMARTLogDirectory logData;
    
    err = IOCreatePlugInInterfaceForService (       service,
        kIOATASMARTUserClientTypeID,
        kIOCFPlugInInterfaceID,
        &cfPlugInInterface,
        &score );

    require_string ( ( err == kIOReturnSuccess ), ErrorExit, "IOCreatePlugInInterfaceForService" );
    herr = ( *cfPlugInInterface )->QueryInterface (
        cfPlugInInterface,
        CFUUIDGetUUIDBytes ( kIOATASMARTInterfaceID ),
        ( LPVOID ) &smartInterface );

    require_string ( ( herr == S_OK ), ReleasePlugIn, "QueryInterface" );


    require_string ( ( smartInterface != NULL ), ReleasePlugIn, "smartInterface" );

    description = GetDriveDescription ( service );
    printf ( "SAT Drive: " );
    fflush ( stdout );
    CFShow ( description );
    CFRelease ( description );
    
    err = ( *smartInterface )->SMARTEnableDisableOperations ( smartInterface, true );
    require_string ( ( err == kIOReturnSuccess ), ReleaseInterface, "SMARTEnableDisableOperations" );

    err = ( *smartInterface )->SMARTEnableDisableAutosave ( smartInterface, true );
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );

    err = ( *smartInterface )->SMARTReturnStatus ( smartInterface, &conditionExceeded );
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );

    if ( conditionExceeded )
    {
        printf ( "SMART condition exceeded, drive will fail soon\n" );
    }

    else
    {
        printf ( "SMART condition not exceeded, drive OK\n" );
    }

    err = ( *smartInterface )->GetATAIdentifyData (smartInterface, &buffer, sizeof buffer, &bytesRead );
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );
    require ( ( bytesRead == sizeof buffer ), ReleaseInterface );
    printf ( "Model: %s\n", buffer + 2 * kATAIdentifyModelNumber ); // FIXME not null terminated
    
    err = ( *smartInterface )->SMARTReadLogDirectory (smartInterface, &logData );
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );
    for (int i = 0; i < 255; i++) {
        if (logData.entries[i].numberOfSectors > 0)
            printf ( "entry[%d]: %d\n", i, logData.entries[i].numberOfSectors);
    }
    err = ( *smartInterface )->SMARTReadLogAtAddress ( smartInterface,
                                                      224,
                                                 buffer,
                                                 sizeof buffer);
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );
    for (int i = 0; i < 512; i++) {
        if (buffer[i])
        printf ( "buffer[%d]: %d\n", i, buffer[i]);
    }
#if 0
    err = ( *smartInterface )->SMARTWriteLogAtAddress ( smartInterface,
                                                      224,
                                                      buffer,
                                                      sizeof buffer);
    require ( ( err == kIOReturnSuccess ), ReleaseInterface );
#endif
    
ReleaseInterface:

    printf ("status %s\n", getStatus(err));

    ( *smartInterface )->Release ( smartInterface );
    smartInterface = NULL;


ReleasePlugIn:


    err = IODestroyPlugInInterface ( cfPlugInInterface );
    require ( ( err == kIOReturnSuccess ), ErrorExit );


//.........这里部分代码省略.........
开发者ID:hnravichandra,项目名称:OS-X-SAT-SMART-Driver,代码行数:101,代码来源:ATASMARTSample.c


示例5: user_main

/* user main function, called by AppFramework after system init done && wifi
 * station on in user_main thread.
 */
OSStatus user_main( app_context_t * const app_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  unsigned char rdata[64];
  unsigned char sdata[64];
  uint16_t datalen;

  require(app_context, exit);

  // platform initialize
  AaSysComInit();
  AaSysLogInit();

  // application initialize
  ControllerBusInit();
  OuterTriggerInit(NULL);
  TemperatureInit();  // will be support in release 2
  BatteryInit();

  // reset f411 and wait until it startup
  ResetF411();

#if 1
  MOInit();
#endif

  err = SntpInit(app_context);
  if(kNoErr != err) {
    AaSysLogPrint(LOGLEVEL_ERR, "SntpInit finished with err code %d", err);
  }
  else {
    AaSysLogPrint(LOGLEVEL_INF, "SntpInit success");
  }

#if 1
  DeviceInit(app_context);
  HealthInit(app_context);
  LightsInit(app_context);
  MusicInit(app_context);

  // start the downstream thread to handle user command
  err = mico_rtos_create_thread(&user_downstrem_thread_handle, MICO_APPLICATION_PRIORITY, "user_downstream", 
                                user_downstream_thread, STACK_SIZE_USER_DOWNSTREAM_THREAD, 
                                app_context );
  require_noerr_action( err, exit, user_log("ERROR: create user_downstream thread failed!") );
#endif


  user_log("[DBG]net_main: Appilcation Initialize success @"SOFTWAREVERSION);

  // user_main loop, update oled display every 1s
  while(1){

#if 1
    mico_thread_sleep(MICO_WAIT_FOREVER);
#else

    mico_thread_sleep(5);

    datalen = user_uartRecv(rdata, 5);
    if(datalen) {
      user_log("[DBG]user_main: Usart recevice datalen %d", datalen);
      user_log("[DBG]user_main: receive %.*s", datalen, rdata);
    }
    else {
      user_log("[DBG]user_main: Usart didn't recevice data");
    }

    mico_thread_sleep(2);

    sprintf(sdata, "hello, world!\r\n");
    user_uartSend(sdata, strlen(sdata));
#endif

  }

exit:
  if(kNoErr != err){
    user_log("[ERR]user_main: user_main thread exit with err=%d", err);
  }
  mico_rtos_delete_thread(NULL);  // delete current thread
  return err;
}
开发者ID:HargicStudio,项目名称:SmartCup_MiCOKit_v2.4.0.0,代码行数:87,代码来源:user_main.c


示例6: Do_NewWindowFromIB

/*****************************************************
*
* Do_NewWindowFromIB(outWindow) 
*
* Purpose:  called to create a new window that has been constructed with Interface Builder
*
* Notes:    called by Do_NewWindow()
*
* Inputs:   outWindow   - if not NULL, the address where to return the WindowRef
*                       - if not NULL, the callee will have to ShowWindow
*
* Returns:  OSStatus    - error code (0 == no error) 
*/
static OSStatus Do_NewWindowFromIB(WindowRef * outWindow)
{
	OSStatus status;
	WindowRef aWindowRef = NULL;
	CFStringRef theTitle = NULL;
	CFMutableStringRef theNewTitle = NULL;
	
	// Create a window. "MainWindow" is the name of the window object. This name is set in 
	// InterfaceBuilder when the nib is created.
	status = CreateWindowFromNib(gIBNibRef, CFSTR("MainWindow"), &aWindowRef);
	require_noerr(status, CreateWindowFromNib);
	require(aWindowRef != NULL, CreateWindowFromNib);
	
	WindowDataPtr wdr = (WindowDataPtr)calloc(1, sizeof(WindowDataRec));
	require(wdr != NULL, CantAllocateWindowData);

	SetWRefCon(aWindowRef, (long)wdr);
	
	status = CopyWindowTitleAsCFString(aWindowRef, &theTitle);
	require_noerr(status, CopyWindowTitleAsCFString);
	
	theNewTitle = CFStringCreateMutableCopy(NULL, 0, theTitle);
	require(theNewTitle != NULL, CFStringCreateMutableCopy);
	
	CFStringAppendFormat(theNewTitle, NULL, CFSTR(" %ld"), ++gWindowCount);
	status = SetWindowTitleWithCFString(aWindowRef, theNewTitle);
	require_noerr(status, SetWindowTitleWithCFString);
	
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowCommandProcess, 1, &eventTypeCP, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
	
	EventTypeSpec eventTypeWC = {kEventClassWindow, kEventWindowClosed};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowIsClosing, 1, &eventTypeWC, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
	
	HIViewID littleArrowsId = { 'LARC', 100 };
	HIViewRef littleArrows;
	status = HIViewFindByID(HIViewGetRoot(aWindowRef), littleArrowsId, &littleArrows);
	require_noerr(status, HIViewFindByID);
	require(littleArrows != NULL, HIViewFindByID);

	SetControlAction(littleArrows, LittleArrowsControlAction);

	EventTypeSpec eventTypeCVFC = {kEventClassControl, kEventControlValueFieldChanged};
	status = HIViewInstallEventHandler(littleArrows, Handle_PostLittleArrowsClick, 1, &eventTypeCVFC, (void *)littleArrows, NULL);
	require_noerr(status, CantInstallEventHandler);

	// The window was created hidden so show it if the outWindow parameter is NULL, 
	// if it's not, it will be the responsibility of the caller to show it.
	if (outWindow == NULL)
		ShowWindow(aWindowRef);
	
	SetWindowModified(aWindowRef, false);

HIViewFindByID:
CantInstallEventHandler:
SetWindowTitleWithCFString:
CFStringCreateMutableCopy:
CopyWindowTitleAsCFString:

	if (theTitle != NULL)
		CFRelease(theTitle);
	if (theNewTitle != NULL)
		CFRelease(theNewTitle);

CantAllocateWindowData:
CreateWindowFromNib:
	
	if (outWindow != NULL)
		*outWindow = aWindowRef;
	
	return status;
}   // Do_NewWindowFromIB
开发者ID:fruitsamples,项目名称:LittleArrowsShowcase,代码行数:87,代码来源:main.c


示例7: require

// Parse a where clause:
//
//    where-clause:
//      'requires' logical-or-expression
Expr&
Parser::requires_clause()
{
  require(tk::requires_tok);
  return logical_or_expression();
}
开发者ID:asutton,项目名称:banjo,代码行数:10,代码来源:parse-decl.cpp


示例8: while

//直接遍历边块,寻找要插入的边所在的块,确保这个块还可以容纳边
b_type Subgraph::not_index_edge(Vertex* v,v_type id,t_type ts,b_type num,char is_repeat,char is_hash){
	b_type res;//要返回的边块的块号
	if(v->head==INVALID_BLOCK){
		//如果顶点还没有边块,则新建一个块
		res=require(2);//获取一个边块号
		BlockHeader<Edge> *insert_b=(BlockHeader<Edge>*)get_block(res,1,is_hash);//获取边块,这个块一直是块头,采取分裂方式扩容
		//把块加入到顶点的边链表中,作为块头,同时把顶点所在块脏位置1
		v->head=res;
		insert_b->pre=INVALID_BLOCK;
		insert_b->next=INVALID_BLOCK;
		BlockHeader<Vertex> *bv=(BlockHeader<Vertex> *)get_block(num,0,is_hash,0);//记得用无锁方式
		bv->clean=1;
		//初始化该块
		insert_b->init_block();
		insert_b->clean=1;
		return res;
	}else{
		BlockHeader<Edge> *b=NULL;  
		//时间戳不用去重
		b_type _blocknum=v->head;
		//旧块用0,新块用1,一定要记住,这里bug弄了好久
		b=(BlockHeader<Edge> *)get_block(_blocknum,0,is_hash);
		while(true){
			if(b->min==INVALID_VERTEX||id<b->min){
				if(is_repeat==1){
					//要根据边的时间戳去重,则要先确认这两个顶点之间的边有没有存在这个时间戳的
					if(b->ts_is_in_all(id,ts,this)){
						unlock2block(b);//如果存在,则释放该边块,返回无效块
						return INVALID_BLOCK;
					}
				}
				//不去重,或者没有重复的,则开始添加边
				if(b->size<b->capacity){
					//如果块没满,则返回块号 
					return b->number;
				}else{
					//如果块满了,则要分裂
					b_type _new_blocknum=require(2);
					BlockHeader<Edge> *_new_block=(BlockHeader<Edge> *)get_block(_new_blocknum,1,is_hash);
					b->split(_new_block,this);//分裂块,新块在后面,旧块在前面
					b->clean=1;
					_new_block->clean=1;
					if(id<b->min){
						//边插入旧块,释放新块的锁
						unlock2block(_new_block);
						return b->number;
					}else{
						//边插入新块,释放旧块的锁
						unlock2block(b);
						return _new_block->number;
					}
				}
			}else{
				_blocknum=b->next;//在释放该块之前得到下一个索引块,以免在中间把该块移除出去了
                unlock2block(b);//释放索引块
				b=(BlockHeader<Edge> *)get_block(_blocknum,0,is_hash);
			}
		}
			
	}
}
开发者ID:zhaomasha,项目名称:panda_new,代码行数:62,代码来源:panda_subgraph.cpp


示例9: PrepareMovieForExtraction

// Prepare the specified movie for extraction:
//	Open an extraction session.
//	Set the "All Channels Discrete" property if required.
//	Set the ASBD and output layout, if specified.
//      Set the extraction start time. 
// Return the audioExtractionSessionRef.
OSStatus PrepareMovieForExtraction( Movie movie, 
                                    MovieAudioExtractionRef* extractionRefPtr, 
                                    Boolean discrete, 
                                    AudioStreamBasicDescription asbd, 
                                    AudioChannelLayout** layout, 
                                    UInt32* layoutSizePtr, 
                                    TimeRecord startTime)
{
	OSStatus	err = noErr;
	
	if (extractionRefPtr == nil)
	{
		err = paramErr;
		goto bail;
	}
	
	// Movie extraction begin: Open an extraction session
	err = MovieAudioExtractionBegin(movie, 0, extractionRefPtr);
	require(err == noErr, bail);	
	
	// If we need to extract all discrete channels, set that property
	if (discrete)
	{
            err = MovieAudioExtractionSetProperty(*extractionRefPtr,
                                                    kQTPropertyClass_MovieAudioExtraction_Movie,
                                                    kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete,
                                                    sizeof (discrete), 
                                                    &discrete);
            require(err == noErr, bail);	
	}
	// Set the extraction ASBD
	err = MovieAudioExtractionSetProperty(*extractionRefPtr,
                                            kQTPropertyClass_MovieAudioExtraction_Audio,
                                            kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription,
                                            sizeof (asbd), &asbd);
	require(err == noErr, bail);	

	// Set the output layout, if supplied
	if (*layout)
	{
		err = MovieAudioExtractionSetProperty(*extractionRefPtr,
                                                kQTPropertyClass_MovieAudioExtraction_Audio,
                                                kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
                                                *layoutSizePtr, *layout);
                require(err == noErr, bail);	
	}

	// Set the extraction start time.  The duration will be determined by how much is pulled.
	err = MovieAudioExtractionSetProperty(*extractionRefPtr,
                                            kQTPropertyClass_MovieAudioExtraction_Movie,
                                            kQTMovieAudioExtractionMoviePropertyID_CurrentTime,
                                            sizeof(TimeRecord), &startTime);

bail:
	// If error, close the extraction session
	if (err != noErr)
	{
		if (*extractionRefPtr != nil)
			MovieAudioExtractionEnd(*extractionRefPtr);
	}	
	return err;
}
开发者ID:fruitsamples,项目名称:SimpleAudioExtraction,代码行数:68,代码来源:MovieAudioExtractionUtils.c


示例10: GetDefaultExtractionLayout

// Get the default extraction layout for this movie, expanded into individual channel descriptions.
// The channel layout returned by this routine must be deallocated by the client.
// If 'asbd' is non-NULL, fill it with the default extraction asbd, which contains the
// highest sample rate among the sound tracks that will be contributing.
//	'outLayoutSize' and 'asbd' may be nil.
OSStatus GetDefaultExtractionLayout(Movie movie, UInt32* outLayoutSize,
                            AudioChannelLayout** outLayout, AudioStreamBasicDescription *asbd)
{
	OSStatus                    err = noErr;
	AudioChannelLayout          *layout = NULL;
	UInt32                      size = 0;
	MovieAudioExtractionRef     extractionSessionRef = nil;

	if (!outLayout)
	{
		err = paramErr;
		goto bail;
	}

	// Initiate a dummy audio extraction here, in order to get the resulting default channel layout.
	err = MovieAudioExtractionBegin(movie, 0, &extractionSessionRef);
	require(err == noErr, bail);	
	
	// Get the size of the extraction output layout
	err = MovieAudioExtractionGetPropertyInfo(extractionSessionRef, kQTPropertyClass_MovieAudioExtraction_Audio,
                                                kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
                                                NULL, &size, NULL);
	require(err == noErr, bail);	

	// Allocate memory for the layout
	layout = (AudioChannelLayout *) calloc(1, size);
	if (layout == nil) 
	{
		err = memFullErr;
		goto bail;
	}

	// Get the layout for the current extraction configuration.
	// This will have already been expanded into channel descriptions.
	err = MovieAudioExtractionGetProperty(extractionSessionRef, kQTPropertyClass_MovieAudioExtraction_Audio,
										  kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
										  size, layout, nil);
	require(err == noErr, bail);	
	
	// Return the layout and size, if requested
	*outLayout = layout;
	if (outLayoutSize)	
		*outLayoutSize = size;

	// If the ASBD was requested, get that also.
	if (asbd != nil)
	{
		// Get the layout for the current extraction configuration.
		// This will have already been expanded into channel descriptions.
		size = sizeof (*asbd);
		err = MovieAudioExtractionGetProperty(extractionSessionRef,
											  kQTPropertyClass_MovieAudioExtraction_Audio,
											  kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription,
											  size, asbd, nil);
        require(err == noErr, bail);	
	}

bail:
	if (err != noErr)
	{
		if (layout)
			free(layout);
		if (outLayoutSize)	
			*outLayoutSize = 0;	
	}

	// Throw away the temporary audio extraction session
	if (extractionSessionRef)
	{
		MovieAudioExtractionEnd(extractionSessionRef);
	}
	
	return err;				
}
开发者ID:fruitsamples,项目名称:SimpleAudioExtraction,代码行数:79,代码来源:MovieAudioExtractionUtils.c


示例11: SecECPrivateKeyInit

static OSStatus SecECPrivateKeyInit(SecKeyRef key,
    const uint8_t *keyData, CFIndex keyDataLength, SecKeyEncoding encoding) {
    ccec_full_ctx_t fullkey;
    fullkey.hdr = key->key;
    OSStatus err = errSecParam;

    switch (encoding) {
    case kSecKeyEncodingPkcs1:
    {
        /* TODO: DER import size (and thus cp), pub.x, pub.y and k. */
        //err = ecc_import(keyData, keyDataLength, fullkey);

        /* DER != PKCS#1, but we'll go along with it */
        ccoid_t oid;
        size_t n;
        ccec_const_cp_t cp;

        require_noerr(ccec_der_import_priv_keytype(keyDataLength, keyData, &oid, &n), abort);
        cp = ccec_cp_for_oid(oid);
        if (cp.zp == NULL) {
            cp = ccec_curve_for_length_lookup(n * 8 /* bytes -> bits */,
                ccec_cp_192(), ccec_cp_224(), ccec_cp_256(), ccec_cp_384(), ccec_cp_521(), NULL);
        }
        require_action(cp.zp != NULL, abort, err = errSecDecode);
        ccec_ctx_init(cp, fullkey);

        require_noerr(ccec_der_import_priv(cp, keyDataLength, keyData, fullkey), abort);
        err = errSecSuccess;
        break;
    }
    case kSecKeyEncodingBytes:
    {
        ccec_const_cp_t cp = getCPForPrivateSize(keyDataLength);
        require(cp.zp != NULL, abort);

        ccec_ctx_init(cp, fullkey);
        size_t pubSize = ccec_export_pub_size(fullkey);

        require(pubSize < (size_t) keyDataLength, abort);
        require_noerr_action(ccec_import_pub(cp, pubSize, keyData, fullkey),
                             abort,
                             err = errSecDecode);


        keyData += pubSize;
        keyDataLength -= pubSize;

        cc_unit *k = ccec_ctx_k(fullkey);
        require_noerr_action(ccn_read_uint(ccec_ctx_n(fullkey), k, keyDataLength, keyData),
                             abort,
                             err = errSecDecode);

        err = errSecSuccess;
        break;

    }
    case kSecGenerateKey:
    {
        CFDictionaryRef parameters = (CFDictionaryRef) keyData;

        CFTypeRef ksize = CFDictionaryGetValue(parameters, kSecAttrKeySizeInBits);
        CFIndex keyLengthInBits = getIntValue(ksize);

        ccec_const_cp_t cp = ccec_get_cp(keyLengthInBits);

        if (!cp.zp) {
            secwarning("Invalid or missing key size in: %@", parameters);
            return errSecKeySizeNotAllowed;
        }

        if (!ccec_generate_key(cp, ccrng_seckey, fullkey))
            err = errSecSuccess;
        break;
    }

    default:
        break;
    }
abort:
    return err;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:81,代码来源:SecECKey.c


示例12: require

int Effects_Buffer::max_delay() const
{
    require( sample_rate() );
    return (echo_size / stereo - max_read) * 1000L / sample_rate();
}
开发者ID:xiaoluoyuan,项目名称:VisualBoyAdvance-2,代码行数:5,代码来源:Effects_Buffer.cpp


示例13: define_operators


//.........这里部分代码省略.........
    });

    m.def("tuple_select", [](py::args args) -> py::tuple {
        _halide_user_assert(args.size() >= 3)
            << "tuple_select() must have at least 3 arguments";
        _halide_user_assert((args.size() % 2) != 0)
            << "tuple_select() must have an odd number of arguments";

        int pos = (int) args.size() - 1;
        Tuple false_value = args[pos--].cast<Tuple>();
        bool has_tuple_cond = false, has_expr_cond = false;
        while (pos > 0) {
            Tuple true_value = args[pos--].cast<Tuple>();;
            // Note that 'condition' can be either Expr or Tuple, but must be consistent across all
            py::object py_cond = args[pos--];
            Expr expr_cond;
            Tuple tuple_cond(expr_cond);
            try {
                tuple_cond = py_cond.cast<Tuple>();
                has_tuple_cond = true;
            } catch (...) {
                expr_cond = py_cond.cast<Expr>();
                has_expr_cond = true;
            }

            if (expr_cond.defined()) {
                false_value = tuple_select(expr_cond, true_value, false_value);
            } else {
                false_value = tuple_select(tuple_cond, true_value, false_value);
            }
        }
        _halide_user_assert(!(has_tuple_cond && has_expr_cond))
            <<"tuple_select() may not mix Expr and Tuple for the condition elements.";
        return to_python_tuple(false_value);
    });

    m.def("sin", &sin);
    m.def("asin", &asin);
    m.def("cos", &cos);
    m.def("acos", &acos);
    m.def("tan", &tan);
    m.def("atan", &atan);
    m.def("atan", &atan2);
    m.def("atan2", &atan2);
    m.def("sinh", &sinh);
    m.def("asinh", &asinh);
    m.def("cosh", &cosh);
    m.def("acosh", &acosh);
    m.def("tanh", &tanh);
    m.def("atanh", &atanh);
    m.def("sqrt", &sqrt);
    m.def("hypot", &hypot);
    m.def("exp", &exp);
    m.def("log", &log);
    m.def("pow", &pow);
    m.def("erf", &erf);
    m.def("fast_log", &fast_log);
    m.def("fast_exp", &fast_exp);
    m.def("fast_pow", &fast_pow);
    m.def("fast_inverse", &fast_inverse);
    m.def("fast_inverse_sqrt", &fast_inverse_sqrt);
    m.def("floor", &floor);
    m.def("ceil", &ceil);
    m.def("round", &round);
    m.def("trunc", &trunc);
    m.def("fract", &fract);
    m.def("is_nan", &is_nan);
    m.def("reinterpret", (Expr (*)(Type, Expr)) &reinterpret);
    m.def("cast", (Expr (*)(Type, Expr)) &cast);
    m.def("print", [](py::args args) -> Expr {
        return print(args_to_vector_for_print(args));
    });
    m.def("print_when", [](Expr condition, py::args args) -> Expr {
        return print_when(condition, args_to_vector_for_print(args));
    }, py::arg("condition"));
    m.def("require", [](Expr condition, Expr value, py::args args) -> Expr {
        auto v = args_to_vector<Expr>(args);
        v.insert(v.begin(), value);
        return require(condition, v);
    }, py::arg("condition"), py::arg("value"));
    m.def("lerp", &lerp);
    m.def("popcount", &popcount);
    m.def("count_leading_zeros", &count_leading_zeros);
    m.def("count_trailing_zeros", &count_trailing_zeros);
    m.def("div_round_to_zero", &div_round_to_zero);
    m.def("mod_round_to_zero", &mod_round_to_zero);
    m.def("random_float", (Expr (*)()) &random_float);
    m.def("random_uint", (Expr (*)()) &random_uint);
    m.def("random_int", (Expr (*)()) &random_int);
    m.def("random_float", (Expr (*)(Expr)) &random_float, py::arg("seed"));
    m.def("random_uint", (Expr (*)(Expr)) &random_uint, py::arg("seed"));
    m.def("random_int", (Expr (*)(Expr)) &random_int, py::arg("seed"));
    m.def("undef", (Expr (*)(Type)) &undef);
    m.def("memoize_tag", [](Expr result, py::args cache_key_values) -> Expr {
        return Internal::memoize_tag_helper(result, args_to_vector<Expr>(cache_key_values));
    }, py::arg("result"));
    m.def("likely", &likely);
    m.def("likely_if_innermost", &likely_if_innermost);
    m.def("saturating_cast", (Expr (*)(Type, Expr))&saturating_cast);
}
开发者ID:adityaatluri,项目名称:Halide,代码行数:101,代码来源:PyIROperator.cpp


示例14: require

Expr const*
Parser::id()
{
  Token tok = require(identifier_tok);
  return on_id(tok);
}
开发者ID:Jenny-fa,项目名称:lingo,代码行数:6,代码来源:parser.cpp


示例15: ConfigCreateReportJsonMessage

json_object* ConfigCreateReportJsonMessage( mico_Context_t * const inContext )
{
  OSStatus err = kNoErr;
  config_delegate_log_trace();
  char name[50], *tempString;
  OTA_Versions_t versions;
  char rfVersion[50];
  json_object *sectors, *sector, *subMenuSectors, *subMenuSector, *mainObject = NULL;

  MicoGetRfVer( rfVersion, 50 );

  if(inContext->flashContentInRam.micoSystemConfig.configured == wLanUnConfigured){
    /*You can upload a specific menu*/
  }

  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  snprintf(name, 50, "%s(%c%c%c%c%c%c)",MODEL, 
                                        inContext->micoStatus.mac[9],  inContext->micoStatus.mac[10], 
                                        inContext->micoStatus.mac[12], inContext->micoStatus.mac[13],
                                        inContext->micoStatus.mac[15], inContext->micoStatus.mac[16]);

  versions.fwVersion = FIRMWARE_REVISION;
  versions.hdVersion = HARDWARE_REVISION;
  versions.protocol =  PROTOCOL;
  versions.rfVersion = NULL;

  sectors = json_object_new_array();
  require( sectors, exit );

  err = MICOAddTopMenu(&mainObject, name, sectors, versions);
  require_noerr(err, exit);

  /*Sector 1*/
  sector = json_object_new_array();
  require( sector, exit );
  err = MICOAddSector(sectors, "MICO SYSTEM",    sector);
  require_noerr(err, exit);

    /*name cell*/
    err = MICOAddStringCellToSector(sector, "Device Name",    inContext->flashContentInRam.micoSystemConfig.name,               "RW", NULL);
    require_noerr(err, exit);

    //Bonjour switcher cell
    err = MICOAddSwitchCellToSector(sector, "Bonjour",        inContext->flashContentInRam.micoSystemConfig.bonjourEnable,      "RW");
    require_noerr(err, exit);

    //RF power save switcher cell
    err = MICOAddSwitchCellToSector(sector, "RF power save",  inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable,  "RW");
    require_noerr(err, exit);

    //MCU power save switcher cell
    err = MICOAddSwitchCellToSector(sector, "MCU power save", inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable, "RW");
    require_noerr(err, exit);

    /*sub menu*/
    subMenuSectors = json_object_new_array();
    require( subMenuSectors, exit );
    err = MICOAddMenuCellToSector(sector, "Detail", subMenuSectors);
    require_noerr(err, exit);
      
      subMenuSector = json_object_new_array();
      require( subMenuSector, exit );
      err = MICOAddSector(subMenuSectors,  "",    subMenuSector);
      require_noerr(err, exit);

        err = MICOAddStringCellToSector(subMenuSector, "Firmware Rev.",  FIRMWARE_REVISION, "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "Hardware Rev.",  HARDWARE_REVISION, "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "MICO OS Rev.",   MicoGetVer(),      "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "RF Driver Rev.", rfVersion,         "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "Model",          MODEL,             "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "Manufacturer",   MANUFACTURER,      "RO", NULL);
        require_noerr(err, exit);
        err = MICOAddStringCellToSector(subMenuSector, "Protocol",       PROTOCOL,          "RO", NULL);
        require_noerr(err, exit);

      subMenuSector = json_object_new_array();
      err = MICOAddSector(subMenuSectors,  "WLAN",    subMenuSector);
      require_noerr(err, exit);
      
        tempString = DataToHexStringWithColons( (uint8_t *)inContext->flashContentInRam.micoSystemConfig.bssid, 6 );
        err = MICOAddStringCellToSector(subMenuSector, "BSSID",        tempString, "RO", NULL);
        require_noerr(err, exit);
        free(tempString);

        err = MICOAddNumberCellToSector(subMenuSector, "Channel",      inContext->flashContentInRam.micoSystemConfig.channel, "RO", NULL);
        require_noerr(err, exit);

        switch(inContext->flashContentInRam.micoSystemConfig.security){
          case SECURITY_TYPE_NONE:
            err = MICOAddStringCellToSector(subMenuSector, "Security",   "Open system", "RO", NULL); 
            break;
          case SECURITY_TYPE_WEP:
            err = MICOAddStringCellToSector(subMenuSector, "Security",   "WEP",         "RO", NULL); 
            break;
          case SECURITY_TYPE_WPA_TKIP:
//.........这里部分代码省略.........
开发者ID:hujg,项目名称:mico_v2.2.0,代码行数:101,代码来源:MICOConfigDelegate.c


示例16: GetOpenDialogForUser

CFURLRef GetOpenDialogForUser(kDialogType type, char* title, char* message)
{
	NavDialogCreationOptions dialogOptions;
	NavDialogRef dialog = NULL;
	NavReplyRecord replyRecord;
	CFURLRef fileAsCFURLRef = NULL;
	FSRef fileAsFSRef;
	OSStatus status;
	
	CFAllocatorRef alloc_default = kCFAllocatorDefault;  // = NULL;

	// Get the standard set of defaults
	status = NavGetDefaultDialogCreationOptions(&dialogOptions);
	require_noerr( status, CantGetNavOptions );

	dialogOptions.optionFlags = kNavNoTypePopup + kNavSupportPackages + kNavAllowOpenPackages;


	if (title != NULL) {
		CFStringRef cftitle = CFStringCreateWithCString(alloc_default,title,kCFStringEncodingMacRoman);
		dialogOptions.windowTitle = cftitle;
	}

	if (message != NULL) {
		CFStringRef cfmessage = CFStringCreateWithCString(alloc_default,message,kCFStringEncodingMacRoman);
		dialogOptions.message = cfmessage;
	}


	// Make the window app-wide modal
	dialogOptions.modality = kWindowModalityAppModal;

	// Create the dialog
	if (type == kDialogFile) {
		status = NavCreateGetFileDialog(&dialogOptions, NULL, NULL, NULL, NULL, NULL, &dialog);
	} else if (type == kDialogFolder) {
		status = NavCreateChooseFolderDialog(&dialogOptions, NULL, NULL, NULL, &dialog);
	}
	require_noerr( status, CantCreateDialog );

	// Show it
	status = NavDialogRun(dialog);
	require_noerr( status, CantRunDialog );

	// Get the reply
	status = NavDialogGetReply(dialog, &replyRecord);
	require( ((status == noErr) || (status == userCanceledErr)), CantGetReply );

	// If the user clicked "Cancel", just bail
	if ( status == userCanceledErr ) goto UserCanceled;

	// Get the file
	status = AEGetNthPtr(&(replyRecord.selection), 1, typeFSRef, NULL, NULL, &fileAsFSRef, sizeof(FSRef), NULL);
	require_noerr( status, CantExtractFSRef );

	// Convert it to a CFURL
	fileAsCFURLRef = CFURLCreateFromFSRef(NULL, &fileAsFSRef);

	// Cleanup
CantExtractFSRef:
UserCanceled:
	verify_noerr( NavDisposeReply(&replyRecord) );
CantGetReply:
CantRunDialog:
	NavDialogDispose(dialog);
CantCreateDialog:
CantGetNavOptions:
    return fileAsCFURLRef;
}
开发者ID:ammalgamma,项目名称:robotconscience-of-addons,代码行数:69,代码来源:ofxFileDialog.cpp


示例17: main

int main(int argc, char **argv)
{
    int wants_wipe = 0;
    int wants_reboot = 0;
    int wants_reboot_bootloader = 0;
    int erase_first = 1;
    void *data;
    unsigned sz;
    int status;
    int c;
    int longindex;

    const struct option longopts[] = {
        {"base", required_argument, 0, 'b'},
        {"kernel_offset", required_argument, 0, 'k'},
        {"page_size", required_argument, 0, 'n'},
        {"ramdisk_offset", required_argument, 0, 'r'},
        {"tags_offset", required_argument, 0, 't'},
        {"help", no_argument, 0, 'h'},
        {"unbuffered", no_argument, 0, 0},
        {"version", no_argument, 0, 0},
        {0, 0, 0, 0}
    };

    serial = getenv("ANDROID_SERIAL");

    while (1) {
        c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, &longindex);
        if (c < 0) {
            break;
        }
        /* Alphabetical cases */
        switch (c) {
        case 'b':
            base_addr = strtoul(optarg, 0, 16);
            break;
        case 'c':
            cmdline = optarg;
            break;
        case 'h':
            usage();
            return 1;
        case 'i': {
                char *endptr = NULL;
                unsigned long val;

                val = strtoul(optarg, &endptr, 0);
                if (!endptr || *endptr != '\0' || (val & ~0xffff))
                    die("invalid vendor id '%s'", optarg);
                vendor_id = (unsigned short)val;
                break;
            }
        case 'k':
            kernel_offset = strtoul(optarg, 0, 16);
            break;
        case 'l':
            long_listing = 1;
            break;
        case 'n':
            page_size = (unsigned)strtoul(optarg, NULL, 0);
            if (!page_size) die("invalid page size");
            break;
        case 'p':
            product = optarg;
            break;
        case 'r':
            ramdisk_offset = strtoul(optarg, 0, 16);
            break;
        case 't':
            tags_offset = strtoul(optarg, 0, 16);
            break;
        case 's':
            serial = optarg;
            break;
        case 'S':
            sparse_limit = parse_num(optarg);
            if (sparse_limit < 0) {
                    die("invalid sparse limit");
            }
            break;
        case 'u':
            erase_first = 0;
            break;
        case 'w':
            wants_wipe = 1;
            break;
        case '?':
            return 1;
        case 0:
        

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ require_action函数代码示例发布时间:2022-05-30
下一篇:
C++ requestdoc函数代码示例发布时间: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