示例#1
0
Ivector2 CInifile::r_ivector2( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    Ivector2	V= {0,0};
    sscanf		(C,"%d,%d",&V.x,&V.y);
    return V;
}
示例#2
0
Fvector3 CInifileEx::r_fvector3( LPCSTR S, LPCSTR L )
{
	LPCSTR		C = r_string(S,L);
	Fvector3	V={0.f,0.f,0.f};
	sscanf		(C,"%f,%f,%f",&V.x,&V.y,&V.z);
	return V;
}
示例#3
0
Ivector4 CInifile::r_ivector4( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    Ivector4	V= {0,0,0,0};
    sscanf		(C,"%d,%d,%d,%d",&V.x,&V.y,&V.z,&V.w);
    return V;
}
示例#4
0
Ivector3 CInifileEx::r_ivector3( LPCSTR S, LPCSTR L )
{
	LPCSTR		C = r_string(S,L);
	Ivector		V={0,0,0};
	sscanf		(C,"%d,%d,%d",&V.x,&V.y,&V.z);
	return V;
}
示例#5
0
Fvector2 CInifile::r_fvector2( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    Fvector2	V= {0.f,0.f};
    sscanf		(C,"%f,%f",&V.x,&V.y);
    return V;
}
示例#6
0
Fvector4 CInifile::r_fvector4( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    Fvector4	V= {0.f,0.f,0.f,0.f};
    sscanf		(C,"%f,%f,%f,%f",&V.x,&V.y,&V.z,&V.w);
    return V;
}
示例#7
0
u32 CInifile::r_color( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    u32			r=0,g=0,b=0,a=255;
    sscanf		(C,"%d,%d,%d,%d",&r,&g,&b,&a);
    return color_rgba(r,g,b,a);
}
示例#8
0
Fcolor CInifile::r_fcolor( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    Fcolor		V= {0,0,0,0};
    sscanf		(C,"%f,%f,%f,%f",&V.r,&V.g,&V.b,&V.a);
    return V;
}
示例#9
0
BOOL	CInifile::r_bool( LPCSTR S, LPCSTR L )
{
	LPCSTR		C = r_string(S,L);
	char		B[8];
	strncpy		(B,C,7);
	strlwr		(B);
    return 		IsBOOL(B);
}
示例#10
0
int		CInifile::r_token	( LPCSTR S, LPCSTR L, const xr_token *token_list)
{
    LPCSTR		C = r_string(S,L);
    for( int i=0; token_list[i].name; i++ )
        if( !stricmp(C,token_list[i].name) )
            return token_list[i].id;
    return 0;
}
示例#11
0
u64 CInifile::r_u64(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
#ifndef _EDITOR
    return		_strtoui64(C,NULL,10);
#else
    return		(u64)_atoi64(C);
#endif
}
示例#12
0
static long r_long(RFILE *p)
{
    long l;
    unsigned char buffer[4];

    r_string((char *)buffer, 4, p);
    __coverity_tainted_string_sanitize_content__(buffer);
    l = (long)buffer;
    return l;
}
示例#13
0
shared_str		CInifile::r_string_wb(LPCSTR S, LPCSTR L)	{
    LPCSTR		_base		= r_string(S,L);

    if	(0==_base)					return	shared_str(0);

    string4096						_original;
    strcpy_s						(_original,_base);
    u32			_len				= xr_strlen(_original);
    if	(0==_len)					return	shared_str("");
    if	('"'==_original[_len-1])	_original[_len-1]=0;				// skip end
    if	('"'==_original[0])			return	shared_str(&_original[0] + 1);	// skip begin
    return									shared_str(_original);
}
示例#14
0
static struct dolnod *r_comlist(Shell_t *shp)
{
	register struct dolnod *dol=0;
	register long l;
	register char **argv;
	if((l=sfgetl(infile))>0)
	{
		dol = (struct dolnod*)stkalloc(shp->stk,sizeof(struct dolnod) + sizeof(char*)*(l+ARG_SPARE));
		dol->dolnum = l;
		dol->dolbot = ARG_SPARE;
		argv = dol->dolval+ARG_SPARE;
		while(*argv++ = r_string(shp->stk));
	}
	return(dol);
}
示例#15
0
static struct ionod *r_redirect(Shell_t* shp)
{
	register long l;
	register struct ionod *iop=0, *iopold, *ioptop=0;
	while((l=sfgetl(infile))>=0)
	{
		iop = (struct ionod*)getnode(shp->stk,ionod);
		if(!ioptop)
			ioptop = iop;
		else
			iopold->ionxt = iop;
		iop->iofile = l;
		iop->ioname = r_string(shp->stk);
		if(iop->iodelim = r_string(shp->stk))
		{
			iop->iosize = sfgetl(infile);
			if(shp->heredocs)
				iop->iooffset = sfseek(shp->heredocs,(off_t)0,SEEK_END);
			else
			{
				shp->heredocs = sftmp(512);
				iop->iooffset = 0;
			}
			sfmove(infile,shp->heredocs, iop->iosize, -1);
		}
		iopold = iop;
		if(iop->iofile&IOVNM)
			iop->iovname = r_string(shp->stk);
		else
			iop->iovname = 0;
		iop->iofile &= ~IOVNM;
	}
	if(iop)
		iop->ionxt = 0;
	return(ioptop);
}
示例#16
0
BOOL	CInifile::r_bool( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    VERIFY2		(
        xr_strlen(C) <= 5,
        make_string(
            "\"%s\" is not a valid bool value, section[%s], line[%s]",
            C,
            S,
            L
        )
    );
    char		B[8];
    strncpy		(B,C,7);
    B[7]		= 0;
    strlwr		(B);
    return 		IsBOOL(B);
}
示例#17
0
u32 CInifileEx::r_u32(LPCSTR S, LPCSTR L)
{
	LPCSTR		C = r_string(S,L);
	return		u32(atoi(C));
}
示例#18
0
文件: speed.c 项目: Cl3Kener/gmp
void
routine_find (struct choice_t *c, const char *s_orig)
{
  const char  *s;
  int     i;
  size_t  nlen;

  c->name = s_orig;
  s = strchr (s_orig, '*');
  if (s != NULL)
    {
      c->scale = atof(s_orig);
      s++;
    }
  else
    {
      c->scale = 1.0;
      s = s_orig;
    }

  for (i = 0; i < numberof (routine); i++)
    {
      nlen = strlen (routine[i].name);
      if (memcmp (s, routine[i].name, nlen) != 0)
        continue;

      if (s[nlen] == '.')
        {
          /* match, with a .r parameter */

          if (! (routine[i].flag & (FLAG_R|FLAG_R_OPTIONAL)))
            {
              fprintf (stderr,
                       "Choice %s bad: doesn't take a \".<r>\" parameter\n",
                       s_orig);
              exit (1);
            }

          c->p = &routine[i];
          c->r = r_string (s + nlen + 1);
          return;
        }

      if (s[nlen] == '\0')
        {
          /* match, with no parameter */

          if (routine[i].flag & FLAG_R)
            {
              fprintf (stderr,
                       "Choice %s bad: needs a \".<r>\" parameter\n",
                       s_orig);
              exit (1);
            }

          c->p = &routine[i];
          c->r = 0;
          return;
        }
    }

  fprintf (stderr, "Choice %s unrecognised\n", s_orig);
  exit (1);
}
示例#19
0
s16 CInifile::r_s16(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		s16(atoi(C));
}
示例#20
0
CLASS_ID CInifile::r_clsid( LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		TEXT2CLSID(C);
}
示例#21
0
u16 CInifileEx::r_u16(LPCSTR S, LPCSTR L)
{
	LPCSTR		C = r_string(S,L);
	return		u16(atoi(C));
}
示例#22
0
s8 CInifile::r_s8(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		s8(atoi(C));
}
示例#23
0
/*
 * read in a shell tree
 */
static Shnode_t *r_tree(Shell_t *shp)
{
	long l = sfgetl(infile); 
	register int type;
	register Shnode_t *t=0;
	if(l<0)
		return(t);
	type = l;
	switch(type&COMMSK)
	{
		case TTIME:
		case TPAR:
			t = getnode(shp->stk,parnod);
			t->par.partre = r_tree(shp);
			break;
		case TCOM:
			t = getnode(shp->stk,comnod);
			t->tre.tretyp = type;
			r_comarg(shp,(struct comnod*)t);
			break;
		case TSETIO:
		case TFORK:
			t = getnode(shp->stk,forknod);
			t->fork.forkline = sfgetu(infile);
			t->fork.forktre = r_tree(shp);
			t->fork.forkio = r_redirect(shp);
			break;
		case TIF:
			t = getnode(shp->stk,ifnod);
			t->if_.iftre = r_tree(shp);
			t->if_.thtre = r_tree(shp);
			t->if_.eltre = r_tree(shp);
			break;
		case TWH:
			t = getnode(shp->stk,whnod);
			t->wh.whinc = (struct arithnod*)r_tree(shp);
			t->wh.whtre = r_tree(shp);
			t->wh.dotre = r_tree(shp);
			break;
		case TLST:
		case TAND:
		case TORF:
		case TFIL:
			t = getnode(shp->stk,lstnod);
			t->lst.lstlef = r_tree(shp);
			t->lst.lstrit = r_tree(shp);
			break;
		case TARITH:
			t = getnode(shp->stk,arithnod);
			t->ar.arline = sfgetu(infile);
			t->ar.arexpr = r_arg(shp);
			t->ar.arcomp = 0;
			if((t->ar.arexpr)->argflag&ARG_RAW)
				 t->ar.arcomp = sh_arithcomp((t->ar.arexpr)->argval);
			break;
		case TFOR:
			t = getnode(shp->stk,fornod);
			t->for_.forline = 0;
			if(type&FLINENO)
				t->for_.forline = sfgetu(infile);
			t->for_.fortre = r_tree(shp);
			t->for_.fornam = r_string(shp->stk);
			t->for_.forlst = (struct comnod*)r_tree(shp);
			break;
		case TSW:
			t = getnode(shp->stk,swnod);
			t->sw.swline = 0;
			if(type&FLINENO)
				t->sw.swline = sfgetu(infile);
			t->sw.swarg = r_arg(shp);
			if(type&COMSCAN)
				t->sw.swio = r_redirect(shp);
			else
				t->sw.swio = 0;
			t->sw.swlst = r_switch(shp);
			break;
		case TFUN:
		{
			Stak_t *savstak;
			struct slnod *slp;
			struct functnod *fp;
			t = getnode(shp->stk,functnod);
			t->funct.functloc = -1;
			t->funct.functline = sfgetu(infile);
			t->funct.functnam = r_string(shp->stk);
			savstak = stakcreate(STAK_SMALL);
			savstak = stakinstall(savstak, 0);
			slp = (struct slnod*)stkalloc(shp->stk,sizeof(struct slnod)+sizeof(struct functnod));
			slp->slchild = 0;
			slp->slnext = shp->st.staklist;
			shp->st.staklist = 0;
			fp = (struct functnod*)(slp+1);
			memset(fp, 0, sizeof(*fp));
			fp->functtyp = TFUN|FAMP;
			if(shp->st.filename)
				fp->functnam = stkcopy(shp->stk,shp->st.filename);
			t->funct.functtre = r_tree(shp); 
			t->funct.functstak = slp;
			slp->slptr =  stakinstall(savstak,0);
			slp->slchild = shp->st.staklist;
			t->funct.functargs = (struct comnod*)r_tree(shp);
			break;
		}
		case TTST:
			t = getnode(shp->stk,tstnod);
			t->tst.tstline = sfgetu(infile);
			if((type&TPAREN)==TPAREN)
				t->lst.lstlef = r_tree(shp); 
			else
			{
				t->lst.lstlef = (Shnode_t*)r_arg(shp);
				if((type&TBINARY))
					t->lst.lstrit = (Shnode_t*)r_arg(shp);
			}
	}
	if(t)
		t->tre.tretyp = type;
	return(t);
}
示例#24
0
s32 CInifile::r_s32(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		s32(atoi(C));
}
示例#25
0
float CInifile::r_float(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		float(atof( C ));
}
示例#26
0
u8 CInifileEx::r_u8(LPCSTR S, LPCSTR L)
{
	LPCSTR		C = r_string(S,L);
	return		u8(atoi(C));
}
示例#27
0
void
routine_find (struct choice_t *c, const char *s_orig)
{
  const char  *s;
  int     i;
  size_t  nlen;

  c->name = s_orig;
  c->nsum=0;
  c->colfile=-1;
  s = strchr (s_orig, '*');
  if (s != NULL)
    {
      c->scale = atof(s_orig);
      s++;
    }
  else
    {
      c->scale = 1.0;
      s = s_orig;
    }

  for (i = 0; i < numberof (routine); i++)
    {
      nlen = strlen (routine[i].name);
      if (memcmp (s, routine[i].name, nlen) != 0)
        continue;

      if (s[nlen] == '.')
        {
          /* match, with a .r parameter */

          if (! (routine[i].flag & (FLAG_R|FLAG_R_OPTIONAL)))
            {
              fprintf (stderr,
                       "Choice %s bad: doesn't take a \".<r>\" parameter\n",
                       s_orig);
              exit (1);
            }

          c->p = &routine[i];
          c->r = r_string (s + nlen + 1);
          return;
        }

      if (s[nlen] == '\0')
        {
          /* match, with no parameter */

          if (routine[i].flag & FLAG_R)
            {
              fprintf (stderr,
                       "Choice %s bad: needs a \".<r>\" parameter\n",
                       s_orig);
              exit (1);
            }

          c->p = &routine[i];
          c->r = 0;
          return;
        }
    }
  #if SUMMAX > 4
  #error Change line below as summax > 4  
  #endif
  c->nsum=sscanf(s,"colsum=%d+%d+%d+%d",&c->sum[0],&c->sum[1],&c->sum[2],&c->sum[3]);
  for(i=0;i<c->nsum;i++)c->sum[i]--;
  for(i=0;i<c->nsum;i++)
     {xcol[xcoln++]=c->sum[i];
      if(xcoln>XCOLMAX){fprintf(stderr,"XCOLMAX not big enough\n");exit(1);}}
  if(c->nsum!=0)return;
  
  c->filename=malloc(1024);// bit of a over kill , but remember what if we have two colfile's , these pointer can get lost
  if(sscanf(s,"colfile=%d,%s",&i,c->filename)==2)
    {c->colfile=i;return;}
  fprintf (stderr, "Choice %s unrecognised\n", s_orig);
  exit (1);
}
示例#28
0
s64 CInifile::r_s64(LPCSTR S, LPCSTR L)
{
    LPCSTR		C = r_string(S,L);
    return		_atoi64(C);
}