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


C++ savestr函数代码示例

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


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


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