Lines Matching refs:fp

105 	register struct history *fp;
128 if(fp=wasopen)
132 hist_ptr = fp;
133 if(strcmp(histname,fp->fixname)==0)
169 if(!(fp=new_of(struct history,(--fixmask)*sizeof(off_t))))
174 hist_ptr = fp;
175 fp->fixfd = fd;
176 fp->fixmax = maxlines;
178 fp->fixfp = io_ftable[fd];
179 fp->fixind = 1;
180 fp->fixcmds[1] = 2;
181 fp->fixcnt = 2;
182 fp->fixname = sh_heap(histname);
194 first = fp->fixind = hist_nearend(fd,hsize-size);
196 his_start = fp->fixind-maxlines;
203 fp->fixind = first;
209 if(hist_clean(fp->fixfd) && his_start>1 && hsize > HISMAX)
218 hist_trim(fp->fixind-maxlines);
229 register struct history *fp = hist_ptr;
230 io_fclose(fp->fixfd);
231 free((char*)fp);
308 register struct fileblk *fp;
327 fp = hist_new->fixfp;
339 if(fp->ptr >= fp->last)
341 *fp->ptr++ = c;
439 register struct history *fp = hist_ptr;
443 register off_t count = fp->fixcnt;
445 io_seek(fp->fixfd,count,SEEK_SET);
447 while((c=io_getc(fp->fixfd))!=EOF)
453 c = *(fp->fixfp->ptr)++;
454 if(c==0 && (fp->fixfp->ptr > fp->fixfp->last))
456 c = io_readbuff(fp->fixfp);
474 fp->fixind += incr;
475 fp->fixcmds[fp->fixind&fixmask] = count;
494 fp->fixcnt = count;
495 p_setout(fp->fixfd);
504 register struct history *fp = hist_ptr;
506 if(!fp)
508 p_setout(fp->fixfd);
512 fp->fixcnt += 2;
513 c = (--fp->fixind)&fixmask;
514 fp->fixcmds[c] = fp->fixcnt;
523 register struct history *fp = hist_ptr;
528 if(!fp)
535 fd = fp->fixfp;
539 fp->fixcnt++;
542 if((fp->fixcnt=lseek(fp->fixfd,(off_t)0,SEEK_END)) <0)
558 p_setout(fp->fixfd);
571 if(++fd->ptr <= fd->base && !fp->fixflush)
573 fp->fixind--;
579 fp->fixcnt += (fd->ptr-fd->base);
582 if(fp->fixcnt&01)
584 fp->fixcnt++;
588 c = (++fp->fixind)&fixmask;
589 savcount = fp->fixcmds[c];
590 fp->fixcmds[c] = fp->fixcnt;
591 if(fp->fixcnt > hist_marker+IOBSIZE/2)
594 fp->fixcnt += 6;
597 c = (fp->fixind>>16);
599 c = (fp->fixind>>8);
601 c = fp->fixind;
605 fp->fixcmds[c&fixmask] = fp->fixcnt;
606 hist_marker = fp->fixcnt;
614 c = (fp->fixind--)&fixmask;
615 fp->fixcmds[c] = savcount;
618 fp->fixflush = 0;
628 register struct history *fp = hist_ptr;
629 return(fp->fixcmds[n&fixmask]);
645 register struct history *fp = hist_ptr;
646 if(offset<0 || !fp)
651 io_seek(fp->fixfd,offset,SEEK_SET);
652 while((c = io_getc(fp->fixfd)) != EOF)
681 register struct history *fp = hist_ptr;
686 if(!fp)
700 index2 = fp->fixind;
703 index2 -= fp->fixmax;
742 register struct history *fp = hist_ptr;
752 io_seek(fp->fixfd,offset,SEEK_SET);
758 if((c=io_getc(fp->fixfd)) == EOF || c ==0)
808 register struct history *fp = hist_ptr;
812 if(!fp)
815 io_seek(fp->fixfd,offset,SEEK_SET);
816 while ((c = io_getc(fp->fixfd)) && c!=EOF)
836 io_seek(fp->fixfd,(off_t)0,SEEK_END);
980 static void io_init(fd,fp,buf)
982 register struct fileblk *fp;
985 if(!fp)
987 fp = new_of(struct fileblk,IOBSIZE+1);
988 buf = (char*)(fp+1);
989 fp->flag = IOFREE;
992 fp->flag = 0;
993 fp->fdes = fd;
994 fp->fseek = 0;
995 fp->base = fp->ptr = fp->last = buf;
996 *fp->ptr = 0;
997 fp->flag |= (IORW|IOREAD);
998 io_ftable[fd] = fp;
1008 register struct fileblk *fp = io_ftable[fd];
1010 if(!fp)
1012 if(c= *fp->ptr++)
1014 if(fp->ptr <= fp->last)
1016 return(io_readbuff(fp));
1031 register struct fileblk *fp;
1035 if(!(fp=io_ftable[fd]))
1037 fp->flag &= ~IOEOF;
1038 if(!(fp->flag&IOREAD))
1044 if(fd==FCIO && ptrname==0 && (fp->flag&IOREAD) && offset<hoffset)
1046 p = hoffset - (fp->last - fp->base);
1049 fp->ptr = fp->base + (int)(offset-p);
1058 if(fp->flag&IORW)
1060 fp->flag &= ~(IOWRT|IOREAD);
1061 fp->last = fp->ptr = fp->base;
1062 *fp->last = 0;
1073 io_readbuff(fp);
1074 fp->ptr += (c-1);
1081 * Read from file into fp
1084 static int io_readbuff(fp)
1085 register struct fileblk *fp;
1089 if (fp->flag & IORW)
1090 fp->flag |= IOREAD;
1091 if (!(fp->flag&IOREAD))
1094 fp->ptr = fp->last;
1096 n = syscall(3, filenum(fp),fp->base, IOBSIZE);
1098 n = rEAd(filenum(fp),fp->base, IOBSIZE);
1100 fp->ptr = fp->base;
1102 fp->last = fp->base + n;
1104 fp->last = fp->ptr;
1105 *fp->last = 0;
1110 fp->flag |= IOEOF;
1111 if (fp->flag & IORW)
1112 fp->flag &= ~IOREAD;
1115 fp->flag |= IOERR;
1118 if(fp->fdes==FCIO)
1120 return(*fp->ptr++&STRIP);
1131 register struct fileblk *fp = io_ftable[fd];
1133 if(fp && !(fp->flag&IOREAD))
1136 if(fp && (fp->flag&IOFREE))
1137 free(fp);