Changeset 1553 for zzuf


Ignore:
Timestamp:
Jan 3, 2007, 11:51:36 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Added a _zz_disabled flag. This is needed on OS X where we protect the fopen_orig() call because it will call our own diverted open() function and we don't want it to fiddle with our structures.
Location:
zzuf/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf.c

    r1532 r1553  
    4040/* Global variables */
    4141int   _zz_ready    = 0;
     42int   _zz_disabled = 0;
    4243int   _zz_hasdebug = 0;
    4344float _zz_ratio    = 0.004f;
  • zzuf/trunk/src/libzzuf.h

    r1535 r1553  
    3434/* Internal variables */
    3535extern int   _zz_ready;
     36extern int   _zz_disabled;
    3637extern int   _zz_hasdebug;
    3738extern float _zz_ratio;
  • zzuf/trunk/src/load-fd.c

    r1543 r1553  
    8686            ret = ORIG(fn)(file, oflag); \
    8787        } \
    88         if(!_zz_ready) \
     88        if(!_zz_ready || _zz_disabled) \
    8989            return ret; \
    9090        if(ret >= 0 \
     
    120120        LOADSYM(read);
    121121    ret = read_orig(fd, buf, count);
    122     if(!_zz_ready || !_zz_iswatched(fd))
     122    if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
    123123        return ret;
    124124
     
    146146            LOADSYM(fn); \
    147147        ret = ORIG(fn)(fd, offset, whence); \
    148         if(!_zz_ready || !_zz_iswatched(fd)) \
     148        if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled) \
    149149            return ret; \
    150150        debug(STR(fn)"(%i, %lli, %i) = %lli", \
     
    182182
    183183    ret = close_orig(fd);
    184     if(!_zz_ready || !_zz_iswatched(fd))
     184    if(!_zz_ready || !_zz_iswatched(fd) || _zz_disabled)
    185185        return ret;
    186186
  • zzuf/trunk/src/load-stream.c

    r1552 r1553  
    9696            return ORIG(fn)(path, mode); \
    9797        } \
     98        _zz_disabled = 1; \
    9899        ret = ORIG(fn)(path, mode); \
     100        _zz_disabled = 0; \
    99101        if(ret && _zz_mustwatch(path)) \
    100102        { \
     
    127129        return fseek_orig(stream, offset, whence);
    128130
     131    _zz_disabled = 1;
    129132    ret = fseek_orig(stream, offset, whence);
     133    _zz_disabled = 0;
    130134    debug("fseek([%i], %li, %i) = %i", fd, offset, whence, ret);
    131135    if(ret != 0)
     
    160164
    161165    pos = ftell(stream);
     166    _zz_disabled = 1;
    162167    ret = fread_orig(ptr, size, nmemb, stream);
     168    _zz_disabled = 0;
    163169    debug("fread(%p, %li, %li, [%i]) = %li",
    164170          ptr, (long int)size, (long int)nmemb, fd, (long int)ret);
     
    185191        if(!_zz_ready || !_zz_iswatched(fd)) \
    186192            return ORIG(fn)(stream); \
     193        _zz_disabled = 1; \
    187194        ret = ORIG(fn)(stream); \
     195        _zz_disabled = 0; \
    188196        if(ret != EOF) \
    189197        { \
     
    228236        for(i = 0; i < size - 1; i++)
    229237        {
    230             int ch = fgetc_orig(stream);
     238            int ch;
     239
     240            _zz_disabled = 1;
     241            ch = fgetc_orig(stream);
     242            _zz_disabled = 0;
    231243
    232244            if(ch == EOF)
     
    287299        return fclose_orig(fp);
    288300
     301    _zz_disabled = 1;
    289302    ret = fclose_orig(fp);
     303    _zz_disabled = 0;
    290304    debug("fclose([%i]) = %i", fd, ret);
    291305    _zz_unregister(fd);
     
    319333                break; \
    320334            } \
     335            _zz_disabled = 1; \
    321336            ch = fgetc_orig(stream); \
     337            _zz_disabled = 0; \
    322338            if(ch == EOF) \
    323339            { \
Note: See TracChangeset for help on using the changeset viewer.