FreeBSD/contrib/subversion/subversion/libsvn_fs_x/low_level.c
/* Given a revision file FILE that has been pre-positioned at the
   beginning of a Node-Rev header block, read in that header block and
   store it in the apr_hash_t HEADERS.  All allocations will be from
   RESULT_POOL. */
Given a revision file FILE that has been pre-positioned at the
beginning of a Node-Rev header block, read in that header block and
store it in the apr_hash_t HEADERS.  All allocations will be from
RESULT_POOL.
Given a revision file FILE that has been pre - positioned at the beginning of a Node - Rev header block read in that header block and store it in the apr_hash_t HEADERS . All allocations will be from RESULT_POOL .
static svn_error_t *
read_header_block(apr_hash_t **headers,
                  svn_stream_t *stream,
                  apr_pool_t *result_pool)
{
  *headers = svn_hash__make(result_pool);
  while (1)
    {
      svn_stringbuf_t *header_str;
      const char *name, *value;
      apr_size_t i = 0;
      apr_size_t name_len;
      svn_boolean_t eof;
      SVN_ERR(svn_stream_readline(stream, &header_str, "\n", &eof,
                                  result_pool));
      if (eof || header_str->len == 0)
        break; 
      while (header_str->data[i] != ':')
        {
          if (header_str->data[i] == '\0')
            return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                     _("Found malformed header '%s' in "
                                       "revision file"),
                                     header_str->data);
          i++;
        }
      header_str->data[i] = '\0';
      name = header_str->data;
      name_len = i;
      if (i + 2 > header_str->len)
        {
          header_str->data[i] = ':';
          return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                   _("Found malformed header '%s' in "
                                     "revision file"),
                                   header_str->data);
        }
      i += 2;
      value = header_str->data + i;
      apr_hash_set(*headers, name, name_len, value);
    }
  return SVN_NO_ERROR;
}
static svn_error_t * read_header_block ( apr_hash_t * * headers , svn_stream_t * stream , apr_pool_t * result_pool ) { * headers = svn_hash__make ( result_pool ) ; while ( 1 ) { svn_stringbuf_t * header_str ; const char * name , * value ; apr_size_t i = 0 ; apr_size_t name_len ; svn_boolean_t eof ; SVN_ERR ( svn_stream_readline ( stream , & header_str , " \n " , & eof , result_pool ) ) ; if ( eof || header_str -> len == 0 ) break ; while ( header_str -> data [ i ] != ' ' ) { if ( header_str -> data [ i ] == ' \0 ' ) return svn_error_createf ( SVN_ERR_FS_CORRUPT , NULL , _ ( " " " " ) , header_str -> data ) ; i ++ ; } header_str -> data [ i ] = ' \0 ' ; name = header_str -> data ; name_len = i ; if ( i + 2 > header_str -> len ) { header_str -> data [ i ] = ' ' ; return svn_error_createf ( SVN_ERR_FS_CORRUPT , NULL , _ ( " " " " ) , header_str -> data ) ; } i += 2 ; value = header_str -> data + i ; apr_hash_set ( * headers , name , name_len , value ) ; } return SVN_NO_ERROR ; }
Given a revision file FILE that has been pre-positioned at the
beginning of a Node-Rev header block, read in that header block and
store it in the apr_hash_t HEADERS.
Given a revision file FILE that has been pre - positioned at the beginning of a Node - Rev header block read in that header block and store it in the apr_hash_t HEADERS .
/* end of header block */ /* Create a 'name' string and point to it. */ /* Check if we have enough data to parse. */ /* Restore the original line for the error. */ /* Skip over the NULL byte and the space following it. */ /* header_str is safely in our pool, so we can use bits of it as
         key and value. */