Lines Matching refs:fp

45 	register Namfun_t	*fp;
47 if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
48 fp = nfp = nfp->next;
50 for(; fp; fp=fp->next)
52 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
54 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
57 if(fp && fp->disc->getval)
58 cp = (*fp->disc->getval)(np,fp);
59 else if(fp && fp->disc->getnum)
61 sfprintf(sh.strbuf,"%.*Lg",12,(*fp->disc->getnum)(np,fp));
77 register Namfun_t *fp;
81 if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
82 fp = nfp = nfp->next;
84 for(; fp; fp=fp->next)
86 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
88 if(!fp->disc->getnum && nv_isattr(np,NV_INTEGER))
90 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
93 if(fp && fp->disc && fp->disc->getnum)
94 d = (*fp->disc->getnum)(np,fp);
102 if(fp && fp->disc && fp->disc->getval)
103 str = (*fp->disc->getval)(np,fp);
105 str = nv_getv(np,fp?fp:nfp);
124 register Namfun_t *fp, *fpnext;
126 if((fp=nfp) != NIL(Namfun_t*) && !nv_local)
127 fp = nfp = nfp->next;
130 fp = 0;
131 for(; fp; fp=fpnext)
133 fpnext = fp->next;
134 if(!fp->disc || !fp->disc->putval)
138 if(fp->disc || !(fp->nofree&1))
139 nv_disc(np,fp,NV_POP);
140 if(!(fp->nofree&1))
141 free((void*)fp);
145 if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
148 if(!value && (flags&NV_TYPE) && fp && fp->disc->putval==assign)
149 fp = 0;
150 if(fp && fp->disc->putval)
151 (*fp->disc->putval)(np,value, flags, fp);
238 Namfun_t *fp;
239 if((fp=nv_stack(np, NIL(Namfun_t*))) && !(fp->nofree&1))
240 free((void*)fp);
448 char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
461 if(np == (Namval_t*)fp)
486 for(fp=(Namfun_t*)vp; fp; fp=fp->next)
488 if(fp->disc && fp->disc->setdisc)
489 return((*fp->disc->setdisc)(np,event,action,fp));
495 if(!fp)
497 if(np != (Namval_t*)fp)
500 while(fp = fp->next)
502 if(fp->disc && fp->disc->setdisc)
503 return((*fp->disc->setdisc)(np,event,action,fp));
558 static char *setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
560 register Nambfun_t *vp = (Nambfun_t*)fp;
584 return(nv_setdisc(np,event,action,fp));
605 static void putdisc(Namval_t* np, const char* val, int flag, Namfun_t* fp)
607 nv_putv(np,val,flag,fp);
610 register Nambfun_t *vp = (Nambfun_t*)fp;
626 nv_disc(np,fp,NV_POP);
627 if(!(fp->nofree&1))
628 free((void*)fp);
635 Namfun_t *nv_clone_disc(register Namfun_t *fp, int flags)
639 if(!fp->disc && !fp->next && (fp->nofree&1))
640 return(fp);
641 if(!(size=fp->dsize) && (!fp->disc || !(size=fp->disc->dsize)))
645 memcpy(nfp,fp,size);
679 * NV_FIRST: Move or push <fp> to top of the stack or delete top
680 * NV_LAST: Move or push <fp> to bottom of stack or delete last
681 * NV_POP: Delete <fp> from top of the stack
682 * NV_CLONE: Replace fp with a copy created my malloc() and return it
684 Namfun_t *nv_disc(register Namval_t *np, register Namfun_t* fp, int mode)
689 if(mode==NV_CLONE && !fp)
691 if(fp)
693 fp->subshell = sh.subshell;
694 if((lp=np->nvfun)==fp)
698 lp = nv_clone_disc(fp,0);
702 return(fp);
705 return(fp);
707 return(fp);
709 /* see if <fp> is on the list already */
715 if(lp->next==fp)
717 if(mode==NV_LAST && fp->next==0)
718 return(fp);
721 fp = nv_clone_disc(fp,0);
722 lp->next = fp;
723 return(fp);
725 lp->next = fp->next;
727 return(fp);
743 fp->next = lp;
745 fp->next = 0;
749 if((fp->nofree&1) && *lpp)
750 fp = nv_clone_disc(fp,0);
751 fp->next = *lpp;
753 *lpp = fp;
760 for(lp=np->nvfun; lp; fp=lp,lp=lp->next);
761 else if(fp = np->nvfun)
762 np->nvfun = fp->next;
764 return(fp);
773 register Namfun_t *fp;
774 for(fp=np->nvfun; fp; fp = fp->next)
776 if(fp->disc== dp)
777 return(fp);
788 static void put_notify(Namval_t* np,const char *val,int flags,Namfun_t *fp)
790 struct notify *pp = (struct notify*)fp;
791 nv_putv(np,val,flags,fp);
792 nv_stack(np,fp);
795 if(!(fp->nofree&1))
796 free((void*)fp);
803 register Namfun_t *fp;
804 for(fp=np->nvfun;fp;fp=fp->next)
806 if(fp->disc->putval==put_notify && ((struct notify*)fp)->ptr==addr)
808 nv_stack(np,fp);
810 if(!(fp->nofree&1))
811 free((void*)fp);
881 register Namfun_t *fp, **mfp = &mp->nvfun, *nfp, *fpnext;
882 for(fp=np->nvfun; fp;fp=fpnext)
884 fpnext = fp->next;
885 if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
887 if((fp->nofree&2) && (flags&NV_NODISC))
889 if(fp->disc && fp->disc->clonef)
890 nfp = (*fp->disc->clonef)(np,mp,flags,fp);
892 nfp = fp;
894 nfp = nv_clone_disc(fp,flags);
913 Namfun_t *fp, *fpnext;
917 for(fp=mp->nvfun; fp; fp=fpnext)
919 fpnext = fp->next;
920 if(!fpnext && (flags&NV_COMVAR) && fp->disc && fp->disc->namef)
922 if(!(fp->nofree&1))
923 free((void*)fp);
925 mp->nvfun = fp;
926 if(fp=np->nvfun)
1263 extern Namfun_t *nv_stack(register Namval_t *np, register Namfun_t* fp)
1265 return(nv_disc(np,fp,0));
1276 static Namval_t *next_table(register Namval_t* np, Dt_t *root,Namfun_t *fp)
1278 struct table *tp = (struct table *)fp;
1285 static Namval_t *create_table(Namval_t *np,const char *name,int flags,Namfun_t *fp)
1287 struct table *tp = (struct table *)fp;
1289 return(nv_create(name, tp->dict, flags, fp));
1292 static Namfun_t *clone_table(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
1294 struct table *tp = (struct table*)fp;
1295 struct table *ntp = (struct table*)nv_clone_disc(fp,0);
1299 memcpy((void*)ntp,(void*)fp,sizeof(struct table));
1326 static void put_table(register Namval_t* np, const char* val, int flags, Namfun_t* fp)
1328 register Dt_t *root = ((struct table*)fp)->dict;
1334 nv_putv(np,val,flags,fp);
1341 data.sh = ((struct table*)fp)->shp;
1352 if(!(fp->nofree&1))
1353 free((void*)fp);
1360 static char *get_table(Namval_t *np, Namfun_t *fp)
1362 register Dt_t *root = ((struct table*)fp)->dict;
1448 Namfun_t *fp = pp->nvfun;
1449 mp = (*fp->disc->createf)(pp,name,0,fp);
1478 register Namfun_t *fp;
1479 for(fp=np->nvfun; fp; fp=fp->next)
1481 if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))