FreeBSD/contrib/subversion/subversion/libsvn_fs_x/index.c
/* Read one unsigned 64 bit value from PROTO_INDEX file and return it in
 * *VALUE_P.  If EOF is NULL, error out when trying to read beyond EOF.
 * Use SCRATCH_POOL for temporary allocations.
 *
 * This function is the inverse to write_uint64_to_proto_index (see there),
 * reading the external LE byte order and convert it into host byte order.
 */
Read one unsigned 64 bit value from PROTO_INDEX file and return it in
*VALUE_P.  If EOF is NULL, error out when trying to read beyond EOF.
Use SCRATCH_POOL for temporary allocations.

This function is the inverse to write_uint64_to_proto_index ,
reading the external LE byte order and convert it into host byte order.
Read one unsigned 64 bit value from PROTO_INDEX file and return it in * VALUE_P . If EOF is NULL error out when trying to read beyond EOF . Use SCRATCH_POOL for temporary allocations . This function is the inverse to write_uint64_to_proto_index reading the external LE byte order and convert it into host byte order .
static svn_error_t *
read_uint64_from_proto_index(apr_file_t *proto_index,
                             apr_uint64_t *value_p,
                             svn_boolean_t *eof,
                             apr_pool_t *scratch_pool)
{
  apr_byte_t buffer[sizeof(*value_p)];
  apr_size_t read;
  SVN_ERR(svn_io_file_read_full2(proto_index, buffer, sizeof(buffer),
                                 &read, eof, scratch_pool));
  SVN_ERR_ASSERT((eof && *eof) || read == sizeof(buffer));
  if (!eof || !*eof)
    {
      int i;
      apr_uint64_t value;
      value = 0;
      for (i = sizeof(buffer) - 1; i >= 0; --i)
        value = (value << CHAR_BIT) + buffer[i];
      *value_p = value;
    }
  return SVN_NO_ERROR;
}
static svn_error_t * read_uint64_from_proto_index ( apr_file_t * proto_index , apr_uint64_t * value_p , svn_boolean_t * eof , apr_pool_t * scratch_pool ) { apr_byte_t buffer [ sizeof ( * value_p ) ] ; apr_size_t read ; SVN_ERR ( svn_io_file_read_full2 ( proto_index , buffer , sizeof ( buffer ) , & read , eof , scratch_pool ) ) ; SVN_ERR_ASSERT ( ( eof && * eof ) || read == sizeof ( buffer ) ) ; if ( ! eof || ! * eof ) { int i ; apr_uint64_t value ; value = 0 ; for ( i = sizeof ( buffer ) - 1 ; i >= 0 ; -- i ) value = ( value << CHAR_BIT ) + buffer [ i ] ; * value_p = value ; } return SVN_NO_ERROR ; }
Read one unsigned 64 bit value from PROTO_INDEX file and return it in
 *VALUE_P.
Read one unsigned 64 bit value from PROTO_INDEX file and return it in * VALUE_P .
/* Read the full 8 bytes or our 64 bit value, unless we hit EOF.
   * Assert that we never read partial values. */ /* If we did not hit EOF, reconstruct the uint64 value and return it. */ /* This could only overflow if CHAR_BIT had a value that is not
       * a divisor of 64. */