/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* AT&T Labs
*
*/
#include "defs.h"
#include "variables.h"
#include "builtins.h"
#include "path.h"
{
return(0);
}
/*
* call the next getval function in the chain
*/
{
register char *cp;
nv_local=0;
{
continue;
break;
}
{
}
else
{
nv_local=1;
}
return(cp);
}
/*
* call the next getnum function in the chain
*/
{
register Sfdouble_t d=0;
char *str;
nv_local=0;
{
continue;
continue;
break;
}
{
nv_local = 1;
}
else
{
else
{
{
while(*str=='0')
str++;
}
}
}
return(d);
}
/*
* call the next assign function in the chain
*/
{
nv_local=0;
fp = 0;
{
{
{
}
continue;
}
break;
}
fp = 0;
else
{
nv_local=1;
if(value)
else
}
}
#define LOOKUPS 0
struct vardisc
{
};
struct blocked
{
int flags;
void *sub;
int isub;
};
/*
* returns pointer to blocking structure
*/
{
void *sub=0;
int isub=0;
{
return(bp);
}
if(pp)
{
}
return(pp);
}
{
}
/*
* free discipline if no more discipline functions
*/
{
register int n;
{
break;
}
{
/* no disc left so pop */
}
}
/*
* This function performs an assignment disc on the given node <np>
*/
{
#if SHOPT_TYPEDEF
if(val && (tp=nv_type(np)) && (nr=nv_open(val,sh.var_tree,NV_VARNAME|NV_ARRAY|NV_NOADD|NV_NOFAIL)) && tp==nv_type(nr))
{
if(sub)
{
}
else
goto done;
}
#endif /* SHOPT_TYPEDEF */
{
{
goto done;
}
{
}
if(flags&NV_INTEGER)
}
else
{
int bflag=0;
if(bflag)
}
if(nv_isarray(np))
if(val)
{
register char *cp;
Sfdouble_t d;
cp=0;
else if(flags&NV_INTEGER)
{
cp = (char*)(&d);
}
else
if(cp)
/* restore everything but the nvlink field */
}
{
/* don't free functions during reinitialization */
}
{
int n;
goto done;
goto done;
{
{
}
}
}
done:
block_done(bp);
{
}
}
/*
* This function executes a lookup disc and then performs
* the lookup on the given node <np>
*/
{
register char *cp=0;
{
{
}
{
}
{
}
{
/* restore everything but the nvlink field */
}
}
if(nv_isarray(np))
if(!cp)
{
else
}
block_done(bp);
{
}
return(cp);
}
{
}
{
Sfdouble_t d;
return(d);
}
/*
* Set disc on given <event> to <action>
* If action==np, the current disc is returned
* A null return value indicates that no <event> is known for <np>
* If <event> is NULL, then return the event name after <action>
* If <event> is NULL, and <action> is NULL, return the first event
*/
char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
{
register int type;
while(vp)
{
break;
}
vp = 0;
{
register const char *name;
register int getname=0;
if(!event)
{
if(!action)
return((char*)nv_discnames[0]);
getname=1;
}
{
break;
}
if(getname)
{
event = 0;
action = 0;
}
if(!name)
{
{
}
}
else if(getname)
return((char*)name);
}
if(!fp)
return(NIL(char*));
{
/* not the top level */
{
}
return(NIL(char*));
}
vp = 0;
if(!vp)
{
return((char*)action);
return(0);
}
{
empty = 0;
}
else if(action)
{
}
else
{
}
}
/*
* Set disc on given <event> to <action>
* If action==np, the current disc is returned
* A null return value indicates that no <event> is known for <np>
* If <event> is NULL, then return the event name after <action>
* If <event> is NULL, and <action> is NULL, return the first event
*/
static char *setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
{
register const char *name;
/* top level call, check for discipline match */
if(!event)
{
if(!action)
return((char*)discnames[0]);
getname=1;
}
{
break;
}
if(getname)
{
event = 0;
action = 0;
}
if(!name)
else if(getname)
return((char*)name);
/* Handle the disciplines */
else if(action)
{
}
else
{
}
}
{
{
register int i;
{
{
if(is_abuiltin(mp))
{
}
}
}
}
}
{
register int size;
return(fp);
return(0);
return(nfp);
}
{
register int n=0;
if(av)
{
while(*av++)
n++;
}
return(0);
if(funs)
else while(n>=0)
return(1);
}
/*
* push, pop, clne, or reorder disciplines onto node <np>
* mode can be one of
* NV_FIRST: Move or push <fp> to top of the stack or delete top
* NV_LAST: Move or push <fp> to bottom of stack or delete last
* NV_POP: Delete <fp> from top of the stack
* NV_CLONE: Replace fp with a copy created my malloc() and return it
*/
{
return(0);
return(0);
if(fp)
{
{
{
}
return(fp);
return(fp);
return(fp);
}
/* see if <fp> is on the list already */
if(lp)
{
{
{
return(fp);
{
return(fp);
}
return(fp);
break;
}
}
}
return(0);
/* push */
{
else
}
else
{
}
}
else
{
}
return(fp);
}
/*
* returns discipline pointer if discipline with specified functions
* is on the discipline stack
*/
{
{
return(fp);
}
return(0);
}
struct notify
{
char **ptr;
};
{
}
{
{
{
return(1);
}
}
return(0);
}
{
if(!pp)
return(0);
return(1);
}
{
register int s;
if(np)
{
}
return((void*)np);
}
/*
* clone a numeric value
*/
{
register int size;
void *nval;
if(!val)
return(0);
{
size = sizeof(Sfdouble_t);
size = sizeof(float);
else
size = sizeof(double);
}
else
{
{
size = sizeof(short);
else
}
else
}
return(0);
return(nval);
}
{
{
return;
nfp = 0;
else
if(!nfp)
continue;
}
}
/*
* clone <mp> from <np> flags can be one of the following
* NV_APPEND - append <np> onto <mp>
* NV_MOVE - move <np> to <mp>
* NV_NOFREE - mark the new node as nofree
* NV_NODISC - discplines with funs non-zero will not be copied
* NV_COMVAR - cloning a compound variable
*/
{
{
break;
}
{
{
}
}
return(1);
{
{
if(size)
else
}
}
{
{
{
}
else
}
else
nv_setsize(np,0);
return(1);
}
{
}
return(1);
}
/*
* The following discipline is for copy-on-write semantics
*/
{
}
{
}
{
if(val)
}
{
0,
};
{
return(np);
}
{
if(mode&HASH_NOSCOPE)
if(mode&HASH_BUCKET)
{
}
else
{
}
#if SHOPT_COSHELL
mode |= HASH_NOSCOPE;
#endif /* SHOPT_COSHELL */
{
{
}
}
if(dp)
return(np);
}
/*
* finds function or builtin for given name and the discipline variable
* if var!=0 the variable pointer is returned and the built-in name
* is put onto the stack at the current offset.
* otherwise, a pointer to the builtin (variable or type) is returned
* and var contains the poiner to the variable
* if last==0 and first component of name is a reference, nv_bfsearch()
will return 0.
*/
{
char *dname=0;
if(var)
*var = 0;
/* check for . in the name before = */
{
if(*sp=='=')
return(0);
if(*sp=='[')
{
while(*sp=='[')
{
return(0);
}
if(*sp==0)
break;
if(*sp!='.')
return(0);
}
else if(*sp=='.')
}
if(!cp)
stakputc(0);
if(last)
c = *cp;
*cp = 0;
*cp = c;
if(!nq)
{
np = 0;
goto done;
}
if(!var)
{
goto done;
}
if(c=='[')
#if SHOPT_NAMESPACE
if(nv_istable(nq))
{
if(last==0)
stakputc(0);
return(np);
}
#endif /* SHOPT_NAMESPACE */
while(nv_isarray(nq) && !nv_isattr(nq,NV_MINIMAL|NV_EXPORT) && nq->nvenv && nv_isarray((Namval_t*)nq->nvenv))
done:
return(np);
}
/*
* add or replace built-in version of command corresponding to <path>
* The <bltin> argument is a pointer to the built-in
* if <extra>==1, the built-in will be deleted
* Special builtins cannot be added or deleted return failure
* The return value for adding builtins is a pointer to the node or NULL on
* failure. For delete NULL means success and the node that cannot be
* deleted is returned on failure.
*/
{
register const char *name;
char *cp;
if(extra==(void*)1)
else if((name = path_basename(path))==path && bltin!=(Shbltin_f)SYSTYPESET->nvalue.bfp && (nq=nv_bfsearch(name,sh.bltin_tree,(Namval_t**)0,&cp)))
{
stakputc('/');
}
{
/* exists without a path */
if(extra == (void*)1)
{
return(0);
}
if(!bltin)
return(np);
}
{
continue;
/* exists probably with different path so delete it */
{
return(np);
if(!bltin)
if(extra == (void*)1)
return(0);
np = 0;
}
break;
}
return(0);
{
if(extra)
return(np);
}
if(bltin)
{
}
if(nq)
{
if(!cp)
}
if(extra == (void*)1)
return(0);
return(np);
}
{
}
struct table
{
};
{
if(root)
else
}
{
}
{
if(!nroot)
return(0);
{
}
}
struct adata
{
char *mapname;
char **argnam;
int attsize;
char *attval;
};
{
}
{
if(val)
{
return;
}
return;
{
}
}
/*
* return space separated list of names of variables in given tree
*/
{
if(out)
else
{
{
if(!first)
else
first = 0;
}
}
if(base)
}
{
sizeof(struct table),
0,
0,
0,
};
{
if(tp)
return(0);
}
{
if(tp)
while(np)
{
#if 0
#else
break;
#endif
}
}
{
}
/*
* create a mountable name-value pair tree
*/
{
else
pp = nv_lastdict();
return(0);
if(name)
{
}
else
return(mp);
}
{
switch(which)
{
case NV_DCADD:
return(&Nv_bdisc);
case NV_DCRESTRICT:
return(&RESTRICTED_disc);
}
return(0);
}
{
{
continue;
return(1);
}
return(0);
}
#if SHOPT_NAMESPACE
{
}
#endif /* SHOPT_NAMESPACE */