本文整理汇总了C++中cleanup_push函数的典型用法代码示例。如果您正苦于以下问题:C++ cleanup_push函数的具体用法?C++ cleanup_push怎么用?C++ cleanup_push使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanup_push函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: doeval1
/*
* Like eval, only using the current file descriptors
*/
static void
doeval1(Char **v)
{
struct eval1_state state;
Char **gv;
int gflag;
gflag = tglob(v);
if (gflag) {
gv = v = globall(v, gflag);
if (v == 0)
stderror(ERR_NOMATCH);
v = copyblk(v);
}
else {
gv = NULL;
v = copyblk(v);
trim(v);
}
if (gv)
cleanup_push(gv, blk_cleanup);
state.evalvec = evalvec;
state.evalp = evalp;
evalvec = v;
evalp = 0;
cleanup_push(&state, eval1_cleanup);
process(0);
cleanup_until(&state);
if (gv)
cleanup_until(gv);
}
开发者ID:Lance0312,项目名称:tcsh,代码行数:35,代码来源:ed.inputl.c
示例2: douniverse
/*ARGSUSED*/
void
douniverse(Char **v, struct command *c)
{
Char *cp = v[1];
Char *cp2; /* dunno how many elements v comes in with */
char ubuf[100];
if (cp == 0) {
(void) getuniverse(ubuf);
xprintf("%s\n", ubuf);
}
else {
cp2 = v[2];
if (cp2 == 0) {
if (*cp == '\0' || setuniverse(short2str(cp)) != 0)
stderror(ERR_NAME | ERR_STRING, CGETS(23, 12, "Illegal universe"));
}
else {
(void) getuniverse(ubuf);
if (*cp == '\0' || setuniverse(short2str(cp)) != 0)
stderror(ERR_NAME | ERR_STRING, CGETS(23, 12, "Illegal universe"));
cleanup_push(ubuf, setuniverse_cleanup);
if (setintr) {
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
}
lshift(v, 2);
if (setintr)
cleanup_until(&pintr_disabled);
reexecute(c);
cleanup_until(ubuf);
}
}
}
开发者ID:tcsh-org,项目名称:tcsh,代码行数:35,代码来源:tc.os.c
示例3: globtilde
static Char *
globtilde(Char *s)
{
Char *name, *u, *home, *res;
u = s;
for (s++; *s && *s != '/' && *s != ':'; s++)
continue;
name = Strnsave(u + 1, s - (u + 1));
cleanup_push(name, xfree);
home = gethdir(name);
if (home == NULL) {
if (adrof(STRnonomatch)) {
cleanup_until(name);
return u;
}
if (*name)
stderror(ERR_UNKUSER, short2str(name));
else
stderror(ERR_NOHOME);
}
cleanup_until(name);
if (home[0] == '/' && home[1] == '\0' && s[0] == '/')
res = Strsave(s);
else
res = Strspl(home, s);
xfree(home);
xfree(u);
return res;
}
开发者ID:2014-class,项目名称:freerouter,代码行数:30,代码来源:sh.glob.c
示例4: dosettc
/*ARGSUSED*/
void
dosettc(Char **v, struct command *c)
{
char *tv[2];
USE(c);
if (!GotTermCaps)
GetTermCaps();
tv[0] = strsave(short2str(v[1]));
cleanup_push(tv[0], xfree);
tv[1] = strsave(short2str(v[2]));
cleanup_push(tv[1], xfree);
SetTC(tv[0], tv[1]);
cleanup_until(tv[0]);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:17,代码来源:tc.func.c
示例5: period_cmd
/*
* Karl Kleinpaste, 18 Jan 1984.
* Added period_cmd(), which executes the alias "periodic" every
* $tperiod minutes. Useful for occasional checking of msgs and such.
*/
void
period_cmd(void)
{
Char *vp;
time_t t, interval;
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
if (periodic_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRperiodic);
xprintf("%s", CGETS(22, 6, "Faulty alias 'periodic' removed.\n"));
goto leave;
}
periodic_active = 1;
if (!whyles && adrof1(STRperiodic, &aliases)) {
vp = varval(STRtperiod);
if (vp == STRNULL) {
aliasrun(1, STRperiodic, NULL);
goto leave;
}
interval = getn(vp);
(void) time(&t);
if (t - t_period >= interval * 60) {
t_period = t;
aliasrun(1, STRperiodic, NULL);
}
}
leave:
periodic_active = 0;
cleanup_until(&pintr_disabled);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:36,代码来源:tc.func.c
示例6: dgoto
static Char *
dgoto(Char *cp)
{
Char *dp, *ret;
if (!ABSOLUTEP(cp))
{
Char *p, *q;
size_t cwdlen;
cwdlen = Strlen(dcwd->di_name);
if (cwdlen == 1) /* root */
cwdlen = 0;
dp = xmalloc((cwdlen + Strlen(cp) + 2) * sizeof(Char));
for (p = dp, q = dcwd->di_name; (*p++ = *q++) != '\0';)
continue;
if (cwdlen)
p[-1] = '/';
else
p--; /* don't add a / after root */
Strcpy(p, cp);
xfree(cp);
cp = dp;
dp += cwdlen;
}
else
dp = cp;
#if defined(WINNT_NATIVE)
return agetcwd();
#elif defined(__CYGWIN__)
if (ABSOLUTEP(cp) && cp[1] == ':') { /* Only DOS paths are treated that way */
return agetcwd();
} else {
cleanup_push(cp, xfree);
ret = dcanon(cp, dp);
cleanup_ignore(cp);
cleanup_until(cp);
}
#else /* !WINNT_NATIVE */
cleanup_push(cp, xfree);
ret = dcanon(cp, dp);
cleanup_ignore(cp);
cleanup_until(cp);
#endif /* WINNT_NATIVE */
return ret;
}
开发者ID:lukem,项目名称:tcsh,代码行数:47,代码来源:sh.dir.c
示例7: stack_socket_close
static void stack_socket_close(UNUSED_PARAM(ssh_session session),
struct event_fd_data_struct *event_fd_data)
{
if (event_fd_data->stacked != 1) {
_ssh_log(SSH_LOG_FUNCTIONS, "=== stack_socket_close", "Closing fd = %d sockets_cnt = %d", *event_fd_data->p_fd, sockets_cnt);
event_fd_data->stacked = 1;
cleanup_push(&cleanup_stack, event_fd_data);
}
}
开发者ID:cedral,项目名称:libssh,代码行数:9,代码来源:sshd_direct-tcpip.c
示例8: dotitle
void dotitle(Char **vc, struct command * c) {
int k;
char titlebuf[512];
char errbuf[128],err2[128];
char **v;
Char **nvc;
UNREFERENCED_PARAMETER(c);
vc++;
nvc = glob_all_or_error(vc);
if (nvc == NULL)
return;
if (nvc != vc)
cleanup_push(nvc, blk_cleanup);
if ((k = GetConsoleTitle(titlebuf, sizeof(titlebuf))) != 0) {
setcopy(STRoldtitle,str2short(titlebuf),
VAR_READWRITE|VAR_NOGLOB);
}
titlebuf[0] = '\0';
v = short2blk(nvc);
if (nvc != vc)
cleanup_until(nvc);
cleanup_push((Char **)v, blk_cleanup);
for (k = 0; v[k] != NULL ; k++){
__try {
StringCbCat(titlebuf,sizeof(titlebuf),v[k]);
StringCbCat(titlebuf,sizeof(titlebuf)," ");
}
__except(GetExceptionCode()) {
stderror(ERR_TOOMANY);
}
}
if (!SetConsoleTitle(titlebuf) ) {
make_err_str(GetLastError(),errbuf,128);
(void)StringCbPrintf(err2,sizeof(err2),"%s",v[k]);
stderror(ERR_SYSTEM,err2,errbuf);
}
cleanup_until((Char **)v);
return;
}
开发者ID:phase,项目名称:tcsh,代码行数:44,代码来源:ntfunc.c
示例9: EchoTC
/*
* Print the termcap string out with variable substitution
*/
void
EchoTC(Char **v)
{
Char **globbed;
char cv[BUFSIZE];/*FIXBUF*/
int verbose = 0, silent = 0;
static char *fmts = "%s\n", *fmtd = "%d\n";
int li,co;
setname("echotc");
v = glob_all_or_error(v);
globbed = v;
cleanup_push(globbed, blk_cleanup);
if (!v || !*v || *v[0] == '\0')
goto end;
if (v[0][0] == '-') {
switch (v[0][1]) {
case 'v':
verbose = 1;
break;
case 's':
silent = 1;
break;
default:
stderror(ERR_NAME | ERR_TCUSAGE);
break;
}
v++;
}
if (!*v || *v[0] == '\0')
goto end;
(void) StringCbCopy(cv,sizeof(cv), short2str(*v));
GetSize(&li,&co);
if(!lstrcmp(cv,"rows") || !lstrcmp(cv,"lines") ) {
xprintf(fmtd,T_Lines);
goto end;
}
else if(!lstrcmp(cv,"cols") ) {
xprintf(fmtd,T_ActualWindowSize);
goto end;
}
else if(!lstrcmp(cv,"buffer") ) {
xprintf(fmtd,T_Cols);
goto end;
}
else
stderror(ERR_SYSTEM, "EchoTC","Sorry, this function is not supported");
end:
cleanup_until(globbed);
}
开发者ID:Lance0312,项目名称:tcsh,代码行数:59,代码来源:nt.screen.c
示例10: xgetpass
static char *
xgetpass(const char *prm)
{
static struct strbuf pass; /* = strbuf_INIT; */
int fd;
sigset_t oset, set;
struct sigaction sa, osa;
sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
(void)sigaction(SIGINT, &sa, &osa);
sigemptyset(&set);
sigaddset(&set, SIGINT);
(void)sigprocmask(SIG_UNBLOCK, &set, &oset);
cleanup_push(&osa, sigint_cleanup);
cleanup_push(&oset, sigprocmask_cleanup);
(void) Rawmode(); /* Make sure, cause we want echo off */
fd = xopen("/dev/tty", O_RDWR|O_LARGEFILE);
if (fd == -1)
fd = SHIN;
else
cleanup_push(&fd, open_cleanup);
xprintf("%s", prm); flush();
pass.len = 0;
for (;;) {
char c;
if (xread(fd, &c, 1) < 1 || c == '\n')
break;
strbuf_append1(&pass, c);
}
strbuf_terminate(&pass);
cleanup_until(&osa);
return pass.s;
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:41,代码来源:tc.func.c
示例11: globone
Char *
globone(Char *str, int action)
{
Char *v[2], **vl, **vo;
int gflg, noglob;
noglob = adrof(STRnoglob) != 0;
v[0] = str;
v[1] = 0;
gflg = tglob(v);
if (gflg == G_NONE)
return (strip(Strsave(str)));
if (gflg & G_CSH) {
/*
* Expand back-quote, tilde and brace
*/
vo = globexpand(v, noglob);
if (noglob || (gflg & G_GLOB) == 0) {
vl = vo;
goto result;
}
cleanup_push(vo, blk_cleanup);
}
else if (noglob || (gflg & G_GLOB) == 0)
return (strip(Strsave(str)));
else
vo = v;
vl = libglob(vo);
if (gflg & G_CSH) {
if (vl != vo)
cleanup_until(vo);
else
cleanup_ignore(vo);
}
if (vl == NULL) {
setname(short2str(str));
stderror(ERR_NAME | ERR_NOMATCH);
}
result:
if (vl && vl[0] == NULL) {
xfree(vl);
return (Strsave(STRNULL));
}
if (vl && vl[1])
return (handleone(str, vl, action));
else {
str = strip(*vl);
xfree(vl);
return (str);
}
}
开发者ID:2014-class,项目名称:freerouter,代码行数:53,代码来源:sh.glob.c
示例12: put_color
/* put_color():
*/
static void
put_color(const Str *color)
{
size_t i;
const char *c = color->s;
int original_output_raw = output_raw;
output_raw = TRUE;
cleanup_push(&original_output_raw, output_raw_restore);
for (i = color->len; 0 < i; i--)
xputchar(*c++);
cleanup_until(&original_output_raw);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:15,代码来源:tw.color.c
示例13: doinlib
/*ARGSUSED*/
void
doinlib(Char **v, struct command *c)
{
Char **globbed;
setname(short2str(*v++));
v = glob_all_or_error(v);
globbed = v;
cleanup_push(globbed, blk_cleanup);
while (v && *v)
llib(*v++);
cleanup_until(globbed);
}
开发者ID:tcsh-org,项目名称:tcsh,代码行数:15,代码来源:tc.os.c
示例14: doucb
/*ARGSUSED*/
void
doucb(Char **v, struct command *c)
{
Char *cp = v[1];
char ubuf[100];
if (cp == 0)
(void) setuniverse("ucb");
else {
(void) getuniverse(ubuf);
(void) setuniverse("ucb");
cleanup_push(ubuf, setuniverse_cleanup);
if (setintr) {
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
}
lshift(v, 1);
if (setintr)
cleanup_until(&pintr_disabled);
reexecute(c);
cleanup_until(ubuf);
}
}
开发者ID:tcsh-org,项目名称:tcsh,代码行数:24,代码来源:tc.os.c
示例15: loaddirs
void
loaddirs(Char *fname)
{
static Char *loaddirs_cmd[] = { STRsource, NULL, NULL };
bequiet = 1;
cleanup_push(&bequiet, bequiet_cleanup);
if (fname)
loaddirs_cmd[1] = fname;
else if ((fname = varval(STRdirsfile)) != STRNULL)
loaddirs_cmd[1] = fname;
else
loaddirs_cmd[1] = STRtildotdirs;
dosource(loaddirs_cmd, NULL);
cleanup_until(&bequiet);
}
开发者ID:lukem,项目名称:tcsh,代码行数:16,代码来源:sh.dir.c
示例16: beep_cmd
/*
* Joachim Hoenig 07/16/91 Added beep_cmd, run every time tcsh wishes
* to beep the terminal bell. Useful for playing nice sounds instead.
*/
void
beep_cmd(void)
{
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
if (beepcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRbeepcmd);
xprintf("%s", CGETS(22, 5, "Faulty alias 'beepcmd' removed.\n"));
}
else {
beepcmd_active = 1;
if (!whyles && adrof1(STRbeepcmd, &aliases))
aliasrun(1, STRbeepcmd, NULL);
}
beepcmd_active = 0;
cleanup_until(&pintr_disabled);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:21,代码来源:tc.func.c
示例17: cwd_cmd
/*
* Paul Placeway 11/24/87 Added cwd_cmd by hacking precmd() into
* submission... Run every time $cwd is set (after it is set). Useful
* for putting your machine and cwd (or anything else) in an xterm title
* space.
*/
void
cwd_cmd(void)
{
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
if (cwdcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRcwdcmd);
xprintf("%s", CGETS(22, 4, "Faulty alias 'cwdcmd' removed.\n"));
goto leave;
}
cwdcmd_active = 1;
if (!whyles && adrof1(STRcwdcmd, &aliases))
aliasrun(1, STRcwdcmd, NULL);
leave:
cwdcmd_active = 0;
cleanup_until(&pintr_disabled);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:23,代码来源:tc.func.c
示例18: job_cmd
/*
* GrP Greg Parker May 2001
* Added job_cmd(), which is run every time a job is started or
* foregrounded. The command is passed a single argument, the string
* used to start the job originally. With precmd, useful for setting
* xterm titles.
* Cloned from cwd_cmd().
*/
void
job_cmd(Char *args)
{
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
if (jobcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRjobcmd);
xprintf("%s", CGETS(22, 14, "Faulty alias 'jobcmd' removed.\n"));
goto leave;
}
jobcmd_active = 1;
if (!whyles && adrof1(STRjobcmd, &aliases)) {
struct process *pp = pcurrjob; /* put things back after the hook */
aliasrun(2, STRjobcmd, args);
pcurrjob = pp;
}
leave:
jobcmd_active = 0;
cleanup_until(&pintr_disabled);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:28,代码来源:tc.func.c
示例19: Gnmatch
int
Gnmatch(const Char *string, const Char *pattern, const Char **endstr)
{
Char ***fblk, **p;
const Char *tstring = string;
int gpol = 1, gres = 0;
if (*pattern == '^') {
gpol = 0;
pattern++;
}
fblk = xmalloc(sizeof(Char ***));
*fblk = xmalloc(GLOBSPACE * sizeof(Char *));
(*fblk)[0] = Strsave(pattern);
(*fblk)[1] = NULL;
cleanup_push(fblk, blk_indirect_cleanup);
expbrace(fblk, NULL, GLOBSPACE);
if (endstr == NULL)
/* Exact matches only */
for (p = *fblk; *p; p++)
gres |= t_pmatch(string, *p, &tstring, 1) == 2 ? 1 : 0;
else {
const Char *end;
/* partial matches */
end = Strend(string);
for (p = *fblk; *p; p++)
if (t_pmatch(string, *p, &tstring, 1) != 0) {
gres |= 1;
if (end > tstring)
end = tstring;
}
*endstr = end;
}
cleanup_until(fblk);
return(gres == gpol);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:41,代码来源:sh.glob.c
示例20: dgetstack
static void
dgetstack(void)
{
int i = 0;
Char **dblk, **dbp;
struct directory *dn;
if (adrof(STRdirstack) == NULL)
return;
for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, i++)
continue;
dbp = dblk = xmalloc((i + 1) * sizeof(Char *));
for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, dbp++)
*dbp = Strsave(dn->di_name);
*dbp = NULL;
cleanup_push(dblk, blk_cleanup);
setq(STRdirstack, dblk, &shvhed, VAR_READWRITE);
cleanup_ignore(dblk);
cleanup_until(dblk);
}
开发者ID:lukem,项目名称:tcsh,代码行数:21,代码来源:sh.dir.c
注:本文中的cleanup_push函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论