本文整理汇总了C++中savestr函数的典型用法代码示例。如果您正苦于以下问题:C++ savestr函数的具体用法?C++ savestr怎么用?C++ savestr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了savestr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: change_env
/*
* Sets/unsets an environment variable from a pointer that may actually be a
* pointer into environ where the string should not be manipulated.
*/
static void
change_env(char *s, int set)
{
char *eqp;
char *ss;
ss = savestr(s);
if ((eqp = strchr(ss, '=')) != NULL)
*eqp = '\0';
if (set && eqp != NULL)
(void) setenv(ss, eqp + 1, 1);
else
(void) unsetenv(ss);
ckfree(ss);
return;
}
开发者ID:akat1,项目名称:impala,代码行数:21,代码来源:var.c
示例2: tryexec
static void
tryexec(char *cmd, char **argv, char **envp)
{
int e;
execve(cmd, argv, envp);
e = errno;
if (e == ENOEXEC) {
initshellproc();
setinputfile(cmd, 0);
commandname = arg0 = savestr(argv[0]);
setparam(argv + 1);
exraise(EXSHELLPROC);
/*NOTREACHED*/
}
errno = e;
}
开发者ID:grayshadow212,项目名称:usr.src,代码行数:17,代码来源:exec.c
示例3: sprintf
Screen_Obj *dup_so(QSP_ARG_DECL Screen_Obj *sop)
{
Screen_Obj *dup;
char name[BUF_LEN];
sprintf(name,"%s.dup",SOB_NAME(sop));
dup = simple_object(name);
if( sop == NULL ) return(sop);
SET_SOB_PARENT(dup, SOB_PARENT(sop) );
SET_SOB_PANEL(dup, SOB_PANEL(sop) );
#ifdef HAVE_MOTIF
SET_SOB_FRAME(dup, SOB_FRAME(sop) );
#endif /* HAVE_MOTIF */
SET_SOB_ACTION(dup,savestr(SOB_ACTION(sop)));
SET_SOB_SELECTOR(dup,NULL);
return(dup);
}
开发者ID:nasa,项目名称:QuIP,代码行数:17,代码来源:screen_objs.c
示例4: InstallFontSizes
DviFontSizeList *
InstallFontSizes (DviWidget dw, const char *x_name, Boolean *scalablep)
{
char fontNameString[2048];
char **fonts;
int i, count;
int size;
DviFontSizeList *sizes, *new_size;
XFontName fontName;
unsigned int fontNameAttributes;
*scalablep = FALSE;
if (!XParseFontName ((XFontNameString)x_name, &fontName,
&fontNameAttributes))
return 0;
fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize
|FontNameAverageWidth);
fontNameAttributes |= FontNameResolutionX;
fontNameAttributes |= FontNameResolutionY;
fontName.ResolutionX = dw->dvi.display_resolution;
fontName.ResolutionY = dw->dvi.display_resolution;
XFormatFontName (&fontName, fontNameAttributes, fontNameString);
fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count);
sizes = 0;
for (i = 0; i < count; i++) {
size = ConvertFontNameToSize (fonts[i]);
if (size == 0) {
DisposeFontSizes (dw, sizes);
sizes = 0;
*scalablep = TRUE;
break;
}
if (size != -1) {
new_size = (DviFontSizeList *) XtMalloc (sizeof *new_size);
new_size->next = sizes;
new_size->size = size;
new_size->x_name = savestr (fonts[i]);
new_size->doesnt_exist = 0;
new_size->font = 0;
sizes = new_size;
}
}
XFreeFontNames (fonts);
return sizes;
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:45,代码来源:font.c
示例5: storedatt
VOID storedatt(PNE pne)
{
int i;
NEAL(pne) = (struct ad *)rmalloc((1+ADN(al))*ADSZ);
memcpy((UNIV)NEAL(pne), (UNIV)al, (1+ADN(al))*ADSZ);
for (i = 1; i <= (int)ADN(al); i++) {
if (GET(ADFLAGS(al, i), ASPEC))
ds.attdef += ADLEN(al, i);
if (NEAL(pne)[i].addef != 0)
NEAL(pne)[i].addef = savestr(NEAL(pne)[i].addef);
}
ds.attcnt += AN(al); /* Number of attributes defined. */
#if 0
/* I can't see any reason to increase AVGRPCNT here. */
ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */
#endif
}
开发者ID:johnBradley501,项目名称:TACT,代码行数:18,代码来源:MD2.CPP
示例6: arpafix
/*
* Deal with arpa net addresses. The way this is done is strange.
* name contains an "@" or "%". Look up the machine after it in
* the hash table. If it isn't found, return name unmolested.
* If ???, return name unmolested.
* Otherwise, delete the "@" or "%" and the machine after it from
* name, and return the new string.
*/
static char *
arpafix(char name[], char from[])
{
register char *cp;
register int arpamach;
char newname[BUFSIZ];
if (debug) {
fprintf(stderr, "arpafix(%s, %s)\n", name, from);
}
cp = strrchr(name, '@');
if (cp == NOSTR)
cp = strrchr(name, '%');
if (cp == NOSTR) {
fprintf(stderr,
gettext("Something's amiss -- no @ or %% in arpafix\n"));
return(name);
}
cp++;
arpamach = netlook(cp, '@');
if (debug)
fprintf(stderr,
"cp '%s', arpamach %o, nettypes arpamach %o LOCAL %o\n",
cp, arpamach, nettype(arpamach), nettype(LOCAL));
if (arpamach == 0) {
if (debug)
fprintf(stderr, "machine %s unknown, uses: %s\n",
cp, name);
return(name);
}
if (((nettype(arpamach) & nettype(LOCAL)) & ~AN) == 0) {
if (debug)
fprintf(stderr, "machine %s known but remote, uses: %s\n",
cp, name);
return(name);
}
nstrcpy(newname, sizeof (newname), name);
cp = strrchr(newname, '@');
if (cp == NOSTR)
cp = strrchr(newname, '%');
*cp = 0;
if (debug) fprintf(stderr, "local address, return '%s'\n", newname);
return(savestr(newname));
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:52,代码来源:optim.c
示例7: use_selected
int
use_selected()
{
register SUBJECT *sp;
register ARTICLE *ap;
bool want_read;
char *cmdstr;
int len, ret = 1;
int subj_mask = (sel_mode == SM_THREAD? (SF_THREAD|SF_VISIT) : SF_VISIT);
if (!finish_command(TRUE)) /* get rest of command */
return 0;
if (!buf[1])
return -1;
cmdstr = savestr(buf+1);
want_read = (sel_rereading || *cmdstr =='m');
perform_cnt = 0;
page_line = 1;
len = strlen(cmdstr);
/* A few commands can just loop through the subjects. */
if ((len == 1 && (*cmdstr == 't' || *cmdstr == 'J'))
|| (len == 2
&& (((*cmdstr == '+' || *cmdstr == '-') && cmdstr[0] == cmdstr[1])
|| *cmdstr == 'T'))) {
for (sp = first_subject; sp; sp = sp->next) {
if ((sp->flags & subj_mask) == subj_mask) {
artp = first_art(sp);
if (artp) {
art = article_num(artp);
if (perform(cmdstr, FALSE)) {
fputs("\nInterrupted\n", stdout) FLUSH;
goto break_out;
}
}
#ifdef VERBOSE
IF(verbose)
if (mode != 't' && *cmdstr != 't' && *cmdstr != 'T')
putchar('\n') FLUSH;
#endif
}
}
} else if (strEQ(cmdstr, "E")) {
开发者ID:Kiddinglife,项目名称:4.4BSD-Lite,代码行数:44,代码来源:ngstuff.c
示例8: LookupFontSizeBySize
static DviFontSizeList *
LookupFontSizeBySize (DviWidget dw, DviFontList *f, int size)
{
DviFontSizeList *fs, *best = 0, *smallest = 0;
int bestsize = 0;
XFontName fontName;
unsigned int fontNameAttributes;
char fontNameString[2048];
int decipointsize;
if (f->scalable) {
decipointsize = (10*size)/dw->dvi.sizescale;
for (best = f->sizes; best; best = best->next)
if (best->size == decipointsize)
return best;
best = (DviFontSizeList *) XtMalloc(sizeof *best);
best->next = f->sizes;
best->size = decipointsize;
f->sizes = best;
XParseFontName (f->x_name, &fontName, &fontNameAttributes);
fontNameAttributes &= ~(FontNamePixelSize|FontNameAverageWidth);
fontNameAttributes |= FontNameResolutionX;
fontNameAttributes |= FontNameResolutionY;
fontNameAttributes |= FontNamePointSize;
fontName.ResolutionX = dw->dvi.display_resolution;
fontName.ResolutionY = dw->dvi.display_resolution;
fontName.PointSize = decipointsize;
XFormatFontName (&fontName, fontNameAttributes, fontNameString);
best->x_name = savestr (fontNameString);
best->doesnt_exist = 0;
best->font = 0;
return best;
}
for (fs = f->sizes; fs; fs=fs->next) {
if (dw->dvi.sizescale*fs->size <= 10*size
&& fs->size >= bestsize) {
best = fs;
bestsize = fs->size;
}
if (smallest == 0 || fs->size < smallest->size)
smallest = fs;
}
return best ? best : smallest;
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:44,代码来源:font.c
示例9: get_arch_name_from_types
/*
* get_arch_name_from_types() returns the name of the architecture for the
* specified cputype and cpusubtype if known. If unknown it returns a pointer
* to the an allocated string "cputype X cpusubtype Y" where X and Y are decimal
* values.
*/
__private_extern__
const char *
get_arch_name_from_types(
cpu_type_t cputype,
cpu_subtype_t cpusubtype)
{
unsigned long i;
char *p;
for(i = 0; arch_flags[i].name != NULL; i++){
if(arch_flags[i].cputype == cputype &&
arch_flags[i].cpusubtype == cpusubtype)
return(arch_flags[i].name);
}
p = savestr("cputype 1234567890 cpusubtype 1234567890");
if(p != NULL)
sprintf(p, "cputype %u cpusubtype %u", cputype, cpusubtype);
return(p);
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:25,代码来源:arch.c
示例10: setparam
void
setparam(char **argv)
{
char **newparam;
char **ap;
int nparam;
for (nparam = 0 ; argv[nparam] ; nparam++);
ap = newparam = ckmalloc((nparam + 1) * sizeof *ap);
while (*argv) {
*ap++ = savestr(*argv++);
}
*ap = NULL;
freeparam(&shellparam);
shellparam.malloc = 1;
shellparam.nparam = nparam;
shellparam.p = newparam;
shellparam.optnext = NULL;
}
开发者ID:mkatri,项目名称:minix,代码行数:19,代码来源:options.c
示例11: setparam
static void
setparam(int argc, char **argv)
{
char **newparam;
char **ap;
ap = newparam = ckmalloc((argc + 1) * sizeof *ap);
while (*argv) {
*ap++ = savestr(*argv++);
}
*ap = NULL;
freeparam(&shellparam);
shellparam.malloc = 1;
shellparam.nparam = argc;
shellparam.p = newparam;
shellparam.optp = NULL;
shellparam.reset = 1;
shellparam.optnext = NULL;
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:19,代码来源:options.c
示例12: Dfix1
/*
* $ substitute one word, for i/o redirection
*/
tchar *
Dfix1(tchar *cp)
{
tchar *Dv[2];
#ifdef TRACE
tprintf("TRACE- Dfix1()\n");
#endif
if (noexec)
return (0);
Dv[0] = cp; Dv[1] = NOSTR;
Dfix2(Dv);
if (gargc != 1) {
setname(cp);
bferr("Ambiguous");
}
cp = savestr(gargv[0]);
blkfree(gargv), gargv = 0;
return (cp);
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:23,代码来源:sh.dol.c
示例13: readlast
void
readlast()
{
if ((tmpfp = fopen(lastfile,"r")) != NULL) {
if (fgets(buf,sizeof buf,tmpfp) != NULL) {
long old_last = lasttime;
buf[strlen(buf)-1] = '\0';
if (*buf) {
safefree0(lastngname);
lastngname = savestr(buf);
}
fscanf(tmpfp,"%ld %ld %ld %ld",&lasttime,&lastactsiz,
&lastnewtime,&lastextranum);
if (!lastnewtime)
lastnewtime = starttime;
if (old_last > lasttime)
lasttime = old_last;
}
fclose(tmpfp);
}
}
开发者ID:LegalizeAdulthood,项目名称:trn,代码行数:21,代码来源:last.c
示例14: ec_add
/* Add a ethernet code to the database */
int
ec_add(register u_int32_t o, register char *text)
{
if (ec_last >= ec_len) {
if (list == NULL) {
ec_len = 512;
list = malloc(ec_len * sizeof(*list));
} else {
ec_len *= 2;
list = realloc(list, ec_len * sizeof(*list));
}
if (list == NULL) {
syslog(LOG_ERR, "ec_add(): malloc: %m");
exit(1);
}
}
list[ec_last].o = o;
list[ec_last].text = savestr(text);
++ec_last;
return (1);
}
开发者ID:einyx,项目名称:arpwatch,代码行数:23,代码来源:ec.c
示例15: varset
void
varset( /* set a variable's value */
char *vname,
int assign,
double val
)
{
char *qname;
EPNODE *ep1, *ep2;
/* get qualified name */
qname = qualname(vname, 0);
/* check for quick set */
if ((ep1 = dlookup(qname)) != NULL && ep1->v.kid->type == SYM &&
(ep1->type == ':') <= (assign == ':')) {
ep2 = ep1->v.kid->sibling;
if (ep2->type == NUM) {
ep2->v.num = val;
ep1->type = assign;
return;
}
}
/* hand build definition */
ep1 = newnode();
ep1->type = assign;
ep2 = newnode();
ep2->type = SYM;
ep2->v.name = savestr(vname);
addekid(ep1, ep2);
ep2 = newnode();
ep2->type = NUM;
ep2->v.num = val;
addekid(ep1, ep2);
if (assign == ':')
dremove(qname);
else
dclear(qname);
dpush(qname, ep1);
}
开发者ID:kalyanam-FMTGA,项目名称:ray-original,代码行数:38,代码来源:caldefn.c
示例16: _make_zombie
static void _make_zombie(QSP_ARG_DECL Data_Obj *dp)
{
static int n_zombie=1;
char zname[LLEN];
/* this function removes it from the hash table and
* active item list, doesn't add the structure to the
* item free list. This is why we release the node
* and later free the object...
*
* I think the idea here is that there might be a dangling reference
* to an image - for instance, if we display an image, then delete it,
* and then later want to refresh the window...
*/
zombie_item(dobj_itp,(Item *)dp);
sprintf(zname,"Z.%s.%d",OBJ_NAME(dp),n_zombie++);
fprintf(stderr,"make_zombie, changing object %s to %s\n",OBJ_NAME(dp),zname);
rls_str( (char *) OBJ_NAME(dp) ); /* unsave old name, make_zombie */
SET_OBJ_NAME(dp,savestr(zname));
SET_OBJ_FLAG_BITS(dp,DT_ZOMBIE);
} // make_zombie
开发者ID:jbmulligan,项目名称:quip,代码行数:23,代码来源:dobj_util.c
示例17: varinsert
VARDEF *
varinsert( /* get a link to a variable */
char *name
)
{
VARDEF *vp;
int hv;
if ((vp = varlookup(name)) != NULL) {
vp->nlinks++;
return(vp);
}
vp = (VARDEF *)emalloc(sizeof(VARDEF));
vp->lib = liblookup(name);
if (vp->lib == NULL) /* if name not in library */
name = qualname(name, 0); /* use fully qualified version */
hv = hash(name);
vp->name = savestr(name);
vp->nlinks = 1;
vp->def = NULL;
vp->next = hashtbl[hv];
hashtbl[hv] = vp;
return(vp);
}
开发者ID:kalyanam-FMTGA,项目名称:ray-original,代码行数:24,代码来源:caldefn.c
示例18: collect
//.........这里部分代码省略.........
goto out;
case 'q':
/*
* Force a quit of sending mail.
* Act like an interrupt happened.
*/
hadintr++;
collint(SIGINT);
exit(1);
case 'x':
/*
* Exit, do not save in dead.letter.
*/
goto err;
case 'h':
/*
* Grab a bunch of headers.
*/
grabh(hp, GTO|GSUBJECT|GCC|GBCC);
goto cont;
case 't':
/*
* Add to the To list.
*/
hp->h_to = cat(hp->h_to, extract(&linebuf[2], GTO));
break;
case 's':
/*
* Set the Subject line.
*/
cp = &linebuf[2];
while (isspace((unsigned char)*cp))
cp++;
hp->h_subject = savestr(cp);
break;
case 'R':
/*
* Set the Reply-To line.
*/
cp = &linebuf[2];
while (isspace((unsigned char)*cp))
cp++;
hp->h_replyto = savestr(cp);
break;
case 'c':
/*
* Add to the CC list.
*/
hp->h_cc = cat(hp->h_cc, extract(&linebuf[2], GCC));
break;
case 'b':
/*
* Add to the BCC list.
*/
hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
break;
case 'i':
case 'A':
case 'a':
/*
* Insert named variable in message.
*/
switch(c) {
case 'i':
cp = &linebuf[2];
while(isspace((unsigned char)*cp))
开发者ID:2trill2spill,项目名称:freebsd,代码行数:67,代码来源:collect.c
示例19: trapcmd
int
trapcmd(int argc, char **argv)
{
char *action;
char **ap;
int signo;
if (argc <= 1) {
for (signo = 0 ; signo <= NSIG ; signo++)
if (trap[signo] != NULL) {
out1fmt("trap -- ");
print_quoted(trap[signo]);
out1fmt(" %s\n",
(signo) ? sys_signame[signo] : "EXIT");
}
return 0;
}
ap = argv + 1;
action = NULL;
if (strcmp(*ap, "--") == 0)
if (*++ap == NULL)
return 0;
if (signame_to_signum(*ap) == -1) {
if ((*ap)[0] == '-') {
if ((*ap)[1] == '\0')
ap++;
else if ((*ap)[1] == 'l' && (*ap)[2] == '\0') {
printsignals();
return 0;
}
else
error("bad option %s\n", *ap);
}
else
action = *ap++;
}
while (*ap) {
if (is_number(*ap))
signo = number(*ap);
else
signo = signame_to_signum(*ap);
if (signo < 0 || signo > NSIG)
error("%s: bad trap", *ap);
INTOFF;
if (action)
action = savestr(action);
if (trap[signo])
ckfree(trap[signo]);
trap[signo] = action;
if (signo != 0)
setsignal(signo, 0);
INTON;
ap++;
}
return 0;
}
开发者ID:2fast4u88,项目名称:oxygen_system_core,代码行数:65,代码来源:trap.c
示例20: readtty
/*
* Read up a header from standard input.
* The source string has the preliminary contents to
* be read.
*
*/
char *
readtty(char *pr, char *src)
{
struct sigaction act, saveint;
char ch, canonb[BUFSIZ];
char *cp, *cp2;
sigset_t oset;
int c;
fputs(pr, stdout);
fflush(stdout);
if (src != NULL && strlen(src) > sizeof(canonb) - 2) {
puts("too long to edit");
return(src);
}
#ifndef TIOCSTI
if (src != NULL)
cp = copy(src, canonb); /* safe, bounds checked above */
else
cp = copy("", canonb);
fputs(canonb, stdout);
fflush(stdout);
#else
cp = src == NULL ? "" : src;
while ((c = (unsigned char)*cp++) != '\0') {
if ((c_erase != _POSIX_VDISABLE && c == c_erase) ||
(c_kill != _POSIX_VDISABLE && c == c_kill)) {
ch = '\\';
ioctl(0, TIOCSTI, &ch);
}
ch = c;
ioctl(0, TIOCSTI, &ch);
}
cp = canonb;
*cp = 0;
#endif
sigemptyset(&act.sa_mask);
act.sa_flags = 0; /* Note: will not restart syscalls */
act.sa_handler = ttyint;
(void)sigaction(SIGINT, &act, &saveint);
act.sa_handler = ttystop;
(void)sigaction(SIGTSTP, &act, NULL);
(void)sigaction(SIGTTOU, &act, NULL);
(void)sigaction(SIGTTIN, &act, NULL);
(void)sigprocmask(SIG_UNBLOCK, &intset, &oset);
clearerr(stdin);
memset(cp, 0, canonb + sizeof(canonb) - cp);
for (cp2 = cp; cp2 < canonb + sizeof(canonb) - 1; ) {
c = getc(stdin);
switch (ttysignal) {
case SIGINT:
ttysignal = 0;
cp2 = NULL;
c = EOF;
/* FALLTHROUGH */
case 0:
break;
default:
ttysignal = 0;
goto redo;
}
if (c == EOF || c == '\n')
break;
*cp2++ = c;
}
act.sa_handler = SIG_DFL;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART;
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
(void)sigaction(SIGTSTP, &act, NULL);
(void)sigaction(SIGTTOU, &act, NULL);
(void)sigaction(SIGTTIN, &act, NULL);
(void)sigaction(SIGINT, &saveint, NULL);
if (cp2 == NULL)
return(NULL); /* user hit ^C */
*cp2 = '\0';
if (c == EOF && ferror(stdin)) {
redo:
cp = strlen(canonb) > 0 ? canonb : NULL;
clearerr(stdin);
/* XXX - make iterative, not recursive */
return(readtty(pr, cp));
}
#ifndef TIOCSTI
if (cp == NULL || *cp == '\0')
return(src);
cp2 = cp;
if (!ttyset)
return(strlen(canonb) > 0 ? savestr(canonb) : NULL);
while (*cp != '\0') {
c = (unsigned char)*cp++;
if (c_erase != _POSIX_VDISABLE && c == c_erase) {
if (cp2 == canonb)
continue;
//.........这里部分代码省略.........
开发者ID:SylvestreG,项目名称:bitrig,代码行数:101,代码来源:tty.c
注:本文中的savestr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论