FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/verify.c
/* Verify that the FNV checksum over the next ENTRY->SIZE bytes read from
 * FILE will match ENTRY's expected checksum.  Use POOL for allocations.
 */
Verify that the FNV checksum over the next ENTRY->SIZE bytes read from
FILE will match ENTRY's expected checksum.  Use POOL for allocations.
Verify that the FNV checksum over the next ENTRY - > SIZE bytes read from FILE will match ENTRY ' s expected checksum . Use POOL for allocations .
static svn_error_t *
expected_streamed_checksum(apr_file_t *file,
                           svn_fs_fs__p2l_entry_t *entry,
                           apr_pool_t *pool)
{
  unsigned char buffer[STREAM_THRESHOLD];
  svn_checksum_t *checksum;
  svn_checksum_ctx_t *context
    = svn_checksum_ctx_create(svn_checksum_fnv1a_32x4, pool);
  apr_off_t size = entry->size;
  while (size > 0)
    {
      apr_size_t to_read = size > sizeof(buffer)
                         ? sizeof(buffer)
                         : (apr_size_t)size;
      SVN_ERR(svn_io_file_read_full2(file, buffer, to_read, NULL, NULL,
                                     pool));
      SVN_ERR(svn_checksum_update(context, buffer, to_read));
      size -= to_read;
    }
  SVN_ERR(svn_checksum_final(&checksum, context, pool));
  SVN_ERR(expected_checksum(file, entry,
                            ntohl(*(const apr_uint32_t *)checksum->digest),
                            pool));
  return SVN_NO_ERROR;
}
static svn_error_t * expected_streamed_checksum ( apr_file_t * file , svn_fs_fs__p2l_entry_t * entry , apr_pool_t * pool ) { unsigned char buffer [ STREAM_THRESHOLD ] ; svn_checksum_t * checksum ; svn_checksum_ctx_t * context = svn_checksum_ctx_create ( svn_checksum_fnv1a_32x4 , pool ) ; apr_off_t size = entry -> size ; while ( size > 0 ) { apr_size_t to_read = size > sizeof ( buffer ) ? sizeof ( buffer ) : ( apr_size_t ) size ; SVN_ERR ( svn_io_file_read_full2 ( file , buffer , to_read , NULL , NULL , pool ) ) ; SVN_ERR ( svn_checksum_update ( context , buffer , to_read ) ) ; size -= to_read ; } SVN_ERR ( svn_checksum_final ( & checksum , context , pool ) ) ; SVN_ERR ( expected_checksum ( file , entry , ntohl ( * ( const apr_uint32_t * ) checksum -> digest ) , pool ) ) ; return SVN_NO_ERROR ; }
Verify that the FNV checksum over the next ENTRY->SIZE bytes read from
 FILE will match ENTRY's expected checksum.
Verify that the FNV checksum over the next ENTRY - > SIZE bytes read from FILE will match ENTRY ' s expected checksum .