da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1982-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * AT&T Labs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinint nv_compare(Dt_t* dict, Void_t *sp, Void_t *dp, Dtdisc_t *disc)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * call the next getval function in the chain
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin sfprintf(sh.strbuf,"%.*Lg",12,(*fp->disc->getnum)(np,fp));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * call the next getnum function in the chain
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSfdouble_t nv_getn(Namval_t *np, register Namfun_t *nfp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register Sfdouble_t d=0;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(d);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * call the next assign function in the chain
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvoid nv_putv(Namval_t *np, const char *value, int flags, register Namfun_t *nfp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * returns pointer to blocking structure
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic struct blocked *block_info(Namval_t *np, struct blocked *pp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin nv_putsub(bp->np, bp->sub,(bp->isub<0?0:bp->isub)|ARRAY_SETSUB);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * free discipline if no more discipline functions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void chktfree(register Namval_t *np, register struct vardisc *vp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int n;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* no disc left so pop */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if((fp=nv_stack(np, NIL(Namfun_t*))) && !(fp->nofree&1))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function performs an assignment disc on the given node <np>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin 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))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif /* SHOPT_TYPEDEF */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin nv_onattr(SH_VALNOD,(flags&(NV_LONG|NV_DOUBLE|NV_EXPNOTE|NV_HEXFLOAT|NV_SHORT)));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin nv_putval(SH_VALNOD, val, (flags&NV_INTEGER)?flags:NV_NOFREE);
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz if (type==APPEND && (bflag= !isblocked(bp,LOOKUPS)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin cp = (char*)(&d);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* restore everything but the nvlink field */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin memcpy(&SH_VALNOD->nvname, &node.nvname, sizeof(node)-sizeof(node.nvlink));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* don't free functions during reinitialization */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(nv_isarray(np) && (ap=nv_arrayptr(np)) && ap->nelem>0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function executes a lookup disc and then performs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the lookup on the given node <np>
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzstatic char* lookup(Namval_t *np, int type, Sfdouble_t *dp,Namfun_t *handle)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* restore everything but the nvlink field */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin memcpy(&SH_VALNOD->nvname, &node.nvname, sizeof(node)-sizeof(node.nvlink));
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzstatic char* lookups(Namval_t *np, Namfun_t *handle)
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz return(lookup(np,LOOKUPS,(Sfdouble_t*)0,handle));
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzstatic Sfdouble_t lookupn(Namval_t *np, Namfun_t *handle)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Set disc on given <event> to <action>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If action==np, the current disc is returned
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * A null return value indicates that no <event> is known for <np>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If <event> is NULL, then return the event name after <action>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If <event> is NULL, and <action> is NULL, return the first event
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinchar *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register struct vardisc *vp = (struct vardisc*)np->nvfun;
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner if(vp->fun.disc && (vp->fun.disc->setdisc || vp->fun.disc->putval == assign))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* top level call, check for get/set */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return((char*)nv_discnames[0]);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return((*fp->disc->setdisc)(np,event,action,fp));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return((char*)name);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(NIL(char*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* not the top level */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(NIL(char*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return((char*)action);
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz if(!(vp = newof(NIL(struct vardisc*),struct vardisc,1,sizeof(Namdisc_t))))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!(bp=block_info(np,(struct blocked*)0)) || !isblocked(bp,UNASSIGN))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Set disc on given <event> to <action>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If action==np, the current disc is returned
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * A null return value indicates that no <event> is known for <np>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If <event> is NULL, then return the event name after <action>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If <event> is NULL, and <action> is NULL, return the first event
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char *setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* top level call, check for discipline match */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return((char*)discnames[0]);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return((char*)name);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* Handle the disciplines */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void putdisc(Namval_t* np, const char* val, int flag, Namfun_t* fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int i;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic const Namdisc_t Nv_bdisc = { 0, putdisc, 0, 0, setdisc };
7c2fbfb345896881c631598ee3852ce9ce33fb07April ChinNamfun_t *nv_clone_disc(register Namfun_t *fp, int flags)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!(size=fp->dsize) && (!fp->disc || !(size=fp->disc->dsize)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!(nfp=newof(NIL(Namfun_t*),Namfun_t,1,size-sizeof(Namfun_t))))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinint nv_adddisc(Namval_t *np, const char **names, Namval_t **funs)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int n=0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!(vp = newof(NIL(Nambfun_t*),Nambfun_t,1,n*sizeof(Namval_t*))))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin memcpy((void*)vp->bltins, (void*)funs,n*sizeof(Namval_t*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin else while(n>=0)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * push, pop, clne, or reorder disciplines onto node <np>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * mode can be one of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_FIRST: Move or push <fp> to top of the stack or delete top
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_LAST: Move or push <fp> to bottom of stack or delete last
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_POP: Delete <fp> from top of the stack
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_CLONE: Replace fp with a copy created my malloc() and return it
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinNamfun_t *nv_disc(register Namval_t *np, register Namfun_t* fp, int mode)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(mode==NV_LAST && (lp->next==0 || lp->next->disc==0))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* see if <fp> is on the list already */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* push */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * returns discipline pointer if discipline with specified functions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * is on the discipline stack
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void put_notify(Namval_t* np,const char *val,int flags,Namfun_t *fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(fp->disc->putval==put_notify && ((struct notify*)fp)->ptr==addr)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int s;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register Namval_t *np = newof(0,Namval_t,1,s=strlen(name)+1);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return((void*)np);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * clone a numeric value
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void *num_clone(register Namval_t *np, void *val)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin size = sizeof(float);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin size = sizeof(double);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin size = sizeof(short);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinvoid clone_all_disc( Namval_t *np, Namval_t *mp, int flags)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin register Namfun_t *fp, **mfp = &mp->nvfun, *nfp, *fpnext;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * clone <mp> from <np> flags can be one of the following
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_APPEND - append <np> onto <mp>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_MOVE - move <np> to <mp>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_NOFREE - mark the new node as nofree
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * NV_NODISC - discplines with funs non-zero will not be copied
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * NV_COMVAR - cloning a compound variable
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(nv_isattr(mp,NV_EXPORT|NV_MINIMAL) == (NV_EXPORT|NV_MINIMAL))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(!(flags&NV_COMVAR) && !nv_isattr(np,NV_MINIMAL) && np->nvenv && !(nv_isattr(mp,NV_MINIMAL)))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mp->nvflag |= np->nvflag&~(NV_ARRAY|NV_MINIMAL|NV_NOFREE);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mp->nvflag = (np->nvflag&~(NV_MINIMAL))|(mp->nvflag&NV_MINIMAL);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(mp->nvalue.cp==val && !nv_isattr(np,NV_INTEGER))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(np->nvalue.cp && np->nvalue.cp!=Empty && (flags&NV_COMVAR) && !(flags&NV_MOVE))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mp->nvalue.cp = (char*)memdup(np->nvalue.cp,size);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(mp,NV_EXPORT))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if(nv_isattr(np,NV_INTEGER) && mp->nvalue.ip!=np->nvalue.ip)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin mp->nvalue.ip = (int*)num_clone(np,(void*)np->nvalue.ip);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(1);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The following discipline is for copy-on-write semantics
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic Sfdouble_t clone_getn(Namval_t *np, Namfun_t *handle)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void clone_putv(Namval_t *np,const char* val,int flags,Namfun_t *handle)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* SHOPT_NAMESPACE */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinNamval_t *nv_search(const char *name, Dt_t *root, int mode)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(sh.namespace && !(mode&HASH_NOSCOPE) && root==sh.var_tree)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * finds function or builtin for given name and the discipline variable
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * if var!=0 the variable pointer is returned and the built-in name
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * is put onto the stack at the current offset.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * otherwise, a pointer to the builtin (variable or type) is returned
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and var contains the poiner to the variable
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * if last==0 and first component of name is a reference, nv_bfsearch()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin will return 0.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinNamval_t *nv_bfsearch(const char *name, Dt_t *root, Namval_t **var, char **last)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* check for . in the name before = */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin nq=nv_open(stakptr(offset),0,NV_VARNAME|NV_ARRAY|NV_NOASSIGN|NV_NOADD|NV_NOFAIL);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin return((Namval_t*)nv_setdisc(nq,dname,nq,(Namfun_t*)nq));
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * add or replace built-in version of command corresponding to <path>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The <bltin> argument is a pointer to the built-in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * if <extra>==1, the built-in will be deleted
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Special builtins cannot be added or deleted return failure
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The return value for adding builtins is a pointer to the node or NULL on
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * failure. For delete NULL means success and the node that cannot be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * deleted is returned on failure.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinNamval_t *sh_addbuiltin(const char *path, int (*bltin)(int, char*[],void*),void *extra)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(name==path && (nq=nv_bfsearch(name,sh.bltin_tree,(Namval_t**)0,&cp)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* exists without a path */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin else for(np=(Namval_t*)dtfirst(sh.bltin_tree);np;np=(Namval_t*)dtnext(sh.bltin_tree,np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* exists probably with different path so delete it */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!np && !(np = nv_search(path,sh.bltin_tree,bltin?NV_ADD:0)))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern Namfun_t *nv_stack(register Namval_t *np, register Namfun_t* fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic Namval_t *next_table(register Namval_t* np, Dt_t *root,Namfun_t *fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic Namval_t *create_table(Namval_t *np,const char *name,int flags,Namfun_t *fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic Namfun_t *clone_table(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin struct table *ntp = (struct table*)nv_clone_disc(fp,0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for(np=(Namval_t*)dtfirst(oroot);np;np=(Namval_t*)dtnext(oroot,np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void put_table(register Namval_t* np, const char* val, int flags, Namfun_t* fp)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(nv_isarray(np) && (ap=nv_arrayptr(np)) && array_elem(ap))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * return space separated list of names of variables in given tree
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for(np=(Namval_t*)dtfirst(root);np;np=(Namval_t*)dtnext(root,np))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin sizeof(struct table),
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin struct table *tp = (struct table *)nv_hasdisc(np,&table_disc);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin struct table *tp = (struct table*)nv_hasdisc(np,&table_disc);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin np = nv_create(np,(const char*)0, NV_FIRST, (Namfun_t*)0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * create a mountable name-value pair tree
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinNamval_t *nv_mount(Namval_t *np, const char *name, Dt_t *dict)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin struct table *tp = newof((struct table*)0, struct table,1,0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return(0);
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))