Changeset 4114
- Timestamp:
- Dec 12, 2009, 11:20:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/libzzuf/lib-stream.c
r4113 r4114 206 206 } 207 207 208 #define DEBUG_STREAM(prefix, fp) \ 209 debug2(prefix "stream([%i], %p, %i)", fileno(fp), \ 210 get_stream_ptr(fp), get_stream_cnt(fp)); 208 static inline void debug_stream(char const *prefix, FILE *stream) 209 { 210 debug2("%p stream([%i], %p, %i)", prefix, fileno(stream), 211 get_stream_ptr(stream), get_stream_cnt(stream)); 212 } 211 213 212 214 /* … … 235 237 _zz_register(fd); \ 236 238 debug("%s(\"%s\", \"%s\") = [%i]", __func__, path, mode, fd); \ 237 DEBUG_STREAM("new", ret); \239 debug_stream("new", ret); \ 238 240 FOPEN_FUZZ(); \ 239 241 } \ … … 340 342 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 341 343 return ORIG(myfseek)(stream, offset, whence); \ 342 DEBUG_STREAM("old", stream); \344 debug_stream("old", stream); \ 343 345 _zz_lock(fd); \ 344 346 ret = ORIG(myfseek)(stream, offset, whence); \ … … 347 349 fd, (long long int)offset, whence, ret); \ 348 350 FSEEK_FUZZ() \ 349 DEBUG_STREAM("new", stream); \351 debug_stream("new", stream); \ 350 352 } while(0) 351 353 … … 388 390 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 389 391 return ORIG(myfsetpos)(stream, pos); \ 390 DEBUG_STREAM("old", stream); \392 debug_stream("old", stream); \ 391 393 _zz_lock(fd); \ 392 394 ret = ORIG(myfsetpos)(stream, pos); \ … … 395 397 fd, (long long int)FPOS_CAST(*pos), ret); \ 396 398 _zz_setpos(fd, (int64_t)FPOS_CAST(*pos)); \ 397 DEBUG_STREAM("new", stream); \399 debug_stream("new", stream); \ 398 400 } \ 399 401 while(0) … … 529 531 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 530 532 return ORIG(myfread)(ptr, size, nmemb, stream); \ 531 DEBUG_STREAM("old", stream); \533 debug_stream("old", stream); \ 532 534 oldpos = MYFTELL(stream); \ 533 535 _zz_setpos(fd, oldpos); \ … … 537 539 FREAD_PREFUZZ(fd, oldpos); \ 538 540 FREAD_FUZZ(fd, oldpos); \ 539 DEBUG_STREAM("new", stream); \541 debug_stream("new", stream); \ 540 542 } while(0) 541 543 … … 584 586 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 585 587 return ORIG(myfgetc)(arg); \ 586 DEBUG_STREAM("old", s); \588 debug_stream("old", s); \ 587 589 _zz_setpos(fd, MYFTELL(s)); \ 588 590 _zz_lock(fd); \ … … 595 597 else \ 596 598 debug("%s([%i]) = '%c'", __func__, fd, ret); \ 597 DEBUG_STREAM("new", s); \599 debug_stream("new", s); \ 598 600 } while(0) 599 601 … … 699 701 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 700 702 return ORIG(myfgets)(s, size, stream); \ 701 DEBUG_STREAM("old", s); \703 debug_stream("old", s); \ 702 704 _zz_setpos(fd, MYFTELL(stream)); \ 703 705 FGETS_FUZZ(myfgets, myfgetc) \ 704 706 debug("%s(%p, %i, [%i]) = %p", __func__, s, size, fd, ret); \ 705 DEBUG_STREAM("new", s); \707 debug_stream("new", s); \ 706 708 } while(0) 707 709 … … 731 733 return ORIG(ungetc)(c, stream); 732 734 733 DEBUG_STREAM("old", stream);735 debug_stream("old", stream); 734 736 _zz_setpos(fd, MYFTELL(stream)); 735 737 _zz_lock(fd); … … 753 755 else 754 756 debug("%s(0x%02x, [%i]) = '%c'", __func__, c, fd, ret); 755 DEBUG_STREAM("new", stream);757 debug_stream("new", stream); 756 758 return ret; 757 759 } … … 770 772 return ORIG(fclose)(fp); 771 773 772 DEBUG_STREAM("old", fp);774 debug_stream("old", fp); 773 775 _zz_lock(fd); 774 776 ret = ORIG(fclose)(fp); … … 798 800 break; \ 799 801 } \ 800 DEBUG_STREAM("old", stream); \802 debug_stream("old", stream); \ 801 803 _zz_setpos(fd, MYFTELL(stream)); \ 802 804 line = *lineptr; \ … … 842 844 debug("%s(%p, %p, [%i]) = %li", __func__, \ 843 845 lineptr, n, fd, (long int)ret); \ 844 DEBUG_STREAM("new", stream); \846 debug_stream("new", stream); \ 845 847 break; \ 846 848 } while(0) … … 888 890 return ORIG(fgetln)(stream, len); 889 891 890 DEBUG_STREAM("old", stream);892 debug_stream("old", stream); 891 893 #if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */ 892 894 _zz_lock(fd); … … 924 926 925 927 debug("%s([%i], &%li) = %p", __func__, fd, (long int)*len, ret); 926 DEBUG_STREAM("new", stream);928 debug_stream("new", stream); 927 929 return ret; 928 930 } … … 949 951 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_isactive(fd)) \ 950 952 return ORIG(myrefill)(fp); \ 951 DEBUG_STREAM("old", fp); \953 debug_stream("old", fp); \ 952 954 pos = _zz_getpos(fd); \ 953 955 _zz_lock(fd); \ … … 990 992 else \ 991 993 debug("%s([%i]) = '%c'", __func__, fd, ret); \ 992 DEBUG_STREAM("new", fp); \994 debug_stream("new", fp); \ 993 995 } \ 994 996 while(0)
Note: See TracChangeset
for help on using the changeset viewer.