FreeBSD/contrib/subversion/subversion/libsvn_subr/packed_data.c
/* Read one 7b/8b encoded value from STREAM and return it in *RESULT.
 *
 * Overflows will be detected in the sense that it will end parsing the
 * input but the result is undefined.
 */
Read one 7b/8b encoded value from STREAM and return it in *RESULT.
Overflows will be detected in the sense that it will end parsing the
input but the result is undefined.
Read one 7b / 8b encoded value from STREAM and return it in * RESULT . Overflows will be detected in the sense that it will end parsing the input but the result is undefined .
static svn_error_t *
read_stream_uint(svn_stream_t *stream, apr_uint64_t *result)
{
  apr_uint64_t shift = 0;
  apr_uint64_t value = 0;
  unsigned char c;
  do
    {
      apr_size_t len = 1;
      SVN_ERR(svn_stream_read_full(stream, (char *)&c, &len));
      if (len != 1)
        return svn_error_create(SVN_ERR_CORRUPT_PACKED_DATA, NULL,
                                _("Unexpected end of stream"));
      value += (apr_uint64_t)(c & 0x7f) << shift;
      shift += 7;
      if (shift > 64)
        return svn_error_create(SVN_ERR_CORRUPT_PACKED_DATA, NULL,
                                _("Integer representation too long"));
    }
  while (c >= 0x80);
  *result = value;
  return SVN_NO_ERROR;
}
static svn_error_t * read_stream_uint ( svn_stream_t * stream , apr_uint64_t * result ) { apr_uint64_t shift = 0 ; apr_uint64_t value = 0 ; unsigned char c ; do { apr_size_t len = 1 ; SVN_ERR ( svn_stream_read_full ( stream , ( char * ) & c , & len ) ) ; if ( len != 1 ) return svn_error_create ( SVN_ERR_CORRUPT_PACKED_DATA , NULL , _ ( " " ) ) ; value += ( apr_uint64_t ) ( c & 0x7f ) << shift ; shift += 7 ; if ( shift > 64 ) return svn_error_create ( SVN_ERR_CORRUPT_PACKED_DATA , NULL , _ ( " " ) ) ; } while ( c >= 0x80 ) ; * result = value ; return SVN_NO_ERROR ; }
Read one 7b/8b encoded value from STREAM and return it in *RESULT.
Read one 7b / 8b encoded value from STREAM and return it in * RESULT .