Esempio n. 1
0
int assign(char *str)
{
    char *cp;
    int rv;
    cp = strchr(str,'=');
    *cp = '\0';
    rv = (okname (str)?VLstore(str,cp+1):-1);
    *cp = '=';
    return rv;
}
Esempio n. 2
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  assign
 *  Description: execute name = val And ensure that name is legal 
 * =====================================================================================
 */
static
int
assign (char *str)
{
    int rv;
    char * cp;
    cp = strchr(str,'=');
    *cp = '\0';
    rv = okname(str)?VLstore(str,cp+1):-1;
    return rv;
}		/* -----  end of function assign  ----- */
Esempio n. 3
0
int VLexport(char *name)
{
  struct var *itemp;
  int rv = 1;

  if ((itemp = find_item(name, 0)) != NULL) {
    itemp->global = 1;
    rv = 0;
  } else if (VLstore(name, "") == 1)
    rv = VLexport(name);
  return rv;
}
Esempio n. 4
0
int assign(char* str)
{
  char *ptr;
  int rv;

  ptr  = strchr(str, '=');
  *ptr = '\0';

  if (okname(str))
    rv = VLstore(str, ptr + 1);

  *ptr = '=';
  return rv;
}
Esempio n. 5
0
int assign(char *str)
/*
 * purpose: execute name=val AND ensure that name is legal
 * returns: -1 for illegal lval, or result of VLstore 
 * warning: modifies the string, but retores it to normal
 */
{
	char	*cp;
	int	rv ;

	cp = strchr(str,'=');
	*cp = '\0';
	rv = ( okname(str) ? VLstore(str,cp+1) : -1 );
	*cp = '=';
	return rv;
}
Esempio n. 6
0
int VLexport(char* name)
{
  struct var *pvar;
  int rv = 1;

  if ((pvar = find_item(name, 0)) != NULL)
  {
    pvar->global = 1;
    rv = 0;
  }
  else if (VLstore(name, ""))
  {
    rv = VLexport(name);
  }

  return rv;
}
Esempio n. 7
0
int VLexport(char *name)
/*
 * marks a var for export, adds it if not there
 * returns 1 for no, 0 for ok
 */
{
    struct var * itemp;
    int rv = 1;

    if ((itemp = find_item(name, 0)) != NULL)
    {
        itemp->global = 1;
        rv = 0;
    }
    else if (VLstore(name, "") == 1)
    {
        rv = VLexport(name);
    }

    return rv;
}
Esempio n. 8
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  builtin_command
 *  Description:  1 for build in command, 0 for not 
 * =====================================================================================
 */
   int 
builtin_command (char **args, int * resultp)
{
    int rv = 0;
    if (strcmp(args[0],"set") == 0)
    {
	VLlist();
	*resultp = 0;
	rv = 1;
    }else if (strchr(args[0],'=') != NULL)
    {
	*resultp = assign(args[0]);
	if (*resultp != -1)
	    rv =1;
    }else if (strcmp(args[0],"export") == 0)
    {
	if (args[1]!=NULL&&okname(args[1]))
	    *resultp = VLexport(args[1]);
	else
	    *resultp = 1;
	rv = 1;
    }else if (strcmp(args[0],"cd") == 0)
    {
	if (args[1]!= NULL )
	{
	    *resultp = VLstore("PWD",args[1]);
	    rv = 1;
	}
    }else if (strcmp(args[0],"exit") == 0)
    {
	rv = 1;
    }
    else if (findCharFromArgv("&",args) == 0)
    {
                                                /* implement '&' char processing, which put the porcess running in back groud */

    }                                           

    return rv;
}		/* -----  end of function builtin_command  ----- */