本文整理汇总了C++中Flag函数的典型用法代码示例。如果您正苦于以下问题:C++ Flag函数的具体用法?C++ Flag怎么用?C++ Flag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Flag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: j_stopped_running
/* are there any running or stopped jobs ? */
int
j_stopped_running(void)
{
Job *j;
int which = 0;
for (j = job_list; j != (Job *) 0; j = j->next) {
#ifdef JOBS
if (j->ppid == procpid && j->state == PSTOPPED)
which |= 1;
#endif /* JOBS */
if (Flag(FLOGIN) && !Flag(FNOHUP) && procpid == kshpid &&
j->ppid == procpid && j->state == PRUNNING)
which |= 2;
}
if (which) {
shellf("You have %s%s%s jobs\n",
which & 1 ? "stopped" : "",
which == 3 ? " and " : "",
which & 2 ? "running" : "");
return 1;
}
return 0;
}
开发者ID:bobertlo,项目名称:openbsd-pdksh,代码行数:26,代码来源:jobs.c
示例2: unwind
/* note: i MUST NOT be 0 */
void
unwind(int i)
{
/*
* This is a kludge. We need to restore everything that was
* changed in the new environment, see cid 1005090337C7A669439
* and 10050903386452ACBF1, but fail to even save things most of
* the time. funcs.c:c_eval() changes FERREXIT temporarily to 0,
* which needs to be restored thus (related to Debian #696823).
* We did not save the shell flags, so we use a special or'd
* value here... this is mostly to clean up behind *other*
* callers of unwind(LERROR) here; exec.c has the regular case.
*/
if (Flag(FERREXIT) & 0x80) {
/* GNU bash does not run this trapsig */
trapsig(ksh_SIGERR);
Flag(FERREXIT) &= ~0x80;
}
/* ordering for EXIT vs ERR is a bit odd (this is what AT&T ksh does) */
if (i == LEXIT || ((i == LERROR || i == LINTR) &&
sigtraps[ksh_SIGEXIT].trap &&
(!Flag(FTALKING) || Flag(FERREXIT)))) {
++trap_nested;
runtrap(&sigtraps[ksh_SIGEXIT], trap_nested == 1);
--trap_nested;
i = LLEAVE;
} else if (Flag(FERREXIT) == 1 && (i == LERROR || i == LINTR)) {
++trap_nested;
runtrap(&sigtraps[ksh_SIGERR], trap_nested == 1);
--trap_nested;
i = LLEAVE;
}
while (/* CONSTCOND */ 1) {
switch (e->type) {
case E_PARSE:
case E_FUNC:
case E_INCL:
case E_LOOP:
case E_ERRH:
kshlongjmp(e->jbuf, i);
/* NOTREACHED */
case E_NONE:
if (i == LINTR)
e->flags |= EF_FAKE_SIGDIE;
/* FALLTHROUGH */
default:
quitenv(NULL);
/*
* quitenv() may have reclaimed the memory
* used by source which will end badly when
* we jump to a function that expects it to
* be valid
*/
source = NULL;
}
}
}
开发者ID:HexagonRom,项目名称:android_external_mksh,代码行数:60,代码来源:main.c
示例3: setTrasformationFlags
void setTrasformationFlags(){
addFlag(Flag("r", "min-alph",
"Minimal Alphabet Size",
INT, &settings::MIN_ALHPABET_SIZE));
addFlag(Flag("R", "max-alph",
"Maximum Alphabet Size",
INT, &settings::MAX_ALHPABET_SIZE));
}
开发者ID:Jakub-Ciecierski,项目名称:AutomataPT,代码行数:8,代码来源:transformation_settings.cpp
示例4: Flag
/*! This method checks if the date mask is complete in the
sense that it doesn't need to have a prefilled "struct tm"
when its time value is computed.
*/
bool
DateMask::IsComplete()
{
// mask must be absolute, at last
if ((fMask & Flag(TYPE_UNIT)) != 0)
return false;
// minimal set of flags to have a complete set
return !(~fMask & (Flag(TYPE_DAY) | Flag(TYPE_MONTH)));
}
开发者ID:svn2github,项目名称:Themis,代码行数:14,代码来源:haiku_parsedate.cpp
示例5: setLogFlags
void setLogFlags(){
/* ------ LOGGER ----- */
addFlag(Flag("D", "log-main-dir",
"Main directory to store all logs",
STRING,
&settings::LOG_MAIN_DIR));
addFlag(Flag("d", "log-dir",
"directory to store logs of current computations",
STRING,
&settings::LOG_CURR_DIR));
}
开发者ID:Jakub-Ciecierski,项目名称:AutomataPT,代码行数:12,代码来源:log_settings.cpp
示例6: j_exit
/* job cleanup before shell exit */
void
j_exit(void)
{
/* kill stopped, and possibly running, jobs */
Job *j;
int killed = 0;
for (j = job_list; j != (Job *) 0; j = j->next) {
if (j->ppid == procpid &&
(j->state == PSTOPPED ||
(j->state == PRUNNING &&
((j->flags & JF_FG) ||
(Flag(FLOGIN) && !Flag(FNOHUP) && procpid == kshpid))))) {
killed = 1;
if (j->pgrp == 0)
kill_job(j, SIGHUP);
else
killpg(j->pgrp, SIGHUP);
#ifdef JOBS
if (j->state == PSTOPPED) {
if (j->pgrp == 0)
kill_job(j, SIGCONT);
else
killpg(j->pgrp, SIGCONT);
}
#endif /* JOBS */
}
}
if (killed)
sleep(1);
j_notify();
#ifdef JOBS
if (kshpid == procpid && restore_ttypgrp >= 0) {
/* Need to restore the tty pgrp to what it was when the
* shell started up, so that the process that started us
* will be able to access the tty when we are done.
* Also need to restore our process group in case we are
* about to do an exec so that both our parent and the
* process we are to become will be able to access the tty.
*/
tcsetpgrp(tty_fd, restore_ttypgrp);
setpgid(0, restore_ttypgrp);
}
if (Flag(FMONITOR)) {
Flag(FMONITOR) = 0;
j_change();
}
#endif /* JOBS */
}
开发者ID:bobertlo,项目名称:openbsd-pdksh,代码行数:51,代码来源:jobs.c
示例7: c_exec
/* exec with no args - args case is taken care of in comexec() */
int
c_exec(char **wp)
{
int i;
/* make sure redirects stay in place */
if (e->savefd != NULL) {
for (i = 0; i < NUFILE; i++) {
if (e->savefd[i] > 0)
close(e->savefd[i]);
/*
* For ksh keep anything > 2 private,
* for sh, let them be (POSIX says what
* happens is unspecified and the bourne shell
* keeps them open).
*/
#ifdef KSH
if (!Flag(FSH) &&i > 2 && e->savefd[i])
fd_clexec(i);
#endif /* KSH */
}
e->savefd = NULL;
}
return 0;
}
开发者ID:tomgrean,项目名称:kash,代码行数:26,代码来源:c_sh.c
示例8: bi_errorf
/* Used by built-in utilities to prefix shell and utility name to message
* (also unwinds environments for special builtins).
*/
void
bi_errorf(const char *fmt, ...)
{
va_list va;
shl_stdout_ok = 0; /* debugging: note that stdout not valid */
exstat = 1;
if (fmt != NULL && *fmt != '\0') {
error_prefix(true);
/* not set when main() calls parse_args() */
if (builtin_argv0)
shf_fprintf(shl_out, "%s: ", builtin_argv0);
va_start(va, fmt);
shf_vfprintf(shl_out, fmt, va);
va_end(va);
shf_putchar('\n', shl_out);
}
shf_flush(shl_out);
/* POSIX special builtins and ksh special builtins cause
* non-interactive shells to exit.
* XXX odd use of KEEPASN; also may not want LERROR here
*/
if ((builtin_flag & SPEC_BI) ||
(Flag(FPOSIX) && (builtin_flag & KEEPASN))) {
builtin_argv0 = NULL;
unwind(LERROR);
}
}
开发者ID:radixo,项目名称:openbsd-src,代码行数:31,代码来源:io.c
示例9: c_set
int
c_set(char **wp)
{
int argi, setargs;
struct block *l = e->loc;
char **owp = wp;
if (wp[1] == NULL) {
static const char *const args [] = { "set", "-", NULL };
return c_typeset((char **) args);
}
argi = parse_args(wp, OF_SET, &setargs);
if (argi < 0)
return 1;
/* set $# and $* */
if (setargs) {
owp = wp += argi - 1;
wp[0] = l->argv[0]; /* save $0 */
while (*++wp != NULL)
*wp = str_save(*wp, &l->area);
l->argc = wp - owp - 1;
l->argv = acalloc(l->argc+2, sizeof(char *), &l->area);
for (wp = l->argv; (*wp++ = *owp++) != NULL; )
;
}
/* POSIX says set exit status is 0, but old scripts that use
* getopt(1), use the construct: set -- `getopt ab:c "[email protected]"`
* which assumes the exit value set will be that of the ``
* (subst_exstat is cleared in execute() so that it will be 0
* if there are no command substitutions).
*/
return Flag(FPOSIX) ? 0 : subst_exstat;
}
开发者ID:Bluerise,项目名称:bitrig,代码行数:34,代码来源:c_sh.c
示例10: printoptions
static void
printoptions(int verbose)
{
int i;
if (verbose) {
struct options_info oi;
int n, len;
/* verbose version */
shprintf("Current option settings\n");
for (i = n = oi.opt_width = 0; i < NELEM(options); i++)
if (options[i].name) {
len = strlen(options[i].name);
oi.opts[n].name = options[i].name;
oi.opts[n++].flag = i;
if (len > oi.opt_width)
oi.opt_width = len;
}
print_columns(shl_stdout, n, options_fmt_entry, &oi,
oi.opt_width + 5, 1);
} else {
/* short version ala ksh93 */
shprintf("set");
for (i = 0; i < NELEM(options); i++)
if (Flag(i) && options[i].name)
shprintf(" -o %s", options[i].name);
shprintf(newline);
}
}
开发者ID:adtools,项目名称:abcsh,代码行数:31,代码来源:misc.c
示例11: main
// int main(int argc,char * const argv[]) // normally this
int main(int argc,char * argv[]) // const argv[] not compatible with TRint
{
const char* cflags="hpRvV";
RunFlags Flag(argc,argv,cflags);
if(Flag.verbose>1 ) cout << __FILE__<< " " << __FUNCTION__ << " after RunFlags line " << setw(4) << __LINE__ << '\n';
const char* Fname_b1_o="~/mad/LEP/lep_twiss.tfs";
const char* Fname_b1_s="~/mad/LEP/lep_survey.tfs";
Ntuple nt_b1(ReadAndMerge(Fname_b1_o,Fname_b1_s,Flag.verbose));
TRint* theApp;
if(Flag.R) theApp = new TRint("", &argc, argv, NULL, 0); // root in line mode, defined theApp
Beam b1(Fname_b1_o,Flag.verbose); // get Energy and synchr integrals from optics twiss header
b1.RFHV_from_twiss(nt_b1 );
b1.Print();
double nsig=1; // quad radiation from sawtooth + beam size. 0 is sawtooth only
double EmitRatio=0.002;
b1.EmitFromSynrad(EmitRatio);
CalcBeamSizeDivergence(nt_b1,b1.ex,b1.ey,b1.sige,Flag.verbose); // calculate beam sizes and divergences and add to ntupl
CalcSynrad(nt_b1,b1,Flag.verbose,nsig);
nt_b1.PrintSummary();
if(Flag.p) Plot_optics(&nt_b1,Flag.verbose);
//nt_b1.WriteAsciiNtFile(NULL,"/tmp/hbu/tlep_175_o_s.tfs"); // write combined optics and survey
// double xmin=-0.3,xmax=0.15,zmin=0,zmax=250.;
//Plot_survey(&nt_b1,Flag.verbose,xmin,xmax,zmin,zmax);
if(Flag.R)
{
cout << " running in line mode. When done quit root from the menu bar / File " << '\n';
theApp->Run();
}
};
开发者ID:collamaf,项目名称:MDISim-1,代码行数:35,代码来源:main_LEP.C
示例12: settrap
void
settrap(Trap *p, char *s)
{
sig_t f;
if (p->trap)
afree(p->trap, APERM);
p->trap = str_save(s, APERM); /* handles s == 0 */
p->flags |= TF_CHANGED;
f = !s ? SIG_DFL : s[0] ? trapsig : SIG_IGN;
p->flags |= TF_USER_SET;
if ((p->flags & (TF_DFL_INTR|TF_FATAL)) && f == SIG_DFL)
f = trapsig;
else if (p->flags & TF_SHELL_USES) {
if (!(p->flags & TF_ORIG_IGN) || Flag(FTALKING)) {
/* do what user wants at exec time */
p->flags &= ~(TF_EXEC_IGN|TF_EXEC_DFL);
if (f == SIG_IGN)
p->flags |= TF_EXEC_IGN;
else
p->flags |= TF_EXEC_DFL;
}
/* assumes handler already set to what shell wants it
* (normally trapsig, but could be j_sigchld() or SIG_IGN)
*/
return;
}
/* todo: should we let user know signal is ignored? how? */
setsig(p, f, SS_RESTORE_CURR|SS_USER);
}
开发者ID:UNGLinux,项目名称:Obase,代码行数:33,代码来源:trap.c
示例13: j_notify
/* list jobs for top-level notification */
void
j_notify(void)
{
Job *j, *tmp;
sigset_t omask;
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
for (j = job_list; j; j = j->next) {
#ifdef JOBS
if (Flag(FMONITOR) && (j->flags & JF_CHANGED))
j_print(j, JP_MEDIUM, shl_out);
#endif /* JOBS */
/* Remove job after doing reports so there aren't
* multiple +/- jobs.
*/
if (j->state == PEXITED || j->state == PSIGNALLED)
j->flags |= JF_REMOVE;
}
for (j = job_list; j; j = tmp) {
tmp = j->next;
if (j->flags & JF_REMOVE)
remove_job(j, "notify");
}
shf_flush(shl_out);
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
}
开发者ID:bobertlo,项目名称:openbsd-pdksh,代码行数:27,代码来源:jobs.c
示例14: change_flag
/* change a Flag(*) value; takes care of special actions */
void
change_flag(enum sh_flag f,
int what, /* flag to change */
int newval) /* what is changing the flag (command line vs set) */
{
int oldval;
oldval = Flag(f);
Flag(f) = newval;
#ifdef JOBS
if (f == FMONITOR) {
if (what != OF_CMDLINE && newval != oldval)
j_change();
} else
#endif /* JOBS */
#ifdef EDIT
if (0
# ifdef VI
|| f == FVI
# endif /* VI */
# ifdef EMACS
|| f == FEMACS || f == FGMACS
# endif /* EMACS */
)
{
if (newval) {
# ifdef VI
Flag(FVI) = 0;
# endif /* VI */
# ifdef EMACS
Flag(FEMACS) = Flag(FGMACS) = 0;
# endif /* EMACS */
Flag(f) = newval;
}
} else
#endif /* EDIT */
/* Turning off -p? */
if (f == FPRIVILEGED && oldval && !newval) {
gid_t gid = getgid();
setresgid(gid, gid, gid);
setgroups(1, &gid);
setresuid(ksheuid, ksheuid, ksheuid);
} else if (f == FPOSIX && newval) {
#ifdef BRACE_EXPAND
Flag(FBRACEEXPAND) = 0
#endif /* BRACE_EXPAND */
;
}
/* Changing interactive flag? */
if (f == FTALKING) {
if ((what == OF_CMDLINE || what == OF_SET) && procpid == kshpid)
Flag(FTALKING_I) = newval;
}
}
开发者ID:Freeaqingme,项目名称:OpenBSD,代码行数:56,代码来源:misc.c
示例15: options_fmt_entry
/* format a single select menu item */
static void
options_fmt_entry(char *buf, size_t buflen, unsigned int i, const void *arg)
{
const struct options_info *oi = (const struct options_info *)arg;
shf_snprintf(buf, buflen, "%-*s %s",
oi->opt_width, OFN(oi->opts[i]),
Flag(oi->opts[i]) ? "on" : "off");
}
开发者ID:rovaughn,项目名称:distro,代码行数:10,代码来源:misc.c
示例16: c_eval
int
c_eval(char **wp)
{
struct source *s,*olds=source;
int retval, errexitflagtmp;
if (ksh_getopt(wp, &builtin_opt, null) == '?')
return 1;
s = pushs(SWORDS, ATEMP);
s->u.strv = wp + builtin_opt.optind;
if (!Flag(FPOSIX)) {
/*
* Handle case where the command is empty due to failed
* command substitution, eg, eval "$(false)".
* In this case, shell() will not set/change exstat (because
* compiled tree is empty), so will use this value.
* subst_exstat is cleared in execute(), so should be 0 if
* there were no substitutions.
*
* A strict reading of POSIX says we don't do this (though
* it is traditionally done). [from 1003.2-1992]
* 3.9.1: Simple Commands
* ... If there is a command name, execution shall
* continue as described in 3.9.1.1. If there
* is no command name, but the command contained a command
* substitution, the command shall complete with the exit
* status of the last command substitution
* 3.9.1.1: Command Search and Execution
* ...(1)...(a) If the command name matches the name of
* a special built-in utility, that special built-in
* utility shall be invoked.
* 3.14.5: Eval
* ... If there are no arguments, or only null arguments,
* eval shall return an exit status of zero.
*/
exstat = subst_exstat;
}
errexitflagtmp = Flag(FERREXIT);
Flag(FERREXIT) = 0;
retval=shell(s, false);
Flag(FERREXIT) = errexitflagtmp;
source=olds;
return retval;
}
开发者ID:tomgrean,项目名称:kash,代码行数:44,代码来源:c_sh.c
示例17: Ground
void Quiddiards::initObjects(){
ground = new Ground({ 0, 0, 0 }, MAXRANGE, WAVEHGT);
//float desktop = table.getRugHgt();
float desktop = WAVEHGT / 2;
table.setCenter({ 0, 0, 0 });
// init balls and stick
cueball.setCenter({ 0, 0, desktop + cueball.getR() });
balls.clear();
balls.push_back(&cueball);
float l = cuebroom.getStickLen();
cuebroom.setAim(cueball.getCenter());
cuebroom.setCenter(cueball.getCenter() + QVector3D({ l, l / 3, l / 3 }));
float boundX = COURTRANGE - 1, boundY = COURTRANGE - 1;
for (unsigned i = 0; i < QUAFNUM; i++){
do{
quaffles[i].setCenter({ randf(-boundX, boundX), randf(-boundY, boundY), desktop + quaffles[i].getR() });
} while (conflict(quaffles[i]));
balls.push_back(&quaffles[i]);
}
float sB = bludgers[0].getSpeed(), sS = snitch.getSpeed();
for (unsigned i = 0; i < BLUGNUM; i++){
do{
bludgers[i].setCenter({ randf(-boundX, boundX), randf(-boundY, boundY), desktop + bludgers[i].getR() });
} while (conflict(bludgers[i]));
bludgers[i].setVelocity({ randf(-sB, sB), randf(-sB, sB), 0.0f });
balls.push_back(&bludgers[i]);
}
do{
snitch.setCenter({ randf(-boundX, boundX), randf(-boundY, boundY), desktop + snitch.getR() + 5.0f });
} while (conflict(snitch));
snitch.setVelocity({ randf(-sS, sS), randf(-sS, sS), 0 });
balls.push_back(&snitch);
// init flag
wind = { 1.0f, 1.0f };
flags[0] = Flag({ COURTRANGE, COURTRANGE, FLAGHGT }, Flag::GRYFFINDOR);
flags[1] = Flag({ -COURTRANGE, COURTRANGE, FLAGHGT }, Flag::SLYTHERIN);
flags[2] = Flag({ -COURTRANGE, -COURTRANGE, FLAGHGT }, Flag::RAVENCLAW);
flags[3] = Flag({ COURTRANGE, -COURTRANGE, FLAGHGT }, Flag::HUFFLEPUFF);
}
开发者ID:silencious,项目名称:Quiddiards,代码行数:44,代码来源:quiddiards.cpp
示例18: options_fmt_entry
/* format a single select menu item */
static char *
options_fmt_entry(char *buf, int buflen, int i, const void *arg)
{
const struct options_info *oi = (const struct options_info *)arg;
shf_snprintf(buf, buflen, "%-*s %s",
oi->opt_width, options[oi->opts[i]].name,
Flag(oi->opts[i]) ? "on" : "off");
return (buf);
}
开发者ID:2fast4u88,项目名称:oxygen_system_core,代码行数:11,代码来源:misc.c
示例19: options_fmt_entry
/* format a single select menu item */
static char *
options_fmt_entry(void *arg, int i, char *buf, int buflen)
{
struct options_info *oi = (struct options_info *) arg;
shf_snprintf(buf, buflen, "%-*s %s",
oi->opt_width, oi->opts[i].name,
Flag(oi->opts[i].flag) ? "on" : "off");
return buf;
}
开发者ID:adtools,项目名称:abcsh,代码行数:11,代码来源:misc.c
示例20: ParseNameOrCall
/// ParseDesignator - Parse a designator. Return null if current token is not a
/// designator.
///
/// [R601]:
/// designator :=
/// object-name
/// or array-element
/// or array-section
/// or coindexed-named-object
/// or complex-part-designator
/// or structure-component
/// or substring
///
/// FIXME: substring for a character array
ExprResult Parser::ParseDesignator(bool IsLvalue) {
auto E = ParseNameOrCall();
struct ScopedFlag {
bool value;
bool &dest;
ScopedFlag(bool &flag) : dest(flag) {
value = flag;
}
~ScopedFlag() {
dest = value;
}
};
ScopedFlag Flag(DontResolveIdentifiers);
if(DontResolveIdentifiersInSubExpressions)
DontResolveIdentifiers = true;
while(true) {
if(!E.isUsable())
break;
if(IsPresent(tok::l_paren)) {
auto EType = E.get()->getType();
if(EType->isArrayType())
E = ParseArraySubscript(E);
else if(EType->isCharacterType())
E = ParseSubstring(E);
else {
Diag.Report(Tok.getLocation(), diag::err_unexpected_lparen);
return ExprError();
}
} else if(IsPresent(tok::percent)) {
auto EType = E.get()->getType();
if(EType->isRecordType())
E = ParseStructureComponent(E);
else {
Diag.Report(Tok.getLocation(), diag::err_unexpected_percent);
return ExprError();
}
} else if(IsPresent(tok::period)) {
auto EType = E.get()->getType();
if(EType->isRecordType())
E = ParseStructureComponent(E);
else {
Diag.Report(Tok.getLocation(), diag::err_unexpected_period);
return ExprError();
}
}
else break;
}
return E;
}
开发者ID:ctgriffiths,项目名称:flang,代码行数:68,代码来源:ParseExpr.cpp
注:本文中的Flag函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论