Lines Matching refs:fp

43 	register Namfun_t	*fp;
45 if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
46 fp = nfp = nfp->next;
48 for(; fp; fp=fp->next)
50 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
52 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
55 if(fp && fp->disc->getval)
56 cp = (*fp->disc->getval)(np,fp);
57 else if(fp && fp->disc->getnum)
59 sfprintf(sh.strbuf,"%.*Lg",12,(*fp->disc->getnum)(np,fp));
75 register Namfun_t *fp;
78 if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
79 fp = nfp = nfp->next;
81 for(; fp; fp=fp->next)
83 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
85 if(!fp->disc->getnum && nv_isattr(np,NV_INTEGER))
87 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
90 if(fp && fp->disc && fp->disc->getnum)
91 d = (*fp->disc->getnum)(np,fp);
99 if(fp && fp->disc && fp->disc->getval)
100 str = (*fp->disc->getval)(np,fp);
102 str = nv_getv(np,fp?fp:nfp);
118 register Namfun_t *fp, *fpnext;
119 if((fp=nfp) != NIL(Namfun_t*) && !nv_local)
120 fp = nfp = nfp->next;
123 fp = 0;
124 for(; fp; fp=fpnext)
126 fpnext = fp->next;
127 if(!fp->disc || !fp->disc->putval)
131 if(fp->disc || !(fp->nofree&1))
132 nv_disc(np,fp,NV_POP);
133 if(!(fp->nofree&1))
134 free((void*)fp);
138 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
141 if(fp && fp->disc->putval)
142 (*fp->disc->putval)(np,value, flags, fp);
229 Namfun_t *fp;
230 if((fp=nv_stack(np, NIL(Namfun_t*))) && !(fp->nofree&1))
231 free((void*)fp);
429 char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
442 if(np == (Namval_t*)fp)
467 for(fp=(Namfun_t*)vp; fp; fp=fp->next)
469 if(fp->disc && fp->disc->setdisc)
470 return((*fp->disc->setdisc)(np,event,action,fp));
476 if(!fp)
478 if(np != (Namval_t*)fp)
481 while(fp = fp->next)
483 if(fp->disc && fp->disc->setdisc)
484 return((*fp->disc->setdisc)(np,event,action,fp));
539 static char *setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
541 register Nambfun_t *vp = (Nambfun_t*)fp;
565 return(nv_setdisc(np,event,action,fp));
581 static void putdisc(Namval_t* np, const char* val, int flag, Namfun_t* fp)
583 nv_putv(np,val,flag,fp);
586 register Nambfun_t *vp = (Nambfun_t*)fp;
602 nv_disc(np,fp,NV_POP);
603 if(!(fp->nofree&1))
604 free((void*)fp);
611 Namfun_t *nv_clone_disc(register Namfun_t *fp, int flags)
615 if(!fp->disc && !fp->next && (fp->nofree&1))
616 return(fp);
617 if(!(size=fp->dsize) && (!fp->disc || !(size=fp->disc->dsize)))
621 memcpy(nfp,fp,size);
655 * NV_FIRST: Move or push <fp> to top of the stack or delete top
656 * NV_LAST: Move or push <fp> to bottom of stack or delete last
657 * NV_POP: Delete <fp> from top of the stack
658 * NV_CLONE: Replace fp with a copy created my malloc() and return it
660 Namfun_t *nv_disc(register Namval_t *np, register Namfun_t* fp, int mode)
665 if(mode==NV_CLONE && !fp)
667 if(fp)
669 fp->subshell = sh.subshell;
670 if((lp=np->nvfun)==fp)
674 lp = nv_clone_disc(fp,0);
678 return(fp);
681 return(fp);
683 return(fp);
685 /* see if <fp> is on the list already */
691 if(lp->next==fp)
693 if(mode==NV_LAST && fp->next==0)
694 return(fp);
697 fp = nv_clone_disc(fp,0);
698 lp->next = fp;
699 return(fp);
701 lp->next = fp->next;
703 return(fp);
717 fp->next = 0;
720 if((fp->nofree&1) && *lpp)
721 fp = nv_clone_disc(fp,0);
722 fp->next = *lpp;
724 *lpp = fp;
731 for(lp=np->nvfun; lp; fp=lp,lp=lp->next);
732 else if(fp = np->nvfun)
733 np->nvfun = fp->next;
735 return(fp);
744 register Namfun_t *fp;
745 for(fp=np->nvfun; fp; fp = fp->next)
747 if(fp->disc== dp)
748 return(fp);
759 static void put_notify(Namval_t* np,const char *val,int flags,Namfun_t *fp)
761 struct notify *pp = (struct notify*)fp;
762 nv_putv(np,val,flags,fp);
763 nv_stack(np,fp);
766 if(!(fp->nofree&1))
767 free((void*)fp);
774 register Namfun_t *fp;
775 for(fp=np->nvfun;fp;fp=fp->next)
777 if(fp->disc->putval==put_notify && ((struct notify*)fp)->ptr==addr)
779 nv_stack(np,fp);
781 if(!(fp->nofree&1))
782 free((void*)fp);
853 register Namfun_t *fp, **mfp = &mp->nvfun, *nfp, *fpnext;
854 for(fp=np->nvfun; fp;fp=fpnext)
856 fpnext = fp->next;
857 if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
859 if((fp->nofree&2) && (flags&NV_NODISC))
861 if(fp->disc && fp->disc->clonef)
862 nfp = (*fp->disc->clonef)(np,mp,flags,fp);
864 nfp = fp;
866 nfp = nv_clone_disc(fp,flags);
885 Namfun_t *fp, *fpnext;
889 for(fp=mp->nvfun; fp; fp=fpnext)
891 fpnext = fp->next;
892 if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
894 if(!(fp->nofree&1))
895 free((void*)fp);
897 mp->nvfun = fp;
898 if(fp=np->nvfun)
1201 extern Namfun_t *nv_stack(register Namval_t *np, register Namfun_t* fp)
1203 return(nv_disc(np,fp,0));
1214 static Namval_t *next_table(register Namval_t* np, Dt_t *root,Namfun_t *fp)
1216 struct table *tp = (struct table *)fp;
1223 static Namval_t *create_table(Namval_t *np,const char *name,int flags,Namfun_t *fp)
1225 struct table *tp = (struct table *)fp;
1227 return(nv_create(name, tp->dict, flags, fp));
1230 static Namfun_t *clone_table(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
1232 struct table *tp = (struct table*)fp;
1233 struct table *ntp = (struct table*)nv_clone_disc(fp,0);
1237 memcpy((void*)ntp,(void*)fp,sizeof(struct table));
1248 static void put_table(register Namval_t* np, const char* val, int flags, Namfun_t* fp)
1250 register Dt_t *root = ((struct table*)fp)->dict;
1253 nv_putv(np,val,flags,fp);
1266 if(!(fp->nofree&1))
1267 free((void*)fp);
1273 static char *get_table(Namval_t *np, Namfun_t *fp)
1275 register Dt_t *root = ((struct table*)fp)->dict;
1358 Namfun_t *fp = pp->nvfun;
1359 mp = (*fp->disc->createf)(pp,name,0,fp);
1388 register Namfun_t *fp;
1389 for(fp=np->nvfun; fp; fp=fp->next)
1391 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))