FreeBSD/contrib/subversion/subversion/libsvn_fs_x/verify.c
/* Verify that the MD5 checksum of the data between offsets START and END
 * in FILE matches the EXPECTED checksum.  If there is a mismatch use the
 * indedx NAME in the error message.  Supports cancellation with CANCEL_FUNC
 * and CANCEL_BATON.  SCRATCH_POOL is for temporary allocations. */
Verify that the MD5 checksum of the data between offsets START and END
in FILE matches the EXPECTED checksum.  If there is a mismatch use the
indedx NAME in the error message.
Verify that the MD5 checksum of the data between offsets START and END in FILE matches the EXPECTED checksum . If there is a mismatch use the indedx NAME in the error message .
static svn_error_t *
verify_index_checksum(apr_file_t *file,
                      const char *name,
                      apr_off_t start,
                      apr_off_t end,
                      svn_checksum_t *expected,
                      svn_cancel_func_t cancel_func,
                      void *cancel_baton,
                      apr_pool_t *scratch_pool)
{
  unsigned char buffer[SVN__STREAM_CHUNK_SIZE];
  apr_off_t size = end - start;
  svn_checksum_t *actual;
  svn_checksum_ctx_t *context
    = svn_checksum_ctx_create(svn_checksum_md5, scratch_pool);
  SVN_ERR(svn_io_file_seek(file, APR_SET, &start, scratch_pool));
  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,
                                     scratch_pool));
      SVN_ERR(svn_checksum_update(context, buffer, to_read));
      size -= to_read;
      if (cancel_func)
        SVN_ERR(cancel_func(cancel_baton));
    }
  SVN_ERR(svn_checksum_final(&actual, context, scratch_pool));
  if (!svn_checksum_match(expected, actual))
    {
      const char *file_name;
      SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
      SVN_ERR(svn_checksum_mismatch_err(expected, actual, scratch_pool,
                                        _("%s checksum mismatch in file %s"),
                                        name, file_name));
    }
  return SVN_NO_ERROR;
}
static svn_error_t * verify_index_checksum ( apr_file_t * file , const char * name , apr_off_t start , apr_off_t end , svn_checksum_t * expected , svn_cancel_func_t cancel_func , void * cancel_baton , apr_pool_t * scratch_pool ) { unsigned char buffer [ SVN__STREAM_CHUNK_SIZE ] ; apr_off_t size = end - start ; svn_checksum_t * actual ; svn_checksum_ctx_t * context = svn_checksum_ctx_create ( svn_checksum_md5 , scratch_pool ) ; SVN_ERR ( svn_io_file_seek ( file , APR_SET , & start , scratch_pool ) ) ; 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 , scratch_pool ) ) ; SVN_ERR ( svn_checksum_update ( context , buffer , to_read ) ) ; size -= to_read ; if ( cancel_func ) SVN_ERR ( cancel_func ( cancel_baton ) ) ; } SVN_ERR ( svn_checksum_final ( & actual , context , scratch_pool ) ) ; if ( ! svn_checksum_match ( expected , actual ) ) { const char * file_name ; SVN_ERR ( svn_io_file_name_get ( & file_name , file , scratch_pool ) ) ; SVN_ERR ( svn_checksum_mismatch_err ( expected , actual , scratch_pool , _ ( " " ) , name , file_name ) ) ; } return SVN_NO_ERROR ; }
Verify that the MD5 checksum of the data between offsets START and END
 in FILE matches the EXPECTED checksum.
Verify that the MD5 checksum of the data between offsets START and END in FILE matches the EXPECTED checksum .
/* Calculate the index checksum. */ /* Verify that it matches the expected checksum. */