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


C++ setvar函数代码示例

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


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

示例1: main

/*
 * get command line flags, initialize keywords & traps.
 * get values from environment.
 * set $pid, $cflag, $*
 * fabricate bootstrap code and start it (*=(argv);. /usr/lib/rcmain $*)
 * start interpreting code
 */
int
main(int argc, char *argv[])
{
	code bootstrap[32];
	char num[12], *rcmain;
	int i;
	
	/* needed for rcmain later */
	putenv("PLAN9", unsharp("#9"));
	argc = getflags(argc, argv, "ftjSsrdiIlxepvVc:1m:1[command]", 1);
	if(argc==-1)
		usage("[file [arg ...]]");
	if(argv[0][0]=='-')
		flag['l'] = flagset;
	if(flag['I'])
		flag['i'] = 0;
	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
	rcmain = flag['m'] ? flag['m'][0] : Rcmain();
	err = openfd(2);
	kinit();
	Trapinit();
	Vinit();
	inttoascii(num, mypid = getpid());
	pathinit();
	setvar("pid", newword(num, (word *)0));
	setvar("cflag", flag['c']?newword(flag['c'][0], (word *)0)
				:(word *)0);
	setvar("rcname", newword(argv[0], (word *)0));
	i = 0;
	bootstrap[i++].i = 1;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xassign;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xdol;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s = rcmain;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s=".";
	bootstrap[i++].f = Xsimple;
	bootstrap[i++].f = Xexit;
	bootstrap[i].i = 0;
	start(bootstrap, 1, (var *)0);
	/* prime bootstrap argv */
	pushlist();
	argv0 = strdup(argv[0]);
	for(i = argc-1;i!=0;--i) pushword(argv[i]);
	for(;;){
		if(flag['r'])
			pfnc(err, runq);
		runq->pc++;
		(*runq->code[runq->pc-1].f)();
		if(ntrap)
			dotrap();
	}
}
开发者ID:chrislusf,项目名称:push,代码行数:67,代码来源:exec.c

示例2: upsdrv_initinfo

void upsdrv_initinfo(void)
{
	if (!upsc_commandlist()) {
		upslogx(LOG_ERR, "No contact with UPS, delaying init.");
		status = UPSC_STAT_NOTINIT;
		return;
	} else {
		status = 0;
	}

	upsc_getbaseinfo();
	if (can_upda) {
		upsc_flush_input();
		upscsend("UPDA");
	}
	if (can_upid) {
		upsc_getvalue("UPID", NULL, "ACID", "ups.id", NULL);
	}
	if (can_uppm) {
		check_uppm();
	}

	/* make sure we have some sensible defaults */
	setvar("ups.delay.shutdown", "10");
	setvar("ups.delay.reboot", "60");

	upsh.instcmd = instcmd;
	upsh.setvar = setvar;
}
开发者ID:alicaccs,项目名称:nut,代码行数:29,代码来源:upscode2.c

示例3: simple_upd

void simple_upd(struct CSRMat *Mat, struct RHS *Rhs, double sol[ncell*nvar])
{
   int icell, ivar, idir;
   double *phi, *dep, *pgrd, *CelldblPnt, *dd_i;

   // Solution update -------------------
   // (all variables except pressure)
   for(icell=0;icell<ncell;icell++) {
      phi = setvar( icell);

      memcpy( &phi[Uvar], &sol[icell*nvar+Uvar], (nvar-1)*sizeof(double));
   }

   if ( eos == IFROZENP)
      return;

   // Not sure if these two instructions are relevant ...
   boundary();
   gradients( nvar, setvar( 0), PGrd, ndep, setdep( 0));

   // Velocity coefficients -------------
   calcdd( Mat);

   // Pressure equation resolution ------
   simple_peqn();

   // SIMPLE BC -------------------------
   simple_bc();

   // PresVel corrections ---------------
   for(icell=0;icell<ncell;icell++)  {
      phi        = setvar(icell);
      CelldblPnt = setdblcell(icell);
  
      //Pressure update P = P + p'
      phi[Pvar] += 0.5 * p_sol[icell];

      //Velocity update U = u* + u'
      dd_i = setsol( icell, ndir, dd);
      pgrd = setsol( icell, ndir, p_grd);

      for (idir=0;idir<ndir;idir++)
         phi[Uvar+idir] -= CelldblPnt[CellVol] * pgrd[idir] / dd_i[idir];

#if _DBG == 10
      // Adding P' and U' to CEI plot
      dep        = setdep(icell);
      dep[Ppdep] = p_sol[icell];
      for (idir=0;idir<ndir;idir++)
         dep[Updep+idir] = -CelldblPnt[CellVol] * pgrd[idir] / dd_i[idir];
#endif
   }

   // Memory release --------------------
   free(p_sol);
   free(p_grd);
   free(dd);
}
开发者ID:rupole1185,项目名称:EriCa,代码行数:58,代码来源:simple.c

示例4: conoutf

	void Client::Init()
	{
	    conoutf("[DEBUG] Client::Init");
		setvar("mainmenu", false);
		setvar("hidehud", 1);

		if(!connected)
			localconnect();
	}
开发者ID:offtools,项目名称:cubej,代码行数:9,代码来源:client.cpp

示例5: while

void AgiEngine::selectItems(int n) {
	int fsel = 0;
	bool exit_select = false;

	while (!exit_select && !(shouldQuit() || _restartGame)) {
		if (n > 0)
			printItem(fsel, STATUS_BG, STATUS_FG);

		switch (waitAnyKey()) {
		case KEY_ENTER:
			setvar(vSelItem, _intobj[fsel]);
			exit_select = true;
			break;
		case KEY_ESCAPE:
			setvar(vSelItem, 0xff);
			exit_select = true;
			break;
		case KEY_UP:
			if (fsel >= 2)
				fsel -= 2;
			break;
		case KEY_DOWN:
			if (fsel + 2 < n)
				fsel += 2;
			break;
		case KEY_LEFT:
			if (fsel % 2 == 1)
				fsel--;
			break;
		case KEY_RIGHT:
			if (fsel % 2 == 0 && fsel + 1 < n)
				fsel++;
			break;
		case BUTTON_LEFT:{
				int i = findItem();
				if (i >= 0 && i < n) {
					setvar(vSelItem, _intobj[fsel = i]);
					debugC(6, kDebugLevelInventory, "item found: %d", fsel);
					showItems();
					printItem(fsel, STATUS_BG, STATUS_FG);
					_gfx->doUpdate();
					exit_select = true;
				}
				break;
			}
		default:
			break;
		}

		if (!exit_select) {
			showItems();
			_gfx->doUpdate();
		}
	}

	debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
开发者ID:0xf1sh,项目名称:scummvm,代码行数:57,代码来源:inv.cpp

示例6: readcmd_handle_line

/** handle one line of the read command.
 *  more fields than variables -> remainder shall be part of last variable.
 *  less fields than variables -> remaining variables unset.
 *
 *  @param line complete line of input
 *  @param ap argument (variable) list
 *  @param len length of line including trailing '\0'
 */
static void
readcmd_handle_line(char *s, char **ap)
{
	struct arglist arglist;
	struct strlist *sl;
	char *backup;
	char *line;

	/* ifsbreakup will fiddle with stack region... */
	line = stackblock();
	s = grabstackstr(s);

	/* need a copy, so that delimiters aren't lost
	 * in case there are more fields than variables */
	backup = sstrdup(line);

	arglist.lastp = &arglist.list;
	
	ifsbreakup(s, &arglist);
	*arglist.lastp = NULL;
	ifsfree();

	sl = arglist.list;

	do {
		if (!sl) {
			/* nullify remaining arguments */
			do {
				setvar(*ap, nullstr, 0);
			} while (*++ap);

			return;
		}

		/* remaining fields present, but no variables left. */
		if (!ap[1] && sl->next) {
			size_t offset;
			char *remainder;

			/* FIXME little bit hacky, assuming that ifsbreakup 
			 * will not modify the length of the string */
			offset = sl->text - s;
			remainder = backup + offset;
			rmescapes(remainder);
			setvar(*ap, remainder, 0);

			return;
		}
		
		/* set variable to field */
		rmescapes(sl->text);
		setvar(*ap, sl->text, 0);
		sl = sl->next;
	} while (*++ap);
}
开发者ID:bkoropoff,项目名称:makekit,代码行数:63,代码来源:miscbltin.c

示例7: select_items

static void select_items(int n) {
	int fsel = 0;

	while (42) {
		if (n > 0)
			print_item(fsel, STATUS_BG, STATUS_FG);

		switch (wait_any_key()) {
		case KEY_ENTER:
			setvar(V_sel_item, intobj[fsel]);
			goto exit_select;
		case KEY_ESCAPE:
			setvar(V_sel_item, 0xff);
			goto exit_select;
		case KEY_UP:
			if (fsel >= 2)
				fsel -= 2;
			break;
		case KEY_DOWN:
			if (fsel + 2 < n)
				fsel += 2;
			break;
		case KEY_LEFT:
			if (fsel % 2 == 1)
				fsel--;
			break;
		case KEY_RIGHT:
			if (fsel % 2 == 0 && fsel + 1 < n)
				fsel++;
			break;
		case BUTTON_LEFT:{
				int i = find_item();
				if (i >= 0 && i < n) {
					setvar(V_sel_item, intobj[fsel = i]);
					debugC(6, kDebugLevelInventory, "item found: %d", fsel);
					show_items();
					print_item(fsel, STATUS_BG, STATUS_FG);
					do_update();
					goto exit_select;
				}
				break;
			}
		default:
			break;
		}

		show_items();
		do_update();
	}

 exit_select:
	debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
开发者ID:iPodLinux-Community,项目名称:iScummVM,代码行数:53,代码来源:inv.cpp

示例8: debugC

int TextMan::print(const char *p, int lin, int col, int len) {
	if (p == NULL)
		return 0;

	debugC(4, kDebugLevelText, "lin = %d, col = %d, len = %d", lin, col, len);

	if (col == 0 && lin == 0 && len == 0)
		lin = col = -1;

	if (len == 0)
		len = 30;

	blit_textbox(p, lin, col, len);

	if (getflag(F_output_mode)) {
		/* non-blocking window */
		setflag(F_output_mode, false);
		return 1;
	}

	/* blocking */

	if (game.vars[V_window_reset] == 0) {
		int k;
		setvar(V_key, 0);
		k = wait_key();
		close_window();
		return k;
	}

	/* timed window */

	debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
	game.msg_box_ticks = getvar(V_window_reset) * 10;
	setvar(V_key, 0);

	do {
		main_cycle();
		if (game.keypress == KEY_ENTER) {
			debugC(4, kDebugLevelText, "KEY_ENTER");
			setvar(V_window_reset, 0);
			game.keypress = 0;
			break;
		}
	} while (game.msg_box_ticks > 0);

	setvar(V_window_reset, 0);

	close_window();

	return 0;
}
开发者ID:iPodLinux-Community,项目名称:iScummVM,代码行数:52,代码来源:text.cpp

示例9: setvar

	void Client::editMode(bool on)
	{
		if(on)
		{
			setvar("hidehud", 0);
			setvar("grabinput", 1);
		}
		else
		{
			setvar("hidehud", 1);
			setvar("grabinput", 0);
		}
	}
开发者ID:offtools,项目名称:cubej,代码行数:13,代码来源:client.cpp

示例10: uefirtvariable_env_cleanup

static void uefirtvariable_env_cleanup(void)
{
	uint64_t status;
	uint8_t data[getvar_buf_size];
	uint64_t getdatasize = sizeof(data);
	uint32_t attributestest;

	long ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
	if (ioret != -1 && status == EFI_SUCCESS) {
		setvar(&gtestguid, attributes, sizeof(AuthVarDel), AuthVarDel, &status);
		setvar(&gtestguid, attributes, sizeof(AuthVarDelDiff), AuthVarDelDiff, &status);
	}
	return;
}
开发者ID:ahs3,项目名称:fwts-sbbr,代码行数:14,代码来源:uefirtauthvar.c

示例11: ulist_set

void	ulist_set(uint i,var_t *v)
{
	sion_sr("user",lpu(i,0));
	clrvar(v);
	sion_read(v);
/* varview(v);*/

	setvar("post"  ,lpu(ulist_getpost  (i),0),v);
	setvar("mpost" ,lpu(ulist_getmpost (i),0),v);
	setvar("login" ,lpu(ulist_getlogin (i),0),v);
	setvar("mlogin",lpu(ulist_getmlogin(i),0),v);
	setvar("wp"    ,lpu(ulist_getwp    (i),0),v);

	sion_write(NULL,v);
}
开发者ID:erukiti,项目名称:ma,代码行数:15,代码来源:user.c

示例12: connectserv

void connectserv(const char *servername, int serverport, const char *serverpassword)
{
    if(connpeer)
    {
        conoutf("aborting connection attempt");
        abortconnect();
    }

    if(serverport <= 0) serverport = server::serverport();

    ENetAddress address;
    address.port = serverport;

    if(servername)
    {
        if(strcmp(servername, connectname)) setsvar("connectname", servername);
        if(serverport != connectport) setvar("connectport", serverport);
        conoutf("attempting to connect to %s:%d", servername, serverport);
        if(!resolverwait(servername, &address))
        {
            conoutf("\f3could not resolve server %s", servername);
            return;
        }
    }
    else
    {
        setsvar("connectname", "");
        setvar("connectport", 0);
        conoutf("attempting to connect over LAN");
        address.host = ENET_HOST_BROADCAST;
    }

    if(!clienthost)
    {
        clienthost = enet_host_create(NULL, 2, server::numchannels(), rate*1024, rate*1024);
        if(!clienthost)
        {
            conoutf("\f3could not connect to server");
            return;
        }
        clienthost->duplicatePeers = 0;
    }

    connpeer = enet_host_connect(clienthost, &address, server::numchannels(), 0);
    enet_host_flush(clienthost);
    connmillis = totalmillis;
    connattempts = 0;
}
开发者ID:ezhangle,项目名称:OF-Engine,代码行数:48,代码来源:client.cpp

示例13: set_script

void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) {

#ifdef TOOLS_ENABLED

	_edited = true;
#endif

	if (script_instance) {

		if (script_instance->set(p_name, p_value)) {
			if (r_valid)
				*r_valid = true;
			return;
		}
	}

	//try built-in setgetter
	{
		if (ClassDB::set_property(this, p_name, p_value, r_valid)) {
			/*
			if (r_valid)
				*r_valid=true;
			*/
			return;
		}
	}

	if (p_name == CoreStringNames::get_singleton()->_script) {
		set_script(p_value);
		if (r_valid)
			*r_valid = true;
		return;

	} else if (p_name == CoreStringNames::get_singleton()->_meta) {
		//set_meta(p_name,p_value);
		metadata = p_value;
		if (r_valid)
			*r_valid = true;
		return;
#ifdef TOOLS_ENABLED
	} else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) {
		Array arr = p_value;
		for (int i = 0; i < arr.size(); i++) {
			editor_section_folding.insert(arr[i]);
		}
		if (r_valid)
			*r_valid = true;
		return;
#endif
	} else {
		//something inside the object... :|
		bool success = _setv(p_name, p_value);
		if (success) {
			if (r_valid)
				*r_valid = true;
			return;
		}
		setvar(p_name, p_value, r_valid);
	}
}
开发者ID:Bonfi96,项目名称:godot,代码行数:60,代码来源:object.cpp

示例14: evalfor

static void
evalfor(union node *n, int flags)
{
	struct arglist arglist;
	union node *argp;
	int i;
	int status;

	emptyarglist(&arglist);
	for (argp = n->nfor.args ; argp ; argp = argp->narg.next) {
		oexitstatus = exitstatus;
		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
	}

	loopnest++;
	status = 0;
	for (i = 0; i < arglist.count; i++) {
		setvar(n->nfor.var, arglist.args[i], 0);
		evaltree(n->nfor.body, flags);
		status = exitstatus;
		if (evalskip) {
			if (evalskip == SKIPCONT && --skipcount <= 0) {
				evalskip = 0;
				continue;
			}
			if (evalskip == SKIPBREAK && --skipcount <= 0)
				evalskip = 0;
			break;
		}
	}
	loopnest--;
	exitstatus = status;
}
开发者ID:FrauBSD,项目名称:FrauBSD,代码行数:33,代码来源:eval.c

示例15: uefirtauthvar_test1

/*
 * Set the created authenticated variable, AuthVarCreate,
 * and checking the data size and data.
 * expect EFI_SUCCESS returned.
 */
static int uefirtauthvar_test1(fwts_framework *fw)
{
	long ioret;

	uint8_t data[getvar_buf_size];
	uint64_t getdatasize = sizeof(data);
	uint64_t status;
	uint32_t attributestest;
	size_t i;

	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarCreate), AuthVarCreate, &status);

	if (ioret == -1) {
		int supcheck = check_fw_support(fw, status);

		if (supcheck != FWTS_OK)
			return supcheck;

		fwts_failed(fw, LOG_LEVEL_HIGH,
			"UEFICreateAuthVar",
			"Failed to create authenticated variable with UEFI "
			"runtime service.");

		fwts_uefi_print_status_info(fw, status);
		return FWTS_ERROR;
	}

	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
	if (ioret == -1) {
		fwts_failed(fw, LOG_LEVEL_HIGH,
			"UEFICreateAuthVar",
			"Failed to get authenticated variable with UEFI "
			"runtime service.");
		fwts_uefi_print_status_info(fw, status);
		return FWTS_ERROR;
	}
	if (getdatasize != sizeof(AuthVarCreateData)) {
		fwts_failed(fw, LOG_LEVEL_HIGH,
			"UEFICreateAuthVar",
			"Get authenticated variable data size is not the "
			"same as it set.");
		return FWTS_ERROR;
	}

	for (i = 0; i < sizeof(AuthVarCreateData); i++) {
		if (data[i] != AuthVarCreateData[i]) {
			fwts_failed(fw, LOG_LEVEL_HIGH,
			"UEFICreateAuthVar",
			"Get authenticated variable data are not the "
			"same as it set.");
			return FWTS_ERROR;
		}
	}

	data_exist |= E_AUTHVARCREATE;

	fwts_passed(fw, "Create authenticated variable test passed.");

	return FWTS_OK;
}
开发者ID:ahs3,项目名称:fwts-sbbr,代码行数:65,代码来源:uefirtauthvar.c


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