Ignore:
Timestamp:
Jul 24, 2008, 1:40:13 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • Hack around to get HP-UX tools to work. It still fails the most nasty zzcat test, though. But a more massive redesign is probably necessary.
File:
1 edited

Legend:

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

    r2336 r2584  
    6060static struct files
    6161{
    62     int managed, locked, active;
    63     int64_t pos;
     62    int managed, locked, active, already_fuzzed;
     63    int64_t pos, already_pos;
    6464    /* Public stuff */
    6565    struct fuzz fuzz;
     
    386386}
    387387
     388void _zz_setfuzzed(int fd, int count)
     389{
     390    if(fd < 0 || fd >= maxfd || fds[fd] == -1)
     391        return;
     392
     393    /* FIXME: what if we just slightly advanced? */
     394    if(files[fds[fd]].pos == files[fds[fd]].already_pos
     395        && count <= files[fds[fd]].already_fuzzed)
     396        return;
     397
     398    files[fds[fd]].already_pos = files[fds[fd]].pos;
     399    files[fds[fd]].already_fuzzed = count;
     400}
     401
     402int _zz_getfuzzed(int fd)
     403{
     404    if(fd < 0 || fd >= maxfd || fds[fd] == -1)
     405        return 0;
     406
     407    if(files[fds[fd]].pos < files[fds[fd]].already_pos)
     408        return 0;
     409
     410    if(files[fds[fd]].pos >= files[fds[fd]].already_pos
     411                               + files[fds[fd]].already_fuzzed)
     412        return 0;
     413
     414    return files[fds[fd]].already_fuzzed + files[fds[fd]].already_pos
     415                                         - files[fds[fd]].pos;
     416}
     417
    388418struct fuzz *_zz_getfuzz(int fd)
    389419{
Note: See TracChangeset for help on using the changeset viewer.