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


C++ CODE函数代码示例

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


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

示例1: i80286_check_permission

static void i80286_check_permission(i8086_state *cpustate, UINT8 check_seg, UINT32 offset, UINT16 size, i80286_operation operation)
{
	int trap = 0;
	UINT8 rights;
	if (PM) {
		rights = cpustate->rights[check_seg];
		trap = i80286_verify(cpustate, cpustate->sregs[check_seg], operation, rights, cpustate->valid[check_seg]);
		if ((CODE(rights) || !EXPDOWN(rights)) && ((offset+size-1) > cpustate->limit[check_seg])) trap = GENERAL_PROTECTION_FAULT;
		if (!CODE(rights) && EXPDOWN(rights) && ((offset <= cpustate->limit[check_seg]) || ((offset+size-1) > 0xffff))) trap = GENERAL_PROTECTION_FAULT;

		if ((trap == GENERAL_PROTECTION_FAULT) && (check_seg == SS)) trap = STACK_FAULT;
		if (trap) throw TRAP(trap, 0);
	}
}
开发者ID:NastyNoah,项目名称:groovyarcade.groovymame,代码行数:14,代码来源:instr286.c

示例2: sockClientStop

// =-=-=-=-=-=-=-
//
irods::error sockClientStop(
    irods::network_object_ptr _ptr,
    rodsEnv*                   _env ) {
    // =-=-=-=-=-=-=-
    // resolve a network interface plugin from the
    // network object
    irods::plugin_ptr p_ptr;
    irods::error ret_err = _ptr->resolve( irods::NETWORK_INTERFACE, p_ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve network interface", ret_err );

    }

    // =-=-=-=-=-=-=-
    // make the call to the "read" interface
    irods::network_ptr net = boost::dynamic_pointer_cast< irods::network >( p_ptr );
    ret_err = net->call< rodsEnv* >( irods::NETWORK_OP_CLIENT_STOP, _ptr, _env );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'client stop'", ret_err );

    }
    else {
        return CODE( ret_err.code() );

    }

} // sockClientStop
开发者ID:hurngchunlee,项目名称:irods,代码行数:32,代码来源:sockComm.cpp

示例3: fileRead

// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX read
irods::error fileRead(
    rsComm_t*                     _comm,
    irods::first_class_object_ptr _object,
    void*                         _buf,
    const int                     _len ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the object
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "read" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< void*, const int >( _comm, irods::RESOURCE_OP_READ, _object, _buf, _len );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'read'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileRead
开发者ID:QuarkDoe,项目名称:irods,代码行数:31,代码来源:fileDriver.cpp

示例4: fileTruncate

// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin truncate
irods::error fileTruncate(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "truncate" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call( _comm, irods::RESOURCE_OP_TRUNCATE, _object );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'truncate'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileTruncate
开发者ID:QuarkDoe,项目名称:irods,代码行数:29,代码来源:fileDriver.cpp

示例5: fileRename

// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX rename
irods::error fileRename(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object,
    const std::string&             _new_file_name ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "rename" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call<  const char* >( _comm, irods::RESOURCE_OP_RENAME,  _object, _new_file_name.c_str() );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'rename'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileRename
开发者ID:QuarkDoe,项目名称:irods,代码行数:30,代码来源:fileDriver.cpp

示例6: fileReaddir

// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX readdir
irods::error fileReaddir(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object,
    struct rodsDirent**            _dirent_ptr ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "readdir" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< struct rodsDirent** >( _comm, irods::RESOURCE_OP_READDIR, _object, _dirent_ptr );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'readdir'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileReaddir
开发者ID:QuarkDoe,项目名称:irods,代码行数:30,代码来源:fileDriver.cpp

示例7: fileLseek

// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX lseek
irods::error fileLseek(
    rsComm_t*                     _comm,
    irods::first_class_object_ptr _object,
    const long long               _offset,
    const int                     _whence ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "lseek" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< const long long, const int >( _comm, irods::RESOURCE_OP_LSEEK, _object, _offset, _whence );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'lseek'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileLseek
开发者ID:QuarkDoe,项目名称:irods,代码行数:31,代码来源:fileDriver.cpp

示例8: get_host_status_by_host_info

// =-=-=-=-=-=-=-
// helper function - get the status property of a resource given a
// match to the incoming pointer
    error get_host_status_by_host_info( rodsServerHost_t* _info ) {
        // =-=-=-=-=-=-=-
        // idiot check pointer
        if ( !_info ) {
            return ERROR( SYS_INVALID_INPUT_PARAM, "null pointer" );
        }

        // =-=-=-=-=-=-=-
        // find a matching resource
        resource_ptr resc;
        error err = resc_mgr.resolve_from_property< rodsServerHost_t* >( RESOURCE_HOST, _info, resc );
        if ( !err.ok() ) {
            return PASSMSG( "failed to resolve resource", err );
        }

        // =-=-=-=-=-=-=-
        // get the status property of the resource
        int status = -1;
        err = resc->get_property< int >( RESOURCE_STATUS, status );
        if ( !err.ok() ) {
            return PASSMSG( "failed to get resource property", err );
        }

        return CODE( status );

    } // get_host_status_by_host_info
开发者ID:QuarkDoe,项目名称:irods,代码行数:29,代码来源:irods_resource_backport.cpp

示例9: clip_line

//bool
//clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t)
int
clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t)
{
    int x1 = *pX1;
    int y1 = *pY1;
    int x2 = *pX2;
    int y2 = *pY2;
    int x = 0, y = 0;
    int c, c1, c2;

    CODE(x1, y1, c1);
    CODE(x2, y2, c2);

    while (c1 || c2) {
        if (c1 & c2)
            return (TRUE); /* Line is invisible. */
        if ((c = c1) == 0)
            c = c2;
        if (c & CODEMINX) {
            y = y1+(y2-y1)*(l-x1)/(x2-x1);
            x = l;
        } else if (c & CODEMAXX) {
            y = y1+(y2-y1)*(r-x1)/(x2-x1);
            x = r;
        } else if (c & CODEMINY) {
            x = x1+(x2-x1)*(b-y1)/(y2-y1);
            y = b;
        } else if (c & CODEMAXY) {
            x = x1+(x2-x1)*(t-y1)/(y2-y1);
            y = t;
        }
        if (c == c1) {
            x1 = x;
            y1 = y;
            CODE(x, y, c1);
        } else {
            x2 = x;
            y2 = y;
            CODE(x, y, c2);
        }
    }
    *pX1 = x1;
    *pY1 = y1;
    *pX2 = x2;
    *pY2 = y2;
    return (FALSE); /* Line is at least partially visible.*/
}
开发者ID:fengmm521,项目名称:myspice,代码行数:49,代码来源:clip.c

示例10: univ_mss_file_stage_to_cache

    /// =-=-=-=-=-=-=-
    /// @brief This routine is for testing the TEST_STAGE_FILE_TYPE.
    ///        Just copy the file from filename to cacheFilename. optionalInfo info
    ///        is not used.
    irods::error univ_mss_file_stage_to_cache(
        irods::resource_plugin_context& _ctx,
        const char*                         _cache_file_name ) {
        // =-=-=-=-=-=-=-
        // check context
        irods::error err = univ_mss_check_param< irods::file_object >( _ctx );
        if ( !err.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - invalid context";
            return PASSMSG( msg.str(), err );

        }

        // =-=-=-=-=-=-=-
        // snag a ref to the fco
        irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
        std::string filename = fco->physical_path();

        // =-=-=-=-=-=-=-
        // get the script property
        std::string script;
        err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
        if ( !err.ok() ) {
            return PASSMSG( __FUNCTION__, err );
        }

        int status = 0;
        execCmd_t execCmdInp;
        char cmdArgv[HUGE_NAME_LEN] = "";
        execCmdOut_t *execCmdOut = NULL;
        bzero( &execCmdInp, sizeof( execCmdInp ) );

        rstrcpy( execCmdInp.cmd, script.c_str(), LONG_NAME_LEN );
        strcat( cmdArgv, "stageToCache" );
        strcat( cmdArgv, " '" );
        strcat( cmdArgv, filename.c_str() );
        strcat( cmdArgv, "' '" );
        strcat( cmdArgv, _cache_file_name );
        strcat( cmdArgv, "'" );
        rstrcpy( execCmdInp.cmdArgv, cmdArgv, HUGE_NAME_LEN );
        rstrcpy( execCmdInp.execAddr, "localhost", LONG_NAME_LEN );
        status = _rsExecCmd( _ctx.comm(), &execCmdInp, &execCmdOut );

        if ( status < 0 ) {
            status = UNIV_MSS_STAGETOCACHE_ERR - errno;
            std::stringstream msg;
            msg << "univ_mss_file_stage_to_cache: staging from [";
            msg << _cache_file_name;
            msg << "] to [";
            msg << filename;
            msg << "] failed.";
            return ERROR( status, msg.str() );
        }

        return CODE( status );

    } // univ_mss_file_stage_to_cache
开发者ID:PlantandFoodResearch,项目名称:irods,代码行数:62,代码来源:libunivmss.cpp

示例11: ScreenWithMenuElements

ScreenSelect::ScreenSelect( CString sClassName ) : ScreenWithMenuElements(sClassName)
{
	LOG->Trace( "ScreenSelect::ScreenSelect()" );

	m_sName = sClassName;

	//
	// Load choices
	//
	{
		// Instead of using NUM_CHOICES, use a comma-separated list of choices.  Each
		// element in the list is a choice name.  This level of indirection 
		// makes it easier to add or remove items without having to change a bunch
		// of indices.
		CStringArray asChoiceNames;
		split( CHOICE_NAMES, ",", asChoiceNames, true );

		for( unsigned c=0; c<asChoiceNames.size(); c++ )
		{
			CString sChoiceName = asChoiceNames[c];
			CString sChoice = CHOICE(sChoiceName);

			ModeChoice mc;
			mc.m_sName = sChoiceName;
			mc.Load( c, sChoice );
			m_aModeChoices.push_back( mc );
		
			CString sBGAnimationDir = THEME->GetPath(BGAnimations, m_sName, mc.m_sName, true);	// true="optional"
			if( sBGAnimationDir == "" )
				sBGAnimationDir = THEME->GetPathToB(m_sName+" background");
			BGAnimation *pBGA = new BGAnimation;
			m_vpBGAnimations.push_back( pBGA );
		}
	}

	//
	// Load codes
	//
	for( int c=0; c<NUM_CODES; c++ )
	{
		CodeItem code;
		if( !code.Load( CODE(c) ) )
			continue;

		m_aCodes.push_back( code );
		m_aCodeActions.push_back( CODE_ACTION(c) );
		ModeChoice mc;
		mc.Load( c, CODE_ACTION(c) );
		m_aCodeChoices.push_back( mc );
	}

	if( !m_aModeChoices.size() )
		RageException::Throw( "Screen \"%s\" does not set any choices", m_sName.c_str() );

	// derived classes can override if they want
	LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
}
开发者ID:augustg,项目名称:stepmania-3.9,代码行数:57,代码来源:ScreenSelect.cpp

示例12: i80286_verify

static int i80286_verify(i80286_state *cpustate, UINT16 selector, i80286_operation operation, UINT8 rights, bool valid)
{
	if (!IDXTBL(selector) && !valid) return GENERAL_PROTECTION_FAULT;
	if (!SEGDESC(rights)) return GENERAL_PROTECTION_FAULT;

	switch(operation) {
		case I80286_READ:
			if (CODE(rights) && !READ(rights)) return GENERAL_PROTECTION_FAULT;
			break;
		case I80286_WRITE:
			if (CODE(rights) || !RW(rights)) return GENERAL_PROTECTION_FAULT;
			break;
		case I80286_EXECUTE:
			if (!CODE(rights)) return GENERAL_PROTECTION_FAULT;
			break;
	}
	return 0;
}
开发者ID:NastyNoah,项目名称:groovyarcade.groovymame,代码行数:18,代码来源:instr286.c

示例13: univ_mss_file_chmod

    /// =-=-=-=-=-=-=-
    /// @brief interface for POSIX chmod
    irods::error univ_mss_file_chmod(
        irods::resource_plugin_context& _ctx ) {
        // =-=-=-=-=-=-=-
        // check context
        irods::error err = univ_mss_check_param< irods::data_object >( _ctx );
        if ( !err.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - invalid context";
            return PASSMSG( msg.str(), err );

        }

        // =-=-=-=-=-=-=-
        // get the script property
        std::string script;
        err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
        if ( !err.ok() ) {
            return PASSMSG( __FUNCTION__, err );
        }

        // =-=-=-=-=-=-=-
        // snag a ref to the fco
        irods::data_object_ptr fco = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
        std::string filename = fco->physical_path();

        int mode = fco->mode();
        int status = 0;
        execCmd_t execCmdInp;

        if ( mode != getDefDirMode() ) {
            mode = getDefFileMode();
        }

        bzero( &execCmdInp, sizeof( execCmdInp ) );
        snprintf( execCmdInp.cmd, sizeof( execCmdInp.cmd ), "%s", script.c_str() );
        snprintf( execCmdInp.cmdArgv, sizeof( execCmdInp.cmdArgv ), "chmod '%s' %o", filename.c_str(), mode );
        snprintf( execCmdInp.execAddr, sizeof( execCmdInp.execAddr ), "%s", "localhost" );
        execCmdOut_t *execCmdOut = NULL;
        status = _rsExecCmd( &execCmdInp, &execCmdOut );
        freeCmdExecOut( execCmdOut );

        if ( status < 0 ) {
            status = UNIV_MSS_CHMOD_ERR - errno;
            std::stringstream msg;
            msg << "univ_mss_file_chmod - failed for [";
            msg << filename;
            msg << "]";
            return ERROR( status, msg.str() );

        }

        return CODE( status );

    } // univ_mss_file_chmod
开发者ID:0x414A,项目名称:irods,代码行数:57,代码来源:libunivmss.cpp

示例14: add_line

static void add_line(ushort line, uint64_t time)
{
	int n;
	char buf[32], num[16];
	char *p;
	
	n = line - _last_line;
	p = buf;
	
	if (n >= -9 && n <= 9)
		*p++ = CODE(0 + n + 9);
	else if (n >= -99 && n <= 99)
	{
		*p++ = n > 0 ? CODE(19) : CODE(20);
		*p++ = CODE(0) + abs(n) - 10;
	}
	else
	{
		*p++ = n > 0 ? CODE(21) : CODE(22);
		n = sprintf(num, "%d", abs(n));
		*p++ = CODE(n);
		strcpy(p, num);
		p += n;
	}
	
	if (time <= 9)
		*p++ = CODE(time);
	else
	{
		n = sprintf(num, "%" PRIu64, time);
		*p++ = CODE(10 + n - 2);
		strcpy(p, num);
		p += n;
	}
	
	*p = 0;
	
	fputs(buf, _file);
	
	_last_line = line;
	_new_line = FALSE;
	_count++;
	if ((_count & 0xFFFFF) == 0)
		check_size();
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:45,代码来源:profile.c

示例15: medsa_print_full

static void
medsa_print_full(netdissect_options *ndo,
		 const struct medsa_pkthdr *medsa,
		 u_int caplen)
{
	u_char tag = TAG(medsa);

	ND_PRINT((ndo, "%s",
		  tok2str(tag_values, "Unknown (%u)", tag)));

	switch (tag) {
	case TAG_TO_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		ND_PRINT((ndo, ", %s",
			  tok2str(code_values, "Unknown (%u)", CODE(medsa))));
		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FROM_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FORWARD:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		if (TRUNK(medsa))
			ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
		else
			ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	default:
		ND_DEFAULTPRINT((const u_char *)medsa, caplen);
		return;
	}
}
开发者ID:Distrotech,项目名称:tcpdump,代码行数:52,代码来源:print-medsa.c


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