Changeset 2533 for zzuf/trunk/src/lib-stream.c
- Timestamp:
- Jul 16, 2008, 11:52:02 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/lib-stream.c
r2528 r2533 40 40 #include "fd.h" 41 41 42 #if defined HAVE___SREFILL || defined HAVE___FILBUF 43 # define HAVE_REFILL_STDIO 44 #endif 45 42 46 #if defined HAVE___SREFILL 43 47 int NEW(__srefill)(FILE *fp); 48 #endif 49 50 #if defined HAVE___FILBUF 51 int NEW(__filbuf)(FILE *fp); 44 52 #endif 45 53 … … 64 72 #if defined HAVE___FSEEKO64 65 73 static int (*ORIG(__fseeko64)) (FILE *stream, off_t offset, int whence); 74 #endif 75 #if defined HAVE___FSETPOS64 76 static int (*ORIG(__fsetpos64)) (FILE *stream, const fpos64_t *pos); 66 77 #endif 67 78 static void (*ORIG(rewind)) (FILE *stream); … … 115 126 #endif 116 127 128 /* Additional HP-UXisms */ 129 #if defined HAVE___FILBUF 130 int (*ORIG(__filbuf)) (FILE *fp); 131 #endif 132 117 133 /* Our function wrappers */ 134 #if defined HAVE_REFILL_STDIO /* Fuzz fp if we have __srefill() */ 135 # define FOPEN_FUZZ() \ 136 _zz_fuzz(fd, ret->__ptr, ret->__cnt) 137 #else 138 # define FOPEN_FUZZ() 139 #endif 140 118 141 #define FOPEN(fn) \ 119 142 do \ … … 130 153 _zz_register(fd); \ 131 154 debug("%s(\"%s\", \"%s\") = [%i]", __func__, path, mode, fd); \ 155 FOPEN_FUZZ(); \ 132 156 } \ 133 157 } while(0) … … 188 212 #endif 189 213 190 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */214 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 191 215 # define FSEEK_FUZZ(fn2) 192 216 #else … … 245 269 #endif 246 270 271 #if defined HAVE___FSETPOS64 272 int NEW(__fsetpos64)(FILE *stream, const fpos64_t *pos) 273 { 274 int ret, fd; 275 276 LOADSYM(__fsetpos64); 277 fd = fileno(stream); 278 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) 279 return ORIG(__fsetpos64)(stream, pos); 280 _zz_lock(fd); 281 ret = ORIG(__fsetpos64)(stream, pos); 282 _zz_unlock(fd); 283 debug("%s([%i], %lli) = %i", __func__, 284 fd, (long long int)*pos, ret); 285 /* On HP-UX at least, fpos64_t == int64_t */ 286 _zz_setpos(fd, (int64_t)*pos); 287 288 return ret; 289 } 290 #endif 291 247 292 void NEW(rewind)(FILE *stream) 248 293 { … … 262 307 debug("%s([%i])", __func__, fd); 263 308 264 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */309 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 265 310 #else 266 311 /* FIXME: check what happens when rewind()ing a pipe */ … … 269 314 } 270 315 271 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */316 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 272 317 # define FREAD_FUZZ() \ 273 318 do \ … … 339 384 #endif 340 385 341 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */386 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 342 387 # define FGETC_FUZZ 343 388 #else … … 417 462 #endif 418 463 419 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */464 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 420 465 # define FGETS_FUZZ(fn, fn2) \ 421 466 _zz_lock(fd); \ … … 501 546 fuzz->upos = _zz_getpos(fd) - 1; 502 547 fuzz->uchar = c; 503 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */548 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 504 549 #else 505 550 _zz_addpos(fd, -1); … … 614 659 { 615 660 char *ret; 616 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */661 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 617 662 #else 618 663 struct fuzz *fuzz; … … 627 672 return ORIG(fgetln)(stream, len); 628 673 629 #if defined HAVE_ __SREFILL/* Don't fuzz or seek if we have __srefill() */674 #if defined HAVE_REFILL_STDIO /* Don't fuzz or seek if we have __srefill() */ 630 675 _zz_lock(fd); 631 676 ret = ORIG(fgetln)(stream, len); … … 682 727 if(ret != EOF) 683 728 { 729 /* FIXME: do we have to fuzz ret, too, like in __filbuf? */ 684 730 if(newpos != -1) 685 731 _zz_setpos(fd, newpos - fp->_r); … … 695 741 #endif 696 742 743 #if defined HAVE___FILBUF 744 int NEW(__filbuf)(FILE *fp) 745 { 746 off_t newpos; 747 int ret, fd; 748 749 LOADSYM(__filbuf); 750 fd = fileno(fp); 751 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) 752 return ORIG(__filbuf)(fp); 753 754 _zz_lock(fd); 755 ret = ORIG(__filbuf)(fp); 756 newpos = lseek(fd, 0, SEEK_CUR); 757 _zz_unlock(fd); 758 if(ret != EOF) 759 { 760 if(newpos != -1) 761 _zz_setpos(fd, newpos - fp->__cnt - 1); 762 _zz_fuzz(fd, fp->__ptr - 1, fp->__cnt + 1); 763 ret = (uint8_t)fp->__ptr[-1]; 764 _zz_addpos(fd, fp->__cnt + 1); 765 } 766 767 if(!_zz_islocked(fd)) 768 debug("%s([%i]) = %i", __func__, fd, ret); 769 770 return ret; 771 } 772 #endif 773
Note: See TracChangeset
for help on using the changeset viewer.