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

C++ CP函数代码示例

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

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



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

示例1: G_xpsave_load

qboolean G_xpsave_load(gentity_t *ent)
{
	int i, j;
	qboolean found = qfalse, XPSMuted = qfalse;
	int clientNum;
	g_xpsave_t *x = g_xpsaves[0];
	time_t t;
	char agestr[MAX_STRING_CHARS];
	//char desc[64];
	// josh: Increased this
	// josh: TODO: tjw? What is this desc thing for?
	char desc[115];
	int age;
	int eff_XPSaveMaxAge_xp = G_getXPSaveMaxAge_xp();
	int eff_XPSaveMaxAge = G_getXPSaveMaxAge();
	float startxptotal = 0.0f;

	if(!ent || !ent->client)
		return qfalse;
	if(!(g_XPSave.integer & XPSF_ENABLE))
		return qfalse;	
	if(!time(&t))
		return qfalse;

	desc[0] = '\0';
	clientNum = ent - g_entities;
	
	for(i=0; g_xpsaves[i]; i++) {
		if(!Q_stricmp(g_xpsaves[i]->guid, 
			ent->client->sess.guid)) {
			found = qtrue;
			x = g_xpsaves[i];
			break;
		}
	}
	if(!found)
		return qfalse;

	age = t - x->time;
	if(age > eff_XPSaveMaxAge) {
		return qfalse;
	}

	if(age <= eff_XPSaveMaxAge_xp) {
		for(i=0; i<SK_NUM_SKILLS; i++) {
			ent->client->sess.skillpoints[i] = x->skill[i];
			// pheno: fix for session startxptotal value
			startxptotal += x->skill[i];
		}
		ent->client->sess.startxptotal = startxptotal;
		ent->client->ps.stats[STAT_XP] = 
			(int)ent->client->sess.startxptotal;
		Q_strcat(desc, sizeof(desc), "XP/");
		if((g_XPDecay.integer & XPDF_ENABLE) &&
			!(g_XPDecay.integer & XPDF_NO_DISCONNECT_DECAY)) {
			G_XPDecay(ent, age, qtrue);
		}
	}

	ent->client->sess.overall_killrating = x->kill_rating;
	ent->client->sess.overall_killvariance = x->kill_variance;
	//ent->client->sess.playerrating = x->playerrating;
	ent->client->sess.rating = x->rating;
	ent->client->sess.rating_variance = x->rating_variance;

	for(i=0; i<SK_NUM_SKILLS; i++) {
		for(j=0; j<NUM_SKILL_LEVELS; j++) {
			ent->client->sess.pr_skill_updates[i][j] =
				x->pr_skill_updates[i][j];
			ent->client->sess.pr_skill[i][j] =
				x->pr_skill[i][j];
		}
	}

	Q_strcat(desc, sizeof(desc), "ratings/");
	
	if(x->mutetime != 0) {
		if(x->mutetime < 0){
			ent->client->sess.auto_unmute_time = -1;
			XPSMuted = qtrue;
		}else if(x->mutetime > t){
			ent->client->sess.auto_unmute_time = (level.time + 1000*(x->mutetime - t));
			XPSMuted = qtrue;;
		}

		if(XPSMuted == qtrue){
			CP("print \"^5You've been muted by XPSave\n\"" );
			Q_strcat(desc, sizeof(desc), "mute/");
		}
	}

	ent->client->sess.hits = x->hits;
	ent->client->sess.team_hits = x->team_hits;
	G_CalcRank(ent->client);
	BG_PlayerStateToEntityState(&ent->client->ps,
			&ent->s,
			level.time,
			qtrue);
	// tjw: trim last / from desc
	if(strlen(desc))
//.........这里部分代码省略.........
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,代码来源:g_xpsave.c


示例2: CP

http_header& http_header::set_host(const char* value)
{
	if (value && *value)
		CP(host_, value);
	return *this;
}
开发者ID:10jschen,项目名称:acl,代码行数:6,代码来源:http_header.cpp


示例3: Cmd_Powerup_f

void Cmd_Powerup_f( gentity_t * ent ) 
{
    int i = 0;
    int argc = trap_Argc();
    char arg[MAX_TOKEN_CHARS] = "\0";
	char arg2[MAX_TOKEN_CHARS] = "\0";

    if( !ent->client->sess.routeMaker )
    {
        CP("cp \"^7You need to be a route maker to create powerups.\n\"");
        return;
    }

    if(argc < 2)
    {
        CP("print \"usage: ^7powerup [type]\n\"");
        return;
    }
	
    trap_Argv(1, arg, sizeof(arg));

    if(!Q_stricmp(arg, "help"))
    {
        PrintPowerupHelp(ent);
        return;
    }
	
	
	if(!Q_stricmp(arg, "info"))
	{
		trap_Argv(2, arg, sizeof(arg));
		PrintPowerupInfo(ent, arg);
		return;
	}

    // Special case, spawn random pwup
    if(!Q_stricmp(arg, "random"))
    {
        int index = rand() % numPowerups;

        if(powerups[index].spawn && powerups[index].think)
        {
            if(level.numPowerups == MAX_POWERUPS)
            {
                CP("print \"^1error: ^7too many powerups spawned.\n\"");
                return;
            }
            level.powerups[level.numPowerups] = powerups[index].spawn(ent, powerups[index].think);
            level.powerups[level.numPowerups]->powerupType = powerups[index].pw;
            level.powerups[level.numPowerups]->powerupModelType = powerups[index].modelIndex;
            level.numPowerups++;
            CP("cp \"^5Spawned a random powerup\n\"");
        }
        return;
    }

    if(!Q_stricmp(arg, "any"))
    {
        if(level.numPowerups == MAX_POWERUPS)
        {
            CP("print \"^1error: ^7too many powerups spawned.\n\"");
            return;
        }
        level.powerups[level.numPowerups] = SpawnRandomPowerupSpawner( ent );
        level.powerups[level.numPowerups]->powerupType = PW_RANDOM;
        level.powerups[level.numPowerups]->powerupModelType = PW_RANDOM;
        level.numPowerups++;
        CP("cp \"^5Spawned a random powerup\n\"");
        return;
    }

    for(; i < numPowerups; i++)
    {
        if(!Q_stricmp(arg, powerups[i].name))
        {
            if(powerups[i].spawn && powerups[i].think)
            {
                if(level.numPowerups == MAX_POWERUPS)
                {
                    CP("print \"^1error: ^7too many powerups spawned.\n\"");
                    return;
                }
                level.powerups[level.numPowerups] = powerups[i].spawn(ent, powerups[i].think);
                level.powerups[level.numPowerups]->powerupType = powerups[i].pw;
                level.powerups[level.numPowerups]->powerupModelType = powerups[i].modelIndex;
                level.numPowerups++;
                CP(va("cp \"^5Spawned a %s powerup\n\"", powerups[i].text));
            } else
            {
                G_LogPrintf("Undefined powerup: %s\n", arg);
            }
            break;
        }
    }
}
开发者ID:haapanen,项目名称:satchelrace,代码行数:95,代码来源:g_powerups.c


示例4: cm_t35_set_muxconf

static void cm_t35_set_muxconf(void)
{
	/* DSS */
	MUX_VAL(CP(DSS_DATA0),		(IDIS | PTD | DIS | M0)); /*DSS_DATA0*/
	MUX_VAL(CP(DSS_DATA1),		(IDIS | PTD | DIS | M0)); /*DSS_DATA1*/
	MUX_VAL(CP(DSS_DATA2),		(IDIS | PTD | DIS | M0)); /*DSS_DATA2*/
	MUX_VAL(CP(DSS_DATA3),		(IDIS | PTD | DIS | M0)); /*DSS_DATA3*/
	MUX_VAL(CP(DSS_DATA4),		(IDIS | PTD | DIS | M0)); /*DSS_DATA4*/
	MUX_VAL(CP(DSS_DATA5),		(IDIS | PTD | DIS | M0)); /*DSS_DATA5*/

	MUX_VAL(CP(DSS_DATA18),         (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/
	MUX_VAL(CP(DSS_DATA19),         (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/
	MUX_VAL(CP(DSS_DATA20),         (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/
	MUX_VAL(CP(DSS_DATA21),         (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/
	MUX_VAL(CP(DSS_DATA22),         (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/
	MUX_VAL(CP(DSS_DATA23),         (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/

	/* MMC1 */
	MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M0)); /*MMC1_DAT4*/
	MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M0)); /*MMC1_DAT5*/
	MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN  | M0)); /*MMC1_DAT6*/
	MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN  | M0)); /*MMC1_DAT7*/
}
开发者ID:5victor,项目名称:u-boot-mini2440,代码行数:23,代码来源:cm_t35.c


示例5: G_voteHelp

// Voting help summary.
void G_voteHelp(gentity_t *ent, qboolean fShowVote)
{
	int i, rows = 0, num_cmds = sizeof(aVoteInfo) / sizeof(aVoteInfo[0]) - 1;     // Remove terminator;
	int vi[100];            // Just make it large static.


	if (fShowVote)
	{
		CP("print \"\nValid ^3callvote^7 commands are:\n^3----------------------------\n\"");
	}

	for (i = 0; i < num_cmds; i++)
	{
		if (aVoteInfo[i].dwGameTypes & (1 << g_gametype.integer))
		{
			vi[rows++] = i;
		}
	}

	num_cmds = rows;
	rows     = num_cmds / HELP_COLUMNS;

	if (num_cmds % HELP_COLUMNS)
	{
		rows++;
	}
	if (rows < 0)
	{
		return;
	}

	for (i = 0; i < rows; i++)
	{
		if (i + rows * 3 + 1 <= num_cmds)
		{
			G_refPrintf(ent, "^5%-17s%-17s%-17s%-17s", aVoteInfo[vi[i]].pszVoteName,
			            aVoteInfo[vi[i + rows]].pszVoteName,
			            aVoteInfo[vi[i + rows * 2]].pszVoteName,
			            aVoteInfo[vi[i + rows * 3]].pszVoteName);
		}
		else if (i + rows * 2 + 1 <= num_cmds)
		{
			G_refPrintf(ent, "^5%-17s%-17s%-17s", aVoteInfo[vi[i]].pszVoteName,
			            aVoteInfo[vi[i + rows]].pszVoteName,
			            aVoteInfo[vi[i + rows * 2]].pszVoteName);
		}
		else if (i + rows + 1 <= num_cmds)
		{
			G_refPrintf(ent, "^5%-17s%-17s", aVoteInfo[vi[i]].pszVoteName,
			            aVoteInfo[vi[i + rows]].pszVoteName);
		}
		else
		{
			G_refPrintf(ent, "^5%-17s", aVoteInfo[vi[i]].pszVoteName);
		}
	}

	if (fShowVote)
	{
		CP("print \"\nUsage: ^3\\callvote <command> <params>\n^7For current settings/help, use: ^3\\callvote <command> ?\n\n\"");
	}

	return;
}
开发者ID:morsik,项目名称:war-territory,代码行数:65,代码来源:g_vote.c


示例6: G_smvAddView

// Add a player entity to another player's multiview list
void G_smvAddView(gentity_t *ent, int pID)
{
	int       i;
	mview_t   *mv = NULL;
	gentity_t *v;

	if (pID >= MAX_MVCLIENTS || G_smvLocateEntityInMVList(ent, pID, qfalse))
	{
		return;
	}

	for (i = 0; i < MULTIVIEW_MAXVIEWS; i++)
	{
		if (!ent->client->pers.mv[i].fActive)
		{
			mv = &ent->client->pers.mv[i];
			break;
		}
	}

	if (mv == NULL)
	{
		CP(va("print \"[lof]** [lon]Sorry, no more MV slots available (all[lof] %d [lon]in use)[lof]\n\"", MULTIVIEW_MAXVIEWS));
		return;
	}

	mv->camera = G_Spawn();
	if (mv->camera == NULL)
	{
		return;
	}

	if (ent->client->sess.sessionTeam == TEAM_SPECTATOR &&  /*ent->client->sess.sessionTeam != TEAM_SPECTATOR ||*/
	    ent->client->sess.spectatorState == SPECTATOR_FOLLOW)
	{
		SetTeam(ent, "s", qtrue, -1, -1, qfalse);
	}
	else if (ent->client->sess.sessionTeam != TEAM_SPECTATOR && !(ent->client->ps.pm_flags & PMF_LIMBO))
	{
		limbo(ent, qtrue);
	}

	ent->client->ps.clientNum        = ent - g_entities;
	ent->client->sess.spectatorState = SPECTATOR_FREE;

	ent->client->pers.mvCount++;
	mv->fActive = qtrue;
	mv->entID   = pID;

	v                 = mv->camera;
	v->classname      = "misc_portal_surface";
	v->r.svFlags      = SVF_PORTAL | SVF_SINGLECLIENT; // Only merge snapshots for the target client
	v->r.singleClient = ent->s.number;
	v->s.eType        = ET_PORTAL;

	VectorClear(v->r.mins);
	VectorClear(v->r.maxs);
	trap_LinkEntity(v);

	v->target_ent = &g_entities[pID];
	v->TargetFlag = pID;
	v->tagParent  = ent;

	G_smvUpdateClientCSList(ent);
}
开发者ID:Classixz,项目名称:etlegacy,代码行数:66,代码来源:g_multiview.c


示例7: G_players_cmd

// ************** PLAYERS
//
// Show client info
void G_players_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fValue)
{
	int i, idnum, max_rate, cnt=0, tteam;
	int user_rate, user_snaps, bots = 0;
	gclient_t *cl;
	gentity_t *cl_ent;
	char n2[MAX_NETNAME], ready[16], ref[16], ign[16], rate[256];
	char *s, *tc, *coach, userinfo[MAX_INFO_STRING];


	if(g_gamestate.integer == GS_PLAYING) {
		if(ent) {
			CP("print \"\n^3 ID^1 : ^3Player                    Nudge  Rate  MaxPkts  Snaps\n\"");
			CP(  "print \"^1-----------------------------------------------------------^7\n\"");
		} else {
			G_Printf(" ID : Player                    Nudge  Rate  MaxPkts  Snaps\n");
			G_Printf("-----------------------------------------------------------\n");
		}
	} else {
		if(ent) {
			CP("print \"\n^3Status^1   : ^3ID^1 : ^3Player                    Nudge  Rate  MaxPkts  Snaps\n\"");
			CP(  "print \"^1---------------------------------------------------------------------^7\n\"");
		} else {
			G_Printf("Status   : ID : Player                    Nudge  Rate  MaxPkts  Snaps\n");
			G_Printf("---------------------------------------------------------------------\n");
		}
	}

	max_rate = trap_Cvar_VariableIntegerValue("sv_maxrate");

	for(i=0; i<level.numConnectedClients; i++) {
		idnum = level.sortedClients[i];//level.sortedNames[i];
		cl = &level.clients[idnum];
		cl_ent = g_entities + idnum;

		SanitizeString(cl->pers.netname, n2, qtrue);
		n2[26] = 0;
		ref[0] = 0;
		ign[0] = 0;
		ready[0] = 0;

		// Rate info
		if(cl_ent->r.svFlags & SVF_BOT) {
			strcpy(rate, va("%s%s%s%s", "[BOT]", " -----", "       --", "     --"));
			bots++;
		} else if(cl->pers.connected == CON_CONNECTING) {
			strcpy(rate, va("%s", "^3>>> CONNECTING <<<"));
		} else {
			trap_GetUserinfo( idnum, userinfo, sizeof(userinfo));
			s = Info_ValueForKey( userinfo, "rate" );
			user_rate = (max_rate > 0 && atoi(s) > max_rate) ? max_rate : atoi(s);
			s = Info_ValueForKey( userinfo, "snaps" );
			user_snaps = atoi(s);

			strcpy(rate, va("%5d%6d%9d%7d", cl->pers.clientTimeNudge, user_rate, cl->pers.clientMaxPackets, user_snaps));
		}

		if(g_gamestate.integer != GS_PLAYING) {
			// Dens: bots aren't counted, but specs are since changeset 1469
			if((g_entities[idnum].r.svFlags & SVF_BOT) || cl->pers.connected == CON_CONNECTING)
				strcpy(ready, ((ent) ? "^5--------^1 :" : "-------- :"));
			else if(cl->pers.ready)
				strcpy(ready, ((ent) ? "^3(READY)^1  :" : "(READY)  :"));
			else
				strcpy(ready, ((ent) ? "NOTREADY^1 :" : "NOTREADY :"));
		}

		if(cl->sess.referee) strcpy(ref, "REF ");

		// pheno: mark ignored clients
		if ( COM_BitCheck(ent->client->sess.ignoreClients, idnum) ) {
			strcpy(ign, (( ent ) ? "^8I" : "I"));
		}

		if(cl->sess.coach_team) {
			tteam = cl->sess.coach_team;
			coach = (ent) ? "^3C" : "C";
		} else {
			tteam = cl->sess.sessionTeam;
			coach = " ";
		}

		tc = (ent) ? "^7 " : " ";
		if(g_gametype.integer >= GT_WOLF) {
			if(tteam == TEAM_AXIS) tc = (ent) ? "^1X^7" : "X";
			if(tteam == TEAM_ALLIES) tc = (ent) ? "^4L^7" : "L";
		}

		if(ent) CP(va("print \"%s%s%2d%s^1:%s %-26s^7%s  ^3%s%s\n\"", ready, tc, idnum, coach, ((ref[0])?"^3":"^7"), n2, rate, ref, ign));
		else G_Printf("%s%s%2d%s: %-26s%s  %s%s\n", ready, tc, idnum, coach, n2, rate, ref, ign);

		cnt++;
	}

	if(ent) CP(va("print \"\n^3%2d^7 total players (^3%2d^7 humans, ^3%2d^7 bots)\n\n\"",
		cnt, cnt - bots, bots));
	else G_Printf("\n%2d total players (%2d humans, %2d bots\n\n", cnt, cnt - bots, bots);
//.........这里部分代码省略.........
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,代码来源:g_cmds_ext.c


示例8: getargs

/*
 * Get the argument words for a command into genbuf
 * expanding # and %.
 */
int
getargs(void)
{
	register int c;
	register char *cp, *fp;
	static char fpatbuf[32];	/* hence limit on :next +/pat */

	pastwh();
	if (peekchar() == '+') {
		for (cp = fpatbuf;;) {
			c = *cp++ = ex_getchar();
			if (cp >= &fpatbuf[sizeof(fpatbuf)])
				error("Pattern too long");
			if (c == '\\' && isspace(peekchar()))
				c = ex_getchar();
			if (c == EOF || isspace(c)) {
				ungetchar(c);
				*--cp = 0;
				firstpat = &fpatbuf[1];
				break;
			}
		}
	}
	if (skipend())
		return (0);
	CP(genbuf, "echo "); cp = &genbuf[5];
	for (;;) {
		c = ex_getchar();
		if (endcmd(c)) {
			ungetchar(c);
			break;
		}
		switch (c) {

		case '\\':
			if (any(peekchar(), "#%|"))
				c = ex_getchar();
			/* fall into... */

		default:
			if (cp > &genbuf[LBSIZE - 2])
flong:
				error("Argument buffer overflow");
			*cp++ = c;
			break;

		case '#':
			fp = altfile;
			if (*fp == 0)
				error("No alternate file[email protected] substitute for #");
			goto filexp;

		case '%':
			fp = savedfile;
			if (*fp == 0)
				error("No current [email protected] substitute for %%");
filexp:
			while (*fp) {
				if (cp > &genbuf[LBSIZE - 2])
					goto flong;
				*cp++ = *fp++;
			}
			break;
		}
	}
	*cp = 0;
	return (1);
}
开发者ID:n-t-roff,项目名称:ex-3.6,代码行数:72,代码来源:ex_io.c


示例9: filename

/*
 * Parse file name for command encoded by comm.
 * If comm is E then command is doomed and we are
 * parsing just so user won't have to retype the name.
 */
void
filename(int comm)
{
	register int c = comm, d;
	register int i;

	d = ex_getchar();
	if (endcmd(d)) {
		if (savedfile[0] == 0 && comm != 'f')
			error("No file|No current filename");
		CP(file, savedfile);
		wasalt = (isalt > 0) ? isalt-1 : 0;
		isalt = 0;
		oldadot = altdot;
		if (c == 'e' || c == 'E')
			altdot = lineDOT();
		if (d == EOF)
			ungetchar(d);
	} else {
		ungetchar(d);
		getone();
		eol();
		if (savedfile[0] == 0 && c != 'E' && c != 'e') {
			c = 'e';
			edited = 0;
		}
		wasalt = strcmp(file, altfile) == 0;
		oldadot = altdot;
		switch (c) {

		case 'f':
			edited = 0;
			/* fall into ... */

		case 'e':
			if (savedfile[0]) {
				altdot = lineDOT();
				CP(altfile, savedfile);
			}
			CP(savedfile, file);
			break;

		default:
			if (file[0]) {
				if (c != 'E')
					altdot = lineDOT();
				CP(altfile, file);
			}
			break;
		}
	}
	if ((hush && comm != 'f') || comm == 'E')
		return;
	if (file[0] != 0) {
		lprintf("\"%s\"", file);
		if (comm == 'f') {
			if (value(READONLY))
				ex_printf(" [Read only]");
			if (!edited)
				ex_printf(" [Not edited]");
			if (tchng)
				ex_printf(" [Modified]");
		}
		flush();
	} else
		ex_printf("No file ");
	if (comm == 'f') {
		if (!(i = lineDOL()))
			i++;
		ex_printf(" line %d of %d --%ld%%--", lineDOT(), lineDOL(),
		    (long) 100 * lineDOT() / i);
	}
}
开发者ID:n-t-roff,项目名称:ex-3.6,代码行数:78,代码来源:ex_io.c


示例10: G_weaponRankings_cmd

// Shows best/worst accuracy for all weapons, or sorted
// accuracies for a single weapon.
void G_weaponRankings_cmd(gentity_t * ent, unsigned int dwCommand, qboolean state)
{
	gclient_t      *cl;
	int             c = 0, i, wBestAcc;
	unsigned int	shots;	// CHRUKER: b068 - unsigned
	char            z[MAX_STRING_CHARS];

	if(trap_Argc() < 2)
	{
		G_weaponStatsLeaders_cmd(ent, state, qfalse);
		return;
	}

	wBestAcc = (state) ? 0 : 99999;

	// Find the weapon
	trap_Argv(1, z, sizeof(z));
	if((iWeap = atoi(z)) == 0 || iWeap < WS_KNIFE || iWeap >= WS_MAX)
	{
		for(iWeap = WS_SYRINGE; iWeap >= WS_KNIFE; iWeap--)
		{
			if(!Q_stricmp(z, aWeaponInfo[iWeap].pszCode))
			{
				break;
			}
		}
	}

	if(iWeap < WS_KNIFE)
	{
		G_commandHelp(ent, (state) ? "topshots" : "bottomshots", dwCommand);

		Q_strncpyz(z, "^3Available weapon codes:^7\n", sizeof(z));
		for(i = WS_KNIFE; i < WS_MAX; i++)
		{
			Q_strcat(z, sizeof(z), va("  %s - %s\n", aWeaponInfo[i].pszCode, aWeaponInfo[i].pszName));
		}
		CP(va("print \"%s\"", z));
		return;
	}

	memcpy(&level.sortedStats, &level.sortedClients, sizeof(level.sortedStats));
	qsort(level.sortedStats, level.numConnectedClients, sizeof(level.sortedStats[0]), SortStats);

	z[0] = 0;
	for(i = 0; i < level.numConnectedClients; i++)
	{
		cl = &level.clients[level.sortedStats[i]];

		if(cl->sess.sessionTeam == TEAM_SPECTATOR)
		{
			continue;
		}

		shots = cl->sess.aWeaponStats[iWeap].atts;
		if(shots >= cQualifyingShots[iWeap])
		{
			float           acc = (float)(cl->sess.aWeaponStats[iWeap].hits * 100.0) / (float)shots;

			c++;
			wBestAcc = (((state) ? acc : wBestAcc) > ((state) ? wBestAcc : acc)) ? (int)acc : wBestAcc;
			Q_strcat(z, sizeof(z), va(" %d %d %d %d %d", level.sortedStats[i],
									  cl->sess.aWeaponStats[iWeap].hits,
									  shots, cl->sess.aWeaponStats[iWeap].kills, cl->sess.aWeaponStats[iWeap].deaths));
		}
	}

	CP(va("astats%s %d %d %d%s", ((state) ? "" : "b"), c, iWeap, wBestAcc, z));
}
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:71,代码来源:g_cmds_ext.c


示例11: G_ref_cmd

// Request for ref status or lists ref commands.
void G_ref_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fValue)
{
	char arg[MAX_TOKEN_CHARS];


	// Roll through ref commands if already a ref
	if (ent == NULL || ent->client->sess.referee)
	{
		voteInfo_t votedata;

		trap_Argv(1, arg, sizeof(arg));

		memcpy(&votedata, &level.voteInfo, sizeof(voteInfo_t));

		if (Cmd_CallVote_f(ent, 0, qtrue))
		{
			memcpy(&level.voteInfo, &votedata, sizeof(voteInfo_t));
			return;
		}
		else
		{
			memcpy(&level.voteInfo, &votedata, sizeof(voteInfo_t));

			if (G_refCommandCheck(ent, arg))
			{
				return;
			}
			else
			{
				G_refHelp_cmd(ent);
			}
		}
		return;
	}

	if (ent)
	{
		if (!Q_stricmp(refereePassword.string, "none") || !refereePassword.string[0])
		{
			CP("cpm \"Sorry, referee status disabled on this server.\n\"");
			return;
		}

		if (trap_Argc() < 2)
		{
			CP("cpm \"Usage: ref [password]\n\"");
			return;
		}

		trap_Argv(1, arg, sizeof(arg));

		if (Q_stricmp(arg, refereePassword.string))
		{
			CP("cpm \"Invalid referee password!\n\"");
			return;
		}

		ent->client->sess.referee     = 1;
		ent->client->sess.spec_invite = TEAM_AXIS | TEAM_ALLIES;
		AP(va("cp \"%s\n^3has become a referee\n\"", ent->client->pers.netname));
		ClientUserinfoChanged(ent - g_entities);
	}
}
开发者ID:morsik,项目名称:war-territory,代码行数:64,代码来源:g_referee.c


示例12: G_pause_cmd

// ************** PAUSE / UNPAUSE
//
// Pause/unpause a match.
void G_pause_cmd(gentity_t * ent, unsigned int dwCommand, qboolean fPause)
{
	char           *status[2] = { "^5UN", "^1" };

	if(team_nocontrols.integer)
	{
		G_noTeamControls(ent);
		return;
	}

	if((PAUSE_UNPAUSING >= level.match_pause && !fPause) || (PAUSE_NONE != level.match_pause && fPause))
	{
		CP(va("print \"The match is already %sPAUSED^7!\n\"", status[fPause]));
		return;
	}

	// Alias for referees
	if(ent->client->sess.referee)
	{
		G_refPause_cmd(ent, fPause);
	}
	else
	{
		int             tteam = G_teamID(ent);

		if(!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName))
		{
			return;
		}

		// Trigger the auto-handling of pauses
		if(fPause)
		{
			if(0 == teamInfo[tteam].timeouts)
			{
				CP("cpm \"^3Your team has no more timeouts remaining!\n\"");
				return;
			}
			else
			{
				teamInfo[tteam].timeouts--;
				level.match_pause = tteam + 128;
				G_globalSound("sound/misc/referee.wav");
				G_spawnPrintf(DP_PAUSEINFO, level.time + 15000, NULL);
				AP(va
				   ("print \"^3Match is ^1PAUSED^3!\n^7[%s^7: - %d Timeouts Remaining]\n\"", aTeams[tteam],
					teamInfo[tteam].timeouts));
				AP(va("cp \"^3Match is ^1PAUSED^3! (%s^3)\n\"", aTeams[tteam]));	// CHRUKER: b040 - Was only sending this to the client sending the command
				level.server_settings |= CV_SVS_PAUSE;
				trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings));
			}
		}
		else if(tteam + 128 != level.match_pause)
		{
			CP("cpm \"^3Your team didn't call the timeout!\n\"");
			return;
		}
		else
		{
			AP("print \"^3Match is ^5UNPAUSED^3 ... resuming in 10 seconds!\n\"");	// CHRUKER: b068 - Had extra linebreaks, before and after.
			level.match_pause = PAUSE_UNPAUSING;
			G_globalSound("sound/osp/prepare.wav");
			G_spawnPrintf(DP_UNPAUSING, level.time + 10, NULL);
		}
	}
}
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:69,代码来源:g_cmds_ext.c


示例13: AB

double Math::Triangle::distance(const Point2D& p, Point2D* closestPoint)
{
    //Source is: http://wonderfl.net/c/b27F

    Vector2D AB(_b.x - _a.x, _b.y - _a.y);
    Vector2D AP(p.x - _a.x, p.y - _a.y);
    double ABXAP = (AB.x * AP.y) - (AB.y * AP.x);

    Vector2D BC(_c.x - _b.x, _c.y - _b.y);
    Vector2D BP(p.x - _b.x, p.y - _b.y);
    double BCXBP = (BC.x * BP.y) - (BC.y * BP.x);

    Vector2D CA(_a.x - _c.x, _a.y - _c.y);
    Vector2D CP(p.x - _c.x, p.y - _c.y);
    double CAXCP = (CA.x * CP.y) - (CA.y * CP.x);

    double distance = 0;

    //+++ //inside
    if (ABXAP >= 0 && BCXBP >= 0 && CAXCP >=0)
    {
        if(closestPoint) {
            closestPoint->x = p.x;
            closestPoint->y = p.y;
        }
    }
    //-+- //vertex
    else if (ABXAP < 0 && BCXBP >= 0 && CAXCP < 0)
    {
        distance = AP.x * AP.x + AP.y * AP.y;
        if(closestPoint) {
            closestPoint->x = _a.x;
            closestPoint->y = _a.y;
        }
    }
    //--+ //vertex
    else if (ABXAP < 0 && BCXBP < 0 && CAXCP >= 0)
    {
        distance = BP.x * BP.x + BP.y * BP.y;
        if(closestPoint) {
            closestPoint->x = _b.x;
            closestPoint->y = _b.y;
        }
    }
    //+-- //vertex
    else if (ABXAP >= 0 && BCXBP < 0 && CAXCP < 0)
    {
        distance = CP.x * CP.x + CP.y * CP.y;
        if(closestPoint) {
            closestPoint->x = _c.x;
            closestPoint->y = _c.y;
        }
    }
    //-++ //edge
    else if (ABXAP < 0 && BCXBP >= 0 && CAXCP >= 0)
    {
        double wd = ((AB.x * AP.x) + (AB.y * AP.y) ) / ((AB.x * AB.x) + (AB.y * AB.y));
        if (wd < 0) {
            wd = 0;
        }
        if (wd > 1) {
            wd = 1;
        }
        Point2D r;
        r.x = _a.x + (_b.x - _a.x) * wd;
        r.y = _a.y + (_b.y - _a.y) * wd;

        if (closestPoint) {
            closestPoint->x = r.x;
            closestPoint->y = r.y;
        }
        r.x = p.x - r.x;
        r.y = p.y - r.y;
        distance = r.x * r.x + r.y * r.y;
    }
    //+-+ //edge
    else if (ABXAP >= 0 && BCXBP < 0 && CAXCP >= 0)
    {
        double wd = ((BC.x * BP.x) + (BC.y * BP.y) ) / ((BC.x * BC.x) + (BC.y * BC.y));
        if (wd < 0) {
            wd = 0;
        }
        if (wd > 1) {
            wd = 1;
        }
        Point2D r;
        r.x = _b.x + (_c.x - _b.x) * wd;
        r.y = _b.y + (_c.y - _b.y) * wd;

        if (closestPoint) {
            closestPoint->x = r.x;
            closestPoint->y = r.y;
        }
        r.x = p.x - r.x;
        r.y = p.y - r.y;
        distance = r.x * r.x + r.y * r.y;
    }
    //++- //edge
    else if (ABXAP >= 0 && BCXBP >= 0 && CAXCP < 0)
    {
//.........这里部分代码省略.........
开发者ID:MartinHaimberger,项目名称:Homegear,代码行数:101,代码来源:Math.cpp


示例14: vappend


//.........这里部分代码省略.........
				addc('0');
			while (CDCNT > 0)
#ifndef	BIT8
				addc('\204'), CDCNT--;
#else
				addc(OVERBUF), CDCNT--;
#endif
			
			if (gobbled)
				addc(' ');
			addtext(ogcursor);
		}
		repcnt = 0;

		/*
		 * Smash the generated and preexisting indents together
		 * and generate one cleanly made out of tabs and spaces
		 * if we are using autoindent.
		 */
		if (!vaifirst && value(AUTOINDENT)) {
			i = fixindent(indent);
			if (!HADUP)
				indent = i;
			gcursor = strend(genbuf);
		}

		/*
		 * Limit the repetition count based on maximum
		 * possible line length; do output implied
		 * by further count (> 1) and cons up the new line
		 * in linebuf.
		 */
		cnt = vmaxrep(ch, cnt);
		CP(gcursor + skipright(ogcursor, gcursor), cursor);
		do {
			CP(cursor, genbuf);
			if (cnt > 1) {
				int oldhold = hold;

				Outchar = vinschar;
				hold |= HOLDQIK;
				ex_printf("%s", genbuf);
				hold = oldhold;
				Outchar = vputchar;
			}
			cursor += gcursor - genbuf;
		} while (--cnt > 0);
		endim();
		vUA2 = cursor;
		if (escape != '\n')
			CP(cursor, gcursor + skipright(ogcursor, gcursor));

		/*
		 * If doomed characters remain, clobber them,
		 * and reopen the line to get the display exact.
		 */
		if (state != HARDOPEN) {
			DEPTH(vcline) = 0;
			savedoomed = doomed;
			if (doomed > 0) {
				register int cind = cindent();

				physdc(cind, cind + doomed);
				doomed = 0;
			}
			i = vreopen(LINE(vcline), lineDOT(), vcline);
开发者ID:n-t-roff,项目名称:heirloom-ex-vi,代码行数:67,代码来源:ex_vops2.c


示例15: cbconv

void cbconv(struct bsdconv_instance *ins){
	char *p;
	int i,j;
	struct bsdconv_phase *this_phase=THIS_PHASE(ins);
	struct my_s *t=this_phase->codec[this_phase->index].priv;
	char d;

	for(;this_phase->i<this_phase->curr->len;this_phase->i+=1){
		d=CP(this_phase->curr->data)[this_phase->i];
		switch(t->status){
			case 0:
				if(d=='%'){
					t->status=10;
					continue;
				}else if(d=='\\'){
					t->status=11;
					continue;
				}else{
					DEADEND();
				}
			case 10:
				if(d=='u'){
					t->status=40;
					continue;
				}else if(hex[(unsigned char)d]==-1){
					DEADEND();
				}else{
					t->status=21;
					t->buf[0]=hex[(unsigned char)d];
					continue;
				}
				break;
			case 11:
				if(d=='u'){
					t->status=40;
					continue;
				}else if(d=='x'){
					t->status=20;
					continue;
				}else if(oct[(unsigned char)d]==-1){
					DEADEND();
				}else{
					t->status=31;
					t->buf[0]=oct[(unsigned char)d];
					continue;
				}
				break;
			case 20:
				if(hex[(unsigned char)d]==-1){
					DEADEND();
				}else{
					t->status=21;
					t->buf[0]=hex[(unsigned char)d];
					continue;
				}
				break;
			case 21:
				if(hex[(unsigned char)d]==-1){
					DEADEND();
				}else{
					t->buf[0]*=16;
					t->buf[0]+=hex[(unsigned char)d];
					DATA_MALLOC(ins, this_phase->data_tail->next);
					this_phase->data_tail=this_phase->data_tail->next;
					this_phase->data_tail->next=NULL;
					this_phase->data_tail->flags=F_FREE;
					this_phase->data_tail->len=2;
					p=this_phase->data_tail->data=malloc(2);
					p[0]=0x03;
					p[1]=t->buf[0];
					this_phase->state.status=NEXTPHASE;
					t->status=0;
					return;
				}
				break;
			case 31:
				if(oct[(unsigned char)d]==-1){
					DEADEND();
				}else{
					t->status=32;
					t->buf[0]*=8;
					t->buf[0]+=oct[(unsigned char)d];
					continue;
				}
				break;
			case 32:
				if(oct[(unsigned char)d]==-1){
					DEADEND();
				}else{
					i=t->buf[0];
					i*=8;
					i+=oct[(unsigned char)d];
					if(i>377)
						DEADEND();
					t->buf[0]=i;
					DATA_MALLOC(ins, this_phase->data_tail->next);
					this_phase->data_tail=this_phase->data_tail->next;
					this_phase->data_tail->next=NULL;
					this_phase->data_tail->flags=F_FREE;
					this_phase->data_tail->len=2;
//.........这里部分代码省略.........
开发者ID:PkmX,项目名称:bsdconv,代码行数:101,代码来源:ESCAPE.c


示例16: wop

/*
 * Write a file.
 */
void
wop(bool dofname)
/* bool dofname;	/ * if 1 call filename, else use savedfile */
{
	register int c, exclam, nonexist;
	line *saddr1, *saddr2;
	struct stat stbuf;

	c = 0;
	exclam = 0;
	if (dofname) {
		if (peekchar() == '!')
			exclam++, ignchar();
		ignore(skipwh());
		while (peekchar() == '>')
			ignchar(), c++, ignore(skipwh());
		if (c != 0 && c != 2)
			error("Write forms are 'w' and 'w>>'");
		filename('w');
	} else {
		if (savedfile[0] == 0)
			error("No file|No current filename");
		saddr1=addr1;
		saddr2=addr2;
		addr1=one;
		addr2=dol;
		CP(file, savedfile);
		if (inopen) {
			vclrech(0);
			splitw++;
		}
		lprintf("\"%s\"", file);
	}
	nonexist = stat(file, &stbuf);
	switch (c) {

	case 0:
		if (!exclam && (!value(WRITEANY) || value(READONLY)))
		switch (edfile()) {
		
		case NOTEDF:
			if (nonexist)
				break;
			if ((stbuf.st_mode & S_IFMT) == S_IFCHR) {
				if (samei(&stbuf, "/dev/null"))
					break;
				if (samei(&stbuf, "/dev/tty"))
					break;
			}
			io = open(file, O_WRONLY);
			if (io < 0)
				syserror();
			if (!isatty(io))
				serror(" File exists| File exists - use \"w! %s\" to overwrite", file);
			close(io);
			break;

		case EDF:
			if (value(READONLY))
				error(" File is read only");
			break;

		case PARTBUF:
			if (value(READONLY))
				error(" File is read only");
			error(" Use \"w!\" to write partial buffer");
		}
cre:
/*
		synctmp();
*/
#ifdef V6
		io = creat(file, 0644);
#else
		io = creat(file, 0666);
#endif
		if (io < 0)
			syserror();
		writing = 1;
		if (hush == 0) {
			if (nonexist)
				ex_printf(" [New file]");
			else if (value(WRITEANY) && edfile() != EDF)
				ex_printf(" [Existing file]");
		}
		break;

	case 2:
		io = open(file, O_WRONLY);
		if (io < 0) {
			if (exclam || value(WRITEANY))
				goto cre;
			syserror();
		}
		lseek(io, 0l, SEEK_END);
		break;
	}
//.........这里部分代码省略.........
开发者ID:n-t-roff,项目名称:ex-3.6,代码行数:101,代码来源:ex_io.c


示例17: mux_config

/**
 * @brief Do the pin muxing required for Board operation.
 * We enable ONLY the pins we require to set. OMAP provides pins which do not
 * have alternate modes. Such pins done need to be set.
 *
 * See @ref MUX_VAL for description of the muxing mode.
 *
 * @return void
 */
static void mux_config(void)
{
	/* SDRC_D0 - SDRC_D31 default mux mode is mode0 */

	/* GPMC */
	MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0));

	/* D0-D7 default mux mode is mode0 */
	MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0));
	/* GPMC_NADV_ALE default mux mode is mode0 */
	/* GPMC_NOE default mux mode is mode0 */
	/* GPMC_NWE default mux mode is mode0 */
	/* GPMC_NBE0_CLE default mux mode is mode0 */
	MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_NBE1), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0));
	/* GPMC_WAIT0 default mux mode is mode0 */
	MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0));

	/* SERIAL INTERFACE */
	MUX_VAL(CP(UART3_CTS_RCTX), (IEN | PTD | EN | M0));
	MUX_VAL(CP(UART3_RTS_SD), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0));
	MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0));
	MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0));
	/* I2C1_SCL default mux mode is mode0 */
	/* I2C1_SDA default mux mode is mode0 */
	/* USB EHCI (port 2) */
	MUX_VAL(CP(MCSPI1_CS3),		(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(MCSPI2_CLK),		(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(MCSPI2_SIMO),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(MCSPI2_SOMI),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(MCSPI2_CS0),		(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(MCSPI2_CS1),		(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D10_ES2),	(IDIS | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D11_ES2),	(IDIS | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D12_ES2),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D13_ES2),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D14_ES2),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(ETK_D15_ES2),	(IEN  | PTU | DIS | M3));
	MUX_VAL(CP(UART2_RX),		(IEN  | PTD | DIS | M4)) /*GPIO_147*/;
	/* Expansion card */
	MUX_VAL(CP(MMC1_CLK),		(IDIS | PTU | EN  | M0)); /* MMC1_CLK */
	MUX_VAL(CP(MMC1_CMD),		(IEN  | PTU | EN  | M0)); /* MMC1_CMD */
	MUX_VAL(CP(MMC1_DAT0),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT0 */
	MUX_VAL(CP(MMC1_DAT1),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT1 */
	MUX_VAL(CP(MMC1_DAT2),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT2 */
	MUX_VAL(CP(MMC1_DAT3),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT3 */
	MUX_VAL(CP(MMC1_DAT4),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT4 */
	MUX_VAL(CP(MMC1_DAT5),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT5 */
	MUX_VAL(CP(MMC1_DAT6),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT6 */
	MUX_VAL(CP(MMC1_DAT7),		(IEN  | PTU | EN  | M0)); /* MMC1_DAT7 */
}
开发者ID:RobertCNelson,项目名称:barebox,代码行数:90,代码来源:lowlevel.c


示例18: G_noTeamControls

void G_noTeamControls(gentity_t *ent)
{
	CP("cpm \"Team commands not enabled on this server.\n\"");
}
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:4,代码来源:g_cmds_ext.c


示例19: freebsd32_ioctl_pciocgetconf

static int
freebsd32_ioctl_pciocgetconf(struct thread *td,
    struct freebsd32_ioctl_args *uap, struct file *fp)
{
	struct pci_conf_io pci;
	struct pci_conf_io32 pci32;
	struct pci_match_conf32 pmc32;
	struct pci_match_conf32 *pmc32p;
	struct pci_match_conf pmc;
	struct pci_match_conf *pmcp;
	struct pci_conf32 pc32;
	struct pci_conf32 *pc32p;
	struct pci_conf pc;
	struct pci_conf *pcp;
	u_int32_t i;
	u_int32_t npat_to_convert;
	u_int32_t nmatch_to_convert;
	vm_offset_t addr;
	int error;

	if ((error = copyin(uap->data, &pci32, sizeof(pci32))) != 0)
		return (error);

	CP(pci32, pci, num_patterns);
	CP(pci32, pci, offset);
	CP(pci32, pci, generation);

	npat_to_convert = pci32.pat_buf_len / sizeof(struct pci_match_conf32);
	pci.pat_buf_len = npat_to_convert * sizeof(struct pci_match_conf);
	pci.patterns = NULL;
	nmatch_to_convert = pci32.match_buf_len / sizeof(struct pci_conf32);
	pci.match_buf_len = nmatch_to_convert * sizeof(struct pci_conf);
	pci.matches = NULL;

	if ((error = copyout_map(td, &addr, pci.pat_buf_len)) != 0)
		goto cleanup;
	pci.patterns = (struct pci_match_conf *)addr;
	if ((error = copyout_map(td, &addr, pci.match_buf_len)) != 0)
		goto cleanup;
	pci.matches = (struct pci_conf *)addr;

	npat_to_convert = min(npat_to_convert, pci.num_patterns);

	for (i = 0, pmc32p = (struct pci_match_conf32 *)PTRIN(pci32.patterns),
	     pmcp = pci.patterns;
	     i < npat_to_convert; i++, pmc32p++, pmcp++) {
		if ((error = copyin(pmc32p, &pmc32, sizeof(pmc32))) != 0)
			goto cleanup;
		CP(pmc32,pmc,pc_sel);
		strlcpy(pmc.pd_name, pmc32.pd_name, sizeof(pmc.pd_name));
		CP(pmc32,pmc,pd_unit);
		CP(pmc32,pmc,pc_vendor);
		CP(pmc32,pmc,pc_device);
		CP(pmc32, 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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