Changeset 4029


Ignore:
Timestamp:
Nov 24, 2009, 2:25:44 AM (10 years ago)
Author:
Sam Hocevar
Message:

We need to know the FILE buffer's current fill status. Implemented for
glibc for now.

Location:
zzuf/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r4011 r4029  
    8080AC_MSG_CHECKING(for FILE* internal members)
    8181ac_cv_have_glibc_fp="no"
     82ac_v_fp_base="unknown"
     83ac_v_fp_ptr="unknown"
    8284ac_v_fp_cnt="unknown"
    83 ac_v_fp_ptr="unknown"
    8485AC_TRY_COMPILE([#include <stdio.h>],
    8586 [FILE *fp; fp->_IO_read_ptr++; fp->_IO_read_end++],
    86  [ac_cv_have_glibc_fp=yes; ac_v_fp_cnt=_IO_read_end; ac_v_fp_ptr=_IO_read_ptr],
     87 [ac_cv_have_glibc_fp=yes; ac_v_fp_base=_IO_read_base
     88  ac_v_fp_cnt=_IO_read_end; ac_v_fp_ptr=_IO_read_ptr],
    8789 [AC_TRY_COMPILE([#include <stdio.h>],
    8890   [FILE *fp; fp->__cnt++; fp->__ptr++],
    89    [ac_v_fp_cnt=__cnt; ac_v_fp_ptr=__ptr],
     91   [ac_v_fp_base=FIXME; ac_v_fp_ptr=__ptr; ac_v_fp_cnt=__cnt],
    9092   [AC_TRY_COMPILE([#include <stdio.h>],
    9193     [FILE *fp; fp->_cnt++; fp->_ptr++],
    92      [ac_v_fp_cnt=_cnt; ac_v_fp_ptr=_ptr],
     94     [aac_v_fp_base=FIXME; c_v_fp_ptr=_ptr; ac_v_fp_cnt=_cnt],
    9395     [AC_TRY_COMPILE([#include <stdio.h>],
    9496       [FILE *fp; fp->_c++; fp->_p++],
    95        [ac_v_fp_cnt=_c; ac_v_fp_ptr=_p],
     97       [aac_v_fp_base=FIXME; c_v_fp_ptr=_p; ac_v_fp_cnt=_c],
    9698       [AC_TRY_COMPILE([#include <stdio.h>],
    9799         [FILE *fp; fp->_r++; fp->_p++],
    98          [ac_v_fp_cnt=_r; ac_v_fp_ptr=_p])])])])])
    99 AC_MSG_RESULT($ac_v_fp_ptr/$ac_v_fp_cnt)
     100         [aac_v_fp_base=FIXME; c_v_fp_ptr=_p; ac_v_fp_cnt=_r])])])])])
     101AC_MSG_RESULT($ac_v_fp_base/$ac_v_fp_ptr/$ac_v_fp_cnt)
    100102if test "$ac_cv_have_glibc_fp" != "no"; then
    101103  AC_DEFINE(HAVE_GLIBC_FP, 1, [Define to 1 if FILE has glibc-style members])
    102104fi
     105AC_DEFINE_UNQUOTED(FILE_BASE, $ac_v_fp_base, [Define to the FILE::base member])
    103106AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member])
    104107AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member])
  • zzuf/trunk/src/lib-stream.c

    r4013 r4029  
    166166#else
    167167    return NULL;
     168#endif
     169}
     170
     171static inline int get_stream_off(FILE *stream)
     172{
     173#if defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     174    return (int)((uint8_t *)stream->FILE_PTR - (uint8_t *)stream->FILE_BASE);
     175#else
     176    return 0;
    168177#endif
    169178}
Note: See TracChangeset for help on using the changeset viewer.