home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / I4BOTTOM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  1021 b   |  48 lines

  1.  
  2. /* i4bottom.c   (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.    Moves the index file pointer to the bottom position.
  5.  
  6.    Returns
  7.       Success 0
  8.       EOF     3
  9.       Error  -1
  10. */
  11.  
  12. #include "d4all.h"
  13.  
  14. extern   BLOCK  *v4block ;
  15. extern   INDEX  *v4index ;
  16. extern   int     v4lock_wait ;
  17.  
  18. i4bottom( int index_ref )
  19. {
  20.    int     rc, cur_block ;
  21.    BLOCK  *block_ptr ;
  22.  
  23.    if ( (rc = i4lock( index_ref, v4lock_wait)) < 0 )  return rc ;
  24.  
  25.    if ( v4index[index_ref].block_ref >= 0 )
  26.    {
  27.       while( (cur_block = b4up( index_ref )) >= 0 ) ;
  28.       b4skip( index_ref, 9999L ) ;
  29.    }
  30.  
  31.    cur_block = 0 ;
  32.    while ( cur_block >= 0 )
  33.    {
  34.       cur_block =  b4down( index_ref, 1 ) ;
  35.       if (cur_block <= -2)  return( -1 ) ;  /* Error */
  36.    }
  37.    block_ptr =  v4block+ v4index[index_ref].block_ref ;
  38.    if ( block_ptr->num_keys == 0 )
  39.    {
  40.       return( 3) ;
  41.    }
  42.    else
  43.    {
  44.       block_ptr->key_on =  block_ptr->num_keys - 1 ;
  45.       return( 0 ) ;
  46.    }
  47. }
  48.