Changeset 2569 for zzuf/trunk/src
- Timestamp:
- Jul 18, 2008, 11:28:30 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/lib-stream.c
r2568 r2569 56 56 #endif 57 57 58 #if defined HAVE___SRGET 59 int NEW(__srget)(FILE *fp); 60 #endif 61 58 62 /* Library functions that we divert */ 59 63 static FILE * (*ORIG(fopen)) (const char *path, const char *mode); … … 138 142 #if defined HAVE___SREFILL 139 143 int (*ORIG(__srefill)) (FILE *fp); 144 #endif 145 #if defined HAVE___SRGET 146 int (*ORIG(__srget)) (FILE *fp); 140 147 #endif 141 148 … … 749 756 #endif 750 757 758 #define REFILL(fn) \ 759 do \ 760 { \ 761 off_t newpos; \ 762 int fd; \ 763 LOADSYM(fn); \ 764 fd = fileno(fp); \ 765 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 766 return ORIG(fn)(fp); \ 767 _zz_lock(fd); \ 768 ret = ORIG(fn)(fp); \ 769 newpos = lseek(fd, 0, SEEK_CUR); \ 770 _zz_unlock(fd); \ 771 if(ret != EOF) \ 772 { \ 773 if(newpos != -1) \ 774 _zz_setpos(fd, newpos - fp->FILE_CNT - 1); \ 775 _zz_fuzz(fd, fp->FILE_PTR - 1, fp->FILE_CNT + 1); \ 776 ret = (uint8_t)fp->FILE_PTR[-1]; \ 777 _zz_addpos(fd, fp->FILE_CNT + 1); \ 778 } \ 779 if(!_zz_islocked(fd)) \ 780 debug("%s([%i]) = %i", __func__, fd, ret); \ 781 } \ 782 while(0) 783 751 784 #if defined HAVE___SREFILL 752 785 int NEW(__srefill)(FILE *fp) 753 786 { 754 off_t newpos; 755 int ret, fd; 756 757 LOADSYM(__srefill); 758 fd = fileno(fp); 759 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) 760 return ORIG(__srefill)(fp); 761 762 _zz_lock(fd); 763 ret = ORIG(__srefill)(fp); 764 newpos = lseek(fd, 0, SEEK_CUR); 765 _zz_unlock(fd); 766 if(ret != EOF) 767 { 768 /* FIXME: do we have to fuzz ret, too, like in __filbuf? */ 769 if(newpos != -1) 770 _zz_setpos(fd, newpos - fp->_r); 771 _zz_fuzz(fd, fp->_p, fp->_r); 772 _zz_addpos(fd, fp->_r); 773 } 774 775 if(!_zz_islocked(fd)) 776 debug("%s([%i]) = %i", __func__, fd, ret); 777 778 return ret; 787 int ret; REFILL(__srefill); return ret; 788 } 789 #endif 790 791 #if defined HAVE___SRGET 792 int NEW(__srget)(FILE *fp) 793 { 794 int ret; REFILL(__srget); return ret; 779 795 } 780 796 #endif … … 783 799 int NEW(__filbuf)(FILE *fp) 784 800 { 785 off_t newpos; 786 int ret, fd; 787 788 LOADSYM(__filbuf); 789 fd = fileno(fp); 790 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) 791 return ORIG(__filbuf)(fp); 792 793 _zz_lock(fd); 794 ret = ORIG(__filbuf)(fp); 795 newpos = lseek(fd, 0, SEEK_CUR); 796 _zz_unlock(fd); 797 if(ret != EOF) 798 { 799 if(newpos != -1) 800 _zz_setpos(fd, newpos - fp->FILE_CNT - 1); 801 _zz_fuzz(fd, fp->FILE_PTR - 1, fp->FILE_CNT + 1); 802 ret = (uint8_t)fp->FILE_PTR[-1]; 803 _zz_addpos(fd, fp->FILE_CNT + 1); 804 } 805 806 if(!_zz_islocked(fd)) 807 debug("%s([%i]) = %i", __func__, fd, ret); 808 809 return ret; 810 } 811 #endif 812 801 int ret; REFILL(__filbuf); return ret; 802 } 803 #endif 804
Note: See TracChangeset
for help on using the changeset viewer.